# Path: yaklient/settings.py
# YIKYAK_APIKEY = "EF64523D2BD1FA21F18F5BC654DFC41B"
# YIKYAK_ENDPOINT = "https://us-central-api.yikyakapi.net/api/"
# YIKYAK_VERSION = "2.7.3"
# YIKYAK_VERSION_LETTER = "e"
# PARSE_APPID = "wMkdjBI4ircsNcRn8mXnBkgH0dwOcrkexrdMY3vY"
# PARSE_CLIENTKEY = "GbNFwvFgoUu1wYuwIexNImy8bnSlNhqssG7gd53Y"
# PARSE_ENDPOINT = "https://api.parse.com/2/"
# PARSE_VERSION = "1.7.1"
# PARSE_VERSION_LETTER = "a"
# PARSE_BUILD = "59"
# PARSE_API_LEVEL = "22"
# NOTIFY_ENDPOINT = "https://notify.yikyakapi.net/api/"
# BASECAMP_ENDPOINT = "https://bc.yikyakapi.net/api/"
# AWS_ACCESS_KEY = "AKIAJFD2ANADKEMPW52A"
# AWS_BUCKET = "photos-upload-yy"
# AWS_SECRET_KEY = None
# AWS_UPLOAD_ENDPOINT = "http://signedup.yikyakapi.net/upload"
# ALLOWED_SITES_URL = "http://lv.yikyakapi.net/getSites"
# CONFIG_URL = "https://d3436qb9f9xu23.cloudfront.net/yikyak-config-android.json"
# VM_TYPE = "Dalvik"
# VM_VERSION = "1.6.0"
# ANDROID_VERSION = "4.0.5"
# DEVICE = "google_sdk"
# BUILD = "MR1"
# VM_VERSIONS = ["1.7.0", "1.8.0", "1.8.1"]
# ANDROID_VERSIONS = ["4.0.4", "4.5", "4.3", "5.1"]
# BUILD_STRING_LENGTHS = [3, 4, 5]
# DEVICES = ["Nexus 4", "Nexus 5", "HTC One_M8", "SM-N900V", "XT1080",
#            "SM-G900V", "SCH-I545", "Android SDK built for x86"]
# RANDOMIZE_USER_AGENT = True
# RANDOMIZE_ENDPOINT = False
# LOCATIONIZE_ENDPOINT = False
# LOG_USERIDS = True
# NO_YAKS_MESSAGE_ID = "Y/b3c6c56b0305f2bc794e40b504f7150f"
# TOO_CLOSE_TO_SCHOOL_MESSAGE_ID = "Y/1687dcbe8ca5a308d46c44343a4c69eb"
# CONTACT_US_REASONS = ["My Basecamp location is wrong.",
#                       "I'm not near a high school but it says I am! Help!",
#                       "I want my college to be a Peek location!",
#                       "I have a really cool idea for the app.",
#                       "Yik Yak isn't working properly on my phone.",
#                       "Someone posted something and I want it taken down.",
#                       "My Yakarma has been reset.", "I forgot my pin code.",
#                       "Other"]
# 
# Path: yaklient/helper.py
# def generate_id(dashes=True, upper=False):
#     """Return ID with or without dashes as either uppercase or lowercase"""
#     uuid = uuid4() if dashes else uuid4().get_hex()
#     return str(uuid).upper() if upper else str(uuid)
# 
# def hash_msg(key, msg):
#     """Return SHA1 hash from key and msg"""
#     return b64encode(hmac.new(key, msg, sha1).digest())


from requests import Session
from time import time
from urllib import urlencode, unquote
from urlparse import urljoin
from yaklient import settings
from yaklient.config import get_token, get_user_agent
from yaklient.helper import generate_id, hash_msg
# -*- coding: utf-8 -*-

"""A low-level API for Yik Yak, providing access to all the basic functions"""



# Session for requests
SESSION = Session()
REQUEST = SESSION.request


def _send(method, url, endpoint, params, data=None):
    """Return response from server after making request with method to endpoint
    with params and, optionally, data"""
    url = urljoin(url, endpoint)
    version = settings.YIKYAK_VERSION + settings.YIKYAK_VERSION_LETTER
    params += [("version", version)]
    salt = str(int(time()))
    msg = urljoin("/api/", endpoint) + '?' + unquote(urlencode(params)) + salt

