pyCryptomusAPI 0.0.8__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyCryptomusAPI-0.0.8/pyCryptomusAPI.egg-info → pycryptomusapi-0.1.1}/PKG-INFO +11 -2
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/pyCryptomusAPI/api.py +108 -9
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/pyCryptomusAPI/cryto_types.py +43 -1
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/pyCryptomusAPI/tests.py +1 -0
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/pyCryptomusAPI/version.py +1 -1
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1/pyCryptomusAPI.egg-info}/PKG-INFO +11 -2
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/LICENSE +0 -0
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/MANIFEST.in +0 -0
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/README.md +0 -0
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/pyCryptomusAPI/__init__.py +0 -0
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/pyCryptomusAPI.egg-info/SOURCES.txt +0 -0
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/pyCryptomusAPI.egg-info/dependency_links.txt +0 -0
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/pyCryptomusAPI.egg-info/top_level.txt +0 -0
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/setup.cfg +0 -0
- {pyCryptomusAPI-0.0.8 → pycryptomusapi-0.1.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: pyCryptomusAPI
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Python implementation of Cryptomus (https://cryptomus.com) pubilc API
|
|
5
5
|
Home-page: https://github.com/Badiboy/pyCryptomusAPI
|
|
6
6
|
Author: Badiboy
|
|
@@ -12,6 +12,15 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
12
12
|
Requires: requests
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: keywords
|
|
21
|
+
Dynamic: license
|
|
22
|
+
Dynamic: requires
|
|
23
|
+
Dynamic: summary
|
|
15
24
|
|
|
16
25
|
[](https://pypi.python.org/pypi/pyCryptomusAPI)
|
|
17
26
|
[](https://pypi.python.org/pypi/pyCryptomusAPI)
|
|
@@ -24,7 +24,8 @@ class pyCryptomusAPI:
|
|
|
24
24
|
|
|
25
25
|
def __init__(self,
|
|
26
26
|
merchant_uuid, payment_api_key = None, payout_api_key = None,
|
|
27
|
-
print_errors = False, timeout = None, add_request_params = None
|
|
27
|
+
print_errors = False, timeout = None, add_request_params = None,
|
|
28
|
+
api_url = API_URL):
|
|
28
29
|
"""
|
|
29
30
|
Create the pyCryptomusAPI instance.
|
|
30
31
|
|
|
@@ -34,6 +35,7 @@ class pyCryptomusAPI:
|
|
|
34
35
|
:param print_errors: (Optional) Print dumps on request errors
|
|
35
36
|
:param timeout: (Optional) Request timeout
|
|
36
37
|
:param add_request_params: (List, Optional) Additional request parameters to pass with API calls
|
|
38
|
+
:param api_url: (Optional) Use custom API endpoint URL
|
|
37
39
|
"""
|
|
38
40
|
self.merchant_uuid = merchant_uuid
|
|
39
41
|
self.payment_api_key = payment_api_key
|
|
@@ -41,7 +43,8 @@ class pyCryptomusAPI:
|
|
|
41
43
|
self.print_errors = print_errors
|
|
42
44
|
self.timeout = timeout
|
|
43
45
|
self.add_request_params = add_request_params
|
|
44
|
-
|
|
46
|
+
self.api_url = api_url
|
|
47
|
+
if (not self.payment_api_key) and (not self.payout_api_key):
|
|
45
48
|
raise Exception("You must specify at least one API key.")
|
|
46
49
|
|
|
47
50
|
def __request(self, method_url, mode, **kwargs):
|
|
@@ -63,11 +66,11 @@ class pyCryptomusAPI:
|
|
|
63
66
|
base_resp = None
|
|
64
67
|
try:
|
|
65
68
|
key = self.payment_api_key if (mode == 1) else self.payout_api_key
|
|
66
|
-
if not
|
|
69
|
+
if not key:
|
|
67
70
|
raise pyCryptomusAPIException(-6, "Key is empty")
|
|
68
71
|
if not(key.isascii()):
|
|
69
72
|
raise pyCryptomusAPIException(-6, "Key contains non-ascii characters")
|
|
70
|
-
if not
|
|
73
|
+
if not self.merchant_uuid:
|
|
71
74
|
raise pyCryptomusAPIException(-6, "Merchant UUID is empty")
|
|
72
75
|
if not(self.merchant_uuid.isascii()):
|
|
73
76
|
raise pyCryptomusAPIException(-6, "Merchant UUID contains non-ascii characters")
|
|
@@ -82,7 +85,7 @@ class pyCryptomusAPI:
|
|
|
82
85
|
"sign": sign,
|
|
83
86
|
"Content-Type": "application/json",
|
|
84
87
|
}
|
|
85
|
-
base_resp = requests.post(
|
|
88
|
+
base_resp = requests.post(self.api_url + method_url, data=pre_sign, headers=headers, timeout=self.timeout)
|
|
86
89
|
resp = base_resp.json()
|
|
87
90
|
except ValueError as ve:
|
|
88
91
|
code = base_resp.status_code if base_resp else -2
|
|
@@ -244,7 +247,7 @@ class pyCryptomusAPI:
|
|
|
244
247
|
method = "wallet/block-address"
|
|
245
248
|
params = {
|
|
246
249
|
}
|
|
247
|
-
if not
|
|
250
|
+
if (not wallet_uuid) and (not order_id):
|
|
248
251
|
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
249
252
|
if wallet_uuid:
|
|
250
253
|
params["uuid"] = wallet_uuid
|
|
@@ -273,7 +276,7 @@ class pyCryptomusAPI:
|
|
|
273
276
|
params = {
|
|
274
277
|
"address": address,
|
|
275
278
|
}
|
|
276
|
-
if not
|
|
279
|
+
if (not wallet_uuid) and (not order_id):
|
|
277
280
|
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
278
281
|
if wallet_uuid:
|
|
279
282
|
params["uuid"] = wallet_uuid
|
|
@@ -298,7 +301,7 @@ class pyCryptomusAPI:
|
|
|
298
301
|
method = "payment/info"
|
|
299
302
|
params = {
|
|
300
303
|
}
|
|
301
|
-
if not
|
|
304
|
+
if (not invoice_uuid) and (not order_id):
|
|
302
305
|
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
303
306
|
if invoice_uuid:
|
|
304
307
|
params["uuid"] = invoice_uuid
|
|
@@ -327,7 +330,7 @@ class pyCryptomusAPI:
|
|
|
327
330
|
"address": address,
|
|
328
331
|
"is_subtract": is_subtract,
|
|
329
332
|
}
|
|
330
|
-
if not
|
|
333
|
+
if (not invoice_uuid) and (not order_id):
|
|
331
334
|
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
332
335
|
if invoice_uuid:
|
|
333
336
|
params["uuid"] = invoice_uuid
|
|
@@ -440,6 +443,102 @@ class pyCryptomusAPI:
|
|
|
440
443
|
resp = self.__request(method, 1).get("result")
|
|
441
444
|
return [Service.de_json(i) for i in resp]
|
|
442
445
|
|
|
446
|
+
def create_payout(self,
|
|
447
|
+
amount, currency, order_id, address, is_subtract, network,
|
|
448
|
+
url_callback = None, to_currency = None, course_source = None,
|
|
449
|
+
from_currency = None, priority = None, memo = None):
|
|
450
|
+
"""
|
|
451
|
+
Creating a payout
|
|
452
|
+
https://doc.cryptomus.com/payouts/creating-payout
|
|
453
|
+
Requires PAYOUT API key
|
|
454
|
+
|
|
455
|
+
amount: (String) Payout amount
|
|
456
|
+
currency: (String) Currency code for the payout. If Currency if fiat, the to_currency parameter is required.
|
|
457
|
+
order_id: (String[1..100]) Order ID in your system. The parameter should be a string consisting of alphabetic characters, numbers, underscores, and dashes. It should not contain any spaces or special characters. The order_id must be unique within the merchant payouts. When we find an existing payout with order_id, we return its details, a new payout will not be created.
|
|
458
|
+
address: (String) The address of the wallet to which the withdrawal will be made
|
|
459
|
+
is_subtract: (Bool) Defines where the withdrawal fee will be deducted. true - from your balance. false - from payout amount, the payout amount will be decreased.
|
|
460
|
+
network: (String) Blockchain network code.Not required when the currency/to_currency is a cryptocurrency and has only one network, for example BTC
|
|
461
|
+
url_callback: (String, Optional) URL to which webhooks with payout status will be sent
|
|
462
|
+
to_currency: (String, Optional) Cryptocurrency code in which the payout will be made. It is used when the currency parameter is fiat.
|
|
463
|
+
course_source: (String, Optional) The service from which the exchange rates are taken for conversion in the invoice. The parameter is applied only if the currency is fiat, otherwise the default value is taken from the merchant's settings.
|
|
464
|
+
from_currency: (String, Optional) Allows to automatically convert the withdrawal amount and use the from_currency balance. Only USDT is available.
|
|
465
|
+
priority: (String, Optional) The parameter for selecting the withdrawal priority. The cost of the withdrawal fee depends on the selected parameter. This parameter is applied only in case of using the BTC, ETH, POLYGON, and BSC networks. Available values: recommended, economy, high, highest
|
|
466
|
+
memo: (String, Optional) Additional identifier for TON, used to specify a particular recipient or target
|
|
467
|
+
"""
|
|
468
|
+
method = "payout"
|
|
469
|
+
params = {
|
|
470
|
+
"amount": str(amount),
|
|
471
|
+
"currency": currency,
|
|
472
|
+
"order_id": str(order_id),
|
|
473
|
+
"address": address,
|
|
474
|
+
"is_subtract": is_subtract,
|
|
475
|
+
"network": network,
|
|
476
|
+
}
|
|
477
|
+
if url_callback:
|
|
478
|
+
params["url_callback"] = url_callback
|
|
479
|
+
if to_currency:
|
|
480
|
+
params["to_currency"] = to_currency
|
|
481
|
+
if course_source:
|
|
482
|
+
params["course_source"] = course_source
|
|
483
|
+
if from_currency:
|
|
484
|
+
params["from_currency"] = from_currency
|
|
485
|
+
if priority:
|
|
486
|
+
params["priority"] = priority
|
|
487
|
+
if memo:
|
|
488
|
+
params["memo"] = memo
|
|
489
|
+
resp = self.__request(method, 2, **params).get("result")
|
|
490
|
+
return Payout.de_json(resp)
|
|
491
|
+
|
|
492
|
+
def payout_information(self,
|
|
493
|
+
payout_uuid = None, order_id = None):
|
|
494
|
+
"""
|
|
495
|
+
Payout information
|
|
496
|
+
https://doc.cryptomus.com/payouts/payout-information
|
|
497
|
+
You need to pass one of the required parameters, if you pass both, the account will be identified by order_id
|
|
498
|
+
Requires PAYOUT API key
|
|
499
|
+
|
|
500
|
+
payout_uuid: (String, Optional if order_id set) Payout UUID
|
|
501
|
+
order_id: (String[1..128], Optional if wallet_uuid set) Payout order ID
|
|
502
|
+
|
|
503
|
+
* To get the payout information you need to pass one of the parameters, if you pass both, the payout will be identified by order_id
|
|
504
|
+
"""
|
|
505
|
+
method = "payout/info"
|
|
506
|
+
params = {
|
|
507
|
+
}
|
|
508
|
+
if (not payout_uuid) and (not order_id):
|
|
509
|
+
raise pyCryptomusAPIException(0, "You need to pass one of the required parameters")
|
|
510
|
+
if payout_uuid:
|
|
511
|
+
params["uuid"] = payout_uuid
|
|
512
|
+
if order_id:
|
|
513
|
+
params["order_id"] = order_id
|
|
514
|
+
resp = self.__request(method, 1, **params).get("result")
|
|
515
|
+
return Payout.de_json(resp)
|
|
516
|
+
|
|
517
|
+
def payout_history(self, date_from = None, date_to = None, cursor = None):
|
|
518
|
+
"""
|
|
519
|
+
Payout history
|
|
520
|
+
https://doc.cryptomus.com/payments/payment-history
|
|
521
|
+
Requires PAYOUT API key
|
|
522
|
+
|
|
523
|
+
date_from: (String, Optional) Filtering by creation date, from
|
|
524
|
+
date_to: (String, Optional) Filtering by creation date, to
|
|
525
|
+
cursor: (String, Optional) Page cursor (hash)
|
|
526
|
+
"""
|
|
527
|
+
params = {
|
|
528
|
+
}
|
|
529
|
+
if date_from:
|
|
530
|
+
params["date_from"] = date_from.strftime(CryptomusDateFormat)
|
|
531
|
+
if date_to:
|
|
532
|
+
params["date_to"] = date_to.strftime(CryptomusDateFormat)
|
|
533
|
+
if cursor:
|
|
534
|
+
params["cursor"] = cursor
|
|
535
|
+
method = "payment/list"
|
|
536
|
+
if params:
|
|
537
|
+
resp = self.__request(method, 1, **params).get("result")
|
|
538
|
+
else:
|
|
539
|
+
resp = self.__request(method, 1).get("result")
|
|
540
|
+
return PayoutHistory.de_json(resp)
|
|
541
|
+
|
|
443
542
|
def payout_services(self):
|
|
444
543
|
"""
|
|
445
544
|
Get collection of all available payout services
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import datetime
|
|
2
1
|
import json
|
|
3
2
|
from abc import ABC
|
|
4
3
|
|
|
@@ -130,9 +129,11 @@ class Balance(JsonDeserializable):
|
|
|
130
129
|
raise ValueError("Not a balance")
|
|
131
130
|
if "merchant" in data:
|
|
132
131
|
for item in data["merchant"]:
|
|
132
|
+
# noinspection PyUnresolvedReferences
|
|
133
133
|
instance.merchant.append(BalanceItem.de_json(item))
|
|
134
134
|
if "user" in data:
|
|
135
135
|
for item in data["user"]:
|
|
136
|
+
# noinspection PyUnresolvedReferences
|
|
136
137
|
instance.user.append(BalanceItem.de_json(item))
|
|
137
138
|
return instance
|
|
138
139
|
|
|
@@ -304,3 +305,44 @@ class PaymentsHistory(JsonDeserializable):
|
|
|
304
305
|
instance.items = [Invoice.de_json(i) for i in instance.items]
|
|
305
306
|
instance.paginate = PaymentPaginate.de_json(instance.paginate)
|
|
306
307
|
return instance
|
|
308
|
+
|
|
309
|
+
# noinspection PyMethodOverriding
|
|
310
|
+
class Payout(JsonDeserializable):
|
|
311
|
+
def __init__(self):
|
|
312
|
+
self.uuid = None
|
|
313
|
+
self.amount = None
|
|
314
|
+
self.currency = None
|
|
315
|
+
self.network = None
|
|
316
|
+
self.address = None
|
|
317
|
+
self.txid = None
|
|
318
|
+
self.status = None
|
|
319
|
+
self.is_final = None
|
|
320
|
+
self.balance = None
|
|
321
|
+
self.payer_currency = None
|
|
322
|
+
self.payer_amount = None
|
|
323
|
+
|
|
324
|
+
@classmethod
|
|
325
|
+
def de_json(cls, json_dict):
|
|
326
|
+
data = cls.check_json(json_dict)
|
|
327
|
+
instance = super(Payout, cls).de_json(data, process_mode=2)
|
|
328
|
+
if instance.amount is not None:
|
|
329
|
+
instance.amount = float(instance.amount)
|
|
330
|
+
if instance.payer_amount is not None:
|
|
331
|
+
instance.payer_amount = float(instance.payer_amount)
|
|
332
|
+
if instance.balance is not None:
|
|
333
|
+
instance.balance = float(instance.balance)
|
|
334
|
+
return instance
|
|
335
|
+
|
|
336
|
+
# noinspection PyMethodOverriding
|
|
337
|
+
class PayoutHistory(JsonDeserializable):
|
|
338
|
+
def __init__(self):
|
|
339
|
+
self.items = []
|
|
340
|
+
self.paginate = PaymentPaginate()
|
|
341
|
+
|
|
342
|
+
@classmethod
|
|
343
|
+
def de_json(cls, json_dict):
|
|
344
|
+
data = cls.check_json(json_dict)
|
|
345
|
+
instance = super(PayoutHistory, cls).de_json(data, process_mode=2)
|
|
346
|
+
instance.items = [Payout.de_json(i) for i in instance.items]
|
|
347
|
+
instance.paginate = PaymentPaginate.de_json(instance.paginate)
|
|
348
|
+
return instance
|
|
@@ -50,6 +50,7 @@ def test_api_functions():
|
|
|
50
50
|
run_and_print(lambda: client.payment_history())
|
|
51
51
|
run_and_print(lambda: client.payment_history_filtered(is_final=True))
|
|
52
52
|
run_and_print(lambda: client.payout_services())
|
|
53
|
+
run_and_print(lambda: client.payout_history())
|
|
53
54
|
run_and_print(lambda: client.balance())
|
|
54
55
|
|
|
55
56
|
test_api_functions()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: pyCryptomusAPI
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Python implementation of Cryptomus (https://cryptomus.com) pubilc API
|
|
5
5
|
Home-page: https://github.com/Badiboy/pyCryptomusAPI
|
|
6
6
|
Author: Badiboy
|
|
@@ -12,6 +12,15 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
12
12
|
Requires: requests
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
License-File: LICENSE
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: keywords
|
|
21
|
+
Dynamic: license
|
|
22
|
+
Dynamic: requires
|
|
23
|
+
Dynamic: summary
|
|
15
24
|
|
|
16
25
|
[](https://pypi.python.org/pypi/pyCryptomusAPI)
|
|
17
26
|
[](https://pypi.python.org/pypi/pyCryptomusAPI)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|