cryptomate_api 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -7
- data/CHANGELOG.md +7 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +67 -0
- data/Rakefile +3 -3
- data/cryptomate_api.gemspec +18 -15
- data/lib/cryptomate_api/base.rb +4 -2
- data/lib/cryptomate_api/management/blockchain.rb +1 -1
- data/lib/cryptomate_api/management/client.rb +4 -4
- data/lib/cryptomate_api/management/configuration.rb +1 -1
- data/lib/cryptomate_api/management/credential.rb +1 -1
- data/lib/cryptomate_api/management/key.rb +2 -2
- data/lib/cryptomate_api/management/operation.rb +1 -1
- data/lib/cryptomate_api/mpc/account.rb +2 -2
- data/lib/cryptomate_api/payment.rb +62 -0
- data/lib/cryptomate_api/version.rb +1 -1
- data/lib/cryptomate_api.rb +2 -1
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '029b00c3b8c7a2e7659083238fa82c181269d650f9e4bb2615b60afa0b8e3e47'
|
4
|
+
data.tar.gz: 34cca9b36b988938110cd54b8e2637741f64194f69e55cbfd3bcf9c8dbbfac29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 859353f5ada4b053995c8752acb8641bb701267344373f584dcbb14bca8f626bf70d775fc2f894a63e7cb4b60a55df10fc1d5292910694bed6ebf994aa8a2545
|
7
|
+
data.tar.gz: effa9092de8200bbf583292928116729c2a9883966103e3c75de9fe0e105cfb9592194a5a430702ebbb4e0ba2a2b90bbdbb75a59acf617b0d22cfd08cc876673
|
data/.rubocop.yml
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
2
|
+
NewCops: enable
|
3
|
+
TargetRubyVersion: 3.1
|
3
4
|
|
4
|
-
Style/
|
5
|
-
Enabled:
|
6
|
-
EnforcedStyle: double_quotes
|
5
|
+
Style/Documentation:
|
6
|
+
Enabled: false
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
EnforcedStyle: double_quotes
|
8
|
+
Naming/VariableNumber:
|
9
|
+
EnforcedStyle: snake_case
|
11
10
|
|
12
11
|
Layout/LineLength:
|
13
12
|
Max: 120
|
13
|
+
AllowedPatterns: ['(\A|\s)#'] # ignore comments
|
14
|
+
|
15
|
+
Lint/AmbiguousBlockAssociation:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Naming/AccessorMethodName:
|
19
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -3,3 +3,10 @@
|
|
3
3
|
## [0.1.0] - 2023-11-04
|
4
4
|
|
5
5
|
- Initial release
|
6
|
+
- Modules included:
|
7
|
+
- [Management](https://cryptomate.me/docs/management)
|
8
|
+
- [MPC](https://cryptomate.me/docs/mpc)
|
9
|
+
|
10
|
+
## [0.2.0] - 2023-11-30
|
11
|
+
|
12
|
+
- Added [Payments module](https://cryptomate.me/docs/payments)
|
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in cryptomate_api.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
8
|
+
gem 'rake', '~> 13.0'
|
9
9
|
|
10
|
-
gem
|
10
|
+
gem 'rspec', '~> 3.0'
|
11
11
|
|
12
|
-
gem
|
12
|
+
gem 'rubocop', '~> 1.21'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cryptomate_api (0.2.2)
|
5
|
+
httparty (~> 0.18)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
httparty (0.21.0)
|
13
|
+
mini_mime (>= 1.0.0)
|
14
|
+
multi_xml (>= 0.5.2)
|
15
|
+
json (2.6.3)
|
16
|
+
language_server-protocol (3.17.0.3)
|
17
|
+
mini_mime (1.1.5)
|
18
|
+
multi_xml (0.6.0)
|
19
|
+
parallel (1.23.0)
|
20
|
+
parser (3.2.2.4)
|
21
|
+
ast (~> 2.4.1)
|
22
|
+
racc
|
23
|
+
racc (1.7.3)
|
24
|
+
rainbow (3.1.1)
|
25
|
+
rake (13.1.0)
|
26
|
+
regexp_parser (2.8.2)
|
27
|
+
rexml (3.2.6)
|
28
|
+
rspec (3.12.0)
|
29
|
+
rspec-core (~> 3.12.0)
|
30
|
+
rspec-expectations (~> 3.12.0)
|
31
|
+
rspec-mocks (~> 3.12.0)
|
32
|
+
rspec-core (3.12.2)
|
33
|
+
rspec-support (~> 3.12.0)
|
34
|
+
rspec-expectations (3.12.3)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.12.0)
|
37
|
+
rspec-mocks (3.12.6)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.12.0)
|
40
|
+
rspec-support (3.12.1)
|
41
|
+
rubocop (1.57.2)
|
42
|
+
json (~> 2.3)
|
43
|
+
language_server-protocol (>= 3.17.0)
|
44
|
+
parallel (~> 1.10)
|
45
|
+
parser (>= 3.2.2.4)
|
46
|
+
rainbow (>= 2.2.2, < 4.0)
|
47
|
+
regexp_parser (>= 1.8, < 3.0)
|
48
|
+
rexml (>= 3.2.5, < 4.0)
|
49
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
50
|
+
ruby-progressbar (~> 1.7)
|
51
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
52
|
+
rubocop-ast (1.30.0)
|
53
|
+
parser (>= 3.2.1.0)
|
54
|
+
ruby-progressbar (1.13.0)
|
55
|
+
unicode-display_width (2.5.0)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
x86_64-darwin-22
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
cryptomate_api!
|
62
|
+
rake (~> 13.0)
|
63
|
+
rspec (~> 3.0)
|
64
|
+
rubocop (~> 1.21)
|
65
|
+
|
66
|
+
BUNDLED WITH
|
67
|
+
2.4.10
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
require
|
8
|
+
require 'rubocop/rake_task'
|
9
9
|
|
10
10
|
RuboCop::RakeTask.new
|
11
11
|
|
data/cryptomate_api.gemspec
CHANGED
@@ -1,31 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/cryptomate_api/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'cryptomate_api'
|
7
7
|
spec.version = CryptomateApi::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
10
|
-
spec.licenses = [
|
8
|
+
spec.authors = ['Matias Albarello']
|
9
|
+
spec.email = ['matias.albarello@gmail.com']
|
10
|
+
spec.licenses = ['MIT']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
|
15
|
-
|
12
|
+
spec.summary = 'Ruby client for the CryptoMate API.'
|
13
|
+
spec.description = 'Provides a Ruby interface to the CryptoMate API, allowing easy access to cryptocurrency data and \
|
14
|
+
transaction operations. Supports retrieving currency details, creating and fetching transactions, \
|
15
|
+
and managing user information.'
|
16
|
+
spec.homepage = 'https://github.com/matiasalbarello/cryptomate_api'
|
17
|
+
spec.required_ruby_version = '>= 3.1'
|
16
18
|
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
19
|
-
spec.metadata[
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
21
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
20
22
|
|
21
23
|
spec.files = Dir.chdir(__dir__) do
|
22
24
|
`git ls-files -z`.split("\x0").reject do |f|
|
23
25
|
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
24
26
|
end
|
25
27
|
end
|
26
|
-
spec.bindir =
|
28
|
+
spec.bindir = 'exe'
|
27
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = [
|
30
|
+
spec.require_paths = ['lib']
|
29
31
|
|
30
|
-
spec.add_dependency
|
32
|
+
spec.add_dependency 'httparty', '~> 0.18'
|
33
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
31
34
|
end
|
data/lib/cryptomate_api/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'httparty'
|
2
4
|
|
3
5
|
module CryptomateApi
|
@@ -9,7 +11,7 @@ module CryptomateApi
|
|
9
11
|
CryptomateApi.configuration ||= CryptomateApi::Configuration.new
|
10
12
|
@api_key = CryptomateApi.configuration.api_key
|
11
13
|
self.class.base_uri CryptomateApi.configuration.base_uri
|
12
|
-
self.class.headers
|
14
|
+
self.class.headers 'x-api-key' => @api_key
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -16,7 +16,7 @@ module CryptomateApi
|
|
16
16
|
# "webhook_url": "string",
|
17
17
|
# }
|
18
18
|
def get_clients
|
19
|
-
self.class.get(
|
19
|
+
self.class.get('/management/clients')
|
20
20
|
end
|
21
21
|
|
22
22
|
# Update Webhook-Url
|
@@ -29,7 +29,7 @@ module CryptomateApi
|
|
29
29
|
# "webhook_url": "string"
|
30
30
|
# }
|
31
31
|
def update_webhook_url(webhook_url)
|
32
|
-
self.class.patch(
|
32
|
+
self.class.patch('/management/clients/webhook-url', body: { webhook_url: }.to_json)
|
33
33
|
end
|
34
34
|
|
35
35
|
# Update Client-Information
|
@@ -44,7 +44,7 @@ module CryptomateApi
|
|
44
44
|
# "webhook_url": "string"
|
45
45
|
# }
|
46
46
|
def update_client_information(name, email, webhook_url)
|
47
|
-
self.class.put(
|
47
|
+
self.class.put('/management/clients', body: { name:, email:, webhook_url: }.to_json)
|
48
48
|
end
|
49
49
|
|
50
50
|
# Update Payment Address
|
@@ -56,7 +56,7 @@ module CryptomateApi
|
|
56
56
|
# "address": "string",
|
57
57
|
# }
|
58
58
|
def update_payment_address(address, blockchain)
|
59
|
-
self.class.patch(
|
59
|
+
self.class.patch('/management/clients/payment-treasury', body: { address:, blockchain: }.to_json)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -24,7 +24,7 @@ module CryptomateApi
|
|
24
24
|
# @param [String] blockchain (Id of the blockchain.)
|
25
25
|
# Response: None
|
26
26
|
def set_payment_destination(address, blockchain)
|
27
|
-
self.class.post(
|
27
|
+
self.class.post('/management/configurations/payments', body: { address:, blockchain: }.to_json)
|
28
28
|
end
|
29
29
|
|
30
30
|
# Delete payment destination
|
@@ -61,7 +61,7 @@ module CryptomateApi
|
|
61
61
|
# }
|
62
62
|
# }
|
63
63
|
def create_credential(api_key, operation_id)
|
64
|
-
self.class.post(
|
64
|
+
self.class.post('/management/credentials', body: { api_key:, operation_id: }.to_json)
|
65
65
|
end
|
66
66
|
|
67
67
|
# Modifies a credential by ID.
|
@@ -16,7 +16,7 @@ module CryptomateApi
|
|
16
16
|
# }
|
17
17
|
# ]
|
18
18
|
def get_all_keys
|
19
|
-
self.class.get(
|
19
|
+
self.class.get('/management/keys/list')
|
20
20
|
end
|
21
21
|
|
22
22
|
# Get a specific key
|
@@ -43,7 +43,7 @@ module CryptomateApi
|
|
43
43
|
# }
|
44
44
|
# ]
|
45
45
|
def create_key(name)
|
46
|
-
self.class.post(
|
46
|
+
self.class.post('/management/keys/create', body: { name: }.to_json)
|
47
47
|
end
|
48
48
|
|
49
49
|
# Modify a key
|
@@ -23,7 +23,7 @@ module CryptomateApi
|
|
23
23
|
# ]
|
24
24
|
# }
|
25
25
|
def get_all_accounts
|
26
|
-
self.class.get(
|
26
|
+
self.class.get('/mpc/accounts/list')
|
27
27
|
end
|
28
28
|
|
29
29
|
# Create an account
|
@@ -36,7 +36,7 @@ module CryptomateApi
|
|
36
36
|
# "wallets": []
|
37
37
|
# }
|
38
38
|
def create_account(alias_name)
|
39
|
-
self.class.post(
|
39
|
+
self.class.post('/mpc/accounts/create', body: { alias: alias_name }.to_json)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Edit account: Modifies the account information.
|
@@ -0,0 +1,62 @@
|
|
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
|
+
# 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
|
34
|
+
|
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
|
49
|
+
|
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")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/cryptomate_api.rb
CHANGED
@@ -2,8 +2,9 @@
|
|
2
2
|
|
3
3
|
require_relative 'cryptomate_api/configuration'
|
4
4
|
require_relative 'cryptomate_api/base'
|
5
|
+
require_relative 'cryptomate_api/payment'
|
5
6
|
|
6
|
-
Dir[File.join(__dir__, 'cryptomate_api/{management,mpc
|
7
|
+
Dir[File.join(__dir__, 'cryptomate_api/{management,mpc}/**/*.rb')].each { |file| require file }
|
7
8
|
|
8
9
|
module CryptomateApi
|
9
10
|
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.
|
4
|
+
version: 0.2.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:
|
28
|
-
to
|
29
|
-
|
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,6 +39,7 @@ 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
|
@@ -52,6 +54,7 @@ files:
|
|
52
54
|
- lib/cryptomate_api/management/operation.rb
|
53
55
|
- lib/cryptomate_api/mpc/account.rb
|
54
56
|
- lib/cryptomate_api/mpc/wallet.rb
|
57
|
+
- lib/cryptomate_api/payment.rb
|
55
58
|
- lib/cryptomate_api/version.rb
|
56
59
|
- sig/cryptomate_api.rbs
|
57
60
|
homepage: https://github.com/matiasalbarello/cryptomate_api
|
@@ -61,6 +64,7 @@ metadata:
|
|
61
64
|
homepage_uri: https://github.com/matiasalbarello/cryptomate_api
|
62
65
|
source_code_uri: https://github.com/matiasalbarello/cryptomate_api
|
63
66
|
changelog_uri: https://github.com/matiasalbarello/cryptomate_api/blob/main/CHANGELOG.md
|
67
|
+
rubygems_mfa_required: 'true'
|
64
68
|
post_install_message:
|
65
69
|
rdoc_options: []
|
66
70
|
require_paths:
|
@@ -69,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
73
|
requirements:
|
70
74
|
- - ">="
|
71
75
|
- !ruby/object:Gem::Version
|
72
|
-
version:
|
76
|
+
version: '3.1'
|
73
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
78
|
requirements:
|
75
79
|
- - ">="
|