diff --git a/blockchain_integration/pi_network/wallet/pi_wallet/services/pi_api_service.py b/blockchain_integration/pi_network/wallet/pi_wallet/services/pi_api_service.py index 4fc6e4d0d..9c68b8e47 100644 --- a/blockchain_integration/pi_network/wallet/pi_wallet/services/pi_api_service.py +++ b/blockchain_integration/pi_network/wallet/pi_wallet/services/pi_api_service.py @@ -1,7 +1,10 @@ import requests + from .exceptions.pi_network_exceptions import PiNetworkApiException + class PiApiService: + def __init__(self, api_endpoint, api_key, api_secret): self.api_endpoint = api_endpoint self.api_key = api_key @@ -9,30 +12,34 @@ def __init__(self, api_endpoint, api_key, api_secret): def get_blockchain_info(self): headers = { - 'Content-Type': 'application/json', - 'Authorization': f'Bearer {self.api_key}' + "Content-Type": "application/json", + "Authorization": f"Bearer {self.api_key}", } - response = requests.get(f'{self.api_endpoint}/blockchain', headers=headers) + response = requests.get(f"{self.api_endpoint}/blockchain", headers=headers) if response.status_code != 200: raise PiNetworkApiException(response.status_code, response.text) return response.json() def broadcast_transaction(self, transaction): headers = { - 'Content-Type': 'application/json', - 'Authorization': f'Bearer {self.api_key}' + "Content-Type": "application/json", + "Authorization": f"Bearer {self.api_key}", } - response = requests.post(f'{self.api_endpoint}/transaction', json=transaction, headers=headers) + response = requests.post( + f"{self.api_endpoint}/transaction", json=transaction, headers=headers + ) if response.status_code != 201: raise PiNetworkApiException(response.status_code, response.text) return response.json() def verify_transaction(self, transaction): headers = { - 'Content-Type': 'application/json', - 'Authorization': f'Bearer {self.api_key}' + "Content-Type": "application/json", + "Authorization": f"Bearer {self.api_key}", } - response = requests.get(f'{self.api_endpoint}/transaction/{transaction["hash"]}', headers=headers) + response = requests.get( + f'{self.api_endpoint}/transaction/{transaction["hash"]}', headers=headers + ) if response.status_code != 200: raise PiNetworkApiException(response.status_code, response.text) return response.json()