Skip to content

add proxies parameter for requests lib #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions fireblocks_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def handle_response(response, page_mode=False):

class FireblocksSDK(object):

def __init__(self, private_key, api_key, api_base_url="https://api.fireblocks.io", timeout=None):
def __init__(self, private_key, api_key, api_base_url="https://api.fireblocks.io", timeout=None, proxies=None):
"""Creates a new Fireblocks API Client.

Args:
Expand All @@ -46,6 +46,7 @@ def __init__(self, private_key, api_key, api_base_url="https://api.fireblocks.io
self.base_url = api_base_url
self.token_provider = SdkTokenProvider(private_key, api_key)
self.timeout = timeout
self.proxies = None

def get_supported_assets(self):
"""Gets all assets that are currently supported by Fireblocks"""
Expand Down Expand Up @@ -1397,7 +1398,7 @@ def _get_request(self, path, page_mode=False):
"Authorization": f"Bearer {token}"
}

response = requests.get(self.base_url + path, headers=headers, timeout=self.timeout)
response = requests.get(self.base_url + path, headers=headers, timeout=self.timeout, proxies=self.proxies)
return handle_response(response, page_mode)

def _delete_request(self, path):
Expand All @@ -1407,7 +1408,7 @@ def _delete_request(self, path):
"Authorization": f"Bearer {token}"
}

response = requests.delete(self.base_url + path, headers=headers, timeout=self.timeout)
response = requests.delete(self.base_url + path, headers=headers, timeout=self.timeout, proxies=self.proxies)
return handle_response(response)

def _post_request(self, path, body={}, idempotency_key=None):
Expand All @@ -1424,7 +1425,7 @@ def _post_request(self, path, body={}, idempotency_key=None):
"Idempotency-Key": idempotency_key
}

response = requests.post(self.base_url + path, headers=headers, json=body, timeout=self.timeout)
response = requests.post(self.base_url + path, headers=headers, json=body, timeout=self.timeout, proxies=self.proxies)
return handle_response(response)

def _put_request(self, path, body={}):
Expand All @@ -1435,5 +1436,5 @@ def _put_request(self, path, body={}):
"Content-Type": "application/json"
}

response = requests.put(self.base_url + path, headers=headers, data=json.dumps(body), timeout=self.timeout)
response = requests.put(self.base_url + path, headers=headers, data=json.dumps(body), timeout=self.timeout, proxies=self.proxies)
return handle_response(response)