Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
19 changes: 13 additions & 6 deletions src/firefly_exchange_client/api_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@


class APIService():
def __init__(self, url):
def __init__(self, url, UUID=""):
self.server_url = url
self.auth_token = None
self.api_token = None
self.uuid = UUID
self.client = aiohttp.ClientSession()

async def close_session(self):
Expand All @@ -31,7 +32,9 @@ async def get(self, service_url, query={}, auth_required=False):
params=query,
headers={
'Authorization': 'Bearer {}'.format(self.auth_token) if self.auth_token else '',
'x-api-token': self.api_token or ''
'x-api-token': self.api_token or '',
'x-mm-id': self.uuid or ''

}
)
else:
Expand All @@ -45,7 +48,7 @@ async def get(self, service_url, query={}, auth_required=False):
except:
raise Exception("Error while getting {}: {}".format(url, response))

async def post(self, service_url, data, auth_required=False, contentType = ""):
async def post(self, service_url, data, auth_required=False, contentType=""):
"""
Makes a POST request and returns the results
Inputs:
Expand All @@ -56,10 +59,13 @@ async def post(self, service_url, data, auth_required=False, contentType = ""):
url = self._create_url(service_url)
response = None
if auth_required:
headers = {'Authorization': 'Bearer {}'.format(self.auth_token)}
headers = {
'Authorization': 'Bearer {}'.format(self.auth_token),
'x-mm-id': self.uuid or ''
}

if contentType is not "":
headers['Content-type'] = contentType
headers['Content-type'] = contentType

response = await self.client.post(url=url, data=data, headers=headers)
else:
Expand Down Expand Up @@ -89,7 +95,8 @@ async def delete(self, service_url, data, auth_required=False):
response = await self.client.delete(
url=url,
data=data,
headers={'Authorization': 'Bearer {}'.format(self.auth_token)})
headers={'Authorization': 'Bearer {}'.format(self.auth_token),
'x-mm-id': self.uuid or ''})
else:
response = await self.client.delete(url=url, data=data)

Expand Down
2 changes: 1 addition & 1 deletion src/firefly_exchange_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, are_terms_accepted, network, private_key=""):
self.w3 = self._connect_w3(self.network["url"])
if private_key != "":
self.account = Account.from_key(private_key)
self.apis = APIService(self.network["apiGateway"])
self.apis = APIService(self.network["apiGateway"], default_value(self.network, "UUID", "") )
self.dmsApi = APIService(self.network["dmsURL"])
self.socket = Sockets(self.network["socketURL"])
self.webSocketClient = WebsocketClient(self.network["webSocketURL"])
Expand Down
2 changes: 2 additions & 0 deletions src/firefly_exchange_client/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"socketURL": "wss://dapi.api.arbitrum-staging.firefly.exchange",
"webSocketURL": "wss://notifications.api.arbitrum-staging.firefly.exchange",
"onboardingUrl": "https://testnet.firefly.exchange",
"UUID": "uuid-default"
},

"MAINNET_BOBA": {
Expand All @@ -32,6 +33,7 @@
"socketURL": "wss://dapi.api.arbitrum-prod.firefly.exchange",
"webSocketURL": "wss://notifications.api.arbitrum-prod.firefly.exchange",
"onboardingUrl": "https://trade-arb.firefly.exchange",
"UUID": "uuid-default"
},
}

Expand Down