|
|
@ -2,19 +2,42 @@ import requests |
|
|
|
from flask import request |
|
|
|
|
|
|
|
|
|
|
|
class Scopes: |
|
|
|
|
|
|
|
user_show = "oauth-user-show" |
|
|
|
|
|
|
|
donation_subcribe = "oauth-donation-subscribe" |
|
|
|
donation_index = "oauth-donation-index" |
|
|
|
|
|
|
|
custom_alert_store = "oauth-custom_alert-store" |
|
|
|
|
|
|
|
goal_subcribe = "oauth-goal-subscribe" |
|
|
|
poll_subcribe = "oauth-poll-subscribe" |
|
|
|
|
|
|
|
all_scopes = [user_show, donation_subcribe, donation_index, custom_alert_store, |
|
|
|
goal_subcribe, poll_subcribe] |
|
|
|
|
|
|
|
|
|
|
|
class DonationAlertsApi: |
|
|
|
""" |
|
|
|
This class describes work with Donation Alerts API |
|
|
|
""" |
|
|
|
|
|
|
|
def __init__(self, client_id, client_secret, redirect_uri, scope): |
|
|
|
def __init__(self, client_id, client_secret, redirect_uri, scopes): |
|
|
|
symbols = [",", ", ", " ", "%20"] |
|
|
|
|
|
|
|
if isinstance(scopes, list): |
|
|
|
obj_scopes = [] |
|
|
|
for scope in scopes: |
|
|
|
obj_scopes.append(scope) |
|
|
|
|
|
|
|
scopes = " ".join(obj_scopes) |
|
|
|
|
|
|
|
for symbol in symbols: |
|
|
|
if symbol in scope: |
|
|
|
self.scope = scope.replace(symbol, "%20").strip() # Replaces some symbols on '%20' for stable work |
|
|
|
if symbol in scopes: |
|
|
|
self.scope = scopes.replace(symbol, "%20").strip() # Replaces some symbols on '%20' for stable work |
|
|
|
else: |
|
|
|
self.scope = scope |
|
|
|
self.scope = scopes |
|
|
|
|
|
|
|
self.client_id = client_id |
|
|
|
self.client_secret = client_secret |
|
|
@ -29,13 +52,11 @@ class DonationAlertsApi: |
|
|
|
|
|
|
|
|
|
|
|
def login(self): |
|
|
|
link = self.login_url |
|
|
|
return link |
|
|
|
return self.login_url |
|
|
|
|
|
|
|
|
|
|
|
def get_code(self): |
|
|
|
code = request.args.get("code") |
|
|
|
return code |
|
|
|
return request.args.get("code") |
|
|
|
|
|
|
|
|
|
|
|
def get_access_token(self, code): |
|
|
|