cryptomate_api 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/lib/cryptomate_api/base.rb +31 -6
- data/lib/cryptomate_api/management/blockchain.rb +13 -11
- data/lib/cryptomate_api/management/client.rb +51 -49
- data/lib/cryptomate_api/management/configuration.rb +31 -28
- data/lib/cryptomate_api/management/credential.rb +83 -81
- data/lib/cryptomate_api/management/key.rb +58 -56
- data/lib/cryptomate_api/management/operation.rb +23 -21
- data/lib/cryptomate_api/mpc/account.rb +58 -56
- data/lib/cryptomate_api/mpc/wallet.rb +102 -100
- data/lib/cryptomate_api/payment.rb +41 -39
- data/lib/cryptomate_api/version.rb +1 -1
- data/lib/cryptomate_api.rb +0 -1
- metadata +1 -2
- data/lib/cryptomate_api/configuration.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 906be66131260ee217ea113c34d721097024af3ccfd109357b16cb63db2710c0
|
4
|
+
data.tar.gz: 94433f3e67c9d62a522e85c640c54a263f0558f049a42ff737d1cef4137838ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd6398f342185320a4e848bf3d9a21561d9b0070cf42b6665b004728fb35fdc84a01a350e0b3d8f38aacbb0c46354d31af2eb4235b0db457cad9ebc95a545ab9
|
7
|
+
data.tar.gz: 784af7e1d756604e05fa01e56f000cdb852383f8b2047cefeb427a6450ebdf21b5d35a08954ab6f209acdf2c893726f4a7fee3016af783731f31152a37a0c8b5
|
data/README.md
CHANGED
data/lib/cryptomate_api/base.rb
CHANGED
@@ -3,15 +3,40 @@
|
|
3
3
|
require 'httparty'
|
4
4
|
|
5
5
|
module CryptomateApi
|
6
|
+
class << self
|
7
|
+
def configure
|
8
|
+
yield self if block_given?
|
9
|
+
end
|
10
|
+
|
11
|
+
def base_uri=(uri)
|
12
|
+
Base.base_uri uri
|
13
|
+
end
|
14
|
+
|
15
|
+
def api_key=(key)
|
16
|
+
Base.headers 'Content-Type' => 'application/json', 'x-api-key' => key
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
6
20
|
class Base
|
7
21
|
include HTTParty
|
8
22
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
23
|
+
class << self
|
24
|
+
[:get, :post, :put, :patch, :delete, :head, :options, :move].each do |http_method|
|
25
|
+
define_method(http_method) do |*args, &block|
|
26
|
+
ensure_configuration!
|
27
|
+
super(*args, &block)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def ensure_configuration!
|
34
|
+
errors = []
|
35
|
+
errors << "Base URI not configured" if base_uri.nil?
|
36
|
+
errors << "API key not configured" if headers['x-api-key'].nil?
|
37
|
+
|
38
|
+
raise CryptomateApi::Error, errors.join(", ") unless errors.empty?
|
39
|
+
end
|
15
40
|
end
|
16
41
|
end
|
17
42
|
end
|
@@ -6,17 +6,19 @@ module CryptomateApi
|
|
6
6
|
# credentials for your clients or using every other endpoints that ask for the blockchain where
|
7
7
|
# you want to operate.
|
8
8
|
class Blockchain < CryptomateApi::Base
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
class << self
|
10
|
+
# Get all blockchains
|
11
|
+
# https://cryptomate.me/docs/management#get-all-blockchains
|
12
|
+
# Response:
|
13
|
+
# [
|
14
|
+
# {
|
15
|
+
# "id": "string",
|
16
|
+
# "description": "string"
|
17
|
+
# }
|
18
|
+
# ]
|
19
|
+
def get_all_blockchains
|
20
|
+
get('/management/blockchains/list')
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -5,58 +5,60 @@ module CryptomateApi
|
|
5
5
|
# Manage the company information from here, like changing the webhook url where we will
|
6
6
|
# notify that some event happened or just changing the name of the company.
|
7
7
|
class Client < CryptomateApi::Base
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
class << self
|
9
|
+
# Get clients information
|
10
|
+
# https://cryptomate.me/docs/management#get-clients-information
|
11
|
+
# Response:
|
12
|
+
# {
|
13
|
+
# "name": "string",
|
14
|
+
# "last_name": "string",
|
15
|
+
# "email": "string",
|
16
|
+
# "social_reason": "string",
|
17
|
+
# "webhook_url": "string",
|
18
|
+
# }
|
19
|
+
def get_clients
|
20
|
+
get('/management/clients')
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
# Update Webhook-Url
|
24
|
+
# https://cryptomate.me/docs/management#update-webhook-url
|
25
|
+
# @param [String] webhook_url (New webhook url to use to inform any changes.)
|
26
|
+
# Response:
|
27
|
+
# {
|
28
|
+
# "name": "string",
|
29
|
+
# "email": "string",
|
30
|
+
# "webhook_url": "string"
|
31
|
+
# }
|
32
|
+
def update_webhook_url(webhook_url)
|
33
|
+
patch('/management/clients/webhook-url', body: { webhook_url: }.to_json)
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
36
|
+
# Update Client-Information
|
37
|
+
# https://cryptomate.me/docs/management#update-client-information
|
38
|
+
# @param [String] name (Name of the client to update.)
|
39
|
+
# @param [String] email (Email of the client to update.)
|
40
|
+
# @param [String] webhook_url (New webhook url to use to inform any changes.)
|
41
|
+
# Response:
|
42
|
+
# {
|
43
|
+
# "name": "string",
|
44
|
+
# "email": "string",
|
45
|
+
# "webhook_url": "string"
|
46
|
+
# }
|
47
|
+
def update_client_information(name, email, webhook_url)
|
48
|
+
put('/management/clients', body: { name:, email:, webhook_url: }.to_json)
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
# Update Payment Address
|
52
|
+
# https://cryptomate.me/docs/management#update-payments-address
|
53
|
+
# @param [String] address (Address where you want to receive the payments)
|
54
|
+
# @param [String] blockchain (Blockchain where you want to receive the payments)
|
55
|
+
# Response:
|
56
|
+
# {
|
57
|
+
# "address": "string",
|
58
|
+
# }
|
59
|
+
def update_payment_address(address, blockchain)
|
60
|
+
patch('/management/clients/payment-treasury', body: { address:, blockchain: }.to_json)
|
61
|
+
end
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
@@ -4,36 +4,39 @@ module CryptomateApi
|
|
4
4
|
module Management
|
5
5
|
# Manage the company configurations from here, like changing the payment destination address for each blockchain.
|
6
6
|
class Configuration < CryptomateApi::Base
|
7
|
-
|
8
|
-
# Gets the treasury wallet address for holding the payments received on the selected blockchain.
|
9
|
-
# https://cryptomate.me/docs/management#get-payment-destination
|
10
|
-
# @param [String] blockchain (Id of the blockchain.)
|
11
|
-
# Response:
|
12
|
-
# {
|
13
|
-
# "address": "string",
|
14
|
-
# "blockchain": "string"
|
15
|
-
# }
|
16
|
-
def get_payment_destination(blockchain)
|
17
|
-
self.class.get("/management/configurations/payments/#{blockchain}")
|
18
|
-
end
|
7
|
+
class << self
|
19
8
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
9
|
+
# Get payment destination
|
10
|
+
# Gets the treasury wallet address for holding the payments received on the selected blockchain.
|
11
|
+
# https://cryptomate.me/docs/management#get-payment-destination
|
12
|
+
# @param [String] blockchain (Id of the blockchain.)
|
13
|
+
# Response:
|
14
|
+
# {
|
15
|
+
# "address": "string",
|
16
|
+
# "blockchain": "string"
|
17
|
+
# }
|
18
|
+
def get_payment_destination(blockchain)
|
19
|
+
get("/management/configurations/payments/#{blockchain}")
|
20
|
+
end
|
21
|
+
|
22
|
+
# Set payment destination
|
23
|
+
# Sets the treasury wallet that all the payments will sent after being completed.
|
24
|
+
# https://cryptomate.me/docs/management#set-payment-destination
|
25
|
+
# @param [String] address (Address of the treasury wallet)
|
26
|
+
# @param [String] blockchain (Id of the blockchain.)
|
27
|
+
# Response: None
|
28
|
+
def set_payment_destination(address, blockchain)
|
29
|
+
post('/management/configurations/payments', body: { address:, blockchain: }.to_json)
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
# Delete payment destination
|
33
|
+
# Deletes the treasury wallet that all the payments will sent after being completed.
|
34
|
+
# https://cryptomate.me/docs/management#delete-payment-destination
|
35
|
+
# @param [String] blockchain (Id of the blockchain.)
|
36
|
+
# Response: None
|
37
|
+
def delete_payment_destination(blockchain)
|
38
|
+
delete("/management/configurations/payments/#{blockchain}")
|
39
|
+
end
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -5,91 +5,93 @@ module CryptomateApi
|
|
5
5
|
# Manage the access you give to each key and the permissions you will have for each blockchain,
|
6
6
|
# such as only receiving transactions or only accessing one of the blockchains.
|
7
7
|
class Credential < CryptomateApi::Base
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
class << self
|
9
|
+
# Get all credentials for an API-Key
|
10
|
+
# https://cryptomate.me/docs/management#get-all-credentials-for-a-api-key
|
11
|
+
# @param [String] api_key (API-Key to see its credentials.)
|
12
|
+
# TODO: check response if it's an array or a hash
|
13
|
+
# Response:
|
14
|
+
# {
|
15
|
+
# "id": "string",
|
16
|
+
# "key": {
|
17
|
+
# "api_key": "string",
|
18
|
+
# "name": "string"
|
19
|
+
# },
|
20
|
+
# "operation": {
|
21
|
+
# "id": "string",
|
22
|
+
# "description": "string"
|
23
|
+
# }
|
24
|
+
# }
|
25
|
+
def get_all_credentials(api_key)
|
26
|
+
get("/management/credentials/api-key/#{api_key}")
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
29
|
+
# Get a credential information by id
|
30
|
+
# https://cryptomate.me/docs/management#get-a-credential-information
|
31
|
+
# @param [String] credential_id (Credential id to see its information.)
|
32
|
+
# Response:
|
33
|
+
# {
|
34
|
+
# "id": "string",
|
35
|
+
# "key": {
|
36
|
+
# "api_key": "string",
|
37
|
+
# "name": "string"
|
38
|
+
# },
|
39
|
+
# "operation": {
|
40
|
+
# "id": "string",
|
41
|
+
# "description": "string"
|
42
|
+
# }
|
43
|
+
# }
|
44
|
+
def get_credential(credential_id)
|
45
|
+
get("/management/credentials/#{credential_id}")
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
48
|
+
# Creates a credential for a API-Key and operation.
|
49
|
+
# https://cryptomate.me/docs/management#create-a-credential
|
50
|
+
# @param [String] api_key (API-Key to create the credential on.)
|
51
|
+
# @param [String] operation_id (Id of the operation to give credential.)
|
52
|
+
# Response:
|
53
|
+
# {
|
54
|
+
# "id": "string",
|
55
|
+
# "key": {
|
56
|
+
# "api_key": "string",
|
57
|
+
# "name": "string"
|
58
|
+
# },
|
59
|
+
# "operation": {
|
60
|
+
# "id": "string",
|
61
|
+
# "description": "string"
|
62
|
+
# }
|
63
|
+
# }
|
64
|
+
def create_credential(api_key, operation_id)
|
65
|
+
post('/management/credentials', body: { api_key:, operation_id: }.to_json)
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
68
|
+
# Modifies a credential by ID.
|
69
|
+
# https://cryptomate.me/docs/management#update-a-credential
|
70
|
+
# @param [String] credential_id (Id of the credential to modify.)
|
71
|
+
# @param [String] api_key (Api-key to modify its credential.)
|
72
|
+
# @param [String] operation_id (Id of the operation.)
|
73
|
+
# Response:
|
74
|
+
# {
|
75
|
+
# "id": "string",
|
76
|
+
# "key": {
|
77
|
+
# "api_key": "string",
|
78
|
+
# "name": "string"
|
79
|
+
# },
|
80
|
+
# "operation": {
|
81
|
+
# "id": "string",
|
82
|
+
# "description": "string"
|
83
|
+
# }
|
84
|
+
# }
|
85
|
+
def update_credential(credential_id, api_key, operation_id)
|
86
|
+
put("/management/credentials/#{credential_id}", body: { api_key:, operation_id: }.to_json)
|
87
|
+
end
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
89
|
+
# Deletes a credential by ID.
|
90
|
+
# https://cryptomate.me/docs/management#delete-a-credential
|
91
|
+
# @param [String] credential_id (Id of the credential to delete.)
|
92
|
+
def delete_credential(credential_id)
|
93
|
+
delete("/management/credentials/#{credential_id}")
|
94
|
+
end
|
93
95
|
end
|
94
96
|
end
|
95
97
|
end
|
@@ -6,66 +6,68 @@ module CryptomateApi
|
|
6
6
|
# You can create, modify and delete them.
|
7
7
|
# This api-keys are used to authenticate the clients in the platform.
|
8
8
|
class Key < CryptomateApi::Base
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
9
|
+
class << self
|
10
|
+
# Get all keys
|
11
|
+
# https://cryptomate.me/docs/management#get-all-keys
|
12
|
+
# Response:
|
13
|
+
# [
|
14
|
+
# {
|
15
|
+
# "api_key": "string",
|
16
|
+
# "name": "string"
|
17
|
+
# }
|
18
|
+
# ]
|
19
|
+
def get_all_keys
|
20
|
+
get('/management/keys/list')
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
# Get a specific key
|
24
|
+
# https://cryptomate.me/docs/management#get-a-key
|
25
|
+
# Response:
|
26
|
+
# [
|
27
|
+
# {
|
28
|
+
# "api_key": "string",
|
29
|
+
# "name": "string"
|
30
|
+
# }
|
31
|
+
# ]
|
32
|
+
def get_key(key_id)
|
33
|
+
get("/management/keys/#{key_id}")
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
36
|
+
# Create a key
|
37
|
+
# https://cryptomate.me/docs/management#create-a-key
|
38
|
+
# @param [String] name (Alias name of the API-Key to create.)
|
39
|
+
# Response:
|
40
|
+
# [
|
41
|
+
# {
|
42
|
+
# "api_key": "string",
|
43
|
+
# "name": "string"
|
44
|
+
# }
|
45
|
+
# ]
|
46
|
+
def create_key(name)
|
47
|
+
post('/management/keys/create', body: { name: }.to_json)
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
50
|
+
# Modify a key
|
51
|
+
# https://cryptomate.me/docs/management#modify-a-key
|
52
|
+
# @param [String] key_name (Name of the key to modify.)
|
53
|
+
# @param [String] new_api_key_value (New api-key value.)
|
54
|
+
# Response:
|
55
|
+
# [
|
56
|
+
# {
|
57
|
+
# "api_key": "string",
|
58
|
+
# "name": "string"
|
59
|
+
# }
|
60
|
+
# ]
|
61
|
+
def modify_key(key_name, new_api_key_value)
|
62
|
+
put("/management/keys/#{key_name}", body: { api_key: new_api_key_value }.to_json)
|
63
|
+
end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
# Delete a key
|
66
|
+
# https://cryptomate.me/docs/management#delete-a-key
|
67
|
+
# @param [String] api_key (Id of the API-Key. Ex: master-ac8ff424-426f-46a7-94c3-13932c6e8adf)
|
68
|
+
def delete_key(api_key)
|
69
|
+
delete("/management/keys/#{api_key}")
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
@@ -5,28 +5,30 @@ module CryptomateApi
|
|
5
5
|
# Get all the operations available in the platform.
|
6
6
|
# You can use this information to create new credentials for your clients.
|
7
7
|
class Operation < CryptomateApi::Base
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
class << self
|
9
|
+
# Get all operations
|
10
|
+
# https://cryptomate.me/docs/management#get-all-operations
|
11
|
+
# Response:
|
12
|
+
# [
|
13
|
+
# {
|
14
|
+
# "id": "string",
|
15
|
+
# "description": "string"
|
16
|
+
# }
|
17
|
+
# ]
|
18
|
+
def get_all_operations
|
19
|
+
get('/management/operations/list')
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
# Get a specific operation
|
23
|
+
# https://cryptomate.me/docs/management#get-a-operation
|
24
|
+
# Response:
|
25
|
+
# {
|
26
|
+
# "id": "string",
|
27
|
+
# "description": "string"
|
28
|
+
# }
|
29
|
+
def get_operation(operation_id)
|
30
|
+
get("/management/operations/#{operation_id}")
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -6,65 +6,67 @@ module CryptomateApi
|
|
6
6
|
# This allows you to manage your crypto assets in a more organized manner,
|
7
7
|
# and also allows you to create multiple wallets for the same or different blockchain.
|
8
8
|
class Account < CryptomateApi::Base
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
9
|
+
class << self
|
10
|
+
# Get all accounts
|
11
|
+
# https://cryptomate.me/docs/mpc#get-all-accounts
|
12
|
+
# TODO: check response if it's an array or a hash
|
13
|
+
# Response:
|
14
|
+
# {
|
15
|
+
# "id": "string",
|
16
|
+
# "alias": "string",
|
17
|
+
# "wallets": [
|
18
|
+
# {
|
19
|
+
# "id": "string",
|
20
|
+
# "alias": "string",
|
21
|
+
# "wallet_address": "string",
|
22
|
+
# "blockchain": "string"
|
23
|
+
# }
|
24
|
+
# ]
|
25
|
+
# }
|
26
|
+
def get_all_accounts
|
27
|
+
get('/mpc/accounts/list')
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
30
|
+
# Create an account
|
31
|
+
# https://cryptomate.me/docs/mpc/create-an-account
|
32
|
+
# @param [String] alias_name (Alias name of the account to create.)
|
33
|
+
# Response:
|
34
|
+
# {
|
35
|
+
# "id": "String",
|
36
|
+
# "alias": "String",
|
37
|
+
# "wallets": []
|
38
|
+
# }
|
39
|
+
def create_account(alias_name)
|
40
|
+
post('/mpc/accounts/create', body: { alias: alias_name }.to_json)
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
43
|
+
# Edit account: Modifies the account information.
|
44
|
+
# https://cryptomate.me/docs/mpc/edit-account
|
45
|
+
# @param [String] account_id (Id of the account to edit.)
|
46
|
+
# @param [String] alias_name (New alias name of the account.)
|
47
|
+
# Response:
|
48
|
+
# {
|
49
|
+
# "id": "string",
|
50
|
+
# "alias": "string",
|
51
|
+
# "wallets": [
|
52
|
+
# {
|
53
|
+
# "id": "string",
|
54
|
+
# "alias": "string",
|
55
|
+
# "wallet_address": "string",
|
56
|
+
# "blockchain": "string"
|
57
|
+
# }
|
58
|
+
# ]
|
59
|
+
# }
|
60
|
+
def edit_account(account_id, alias_name)
|
61
|
+
put("/mpc/account/#{account_id}", body: { alias: alias_name }.to_json)
|
62
|
+
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
# Delete account
|
65
|
+
# https://cryptomate.me/docs/mpc/delete-account
|
66
|
+
# @param [String] account_id (Id of the account to delete.)
|
67
|
+
def delete_account(account_id)
|
68
|
+
delete("/mpc/account/#{account_id}")
|
69
|
+
end
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
@@ -6,111 +6,113 @@ module CryptomateApi
|
|
6
6
|
# This allows you to manage your crypto assets in a more organized manner,
|
7
7
|
# and also allows you to create multiple wallets for the same or different blockchain.
|
8
8
|
class Wallet < CryptomateApi::Base
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
9
|
+
class << self
|
10
|
+
# Get a wallet: Retrieves a wallet by ID.
|
11
|
+
# https://cryptomate.me/docs/mpc/get-a-wallet
|
12
|
+
# @param [String] account_id (Id of the account to get the wallet from.)
|
13
|
+
# @param [String] wallet_id (Id of the wallet to get.)
|
14
|
+
# Response:
|
15
|
+
# {
|
16
|
+
# "id": "string",
|
17
|
+
# "alias": "string",
|
18
|
+
# "wallet_address": "string",
|
19
|
+
# "blockchain": "string"
|
20
|
+
# }
|
21
|
+
def get_wallet(account_id, wallet_id)
|
22
|
+
get("/mpc/accounts/#{account_id}/wallets/#{wallet_id}")
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
# Get all wallets for an account
|
26
|
+
# https://cryptomate.me/docs/mpc/get-all-wallets
|
27
|
+
# @param [String] account_id (Id of the account to get the wallets from.)
|
28
|
+
# TODO: check response if it's an array or a hash
|
29
|
+
# Response:
|
30
|
+
# {
|
31
|
+
# "id": "string",
|
32
|
+
# "alias": "string",
|
33
|
+
# "wallet_address": "string",
|
34
|
+
# "blockchain": "string"
|
35
|
+
# }
|
36
|
+
def get_all_wallets(account_id)
|
37
|
+
get("/mpc/accounts/#{account_id}/wallets/list")
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
40
|
+
# Create a new wallet for an account
|
41
|
+
# https://cryptomate.me/docs/mpc/create-a-wallet
|
42
|
+
# @param [String] account_id (Id of the account to create the wallet on.)
|
43
|
+
# @param [String] alias_name (Alias name of the wallet to create.)
|
44
|
+
# @param [String] blockchain (Blockchain of the wallet to create.)
|
45
|
+
# Response:
|
46
|
+
# {
|
47
|
+
# "id": "string",
|
48
|
+
# "alias": "string",
|
49
|
+
# "wallet_address": "string",
|
50
|
+
# "blockchain": "string"
|
51
|
+
# }
|
52
|
+
def create_wallet(account_id, alias_name, blockchain)
|
53
|
+
post("/mpc/accounts/#{account_id}/wallets/create", body: { alias: alias_name, blockchain: }.to_json)
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
56
|
+
# Update a wallet: Modifies the wallet information.
|
57
|
+
# https://cryptomate.me/docs/mpc/update-wallet
|
58
|
+
# @param [String] account_id (Id of the account to update the wallet on.)
|
59
|
+
# @param [String] wallet_id (Id of the wallet to update.)
|
60
|
+
# @param [String] alias_name (Alias to identify the wallet to update.)
|
61
|
+
# Response:
|
62
|
+
# {
|
63
|
+
# "id": "string",
|
64
|
+
# "alias": "string",
|
65
|
+
# "wallet_address": "string",
|
66
|
+
# "blockchain": "string"
|
67
|
+
# }
|
68
|
+
def update_wallet(account_id, wallet_id, alias_name)
|
69
|
+
put("/mpc/accounts/#{account_id}/wallets/#{wallet_id}", body: { alias: alias_name }.to_json)
|
70
|
+
end
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
72
|
+
# Transfer Token
|
73
|
+
# Transfer any of the listed tokens that are in your MPC wallet to another wallet (internal or external).
|
74
|
+
# The status determines the transaction state. Normally, the service will return SUCCESSFUL or FAILED.
|
75
|
+
# In some cases, if the blockchain is congested, the service may return a PENDING state, which means that
|
76
|
+
# the transaction is still waiting to be processed. But sometimes, due to variations in gas prices from
|
77
|
+
# block to block, a transaction may be in a state where it was sent to be processed but the blockchain did
|
78
|
+
# not program it to be executed. In these cases, the transaction will be marked as MANUAL_CHECK and will
|
79
|
+
# need to be verified manually.
|
80
|
+
# https://cryptomate.me/docs/mpc/transfer-token
|
81
|
+
# @param [String] account_id (Id of the account to transfer the token from.)
|
82
|
+
# @param [String] wallet_id (Id of the wallet to transfer the token from.)
|
83
|
+
# @param [String] token_address (Address of the contract for the token to transfer. This address can be obtained from the listed token API.)
|
84
|
+
# @param [String] amount (Amount of the selected asset to be send. Ex: 123.45.)
|
85
|
+
# @param [String] to (Address of the receiver wallet.)
|
86
|
+
# Response:
|
87
|
+
# {
|
88
|
+
# "transaction_hash": "string",
|
89
|
+
# "status": "success|failed|pending|manual_check"
|
90
|
+
# }
|
91
|
+
def transfer_token(account_id, wallet_id, token_address, amount, to)
|
92
|
+
post(
|
93
|
+
"/mpc/accounts/#{account_id}/wallets/#{wallet_id}/transfer",
|
94
|
+
body: { token_address:, amount:, to: }.to_json
|
95
|
+
)
|
96
|
+
end
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
98
|
+
# Get balance
|
99
|
+
# https://cryptomate.me/docs/mpc#balance
|
100
|
+
# Returns the balance of all the listed tokens from the blockchain of a wallet,
|
101
|
+
# with the amount of them even if they are 0.
|
102
|
+
# @param [String] account_id (Id of the account to get the balance from.)
|
103
|
+
# @param [String] wallet_id (Id of the wallet to get the balance from.)
|
104
|
+
# Response:
|
105
|
+
# [
|
106
|
+
# {
|
107
|
+
# "name": "string",
|
108
|
+
# "symbol": "string",
|
109
|
+
# "balance": 0.0,
|
110
|
+
# "token_address": "string"
|
111
|
+
# }
|
112
|
+
# ]
|
113
|
+
def get_balance(account_id, wallet_id)
|
114
|
+
get("/mpc/accounts/#{account_id}/wallets/#{wallet_id}/balance")
|
115
|
+
end
|
114
116
|
end
|
115
117
|
end
|
116
118
|
end
|
@@ -16,47 +16,49 @@ module CryptomateApi
|
|
16
16
|
# This notification will contain the status of the payment.
|
17
17
|
#
|
18
18
|
class Payment < Base
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
19
|
+
class << self
|
20
|
+
# Creates a new payment request.
|
21
|
+
# https://cryptomate.me/docs/payments#create-payments-request
|
22
|
+
# @param [String] token_address (Address of the contract from the token to transfer.)
|
23
|
+
# @param [double] amount (Amount of the selected asset to be payed.)
|
24
|
+
# @param [String] blockchain (Blockchain to create the payment.)
|
25
|
+
# Response:
|
26
|
+
# {
|
27
|
+
# "id": "String",
|
28
|
+
# "token_address": "String",
|
29
|
+
# "wallet_address": "String",
|
30
|
+
# "amount": "Decimal",
|
31
|
+
# }
|
32
|
+
def create_payments_request(token_address, amount, blockchain)
|
33
|
+
post('/commerce/payments/create', body: { token_address:, amount:, blockchain: }.to_json)
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
36
|
+
# Returns all the pending payments.
|
37
|
+
# https://cryptomate.me/docs/payments#pending-payments
|
38
|
+
# Response:
|
39
|
+
# [
|
40
|
+
# {
|
41
|
+
# "id": "String",
|
42
|
+
# "token_address": "String",
|
43
|
+
# "wallet_address": "String",
|
44
|
+
# "amount": "Decimal",
|
45
|
+
# }
|
46
|
+
# ]
|
47
|
+
def pending_payments
|
48
|
+
get('/commerce/payments/list')
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
# Retrieves all the listed tokens to create payments. In the response you will see the token name and it's address on the blockchain.
|
52
|
+
# https://cryptomate.me/docs/payments#get-listed-tokens
|
53
|
+
# @param [String] blockchain (Blockchain to get the listed tokens.)
|
54
|
+
# Response:
|
55
|
+
# {
|
56
|
+
# "Token name 1": "String",
|
57
|
+
# "Token name 2": "String",
|
58
|
+
# }
|
59
|
+
def get_listed_tokens(blockchain)
|
60
|
+
get("/commerce/payments/#{blockchain}/tokens")
|
61
|
+
end
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
data/lib/cryptomate_api.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptomate_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matias Albarello
|
@@ -45,7 +45,6 @@ files:
|
|
45
45
|
- cryptomate_api.gemspec
|
46
46
|
- lib/cryptomate_api.rb
|
47
47
|
- lib/cryptomate_api/base.rb
|
48
|
-
- lib/cryptomate_api/configuration.rb
|
49
48
|
- lib/cryptomate_api/management/blockchain.rb
|
50
49
|
- lib/cryptomate_api/management/client.rb
|
51
50
|
- lib/cryptomate_api/management/configuration.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CryptomateApi
|
4
|
-
class << self
|
5
|
-
attr_accessor :configuration
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.configure
|
9
|
-
self.configuration ||= Configuration.new
|
10
|
-
yield(configuration)
|
11
|
-
end
|
12
|
-
|
13
|
-
class Configuration
|
14
|
-
attr_accessor :api_key, :base_uri
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@api_key = nil
|
18
|
-
@base_uri = 'https://cryptomate.me/api'
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|