# Path: yaklient/settings.py
# YIKYAK_APIKEY = "EF64523D2BD1FA21F18F5BC654DFC41B"
# YIKYAK_ENDPOINT = "https://us-central-api.yikyakapi.net/api/"
# YIKYAK_VERSION = "2.7.3"
# YIKYAK_VERSION_LETTER = "e"
# PARSE_APPID = "wMkdjBI4ircsNcRn8mXnBkgH0dwOcrkexrdMY3vY"
# PARSE_CLIENTKEY = "GbNFwvFgoUu1wYuwIexNImy8bnSlNhqssG7gd53Y"
# PARSE_ENDPOINT = "https://api.parse.com/2/"
# PARSE_VERSION = "1.7.1"
# PARSE_VERSION_LETTER = "a"
# PARSE_BUILD = "59"
# PARSE_API_LEVEL = "22"
# NOTIFY_ENDPOINT = "https://notify.yikyakapi.net/api/"
# BASECAMP_ENDPOINT = "https://bc.yikyakapi.net/api/"
# AWS_ACCESS_KEY = "AKIAJFD2ANADKEMPW52A"
# AWS_BUCKET = "photos-upload-yy"
# AWS_SECRET_KEY = None
# AWS_UPLOAD_ENDPOINT = "http://signedup.yikyakapi.net/upload"
# ALLOWED_SITES_URL = "http://lv.yikyakapi.net/getSites"
# CONFIG_URL = "https://d3436qb9f9xu23.cloudfront.net/yikyak-config-android.json"
# VM_TYPE = "Dalvik"
# VM_VERSION = "1.6.0"
# ANDROID_VERSION = "4.0.5"
# DEVICE = "google_sdk"
# BUILD = "MR1"
# VM_VERSIONS = ["1.7.0", "1.8.0", "1.8.1"]
# ANDROID_VERSIONS = ["4.0.4", "4.5", "4.3", "5.1"]
# BUILD_STRING_LENGTHS = [3, 4, 5]
# DEVICES = ["Nexus 4", "Nexus 5", "HTC One_M8", "SM-N900V", "XT1080",
#            "SM-G900V", "SCH-I545", "Android SDK built for x86"]
# RANDOMIZE_USER_AGENT = True
# RANDOMIZE_ENDPOINT = False
# LOCATIONIZE_ENDPOINT = False
# LOG_USERIDS = True
# NO_YAKS_MESSAGE_ID = "Y/b3c6c56b0305f2bc794e40b504f7150f"
# TOO_CLOSE_TO_SCHOOL_MESSAGE_ID = "Y/1687dcbe8ca5a308d46c44343a4c69eb"
# CONTACT_US_REASONS = ["My Basecamp location is wrong.",
#                       "I'm not near a high school but it says I am! Help!",
#                       "I want my college to be a Peek location!",
#                       "I have a really cool idea for the app.",
#                       "Yik Yak isn't working properly on my phone.",
#                       "Someone posted something and I want it taken down.",
#                       "My Yakarma has been reset.", "I forgot my pin code.",
#                       "Other"]
# 
# Path: yaklient/helper.py
# def generate_id(dashes=True, upper=False):
#     """Return ID with or without dashes as either uppercase or lowercase"""
#     uuid = uuid4() if dashes else uuid4().get_hex()
#     return str(uuid).upper() if upper else str(uuid)
# 
# def hash_msg(key, msg):
#     """Return SHA1 hash from key and msg"""
#     return b64encode(hmac.new(key, msg, sha1).digest())


# Path: yaklient/api/yikyakapi.py
from requests import Session
from time import time
from urllib import urlencode, unquote
from urlparse import urljoin
from yaklient import settings
from yaklient.config import get_token, get_user_agent
from yaklient.helper import generate_id, hash_msg

# -*- coding: utf-8 -*-

"""A low-level API for Yik Yak, providing access to all the basic functions"""



# Session for requests
SESSION = Session()
REQUEST = SESSION.request


def _send(method, url, endpoint, params, data=None):
    """Return response from server after making request with method to endpoint
    with params and, optionally, data"""
    url = urljoin(url, endpoint)
    version = settings.YIKYAK_VERSION + settings.YIKYAK_VERSION_LETTER
    params += [("version", version)]
    salt = str(int(time()))
    msg = urljoin("/api/", endpoint) + '?' + unquote(urlencode(params)) + salt

    hash_string = hash_msg(settings.YIKYAK_APIKEY, msg)