cryptomate_api 0.1.4 → 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.
@@ -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
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ # The Payments tool is designed to create payments in specific assets through a secure escrow wallet system.
5
+ # To use this module, you will first need to set up your `payment_address` on the Management API. This address is where you want to receive your funds once the payment is complete.
6
+
7
+ # Once you have set up your `payment_address`, you can use the Payments API to create payments in the following steps:
8
+
9
+ # 1. Create a payment intent: is a representation of a payment that is being processed. To create a payment intent, you will need to specify the following information:
10
+ # a. The amount of the payment
11
+ # b. The address of the asset in which the payment is to be made (Check listed token API from this section)
12
+ # c. The blockchain where your assets exists (Check get blockchain from the Management API)
13
+ # 2. Send the customer the address returned by this service.
14
+
15
+ # Once the customer has completed the payment, you will receive a webhook notification (configurable in Management API).
16
+ # This notification will contain the status of the payment.
17
+ #
18
+ class Payment < Base
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
35
+
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
50
+
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
62
+ end
63
+ end
64
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CryptomateApi
4
- VERSION = "0.1.4"
4
+ VERSION = '0.3.0'
5
5
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'cryptomate_api/configuration'
4
3
  require_relative 'cryptomate_api/base'
4
+ require_relative 'cryptomate_api/payment'
5
5
 
6
- Dir[File.join(__dir__, 'cryptomate_api/{management,mpc,nft}/**/*.rb')].sort.each { |file| require file }
6
+ Dir[File.join(__dir__, 'cryptomate_api/{management,mpc}/**/*.rb')].each { |file| require file }
7
7
 
8
8
  module CryptomateApi
9
9
  class Error < StandardError; end
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.1.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Albarello
@@ -24,9 +24,10 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.18'
27
- description: Provides a Ruby interface to the CryptoMate API, allowing easy access
28
- to cryptocurrency data and transaction operations. Supports retrieving currency
29
- details, creating and fetching transactions, and managing user information.
27
+ description: |-
28
+ Provides a Ruby interface to the CryptoMate API, allowing easy access to cryptocurrency data and \
29
+ transaction operations. Supports retrieving currency details, creating and fetching transactions, \
30
+ and managing user information.
30
31
  email:
31
32
  - matias.albarello@gmail.com
32
33
  executables: []
@@ -38,12 +39,12 @@ files:
38
39
  - CHANGELOG.md
39
40
  - CODE_OF_CONDUCT.md
40
41
  - Gemfile
42
+ - Gemfile.lock
41
43
  - README.md
42
44
  - Rakefile
43
45
  - cryptomate_api.gemspec
44
46
  - lib/cryptomate_api.rb
45
47
  - lib/cryptomate_api/base.rb
46
- - lib/cryptomate_api/configuration.rb
47
48
  - lib/cryptomate_api/management/blockchain.rb
48
49
  - lib/cryptomate_api/management/client.rb
49
50
  - lib/cryptomate_api/management/configuration.rb
@@ -52,6 +53,7 @@ files:
52
53
  - lib/cryptomate_api/management/operation.rb
53
54
  - lib/cryptomate_api/mpc/account.rb
54
55
  - lib/cryptomate_api/mpc/wallet.rb
56
+ - lib/cryptomate_api/payment.rb
55
57
  - lib/cryptomate_api/version.rb
56
58
  - sig/cryptomate_api.rbs
57
59
  homepage: https://github.com/matiasalbarello/cryptomate_api
@@ -61,6 +63,7 @@ metadata:
61
63
  homepage_uri: https://github.com/matiasalbarello/cryptomate_api
62
64
  source_code_uri: https://github.com/matiasalbarello/cryptomate_api
63
65
  changelog_uri: https://github.com/matiasalbarello/cryptomate_api/blob/main/CHANGELOG.md
66
+ rubygems_mfa_required: 'true'
64
67
  post_install_message:
65
68
  rdoc_options: []
66
69
  require_paths:
@@ -69,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
72
  requirements:
70
73
  - - ">="
71
74
  - !ruby/object:Gem::Version
72
- version: 2.6.0
75
+ version: '3.1'
73
76
  required_rubygems_version: !ruby/object:Gem::Requirement
74
77
  requirements:
75
78
  - - ">="
@@ -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