@@ 69-84 (lines=16) @@ | ||
66 | POST to any resource |
|
67 | Make sure to include the proper token in the params |
|
68 | """ |
|
69 | def post_to_bitpay_api(client, uri, resource, params): |
|
70 | payload = json.dumps(params) |
|
71 | uri = uri + "/" + resource |
|
72 | xidentity = key_utils.get_compressed_public_key_from_pem(client.pem) |
|
73 | xsignature = key_utils.sign(uri + payload, client.pem) |
|
74 | headers = {"content-type": "application/json", |
|
75 | "accept": "application/json", "X-Identity": xidentity, |
|
76 | "X-Signature": xsignature, "X-accept-version": "2.0.0"} |
|
77 | try: |
|
78 | response = requests.post(uri, data=payload, headers=headers, |
|
79 | verify=client.verify) |
|
80 | except Exception as pro: |
|
81 | raise BitPayConnectionError(pro.args) |
|
82 | if response.ok: |
|
83 | return response.json()['data'] |
|
84 | client.response_error(response) |
|
85 | ||
86 | fetch_token("merchant") |
|
87 | ||
@@ 48-63 (lines=16) @@ | ||
45 | f.write(client.tokens[facade]) |
|
46 | f.close() |
|
47 | ||
48 | def get_from_bitpay_api(client, uri, token): |
|
49 | payload = "?token=%s" % token |
|
50 | xidentity = bku.get_compressed_public_key_from_pem(client.pem) |
|
51 | xsignature = bku.sign(uri + payload, client.pem) |
|
52 | headers = {"content-type": "application/json", |
|
53 | "X-Identity": xidentity, |
|
54 | "X-Signature": xsignature, "X-accept-version": "2.0.0"} |
|
55 | try: |
|
56 | pp.pprint(headers) |
|
57 | print(uri + payload) |
|
58 | response = requests.get(uri + payload, headers=headers, verify=client.verify) |
|
59 | except Exception as pro: |
|
60 | raise BitPayConnectionError(pro.args) |
|
61 | if response.ok: |
|
62 | return response.json()['data'] |
|
63 | client.response_error(response) |
|
64 | ||
65 | """ |
|
66 | POST to any resource |
@@ 68-83 (lines=16) @@ | ||
65 | POST to any resource |
|
66 | Make sure to include the proper token in the params |
|
67 | """ |
|
68 | def post_to_bitpay_api(client, uri, resource, params): |
|
69 | payload = json.dumps(params) |
|
70 | uri = uri + "/" + resource |
|
71 | xidentity = key_utils.get_compressed_public_key_from_pem(client.pem) |
|
72 | xsignature = key_utils.sign(uri + payload, client.pem) |
|
73 | headers = {"content-type": "application/json", |
|
74 | "accept": "application/json", "X-Identity": xidentity, |
|
75 | "X-Signature": xsignature, "X-accept-version": "2.0.0"} |
|
76 | try: |
|
77 | response = requests.post(uri, data=payload, headers=headers, |
|
78 | verify=client.verify) |
|
79 | except Exception as pro: |
|
80 | raise BitPayConnectionError(pro.args) |
|
81 | if response.ok: |
|
82 | return response.json()['data'] |
|
83 | client.response_error(response) |
|
84 | ||
85 | fetch_token("payroll") |
|
86 | ||
@@ 47-62 (lines=16) @@ | ||
44 | f.write(client.tokens[facade]) |
|
45 | f.close() |
|
46 | ||
47 | def get_from_bitpay_api(client, uri, token): |
|
48 | payload = "?token=%s" % token |
|
49 | xidentity = bku.get_compressed_public_key_from_pem(client.pem) |
|
50 | xsignature = bku.sign(uri + payload, client.pem) |
|
51 | headers = {"content-type": "application/json", |
|
52 | "X-Identity": xidentity, |
|
53 | "X-Signature": xsignature, "X-accept-version": "2.0.0"} |
|
54 | try: |
|
55 | pp.pprint(headers) |
|
56 | print(uri + payload) |
|
57 | response = requests.get(uri + payload, headers=headers, verify=client.verify) |
|
58 | except Exception as pro: |
|
59 | raise BitPayConnectionError(pro.args) |
|
60 | if response.ok: |
|
61 | return response.json()['data'] |
|
62 | client.response_error(response) |
|
63 | ||
64 | """ |
|
65 | POST to any resource |