# Path: courseraresearchexports/constants/api_constants.py
# COURSE_API = 'https://www.coursera.org/api/onDemandCourses.v1/'
# 
# PARTNER_API = 'https://www.coursera.org/api/partners.v1/'


import logging
import requests
from courseraresearchexports.constants.api_constants import \
    COURSE_API, PARTNER_API
                    'Request to {url} with body:\n\t{body}\nreceived response'
                    ':\n\t{text}\n'
                    '{help_string}\n'
                    .format(url=response.url,
                            text=response.text,
                            body=(response.request and response.request.body),
                            help_string=help_string))
                raise

            return response_transformer(response)
        return response_transformer_wrapper
    return response_transform_decorator


@requests_response_to_model(
    lambda response: response.json()['elements'][0]['slug'])
def lookup_course_slug_by_id(course_id):
    """
    Find the course slug given an course_id
    """
    return requests.get(requests.compat.urljoin(COURSE_API, course_id))


@requests_response_to_model(
    lambda response: response.json()['elements'][0]['id'])
def lookup_course_id_by_slug(course_slug):
    """
    Find the course_id given a course_slug
    """
    payload = {'q': 'slug', 'slug': course_slug}

# Path: courseraresearchexports/constants/api_constants.py
# COURSE_API = 'https://www.coursera.org/api/onDemandCourses.v1/'
# 
# PARTNER_API = 'https://www.coursera.org/api/partners.v1/'


# Path: courseraresearchexports/models/utils.py
import logging
import requests
from courseraresearchexports.constants.api_constants import \
    COURSE_API, PARTNER_API

                    'Request to {url} with body:\n\t{body}\nreceived response'
                    ':\n\t{text}\n'
                    '{help_string}\n'
                    .format(url=response.url,
                            text=response.text,
                            body=(response.request and response.request.body),
                            help_string=help_string))
                raise

            return response_transformer(response)
        return response_transformer_wrapper
    return response_transform_decorator


@requests_response_to_model(
    lambda response: response.json()['elements'][0]['slug'])
def lookup_course_slug_by_id(course_id):
    """
    Find the course slug given an course_id
    """
    return requests.get(requests.compat.urljoin(COURSE_API, course_id))


@requests_response_to_model(
    lambda response: response.json()['elements'][0]['id'])
def lookup_course_id_by_slug(course_slug):
    """
    Find the course_id given a course_slug
    """
    payload = {'q': 'slug', 'slug': course_slug}

    return requests.get(COURSE_API, params=payload)