@@ -7,14 +7,15 @@ class Client:
77 flow_base_url = "https://oauth.pipedrive.com/oauth/"
88 oauth_end = "authorize?"
99 token_end = "token"
10- api_base_url = ""
11- example_url = "https://api-proxy.pipedrive.com "
10+ api_base_url = "https://companydomain.pipedrive.com/ "
11+ api_version = "v1/ "
1212 header = {"Accept" : "application/json, */*" , "content-type" : "application/json" }
1313
14- def __init__ (self , client_id = None , client_secret = None , token = None ):
14+ def __init__ (self , client_id = None , client_secret = None , oauth = False ):
1515 self .client_id = client_id
1616 self .client_secret = client_secret
17- self .token = token
17+ self .oauth = oauth
18+ self .token = None
1819
1920 def make_request (self , method , endpoint , data = None , json = None , ** kwargs ):
2021 """
@@ -26,9 +27,11 @@ def make_request(self, method, endpoint, data=None, json=None, **kwargs):
2627 :return:
2728 """
2829 if self .token :
29- self .header ["Authorization" ] = "Bearer " + self .token
30- url = '{0}{1}' .format (self .api_base_url , endpoint )
31-
30+ if self .oauth :
31+ self .header ["Authorization" ] = "Bearer " + self .token
32+ url = '{0}{1}{2}' .format (self .api_base_url , self .api_version , endpoint )
33+ else :
34+ url = '{0}{1}{2}?api_token={3}' .format (self .api_base_url , self .api_version , endpoint , self .token )
3235 if method == "get" :
3336 response = requests .request (method , url , headers = self .header , params = kwargs )
3437 else :
@@ -413,7 +416,3 @@ def delete_hook_subscription(self, hook_id):
413416 return self ._delete (url )
414417 else :
415418 raise Exception ("The attributes necessary to delete the webhook were not obtained." )
416-
417-
418-
419-
0 commit comments