cryptomate_api 0.1.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 665269594527cdc382621877f03ce9945b856cd13564bda1602db1025fda8691
4
- data.tar.gz: fe1fc8c40784ff932c02416be565846f6045dc8d3f06bd92185765fc2d4561aa
3
+ metadata.gz: 906be66131260ee217ea113c34d721097024af3ccfd109357b16cb63db2710c0
4
+ data.tar.gz: 94433f3e67c9d62a522e85c640c54a263f0558f049a42ff737d1cef4137838ce
5
5
  SHA512:
6
- metadata.gz: 1b8d78e0075c9cb87a036aba6153cc5d5ef4f93e65e71346d749221a465b25808a400dd0fb874cf96435c54be05eaadba81006b3addef6fb9347674a8e515baf
7
- data.tar.gz: dc44a554406da97883282b4bd583d343a9c6cd7732d78dd78dad1e9ac8db942d934f4b1cc91646888cb7f987461a9e6410eba03ee3fe0da01bdfe3d1b7ee060a
6
+ metadata.gz: dd6398f342185320a4e848bf3d9a21561d9b0070cf42b6665b004728fb35fdc84a01a350e0b3d8f38aacbb0c46354d31af2eb4235b0db457cad9ebc95a545ab9
7
+ data.tar.gz: 784af7e1d756604e05fa01e56f000cdb852383f8b2047cefeb427a6450ebdf21b5d35a08954ab6f209acdf2c893726f4a7fee3016af783731f31152a37a0c8b5
data/.rubocop.yml CHANGED
@@ -1,13 +1,19 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.1
3
4
 
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
5
+ Style/Documentation:
6
+ Enabled: false
7
7
 
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
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 "https://rubygems.org"
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 "rake", "~> 13.0"
8
+ gem 'rake', '~> 13.0'
9
9
 
10
- gem "rspec", "~> 3.0"
10
+ gem 'rspec', '~> 3.0'
11
11
 
12
- gem "rubocop", "~> 1.21"
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/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
  ```
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
8
+ require 'rubocop/rake_task'
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
@@ -1,31 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "lib/cryptomate_api/version"
3
+ require_relative 'lib/cryptomate_api/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "cryptomate_api"
6
+ spec.name = 'cryptomate_api'
7
7
  spec.version = CryptomateApi::VERSION
8
- spec.authors = ["Matias Albarello"]
9
- spec.email = ["matias.albarello@gmail.com"]
10
- spec.licenses = ["MIT"]
8
+ spec.authors = ['Matias Albarello']
9
+ spec.email = ['matias.albarello@gmail.com']
10
+ spec.licenses = ['MIT']
11
11
 
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 transaction operations. Supports retrieving currency details, creating and fetching transactions, and managing user information."
14
- spec.homepage = "https://github.com/matiasalbarello/cryptomate_api"
15
- spec.required_ruby_version = ">= 2.6.0"
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["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
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 = "exe"
28
+ spec.bindir = 'exe'
27
29
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
30
+ spec.require_paths = ['lib']
29
31
 
30
- spec.add_dependency "httparty", "~> 0.18"
32
+ spec.add_dependency 'httparty', '~> 0.18'
33
+ spec.metadata['rubygems_mfa_required'] = 'true'
31
34
  end
@@ -1,15 +1,42 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'httparty'
2
4
 
3
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
+
4
20
  class Base
5
21
  include HTTParty
6
22
 
7
- # Initializes the client with the given API key
8
- def initialize
9
- CryptomateApi.configuration ||= CryptomateApi::Configuration.new
10
- @api_key = CryptomateApi.configuration.api_key
11
- self.class.base_uri CryptomateApi.configuration.base_uri
12
- 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
13
40
  end
14
41
  end
15
- end
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