max_exchange_api 1.0.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -0
- data/CHANGELOG.md +14 -0
- data/README.md +41 -5
- data/bin/setup +8 -8
- data/gemfiles/Gemfile +2 -1
- data/lib/max_exchange_api/base_api.rb +16 -4
- data/lib/max_exchange_api/config.rb +10 -3
- data/lib/max_exchange_api/private_api.rb +17 -3
- data/lib/max_exchange_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f55473cff3a0a3a235b9e164ddc0e35ada7de436ac2fea87d9e17c179ed7135
|
4
|
+
data.tar.gz: 8de22008ea06fe624634099ad7cd1133876ed2182fd515b024c311ac49a4407e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 444b86438ad9c6055914ce5413225256cb986b7519dd94c255c6bd88837cf3c549db2193cd950c20fce073431e834163b68c7763f72abca45c586b10a4276708
|
7
|
+
data.tar.gz: 4abfa0033b87e4dab40a5b590c878ec4600e3d56dd94ee9b8db6db9d612b916a84e6e49e009f1d4e489be443e487029ec399d7017f9c6b75f8a54524f2627e05
|
data/.github/workflows/ruby.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
## Change Log
|
2
2
|
|
3
|
+
### [v1.2.0](https://github.com/khiav223577/max_exchange_api/compare/v1.1.1...v1.2.0) 2021/08/01
|
4
|
+
- [#9](https://github.com/khiav223577/max_exchange_api/pull/9) add yields api (@khiav223577)
|
5
|
+
|
6
|
+
### [v1.1.1](https://github.com/khiav223577/max_exchange_api/compare/v1.1.0...v1.1.1) 2021/08/01
|
7
|
+
- [#7](https://github.com/khiav223577/max_exchange_api/pull/7) Fix wrong path in rewards API (@khiav223577)
|
8
|
+
- [#8](https://github.com/khiav223577/max_exchange_api/pull/8) Adjust: maker fee and min base amount test cases (@khiav223577)
|
9
|
+
|
10
|
+
### [v1.1.0](https://github.com/khiav223577/max_exchange_api/compare/v1.0.0...v1.1.0) 2021/06/27
|
11
|
+
- [#6](https://github.com/khiav223577/max_exchange_api/pull/6) Allow every api instance to have custom config (@khiav223577)
|
12
|
+
|
13
|
+
### [v1.0.0](https://github.com/khiav223577/max_exchange_api/compare/v0.1.0...v1.0.0) 2021/06/27
|
14
|
+
- [#5](https://github.com/khiav223577/max_exchange_api/pull/5) Implement all v2 private APIs (@khiav223577)
|
15
|
+
- [#4](https://github.com/khiav223577/max_exchange_api/pull/4) Add logger config (@khiav223577)
|
16
|
+
|
3
17
|
### [v0.1.0](https://github.com/khiav223577/max_exchange_api/compare/v0.0.1...v0.1.0) 2021/06/26
|
4
18
|
- [#3](https://github.com/khiav223577/max_exchange_api/pull/3) Add default_timeout config (@khiav223577)
|
5
19
|
- [#2](https://github.com/khiav223577/max_exchange_api/pull/2) Implement all v2 public APIs (@khiav223577)
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ A ruby implementation of MAX exchange API
|
|
19
19
|
|
20
20
|
|
21
21
|
## Supports
|
22
|
-
- Ruby 2.2 ~ 2.7
|
22
|
+
- Ruby 2.2 ~ 2.7, 3.0
|
23
23
|
|
24
24
|
## Installation
|
25
25
|
|
@@ -37,19 +37,31 @@ Or install it yourself as:
|
|
37
37
|
|
38
38
|
## Configuration
|
39
39
|
|
40
|
-
###
|
40
|
+
### Set timeout time
|
41
41
|
|
42
42
|
```rb
|
43
|
+
# Set default timeout time
|
43
44
|
MaxExchangeApi.default_config.timeout = 3 # seconds
|
45
|
+
|
46
|
+
# Create an api instance with custom timeout time
|
47
|
+
api = MaxExchangeApi::PublicApi.new(config: { timeout: 12 })
|
48
|
+
api = MaxExchangeApi::PrivateApi.new(access_key, secret_key, config: { timeout: 12 })
|
44
49
|
```
|
45
50
|
|
46
|
-
###
|
51
|
+
### Logging
|
47
52
|
|
48
53
|
```rb
|
49
54
|
require 'logger'
|
50
55
|
|
51
|
-
|
56
|
+
# Print log to standard output
|
57
|
+
MaxExchangeApi.default_config.logger = Logger.new(STDOUT)
|
58
|
+
|
59
|
+
# Print log to file
|
52
60
|
MaxExchangeApi.default_config.logger = Logger.new('log/api.log')
|
61
|
+
|
62
|
+
# Create an api instance with custom logger
|
63
|
+
api = MaxExchangeApi::PublicApi.new(config: { logger: Logger.new(STDOUT) })
|
64
|
+
api = MaxExchangeApi::PrivateApi.new(access_key, secret_key, config: { logger: Logger.new(STDOUT) })
|
53
65
|
```
|
54
66
|
|
55
67
|
## Usage
|
@@ -60,7 +72,7 @@ MaxExchangeApi.default_config.logger = Logger.new('log/api.log')
|
|
60
72
|
@api = MaxExchangeApi::PublicApi.new
|
61
73
|
```
|
62
74
|
|
63
|
-
#### [GET
|
75
|
+
#### [GET /api/v2/vip_levels](https://max.maicoin.com/documents/api_list#!/public/getApiV2VipLevels)
|
64
76
|
|
65
77
|
> Get all VIP level fees.
|
66
78
|
|
@@ -563,6 +575,30 @@ secret_key = 'YOUR_SECRET_KEY'
|
|
563
575
|
```
|
564
576
|
</details>
|
565
577
|
|
578
|
+
#### [GET /api/v2/yields](https://max.maicoin.com/documents/api_list#!/private/getApiV2Yields)
|
579
|
+
|
580
|
+
> get yields history
|
581
|
+
|
582
|
+
<details>
|
583
|
+
<summary>Show code</summary>
|
584
|
+
|
585
|
+
```rb
|
586
|
+
# use default parameters
|
587
|
+
@api.yields
|
588
|
+
|
589
|
+
# provide all possible parameters
|
590
|
+
@api.yields(
|
591
|
+
currency: 'usdt',
|
592
|
+
from: 68444,
|
593
|
+
to: 69444,
|
594
|
+
pagination: true,
|
595
|
+
page: 3,
|
596
|
+
limit: 15,
|
597
|
+
offset: 5,
|
598
|
+
)
|
599
|
+
```
|
600
|
+
</details>
|
601
|
+
|
566
602
|
### Order
|
567
603
|
#### [GET /api/v2/orders](https://max.maicoin.com/documents/api_list#!/private/getApiV2Orders)
|
568
604
|
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install --gemfile=gemfiles/
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install --gemfile=gemfiles/Gemfile
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/gemfiles/Gemfile
CHANGED
@@ -7,19 +7,31 @@ module MaxExchangeApi
|
|
7
7
|
class BaseApi
|
8
8
|
include HTTParty
|
9
9
|
|
10
|
+
attr_reader :config
|
11
|
+
|
12
|
+
def initialize(config: nil)
|
13
|
+
@config = Config.new(config)
|
14
|
+
@config.reverse_merge!(MaxExchangeApi.default_config)
|
15
|
+
end
|
16
|
+
|
10
17
|
protected
|
11
18
|
|
12
19
|
def send_request(method, path, headers, query)
|
13
20
|
uuid = SecureRandom.uuid
|
14
21
|
print_log(:info, "[API] #{uuid} #{method.upcase} '#{path}' query = #{query}")
|
15
22
|
|
23
|
+
body_or_query = method == :get ? :query : :body
|
24
|
+
|
16
25
|
begin
|
17
26
|
response = self.class.send(
|
18
27
|
method,
|
19
28
|
path,
|
20
|
-
headers: headers
|
21
|
-
|
22
|
-
|
29
|
+
headers: headers.merge(
|
30
|
+
'Accept' => 'application/json',
|
31
|
+
'User-Agent' => "max_exchange_api (#{MaxExchangeApi::VERSION})",
|
32
|
+
),
|
33
|
+
timeout: @config.timeout,
|
34
|
+
body_or_query => query,
|
23
35
|
).parsed_response
|
24
36
|
|
25
37
|
print_log(:info, "[API] #{uuid} response #{response}")
|
@@ -33,7 +45,7 @@ module MaxExchangeApi
|
|
33
45
|
private
|
34
46
|
|
35
47
|
def print_log(method, message)
|
36
|
-
logger =
|
48
|
+
logger = @config.logger
|
37
49
|
logger.send(method, message) if logger
|
38
50
|
end
|
39
51
|
end
|
@@ -5,13 +5,20 @@ module MaxExchangeApi
|
|
5
5
|
attr_accessor :timeout
|
6
6
|
attr_accessor :logger
|
7
7
|
|
8
|
-
def initialize
|
9
|
-
|
10
|
-
@
|
8
|
+
def initialize(data = nil)
|
9
|
+
data ||= {}
|
10
|
+
@timeout = data[:timeout]
|
11
|
+
@logger = data[:logger]
|
12
|
+
end
|
13
|
+
|
14
|
+
def reverse_merge!(other)
|
15
|
+
@timeout ||= other.timeout
|
16
|
+
@logger ||= other.logger
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
14
20
|
@default_config = Config.new
|
21
|
+
@default_config.timeout = 3
|
15
22
|
|
16
23
|
class << self
|
17
24
|
attr_reader :default_config
|
@@ -6,8 +6,8 @@ module MaxExchangeApi
|
|
6
6
|
class PrivateApi < BaseApi
|
7
7
|
base_uri 'https://max-api.maicoin.com/api/v2'
|
8
8
|
|
9
|
-
def initialize(access_key, secret_key)
|
10
|
-
super()
|
9
|
+
def initialize(access_key, secret_key, config: nil)
|
10
|
+
super(config: config)
|
11
11
|
|
12
12
|
@access_key = access_key
|
13
13
|
@secret_key = secret_key
|
@@ -148,7 +148,7 @@ module MaxExchangeApi
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def rewards(reward_type: nil, currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
151
|
-
path = reward_type ?
|
151
|
+
path = reward_type ? "/rewards/#{reward_type}" : '/rewards'
|
152
152
|
send_request(
|
153
153
|
:get,
|
154
154
|
path,
|
@@ -162,6 +162,20 @@ module MaxExchangeApi
|
|
162
162
|
)
|
163
163
|
end
|
164
164
|
|
165
|
+
def yields(currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
|
166
|
+
send_request(
|
167
|
+
:get,
|
168
|
+
'/yields',
|
169
|
+
currency: currency,
|
170
|
+
from: from,
|
171
|
+
to: to,
|
172
|
+
pagination: pagination,
|
173
|
+
page: page,
|
174
|
+
limit: limit,
|
175
|
+
offset: offset,
|
176
|
+
)
|
177
|
+
end
|
178
|
+
|
165
179
|
def max_rewards_yesterday
|
166
180
|
send_request(:get, '/max_rewards/yesterday', {})
|
167
181
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: max_exchange_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khiav reoy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|