def get_dynamic(user_id, client_api_token, user_token): authorization = 'Bearer %s' % (user_token) headers = { 'MyApp-AccessToken': client_api_token, 'Authorization': authorization } return http_client.get(dynamic_url(user_id), headers=headers).json()
def public_get_vast_wrapper(partner, user_id, device_id, vast_url): url = '%s/ads/v1/vast-wrapper/%s/%s/%s' % ( config.url('ads'), partner['id'], user_id, device_id) params = {'vastUrl': vast_url} headers = {'MyApp-PartnerId': partner['id']} return http_client.get(url, params=params, headers=headers, valid_codes={200})
def public_get(playable_id, partner, device_type=None, user_token=None): url = '%s/ads/v1/%s' % (config.url('ads'), playable_id) # NOTE: api_global takes the MyApp-AccessToken (clientApiToken) header # and sets the MyApp-PartnerBackendSecret and MyApp-PartnerId headers headers = { 'MyApp-PartnerId': partner['id'], 'MyApp-PartnerBackendSecret': partner['backendSecret'], # 'MyApp-AccessToken': partner['clientApiToken'], 'MyApp-Play-DeviceType': device_type } if user_token: headers['Authorization'] = 'Bearer %s' % (user_token) return http_client.get(url, headers=headers, valid_codes={200, 404, 400})
def get_offer(partner_id, offer_id): url = '%s/offer/v1/offers/%s' % (config.url('offer'), offer_id) return http_client.get(url, headers=headers(partner_id))
def list_packs(partner_id): url = '%s/offer/v1/packs' % (config.url('offer')) return http_client.get(url, headers=headers(partner_id))
def get_pack(partner_id, pack_id): url = '%s/offer/v1/packs/%s' % (config.url('offer'), pack_id) return http_client.get(url, headers=headers(partner_id))
def search(partner_id): url = '%s/offer/v1/search' % (config.url('offer')) return http_client.get(url, headers=headers(partner_id))
def get(partner_id): return http_client.get(get_url(partner_id))
def query(partner_id, query): url = api_url(f'/query?q={query}&size=-1') return http_client.get(url, headers=headers(partner_id))
def get_history(user_id, partner_id): return http_client.get(url(user_id, '/history'), headers=headers(partner_id))
def public_get_tracking(partner, user_id, device_id): url = '%s/ads/v1/vast-tracking/%s/%s/%s' % ( config.url('ads'), partner['id'], user_id, device_id) headers = {'MyApp-PartnerId': partner['id']} return http_client.get(url, headers=headers, valid_codes={204})
def internal_defaults_list(): return http_client.get(internal_defaults_list_url())
def internal_defaults_get(partner_id): return http_client.get(internal_defaults_get_url(partner_id))
def list_offers(partner_id, pack_id): url = '%s/offer/v1/offers' % (config.url('offer')) params = {'packId': pack_id} return http_client.get(url, params=params, headers=headers(partner_id))
def internal_get(partner_id, playable_id): return http_client.get(internal_get_url(partner_id, playable_id))
def get_subscription(user_id, partner_id): return http_client.get(url(user_id), headers=headers(partner_id))
def internal_list(partner_id): return http_client.get(internal_list_url(partner_id))
def get_payments(partner, user): url = api_url(f'/users/{user["userId"]}/payments') return http_client.get(url, headers=headers(partner, user))
def get_subscription(user_id, client_api_token, user_token): url = '%s/superscription/v2/users/%s/subscription' % (config.url('api_global'), user_id) authorization = 'Bearer %s' % (user_token) headers = {'MyApp-AccessToken': client_api_token, 'Authorization': authorization} return http_client.get(url, headers=headers)