cryptomate_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 01ca8f5c3116e059e1bfc7988057b7ec6005f47cf7e13f3446929c16d2b92216
4
+ data.tar.gz: e7ebffbebe64b76ae748fd3ad838c79f0d29b98bd34b0443bdecc7570897799a
5
+ SHA512:
6
+ metadata.gz: 59accf08c6decfa7958efea06fceecb1e6c216394edb56d3b47664e89fb21605468e50d785317c79abdb96d45adf0e7b472df4bdbae086e84f0d81dd48e7d316
7
+ data.tar.gz: 9fc4a32a8856c6f67e25cd149002aa5ff5626afdc4cbee76e9ebdad8c3b66c70e5b67b334c1226773183c070c6df2b7f3442d96c0df3c682a22fe7b3e63e50cb
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-11-04
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 1678497+matiasalbarello@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in cryptomate_api.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # CryptomateApi
2
+
3
+ Welcome to the `cryptomate_api` gem! This library is designed to interface with the [Cryptomate API](https://cryptomate.me/docs), providing a simple and efficient way to integrate cryptocurrency data into your Ruby applications.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'cryptomate_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ bundle install
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ gem install cryptomate_api
23
+ ```
24
+
25
+ ## Configuration
26
+
27
+ Before using the `cryptomate_api` gem, configure the global API key as follows:
28
+
29
+ ```ruby
30
+ require 'cryptomate_api'
31
+
32
+ CryptomateApi.configure do |config|
33
+ config.api_key = 'your_api_key_here'
34
+ end
35
+ ```
36
+ ## Usage
37
+
38
+ Here's a quick example of how to use `cryptomate_api`:
39
+
40
+ ```ruby
41
+ client = CryptomateAPI::Management::Client.new
42
+ response = client.get_clients
43
+ ```
44
+
45
+ ## API Documentation
46
+
47
+ For detailed information about the API endpoints and responses, visit the [Cryptomate API documentation](https://cryptomate.me/docs).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
56
+
57
+ ## Changelog
58
+
59
+ See [CHANGELOG.md](CHANGELOG.md) for details about each release.
60
+
61
+ ## Code of Conduct
62
+
63
+ Everyone interacting in the `cryptomate_api` project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/cryptomate_api/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "cryptomate_api"
7
+ spec.version = CryptomateApi::VERSION
8
+ spec.authors = ["Matias Albarello"]
9
+ spec.email = ["matias.albarello@gmail.com"]
10
+ spec.licenses = ["MIT"]
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"
16
+
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"
20
+
21
+ spec.files = Dir.chdir(__dir__) do
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
24
+ end
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "httparty", "~> 0.18"
31
+ end
@@ -0,0 +1,14 @@
1
+ require 'httparty'
2
+
3
+ module CryptomateApi
4
+ class Base
5
+ include HTTParty
6
+ base_uri 'https://cryptomate.me/api'
7
+
8
+ # Initializes the client with the given API key
9
+ def initialize(api_key = CryptomateApi.configuration.api_key)
10
+ @api_key = api_key
11
+ self.class.headers "Authorization" => "Bearer #{@api_key}"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
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
15
+
16
+ def initialize
17
+ @api_key = nil
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ module Management
5
+ # Get all the blockchains available in the platform. You can use this information to create new
6
+ # credentials for your clients or using every other endpoints that ask for the blockchain where
7
+ # you want to operate.
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")
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ module Management
5
+ # Manage the company information from here, like changing the webhook url where we will
6
+ # notify that some event happened or just changing the name of the company.
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
21
+
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
34
+
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
49
+
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)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ module Management
5
+ # Manage the company configurations from here, like changing the payment destination address for each blockchain.
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
19
+
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
29
+
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}")
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ module Management
5
+ # Manage the access you give to each key and the permissions you will have for each blockchain,
6
+ # such as only receiving transactions or only accessing one of the blockchains.
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
27
+
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
46
+
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
66
+
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
87
+
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}")
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ module Management
5
+ # Manage the api-keys of your clients.
6
+ # You can create, modify and delete them.
7
+ # This api-keys are used to authenticate the clients in the platform.
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
21
+
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
34
+
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
48
+
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
63
+
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}")
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ module Management
5
+ # Get all the operations available in the platform.
6
+ # You can use this information to create new credentials for your clients.
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
20
+
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}")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ module Mpc
5
+ # The accounts module allows you to create and manage multiple accounts, each with their own wallets.
6
+ # This allows you to manage your crypto assets in a more organized manner,
7
+ # and also allows you to create multiple wallets for the same or different blockchain.
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
28
+
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
41
+
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
62
+
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}")
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ module Mpc
5
+ # The accounts module allows you to create and manage multiple accounts, each with their own wallets.
6
+ # This allows you to manage your crypto assets in a more organized manner,
7
+ # and also allows you to create multiple wallets for the same or different blockchain.
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
23
+
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
38
+
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
54
+
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
70
+
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
96
+
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")
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CryptomateApi
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'cryptomate_api/base'
4
+ require_relative 'cryptomate_api/configuration'
5
+
6
+ Dir[File.join(__dir__, 'cryptomate_api/{management,mpc,nft}/**/*.rb')].sort.each { |file| require file }
7
+
8
+ module CryptomateApi
9
+ class Error < StandardError; end
10
+ end
@@ -0,0 +1,4 @@
1
+ module CryptomateApi
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cryptomate_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matias Albarello
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
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.
30
+ email:
31
+ - matias.albarello@gmail.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".rspec"
37
+ - ".rubocop.yml"
38
+ - CHANGELOG.md
39
+ - CODE_OF_CONDUCT.md
40
+ - Gemfile
41
+ - README.md
42
+ - Rakefile
43
+ - cryptomate_api.gemspec
44
+ - lib/cryptomate_api.rb
45
+ - lib/cryptomate_api/base.rb
46
+ - lib/cryptomate_api/configuration.rb
47
+ - lib/cryptomate_api/management/blockchain.rb
48
+ - lib/cryptomate_api/management/client.rb
49
+ - lib/cryptomate_api/management/configuration.rb
50
+ - lib/cryptomate_api/management/credential.rb
51
+ - lib/cryptomate_api/management/key.rb
52
+ - lib/cryptomate_api/management/operation.rb
53
+ - lib/cryptomate_api/mpc/account.rb
54
+ - lib/cryptomate_api/mpc/wallet.rb
55
+ - lib/cryptomate_api/version.rb
56
+ - sig/cryptomate_api.rbs
57
+ homepage: https://github.com/matiasalbarello/cryptomate_api
58
+ licenses:
59
+ - MIT
60
+ metadata:
61
+ homepage_uri: https://github.com/matiasalbarello/cryptomate_api
62
+ source_code_uri: https://github.com/matiasalbarello/cryptomate_api
63
+ changelog_uri: https://github.com/matiasalbarello/cryptomate_api/blob/main/CHANGELOG.md
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.6.0
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 3.4.6
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Ruby client for the CryptoMate API.
83
+ test_files: []