cryptomate_api 0.2.0 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '029b00c3b8c7a2e7659083238fa82c181269d650f9e4bb2615b60afa0b8e3e47'
4
- data.tar.gz: 34cca9b36b988938110cd54b8e2637741f64194f69e55cbfd3bcf9c8dbbfac29
3
+ metadata.gz: 906be66131260ee217ea113c34d721097024af3ccfd109357b16cb63db2710c0
4
+ data.tar.gz: 94433f3e67c9d62a522e85c640c54a263f0558f049a42ff737d1cef4137838ce
5
5
  SHA512:
6
- metadata.gz: 859353f5ada4b053995c8752acb8641bb701267344373f584dcbb14bca8f626bf70d775fc2f894a63e7cb4b60a55df10fc1d5292910694bed6ebf994aa8a2545
7
- data.tar.gz: effa9092de8200bbf583292928116729c2a9883966103e3c75de9fe0e105cfb9592194a5a430702ebbb4e0ba2a2b90bbdbb75a59acf617b0d22cfd08cc876673
6
+ metadata.gz: dd6398f342185320a4e848bf3d9a21561d9b0070cf42b6665b004728fb35fdc84a01a350e0b3d8f38aacbb0c46354d31af2eb4235b0db457cad9ebc95a545ab9
7
+ data.tar.gz: 784af7e1d756604e05fa01e56f000cdb852383f8b2047cefeb427a6450ebdf21b5d35a08954ab6f209acdf2c893726f4a7fee3016af783731f31152a37a0c8b5
data/README.md CHANGED
@@ -31,8 +31,6 @@ require 'cryptomate_api'
31
31
 
32
32
  CryptomateApi.configure do |config|
33
33
  config.api_key = 'your_api_key_here'
34
-
35
- # optional:
36
34
  config.base_uri = 'your-sandbox-uri'
37
35
  end
