diff --git a/README.md b/README.md index d5f58bb..6785073 100644 --- a/README.md +++ b/README.md @@ -61,4 +61,34 @@ aws cloudformation describe-stacks \ --stack-name breez-integration \ --query 'Stacks[0].Outputs' -``` \ No newline at end of file +``` +Output will look like this: +``` +root@2edec8635e65:/# aws cloudformation describe-stacks --stack-name breez-integration --query 'Stacks[0].Outputs' +[ + { + "OutputKey": "ApiGatewayBaseURL", + "OutputValue": "https://yxzjorems5.execute-api.us-east-1.amazonaws.com/prod", + "Description": "Base URL for API Gateway" + }, + { + "OutputKey": "SendEndpoint", + "OutputValue": "https://yxzjorems5.execute-api.us-east-1.amazonaws.com/prod/send_payment", + "Description": "Send endpoint URL" + }, + { + "OutputKey": "PaymentsEndpoint", + "OutputValue": "https://yxzjorems5.execute-api.us-east-1.amazonaws.com/prod/list_payments", + "Description": "Payments endpoint URL" + }, + { + "OutputKey": "ReceiveEndpoint", + "OutputValue": "https://yxzjorems5.execute-api.us-east-1.amazonaws.com/prod/receive_payment", + "Description": "Receive endpoint URL" + } +] + +``` +### Example usage +You can use example-client.py to test the functionality. Take Base URL from the above output and put it in API_URL in example-client.py +API_KEY is the secret you set at the begining. \ No newline at end of file diff --git a/example-client.py b/example-client.py new file mode 100644 index 0000000..8231571 --- /dev/null +++ b/example-client.py @@ -0,0 +1,68 @@ +import requests +import json + +API_URL = "https://yxzjorems5.execute-api.us-east-1.amazonaws.com/prod" + +API_KEY = "1234567890" + +class BreezClient: + def __init__(self): + # Load API key from file + self.api_url = API_URL + self.headers = { + 'Content-Type': 'application/json', + 'x-api-key': API_KEY + } + + def list_payments(self, from_timestamp=None, to_timestamp=None, offset=None, limit=None): + """List all payments with optional filters.""" + params = { + "from_timestamp": from_timestamp, + "to_timestamp": to_timestamp, + "offset": offset, + "limit": limit + } + response = requests.get(f"{self.api_url}/list_payments", params=params, headers=self.headers) + print(response.json()) + print(self.headers) + return self._handle_response(response) + + def receive_payment(self, amount, method="LIGHTNING"): + """Generate a Lightning/Bitcoin/Liquid invoice to receive payment.""" + payload = { + "amount": amount, + "method": method + } + response = requests.post(f"{self.api_url}/receive_payment", json=payload, headers=self.headers) + return self._handle_response(response) + + def send_payment(self, destination, amount=None, drain=False): + """Send a payment via Lightning or Liquid.""" + payload = { + "destination": destination, + "amount": amount, + "drain": drain + } + response = requests.post(f"{self.api_url}/send_payment", json=payload, headers=self.headers) + return self._handle_response(response) + + def _handle_response(self, response): + """Helper method to handle API responses.""" + if response.status_code == 200: + return response.json() + else: + return {"error": f"Request failed with status {response.status_code}", "details": response.text} + +# Initialize client +breez = BreezClient() + +# Example Usage +if __name__ == "__main__": + print("šŸ”„ Listing Payments...") + print(breez.list_payments()) + + #print("\nšŸ’° Receiving Payment...") + #print(breez.receive_payment(amount=1000, method="LIGHTNING")) + + #print("\nšŸš€ Sending Payment...") + #print(breez.send_payment(destination="lnbc...", amount=1000))