quidax 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9d57e41e7f2ccf18203238cc7c9611a1abdaff3edc6168748c8011882daf36fc
4
+ data.tar.gz: 986fbc758fda6512fe75333c16102a96ee8b1711f96d5b889370ff2ff02a4f52
5
+ SHA512:
6
+ metadata.gz: 88da99c664a4301e192436df5e3d658f3d1efc5262374f0dd8fc8eda597b25f9af3b68bb561316ed0beff7009346d4355a43863c8afc2faaad86cdc19ee3655e
7
+ data.tar.gz: ba08bc8aa067a7947df19250fbca958e0fd48c8937c7415c8401742c678538698ab4264475485b8daf87fdc8cb1c38f71e8c501dd107ac70d4213b8559efdade
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,28 @@
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
14
+
15
+ Metrics/MethodLength:
16
+ Max: 500
17
+
18
+ Metrics/BlockLength:
19
+ Max: 500
20
+
21
+ Metrics/CyclomaticComplexity:
22
+ Max: 15
23
+
24
+ Naming/MethodName:
25
+ EnforcedStyle: snake_case
26
+
27
+ Metrics/ParameterLists:
28
+ Max: 7
@@ -0,0 +1,22 @@
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "type": "ruby_lsp",
6
+ "name": "Debug",
7
+ "request": "launch",
8
+ "program": "ruby ${file}"
9
+ },
10
+ {
11
+ "type": "ruby_lsp",
12
+ "request": "launch",
13
+ "name": "Debug test file",
14
+ "program": "ruby -Itest ${relativeFile}"
15
+ },
16
+ {
17
+ "type": "ruby_lsp",
18
+ "request": "attach",
19
+ "name": "Attach to existing server"
20
+ }
21
+ ]
22
+ }
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-02-07
4
+
5
+ - Initial release
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 quidax.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,85 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ quidax (0.1.0)
5
+ faraday (~> 2.7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.6)
11
+ public_suffix (>= 2.0.2, < 6.0)
12
+ ast (2.4.2)
13
+ bigdecimal (3.1.6)
14
+ crack (1.0.0)
15
+ bigdecimal
16
+ rexml
17
+ diff-lcs (1.5.1)
18
+ dotenv (2.8.1)
19
+ faraday (2.9.0)
20
+ faraday-net_http (>= 2.0, < 3.2)
21
+ faraday-net_http (3.1.0)
22
+ net-http
23
+ hashdiff (1.1.0)
24
+ json (2.7.1)
25
+ language_server-protocol (3.17.0.3)
26
+ net-http (0.4.1)
27
+ uri
28
+ parallel (1.24.0)
29
+ parser (3.3.0.5)
30
+ ast (~> 2.4.1)
31
+ racc
32
+ public_suffix (5.0.4)
33
+ racc (1.7.3)
34
+ rainbow (3.1.1)
35
+ rake (13.1.0)
36
+ regexp_parser (2.9.0)
37
+ rexml (3.2.6)
38
+ rspec (3.13.0)
39
+ rspec-core (~> 3.13.0)
40
+ rspec-expectations (~> 3.13.0)
41
+ rspec-mocks (~> 3.13.0)
42
+ rspec-core (3.13.0)
43
+ rspec-support (~> 3.13.0)
44
+ rspec-expectations (3.13.0)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.13.0)
47
+ rspec-mocks (3.13.0)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.13.0)
50
+ rspec-support (3.13.1)
51
+ rubocop (1.60.2)
52
+ json (~> 2.3)
53
+ language_server-protocol (>= 3.17.0)
54
+ parallel (~> 1.10)
55
+ parser (>= 3.3.0.2)
56
+ rainbow (>= 2.2.2, < 4.0)
57
+ regexp_parser (>= 1.8, < 3.0)
58
+ rexml (>= 3.2.5, < 4.0)
59
+ rubocop-ast (>= 1.30.0, < 2.0)
60
+ ruby-progressbar (~> 1.7)
61
+ unicode-display_width (>= 2.4.0, < 3.0)
62
+ rubocop-ast (1.30.0)
63
+ parser (>= 3.2.1.0)
64
+ ruby-progressbar (1.13.0)
65
+ unicode-display_width (2.5.0)
66
+ uri (0.13.0)
67
+ webmock (3.23.0)
68
+ addressable (>= 2.8.0)
69
+ crack (>= 0.3.2)
70
+ hashdiff (>= 0.4.0, < 2.0.0)
71
+
72
+ PLATFORMS
73
+ ruby
74
+ x86_64-darwin-23
75
+
76
+ DEPENDENCIES
77
+ dotenv (~> 2.8.1)
78
+ quidax!
79
+ rake (~> 13.0)
80
+ rspec (~> 3.0)
81
+ rubocop (~> 1.21)
82
+ webmock (~> 3.19)
83
+
84
+ BUNDLED WITH
85
+ 2.5.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Aremu Oluwagbamila
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ ![Quidax](https://res.cloudinary.com/aremusmog/image/upload/v1710023421/quidax-ruby/quidax_bwwbks.svg)
2
+
3
+ # Quidax Ruby Library
4
+
5
+ ![RSpec Test status](https://github.com/aremu-smog/quidax-ruby/actions/workflows/rspec.yml/badge.svg)
6
+
7
+ A ruby gem for easy integration of [Quidax](https://docs.quidax.com/docs/getting-started). Please kindly see the [docs](https://docs.quidax.com/docs/getting-started) to get a sense of how the API behaves
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'quidax'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install quidax
24
+
25
+ ## Usage
26
+
27
+ ### Instantiate a Quidax Object
28
+
29
+ To use the SDK, you need to instantiate a quidax object with a secret key
30
+
31
+ ```
32
+ secret_key = ENV["QUIDAX_SECRET_KEY"]
33
+
34
+ quidax_object = Quidax.new(secret_key)
35
+ ```
36
+
37
+ ### Using an object
38
+
39
+ See the [table](#quidax-objects) below for a list of available objects.
40
+ Kindly note that all objects and methods accepts parameters via named keywords.
41
+ There are two ways to use an object:
42
+
43
+ #### 1. Accessing methods after initializing object instance
44
+
45
+ In this case you need to pass your `quidax_object` once to the object instance, and you will now be able to access methods on the class. The keyword is `q_object`
46
+
47
+ ```
48
+ markets = QuidaxMarkets(q_object: quidax_object)
49
+
50
+ all_market_tickers = markets.get_all_tickers
51
+ ```
52
+
53
+ #### 2. Accessing methods directly from the object
54
+
55
+ In this case you need to pass `quidax_object` to the method you directly calling, the `keyword` is `q_object`
56
+
57
+ ```
58
+ all_market_tickers = QuidaxMarket.get_all_tickers(q_object: quidax_object)
59
+ ```
60
+
61
+ > Like you may suspect, the parameters that each method differs, please kindly see the [docs](https://docs.quidax.com/docs/getting-started) to know the expected parameters, `query:` is used to get requests with a payload, while `body:` is used for `post`/`put` requests with a payload
62
+
63
+ ## Quidax Objects
64
+
65
+ | Object | Methods |
66
+ | :----------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
67
+ | QuidaxBeneficiary | get_all <br/> create <br/> get_account <br/> edit_account |
68
+ | QuidaxDeposits | by_user <br /> get_a_deposit <br/> by_sub_users |
69
+ | QuidaxInstantOrder | get_all <br /> by_sub_users <br/> get_detail <br/> buy_crypto_from_fiat <br/> sell_crypto_to_fiat <br/> confirm <br/> requote |
70
+ | QuidaxMarkets | get_all <br/> get_all_tickers <br/> get_ticker <br/> get_k_line <br /> get_k_line_with_pending_trades <br/> get_orderbook_items <br/> get_depth_for_a_market |
71
+ | QuidaxOrder | get_all <br/> create <br /> cancle <br/> get_details |
72
+ | QuidaxQuote | get |
73
+ | QuidaxTrade | for_user <br/> for_market |
74
+ | QuidaxUser | get_account_details <br/> create_sub_account <br/> get_all_sub_accounts <br/> edit_account <br/> |
75
+ | QuidaxWallet | get_user_wallets <br/> get_user_wallet <br/> get_payment_address <br/> get_payment_address_by_id <br/> get_payment_addresses <br/> create_crypto_payment_address <br/> validate_address |
76
+ | QuidaxWithdrawal | get_all_withdrawals_detail <br/> get_detail <br/> cancel |
77
+
78
+ ## Development
79
+
80
+ ## Contributing
81
+
82
+ Bug reports and pull requests are welcome on GitHub at https://github.com/aremu-smog/quidax-ruby.
83
+
84
+ ## License
85
+
86
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Base for errors thrown by the quidax server
4
+ class QuidaxServerError < StandardError
5
+ attr_reader :response
6
+
7
+ def initialize(response)
8
+ super(response)
9
+ @response = response
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DepositMock
4
+ A_DEPOSIT = {
5
+ id: "122345",
6
+ type: "",
7
+ currency: "",
8
+ amount: "",
9
+ fee: "",
10
+ txid: "",
11
+ status: "",
12
+ reason: "",
13
+ created_at: "",
14
+ done_at: "",
15
+ wallet: {},
16
+ user: {},
17
+ payment_transaction: {},
18
+ payment_address: {}
19
+ }.freeze
20
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FeesMock
4
+ BTC_FEE = {
5
+ fee: 0.00005,
6
+ type: "flat"
7
+ }.freeze
8
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MarketsMock
4
+ ALL_MARKETS = [
5
+ {
6
+ id: "1",
7
+ name: "qdxusdt",
8
+ base_unit: "qdx",
9
+ quote_unit: "usdt",
10
+ filters: {}
11
+ }
12
+ ].freeze
13
+
14
+ QDX_USDT_ORDERBOOK_ITEMS_FOR_MARKET = {
15
+ asks: [{}],
16
+ bids: [{}]
17
+ }.freeze
18
+
19
+ QDX_USDT_MARKET_KLINE = [0.0005, 0.0049, 0.00051, 0.0005].freeze
20
+ QDX_USDT_K_WITH_PENDING_TRADES = {
21
+ k: QDX_USDT_MARKET_KLINE,
22
+ trades: [
23
+ { tid: 1, type: "buy", date: 2002, price: 0.0005, base_volume: 2000, quote_volume: 2001 }
24
+ ]
25
+ }.freeze
26
+
27
+ QDX_USDT_MARKET_TICKER = {
28
+ at: 1,
29
+ ticker: {
30
+ buy: "0.00055",
31
+ sell: "0.00054",
32
+ low: "0.00052",
33
+ high: "0.00057",
34
+ open: "0.00034",
35
+ last: "0.00053",
36
+ vol: "20000"
37
+ },
38
+ market: "qdxusdt"
39
+ }.freeze
40
+
41
+ ALL_MARKET_TICKERS =
42
+ {
43
+ "qdxusdt": QDX_USDT_MARKET_TICKER
44
+ }.freeze
45
+
46
+ QDX_USDT_MARKET_DEPTH = {
47
+ timestamp: 120_290_909,
48
+ asks: ["0.0005", "0.00049", "0.00051"],
49
+ bids: ["0.00041", "0.00045", "0.00055"]
50
+ }.freeze
51
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OrderMock
4
+ ORDER_DETAILS = {
5
+ id: "sample",
6
+ reference: "1lkj2lw30",
7
+ market: {},
8
+ side: "buy",
9
+ order_type: "limit",
10
+ price: {},
11
+ avg_price: {},
12
+ volume: {},
13
+ origin_volume: {},
14
+ executed_volume: {},
15
+ status: "pend",
16
+ trades_count: 1,
17
+ created_at: "",
18
+ updated_at: "",
19
+ done_at: "",
20
+ user: {},
21
+ trades: []
22
+ }.freeze
23
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module QuotesMock
4
+ QDX_USDT_QUOTE = {
5
+ price: {
6
+ unit: "usdt",
7
+ amount: "0.005"
8
+ },
9
+ total: {
10
+ unit: "usdt",
11
+ amount: "0.010"
12
+ },
13
+ volume: {
14
+ unit: "usdt",
15
+ amount: "2"
16
+ },
17
+ fee: {
18
+ unit: "usdt",
19
+ amount: "0.001"
20
+ },
21
+ receive: {
22
+ unit: "usdt",
23
+ amount: "0.0010"
24
+ }
25
+ }.freeze
26
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UserMock
4
+ ACCOUNT = {
5
+ id: "QSKDJLK",
6
+ sn: "2",
7
+ email: "test@domain.com",
8
+ reference: "",
9
+ first_name: "Aremu",
10
+ last_name: "Smog",
11
+ display_name: "null",
12
+ created_at: "",
13
+ updated_at: ""
14
+ }.freeze
15
+
16
+ ALL_SUBACCOUNTS = [
17
+ {
18
+ id: "QSKDJLK",
19
+ sn: "2",
20
+ email: "test@domain.com",
21
+ reference: "ajlkskl",
22
+ first_name: "Aremu",
23
+ last_name: "Smog",
24
+ display_name: "null",
25
+ created_at: "",
26
+ updated_at: ""
27
+ },
28
+ {
29
+ id: "QS3DJLK",
30
+ sn: "4",
31
+ email: "test@domain.com",
32
+ reference: "sjld",
33
+ first_name: "Aremu",
34
+ last_name: "Smog",
35
+ display_name: "null",
36
+ created_at: "",
37
+ updated_at: ""
38
+ }
39
+ ].freeze
40
+
41
+ NEW_USER = { # rubocop:disable Style/MutableConstant
42
+ email: "test@domain.com",
43
+ first_name: "Aremu",
44
+ last_name: "Smog",
45
+ phone_number: "09012345678"
46
+ }
47
+
48
+ UPDATE_INFO = {
49
+ first_name: "Daddy"
50
+ }.freeze
51
+
52
+ UPDATED_ACCOUNT = {
53
+ id: "QSKDJLK",
54
+ sn: "2",
55
+ email: "test@domain.com",
56
+ reference: "",
57
+ first_name: "Daddy",
58
+ last_name: "Smog",
59
+ display_name: "null",
60
+ created_at: "",
61
+ updated_at: ""
62
+ }.freeze
63
+ end
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WalletMock
4
+ ALL_WALLETS = [
5
+ {
6
+ id: "ppsoudo",
7
+ currency: "btc",
8
+ balance: "0.0001",
9
+ locked: "0",
10
+ staked: "0",
11
+ user: {},
12
+ converted_balance: "55",
13
+ reference_currency: "usdt",
14
+ is_crypto: true,
15
+ created_at: "",
16
+ updated_at: ""
17
+ },
18
+ {
19
+ id: "ppsoudo",
20
+ currency: "usdt",
21
+ balance: "500",
22
+ locked: "0",
23
+ staked: "0",
24
+ user: {},
25
+ converted_balance: "750000",
26
+ reference_currency: "ngn",
27
+ is_crypto: false,
28
+ created_at: "",
29
+ updated_at: ""
30
+ }
31
+ ].freeze
32
+
33
+ ALL_BTC_PAYMENT_ADDRESS = [
34
+ {
35
+ id: "34",
36
+ reference: "sjlkjldk",
37
+ currency: "btc",
38
+ address: "9302983093",
39
+ destination_tag: "Quser",
40
+ total_payments: "0.1234",
41
+ created_at: "",
42
+ updated_at: ""
43
+ },
44
+ {
45
+ id: "35",
46
+ reference: "ssjlkdljkjldk",
47
+ currency: "btc",
48
+ address: "93043303093",
49
+ destination_tag: "Quser",
50
+ total_payments: "0.2034",
51
+ created_at: "",
52
+ updated_at: ""
53
+ }
54
+ ].freeze
55
+
56
+ NEW_PAYMENT_ADDRESS = {
57
+ id: "36",
58
+ reference: "670",
59
+ currency: "btc",
60
+ address: "9302983093",
61
+ destination_tag: "Quser",
62
+ total_payments: "0.1534",
63
+ created_at: "",
64
+ updated_at: ""
65
+ }.freeze
66
+
67
+ PAYMENT_ADDRESS = {
68
+ id: "34",
69
+ reference: "sjlkjldk",
70
+ currency: "btc",
71
+ address: "9302983093",
72
+ destination_tag: "Quser",
73
+ total_payments: "0.1234",
74
+ created_at: "",
75
+ updated_at: ""
76
+ }.freeze
77
+
78
+ WALLET = {
79
+ id: "ppsoudo",
80
+ currency: "btc",
81
+ balance: "0.0001",
82
+ deposit_address: "sljdlkjsdld",
83
+ destination_tag: "skjd",
84
+ locked: "0",
85
+ staked: "0",
86
+ user: {},
87
+ converted_balance: "55",
88
+ reference_currency: "usdt",
89
+ is_crypto: true,
90
+ created_at: "",
91
+ updated_at: ""
92
+ }.freeze
93
+
94
+ VALID_ADDRESS = {
95
+ currency: "btc",
96
+ address: "1Lbcfr7sAHTD9CgdQo3HTMTkV8LK4ZnX71",
97
+ valid: false
98
+ }.freeze
99
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WithdrawalMock
4
+ ALL_BTC_WITHDRAWAL_DETAILS = [].freeze
5
+
6
+ WITHDRAWAL = {
7
+ id: "1234",
8
+ reference: "ksjdlkssjld",
9
+ type: "",
10
+ currency: "usdt",
11
+ amount: "2000",
12
+ fee: "2",
13
+ total: "2002",
14
+ txid: "jslkdjlsj",
15
+ transaction_note: "stay alive",
16
+ narration: "staying alive funds",
17
+ status: "pend",
18
+ reason: "nil",
19
+ created_at: "",
20
+ done_at: "",
21
+ recipient: {},
22
+ wallet: {},
23
+ user: {}
24
+ }.freeze
25
+
26
+ CANCELLED_WITHDRAWAL = {}
27
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add in alphabetical order
4
+ module API
5
+ BASE_URL = "https://www.quidax.com/api/v1"
6
+ BENEFICIARY_PATH = "/beneficiaries"
7
+ DEPOSIT_PATH = "/deposits"
8
+ FEE_PATH = "/fee"
9
+ INSTANT_ORDER_PATH = "/instant_orders"
10
+ MARKET_PATH = "/markets"
11
+ ORDER_PATH = "/orders"
12
+ QUOTE_PATH = "/quotes"
13
+ TRADES_PATH = "/trades"
14
+ USER_PATH = "/users"
15
+ WALLET_PATH = "/wallets"
16
+ WITHDRAWAL_PATH = "/withdraws"
17
+ end