38
36
  ```
@@ -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
- # Initializes the client with the given API key
10
- def initialize
11
- CryptomateApi.configuration ||= CryptomateApi::Configuration.new
12
- @api_key = CryptomateApi.configuration.api_key
13
- self.class.base_uri CryptomateApi.configuration.base_uri
14
- self.class.headers 'x-api-key' => @api_key
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
- # Get all blockchains
10
- # https://cryptomate.me/docs/management#get-all-blockchains
11
- # Response:
12
- # [
13
- # {
14
- # "id": "string",
15
- # "description": "string"
16
- # }
17
- # ]
18
- def get_all_blockchains
19
- self.class.get('/management/blockchains/list')
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
- # Get clients information
9
- # https://cryptomate.me/docs/management#get-clients-information
10
- # Response:
11
- # {
12
- # "name": "string",
13
- # "last_name": "string",
14
- # "email": "string",
15
- # "social_reason": "string",
16
- # "webhook_url": "string",
17
- # }
18
- def get_clients
19
- self.class.get('/management/clients')
20
- end
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
- # Update Webhook-Url
23
- # https://cryptomate.me/docs/management#update-webhook-url
24
- # @param [String] webhook_url (New webhook url to use to inform any changes.)
25
- # Response:
26
- # {
27
- # "name": "string",
28
- # "email": "string",
29
- # "webhook_url": "string"
30
- # }
31
- def update_webhook_url(webhook_url)
32
- self.class.patch('/management/clients/webhook-url', body: { webhook_url: }.to_json)
33
- end
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
- # Update Client-Information
36
- # https://cryptomate.me/docs/management#update-client-information
37
- # @param [String] name (Name of the client to update.)
38
- # @param [String] email (Email of the client to update.)
39
- # @param [String] webhook_url (New webhook url to use to inform any changes.)
40
- # Response:
41
- # {
42
- # "name": "string",
43
- # "email": "string",
44
- # "webhook_url": "string"
45
- # }
46
- def update_client_information(name, email, webhook_url)
47
- self.class.put('/management/clients', body: { name:, email:, webhook_url: }.to_json)
48
- end
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
- # Update Payment Address
51
- # https://cryptomate.me/docs/management#update-payments-address
52
- # @param [String] address (Address where you want to receive the payments)
53
- # @param [String] blockchain (Blockchain where you want to receive the payments)
54
- # Response:
55
- # {
56
- # "address": "string",
57
- # }
58
- def update_payment_address(address, blockchain)
59
- self.class.patch('/management/clients/payment-treasury', body: { address:, blockchain: }.to_json)
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
- # Get payment destination
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
- # Set payment destination
21
- # Sets the treasury wallet that all the payments will sent after being completed.
22
- # https://cryptomate.me/docs/management#set-payment-destination
23
- # @param [String] address (Address of the treasury wallet)
24
- # @param [String] blockchain (Id of the blockchain.)
25
- # Response: None
26
- def set_payment_destination(address, blockchain)
27
- self.class.post('/management/configurations/payments', body: { address:, blockchain: }.to_json)
28
- end
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
- # Delete payment destination
31
- # Deletes the treasury wallet that all the payments will sent after being completed.
32
- # https://cryptomate.me/docs/management#delete-payment-destination
33
- # @param [String] blockchain (Id of the blockchain.)
34
- # Response: None
35
- def delete_payment_destination(blockchain)
36
- self.class.delete("/management/configurations/payments/#{blockchain}")
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
- # Get all credentials for an API-Key
9
- # https://cryptomate.me/docs/management#get-all-credentials-for-a-api-key
10
- # @param [String] api_key (API-Key to see its credentials.)
11
- # TODO: check response if it's an array or a hash
12
- # Response:
13
- # {
14
- # "id": "string",
15
- # "key": {
16
- # "api_key": "string",
17
- # "name": "string"
18
- # },
19
- # "operation": {
20
- # "id": "string",
21
- # "description": "string"
22
- # }
23
- # }
24
- def get_all_credentials(api_key)
25
- self.class.get("/management/credentials/api-key/#{api_key}")
26
- end
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
- # Get a credential information by id
29
- # https://cryptomate.me/docs/management#get-a-credential-information
30
- # @param [String] credential_id (Credential id to see its information.)
31
- # Response:
32
- # {
33
- # "id": "string",
34
- # "key": {
35
- # "api_key": "string",
36
- # "name": "string"
37
- # },
38
- # "operation": {
39
- # "id": "string",
40
- # "description": "string"
41
- # }
42
- # }
43
- def get_credential(credential_id)
44
- self.class.get("/management/credentials/#{credential_id}")
45
- end
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
- # Creates a credential for a API-Key and operation.
48
- # https://cryptomate.me/docs/management#create-a-credential
49
- # @param [String] api_key (API-Key to create the credential on.)
50
- # @param [String] operation_id (Id of the operation to give credential.)
51
- # Response:
52
- # {
53
- # "id": "string",
54
- # "key": {
55
- # "api_key": "string",
56
- # "name": "string"
57
- # },
58
- # "operation": {
59
- # "id": "string",
60
- # "description": "string"
61
- # }
62
- # }
63
- def create_credential(api_key, operation_id)
64
- self.class.post('/management/credentials', body: { api_key:, operation_id: }.to_json)
65
- end
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
- # Modifies a credential by ID.
68
- # https://cryptomate.me/docs/management#update-a-credential
69
- # @param [String] credential_id (Id of the credential to modify.)
70
- # @param [String] api_key (Api-key to modify its credential.)
71
- # @param [String] operation_id (Id of the operation.)
72
- # Response:
73
- # {
74
- # "id": "string",
75
- # "key": {
76
- # "api_key": "string",
77
- # "name": "string"
78
- # },
79
- # "operation": {
80
- # "id": "string",
81
- # "description": "string"
82
- # }
83
- # }
84
- def update_credential(credential_id, api_key, operation_id)
85
- self.class.put("/management/credentials/#{credential_id}", body: { api_key:, operation_id: }.to_json)
86
- end
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
- # Deletes a credential by ID.
89
- # https://cryptomate.me/docs/management#delete-a-credential
90
- # @param [String] credential_id (Id of the credential to delete.)
91
- def delete_credential(credential_id)
92
- self.class.delete("/management/credentials/#{credential_id}")
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
- # Get all keys
10
- # https://cryptomate.me/docs/management#get-all-keys
11
- # Response:
12
- # [
13
- # {
14
- # "api_key": "string",
15
- # "name": "string"
16
- # }
17
- # ]
18
- def get_all_keys
19
- self.class.get('/management/keys/list')
20
- end
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
- # Get a specific key
23
- # https://cryptomate.me/docs/management#get-a-key
24
- # Response:
25
- # [
26
- # {
27
- # "api_key": "string",
28
- # "name": "string"
29
- # }
30
- # ]
31
- def get_key(key_id)
32
- self.class.get("/management/keys/#{key_id}")
33
- end
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
- # Create a key
36
- # https://cryptomate.me/docs/management#create-a-key
37
- # @param [String] name (Alias name of the API-Key to create.)
38
- # Response:
39
- # [
40
- # {
41
- # "api_key": "string",
42
- # "name": "string"
43
- # }
44
- # ]
45
- def create_key(name)
46
- self.class.post('/management/keys/create', body: { name: }.to_json)
47
- end
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
- # Modify a key
50
- # https://cryptomate.me/docs/management#modify-a-key
51
- # @param [String] key_name (Name of the key to modify.)
52
- # @param [String] new_api_key_value (New api-key value.)
53
- # Response:
54
- # [
55
- # {
56
- # "api_key": "string",
57
- # "name": "string"
58
- # }
59
- # ]
60
- def modify_key(key_name, new_api_key_value)
61
- self.class.put("/management/keys/#{key_name}", body: { api_key: new_api_key_value }.to_json)
62
- end
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
- # Delete a key
65
- # https://cryptomate.me/docs/management#delete-a-key
66
- # @param [String] api_key (Id of the API-Key. Ex: master-ac8ff424-426f-46a7-94c3-13932c6e8adf)
67
- def delete_key(api_key)
68
- self.class.delete("/management/keys/#{api_key}")
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
- # Get all operations
9
- # https://cryptomate.me/docs/management#get-all-operations
10
- # Response:
11
- # [
12
- # {
13
- # "id": "string",
14
- # "description": "string"
15
- # }
16
- # ]
17
- def get_all_operations
18
- self.class.get('/management/operations/list')
19
- end
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
- # Get a specific operation
22
- # https://cryptomate.me/docs/management#get-a-operation
23
- # Response:
24
- # {
25
- # "id": "string",
26
- # "description": "string"
27
- # }
28
- def get_operation(operation_id)
29
- self.class.get("/management/operations/#{operation_id}")
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
- # Get all accounts
10
- # https://cryptomate.me/docs/mpc#get-all-accounts
11
- # TODO: check response if it's an array or a hash
12
- # Response:
13
- # {
14
- # "id": "string",
15
- # "alias": "string",
16
- # "wallets": [
17
- # {
18
- # "id": "string",
19
- # "alias": "string",
20
- # "wallet_address": "string",
21
- # "blockchain": "string"
22
- # }
23
- # ]
24
- # }
25
- def get_all_accounts
26
- self.class.get('/mpc/accounts/list')
27
- end
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
- # Create an account
30
- # https://cryptomate.me/docs/mpc/create-an-account
31
- # @param [String] alias_name (Alias name of the account to create.)
32
- # Response:
33
- # {
34
- # "id": "String",
35
- # "alias": "String",
36
- # "wallets": []
37
- # }
38
- def create_account(alias_name)
39
- self.class.post('/mpc/accounts/create', body: { alias: alias_name }.to_json)
40
- end
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
- # Edit account: Modifies the account information.
43
- # https://cryptomate.me/docs/mpc/edit-account
44
- # @param [String] account_id (Id of the account to edit.)
45
- # @param [String] alias_name (New alias name of the account.)
46
- # Response:
47
- # {
48
- # "id": "string",
49
- # "alias": "string",
50
- # "wallets": [
51
- # {
52
- # "id": "string",
53
- # "alias": "string",
54
- # "wallet_address": "string",
55
- # "blockchain": "string"
56
- # }
57
- # ]
58
- # }
59
- def edit_account(account_id, alias_name)
60
- self.class.put("/mpc/account/#{account_id}", body: { alias: alias_name }.to_json)
61
- end
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
- # Delete account
64
- # https://cryptomate.me/docs/mpc/delete-account
65
- # @param [String] account_id (Id of the account to delete.)
66
- def delete_account(account_id)
67
- self.class.delete("/mpc/account/#{account_id}")
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
- # Get a wallet: Retrieves a wallet by ID.
10
- # https://cryptomate.me/docs/mpc/get-a-wallet
11
- # @param [String] account_id (Id of the account to get the wallet from.)
12
- # @param [String] wallet_id (Id of the wallet to get.)
13
- # Response:
14
- # {
15
- # "id": "string",
16
- # "alias": "string",
17
- # "wallet_address": "string",
18
- # "blockchain": "string"
19
- # }
20
- def get_wallet(account_id, wallet_id)
21
- self.class.get("/mpc/accounts/#{account_id}/wallets/#{wallet_id}")
22
- end
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
- # Get all wallets for an account
25
- # https://cryptomate.me/docs/mpc/get-all-wallets
26
- # @param [String] account_id (Id of the account to get the wallets from.)
27
- # TODO: check response if it's an array or a hash
28
- # Response:
29
- # {
30
- # "id": "string",
31
- # "alias": "string",
32
- # "wallet_address": "string",
33
- # "blockchain": "string"
34
- # }
35
- def get_all_wallets(account_id)
36
- self.class.get("/mpc/accounts/#{account_id}/wallets/list")
37
- end
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
- # Create a new wallet for an account
40
- # https://cryptomate.me/docs/mpc/create-a-wallet
41
- # @param [String] account_id (Id of the account to create the wallet on.)
42
- # @param [String] alias_name (Alias name of the wallet to create.)
43
- # @param [String] blockchain (Blockchain of the wallet to create.)
44
- # Response:
45
- # {
46
- # "id": "string",
47
- # "alias": "string",
48
- # "wallet_address": "string",
49
- # "blockchain": "string"
50
- # }
51
- def create_wallet(account_id, alias_name, blockchain)
52
- self.class.post("/mpc/accounts/#{account_id}/wallets/create", body: { alias: alias_name, blockchain: }.to_json)
53
- end
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
- # Update a wallet: Modifies the wallet information.
56
- # https://cryptomate.me/docs/mpc/update-wallet
57
- # @param [String] account_id (Id of the account to update the wallet on.)
58
- # @param [String] wallet_id (Id of the wallet to update.)
59
- # @param [String] alias_name (Alias to identify the wallet to update.)
60
- # Response:
61
- # {
62
- # "id": "string",
63
- # "alias": "string",
64
- # "wallet_address": "string",
65
- # "blockchain": "string"
66
- # }
67
- def update_wallet(account_id, wallet_id, alias_name)
68
- self.class.put("/mpc/accounts/#{account_id}/wallets/#{wallet_id}", body: { alias: alias_name }.to_json)
69
- end
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
- # Transfer Token
72
- # Transfer any of the listed tokens that are in your MPC wallet to another wallet (internal or external).
73
- # The status determines the transaction state. Normally, the service will return SUCCESSFUL or FAILED.
74
- # In some cases, if the blockchain is congested, the service may return a PENDING state, which means that
75
- # the transaction is still waiting to be processed. But sometimes, due to variations in gas prices from
76
- # block to block, a transaction may be in a state where it was sent to be processed but the blockchain did
77
- # not program it to be executed. In these cases, the transaction will be marked as MANUAL_CHECK and will
78
- # need to be verified manually.
79
- # https://cryptomate.me/docs/mpc/transfer-token
80
- # @param [String] account_id (Id of the account to transfer the token from.)
81
- # @param [String] wallet_id (Id of the wallet to transfer the token from.)
82
- # @param [String] token_address (Address of the contract for the token to transfer. This address can be obtained from the listed token API.)
83
- # @param [String] amount (Amount of the selected asset to be send. Ex: 123.45.)
84
- # @param [String] to (Address of the receiver wallet.)
85
- # Response:
86
- # {
87
- # "transaction_hash": "string",
88
- # "status": "success|failed|pending|manual_check"
89
- # }
90
- def transfer_token(account_id, wallet_id, token_address, amount, to)
91
- self.class.post(
92
- "/mpc/accounts/#{account_id}/wallets/#{wallet_id}/transfer",
93
- body: { token_address:, amount:, to: }.to_json
94
- )
95
- end
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
- # Get balance
98
- # https://cryptomate.me/docs/mpc#balance
99
- # Returns the balance of all the listed tokens from the blockchain of a wallet,
100
- # with the amount of them even if they are 0.
101
- # @param [String] account_id (Id of the account to get the balance from.)
102
- # @param [String] wallet_id (Id of the wallet to get the balance from.)
103
- # Response:
104
- # [
105
- # {
106
- # "name": "string",
107
- # "symbol": "string",
108
- # "balance": 0.0,
109
- # "token_address": "string"
110
- # }
111
- # ]
112
- def get_balance(account_id, wallet_id)
113
- self.class.get("/mpc/accounts/#{account_id}/wallets/#{wallet_id}/balance")
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
- # Creates a new payment request.
20
- # https://cryptomate.me/docs/payments#create-payments-request
21
- # @param [String] token_address (Address of the contract from the token to transfer.)
22
- # @param [double] amount (Amount of the selected asset to be payed.)
23
- # @param [String] blockchain (Blockchain to create the payment.)
24
- # Response:
25
- # {
26
- # "id": "String",
27
- # "token_address": "String",
28
- # "wallet_address": "String",
29
- # "amount": "Decimal",
30
- # }
31
- def create_payments_request(token_address, amount, blockchain)
32
- self.class.post('/commerce/payments/create', body: { token_address:, amount:, blockchain: }.to_json)
33
- end
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
- # Returns all the pending payments.
36
- # https://cryptomate.me/docs/payments#pending-payments
37
- # Response:
38
- # [
39
- # {
40
- # "id": "String",
41
- # "token_address": "String",
42
- # "wallet_address": "String",
43
- # "amount": "Decimal",
44
- # }
45
- # ]
46
- def pending_payments
47
- self.class.get('/commerce/payments/list')
48
- end
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
- # Retrieves all the listed tokens to create payments. In the response you will see the token name and it's address on the blockchain.
51
- # https://cryptomate.me/docs/payments#get-listed-tokens
52
- # @param [String] blockchain (Blockchain to get the listed tokens.)
53
- # Response:
54
- # {
55
- # "Token name 1": "String",
56
- # "Token name 2": "String",
57
- # }
58
- def get_listed_tokens(blockchain)
59
- self.class.get("/commerce/payments/#{blockchain}/tokens")
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CryptomateApi
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'cryptomate_api/configuration'
4
3
  require_relative 'cryptomate_api/base'
5
4
  require_relative 'cryptomate_api/payment'
6
5
 
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.2.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