Browse Source

update: DonationAlertsApi | new: class Scopes

main
Fsoky 4 years ago
parent
commit
b01777aba1
  1. 37
      donationalerts_api.py

37
donationalerts_api.py

@ -2,19 +2,42 @@ import requests
from flask import request 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: class DonationAlertsApi:
""" """
This class describes work with Donation Alerts API 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"] symbols = [",", ", ", " ", "%20"]
if isinstance(scopes, list):
obj_scopes = []
for scope in scopes:
obj_scopes.append(scope)
scopes = " ".join(obj_scopes)
for symbol in symbols: for symbol in symbols:
if symbol in scope: if symbol in scopes:
self.scope = scope.replace(symbol, "%20").strip() # Replaces some symbols on '%20' for stable work self.scope = scopes.replace(symbol, "%20").strip() # Replaces some symbols on '%20' for stable work
else: else:
self.scope = scope self.scope = scopes
self.client_id = client_id self.client_id = client_id
self.client_secret = client_secret self.client_secret = client_secret
@ -29,13 +52,11 @@ class DonationAlertsApi:
def login(self): def login(self):
link = self.login_url return self.login_url
return link
def get_code(self): def get_code(self):
code = request.args.get("code") return request.args.get("code")
return code
def get_access_token(self, code): def get_access_token(self, code):

Loading…
Cancel
Save