coin_market_pro 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +17 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +92 -0
- data/LICENSE.txt +21 -0
- data/README.md +493 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/coin_market_pro.gemspec +35 -0
- data/lib/coin_market_pro/client/base.rb +125 -0
- data/lib/coin_market_pro/client/result.rb +63 -0
- data/lib/coin_market_pro/endpoint/base.rb +48 -0
- data/lib/coin_market_pro/endpoint/cryptocurrency.rb +235 -0
- data/lib/coin_market_pro/endpoint/exchange.rb +161 -0
- data/lib/coin_market_pro/endpoint/global_metrics.rb +48 -0
- data/lib/coin_market_pro/endpoint/tools.rb +43 -0
- data/lib/coin_market_pro/version.rb +5 -0
- data/lib/coin_market_pro.rb +12 -0
- metadata +191 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CoinMarketPro
|
4
|
+
module Endpoint
|
5
|
+
# @see https://pro.coinmarketcap.com/api/v1#tag/exchange
|
6
|
+
class GlobalMetrics < Base
|
7
|
+
ENDPOINT = '/global-metrics'
|
8
|
+
|
9
|
+
# Get an interval of aggregate 24 hour volume and market cap data globally based on time and interval parameters.
|
10
|
+
#
|
11
|
+
# @param [Hash] args
|
12
|
+
# @option args [String] :time_start
|
13
|
+
# @option args [String] :time_end
|
14
|
+
# @option args [Number] :count
|
15
|
+
# @option args [String] :interval
|
16
|
+
# @option args [String] :convert
|
17
|
+
# @return [CoinMarketPro::Result]
|
18
|
+
#
|
19
|
+
# @see https://pro.coinmarketcap.com/api/v1#operation/getV1ExchangeQuotesHistorical
|
20
|
+
def quotes_historical(**args)
|
21
|
+
params = convert_params(args)
|
22
|
+
client.get("#{ENDPOINT}/quotes/historical", options: params.compact).tap do |resp|
|
23
|
+
resp.body = resp.body[:quotes]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
alias market_quotes_historical quotes_historical
|
28
|
+
|
29
|
+
# Get the latest quote of aggregate market metrics.
|
30
|
+
# Use the "convert" option to return market values in multiple fiat and cryptocurrency conversions in the same call.
|
31
|
+
#
|
32
|
+
# @param [Hash] args
|
33
|
+
# @option args [String] :convert
|
34
|
+
# @return [CoinMarketPro::Result]
|
35
|
+
#
|
36
|
+
# @see https://pro.coinmarketcap.com/api/v1#operation/getV1GlobalmetricsQuotesLatest
|
37
|
+
def quotes(**args)
|
38
|
+
params = convert_params(args)
|
39
|
+
client.get("#{ENDPOINT}/quotes/latest", options: params.compact).tap do |resp|
|
40
|
+
resp.body = [resp.body]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
alias market_quotes quotes
|
45
|
+
alias quotes_latest quotes
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CoinMarketPro
|
4
|
+
module Endpoint
|
5
|
+
# @see https://pro.coinmarketcap.com/api/v1#tag/exchange
|
6
|
+
class Tools < Base
|
7
|
+
ENDPOINT = '/tools'
|
8
|
+
|
9
|
+
# Convert an amount of one currency into up to 32 other cryptocurrency or fiat currencies
|
10
|
+
# at the same time using latest exchange rates.
|
11
|
+
# Optionally pass a historical timestamp to convert values based on historic averages.
|
12
|
+
#
|
13
|
+
# @param [Hash] args
|
14
|
+
# @option args [Number] :amount
|
15
|
+
# @option args [Array<Integer>] :id
|
16
|
+
# @option args [Array<String>] :symbol
|
17
|
+
# @option args [String] :time
|
18
|
+
# @option args [String] :convert
|
19
|
+
# @return [CoinMarketPro::Result]
|
20
|
+
#
|
21
|
+
# @see https://pro.coinmarketcap.com/api/v1#operation/getV1ToolsPriceconversion
|
22
|
+
def price_conversion(**args)
|
23
|
+
valid_params?(args)
|
24
|
+
params = convert_params(args)
|
25
|
+
client.get("#{ENDPOINT}/price-conversion", options: params.compact).tap do |resp|
|
26
|
+
resp.body = [resp.body]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
# @param args [Hash]
|
33
|
+
# @return [Boolean]
|
34
|
+
# @raise [ArgumentError]
|
35
|
+
def valid_params?(args)
|
36
|
+
raise ArgumentError.new('amount is required.') if args[:amount].blank?
|
37
|
+
raise ArgumentError.new('At least one "id" or "slug" is required.') if args[:id].blank? && args[:slug].blank?
|
38
|
+
|
39
|
+
true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coin_market_pro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- snogrammer
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: multi_json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.13'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.11'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.11'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '12.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '12.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.8'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.8'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.16'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.16'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.4'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '3.4'
|
139
|
+
description:
|
140
|
+
email:
|
141
|
+
executables: []
|
142
|
+
extensions: []
|
143
|
+
extra_rdoc_files: []
|
144
|
+
files:
|
145
|
+
- ".gitignore"
|
146
|
+
- ".rspec"
|
147
|
+
- ".rubocop.yml"
|
148
|
+
- ".ruby-version"
|
149
|
+
- ".travis.yml"
|
150
|
+
- Gemfile
|
151
|
+
- Gemfile.lock
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- bin/console
|
156
|
+
- bin/setup
|
157
|
+
- coin_market_pro.gemspec
|
158
|
+
- lib/coin_market_pro.rb
|
159
|
+
- lib/coin_market_pro/client/base.rb
|
160
|
+
- lib/coin_market_pro/client/result.rb
|
161
|
+
- lib/coin_market_pro/endpoint/base.rb
|
162
|
+
- lib/coin_market_pro/endpoint/cryptocurrency.rb
|
163
|
+
- lib/coin_market_pro/endpoint/exchange.rb
|
164
|
+
- lib/coin_market_pro/endpoint/global_metrics.rb
|
165
|
+
- lib/coin_market_pro/endpoint/tools.rb
|
166
|
+
- lib/coin_market_pro/version.rb
|
167
|
+
homepage: https://gitlab.com/snogrammer/coin_market_pro
|
168
|
+
licenses:
|
169
|
+
- MIT
|
170
|
+
metadata: {}
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
185
|
+
requirements: []
|
186
|
+
rubyforge_project:
|
187
|
+
rubygems_version: 2.7.6
|
188
|
+
signing_key:
|
189
|
+
specification_version: 4
|
190
|
+
summary: CoinMarketCap Pro v1 Api Ruby wrapper
|
191
|
+
test_files: []
|