coinmarketcap_free 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f89d021dcc8f88f0730ed6c3a95de9fe66125138007e30f643e2637c3cc0829
4
- data.tar.gz: 5402fc9c5ff6766a6ee126057de2e12d96519c9622325b3d939e978f5e8f5dcb
3
+ metadata.gz: 4297fadc64121db9012143a350b4030cd841416f7a7b6fdeb07b46a3234b6af9
4
+ data.tar.gz: 9860e70e322113e3cc9fbeae4af47a71c0f69032931b28705fb09448fdf42091
5
5
  SHA512:
6
- metadata.gz: 47678471ba7e3a8362485be4f4781d0c0837c22b969e90f20bcb40bfe662080827742fe6790137102817b076f18bb3a45685ef6199ea829d5d2cb861960835e9
7
- data.tar.gz: 3a46d496f02511b7b6536c8d4dda4b1cc4ca73ee485b39a8271ca5ce1436ff0404563633ab792028f5226c8226b3426074f8497a6fed249b66408f9a90fac586
6
+ metadata.gz: 47a049b178e777f9bf609ccd2a4015e36e4340626dc311d9850adc513e8530020c7a68a16a9d501bad48bcdf4fed516cbf4dd3f9454c000f7d0aed7aa92b811a
7
+ data.tar.gz: c54fc0e35cbbf0dc6c36f3ea8426eeaacfb11116baa46adb14b9638941d6d6f6c48eb4c395692b21371c832d6efcb7caddfc37fb9290323c8c6b0763f91f8b35
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coinmarketcap_free (0.1.3)
4
+ coinmarketcap_free (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -54,71 +54,6 @@ module CoinmarketcapFree
54
54
  @id = id
55
55
  @range_time = range_time
56
56
  end
57
- class << self
58
- @@coin = Coin.new()
59
-
60
- # Returns an interval of historic for the day
61
- #
62
- # @param [Integer] id Cryptocurrency identifier
63
- def history_day(id)
64
- history(id, '1D')
65
- end
66
- # Returns an interval of historic for the seven days
67
- #
68
- # @param [Integer] id Cryptocurrency identifier
69
- def history_seven_days(id)
70
- history(id, '7D')
71
- end
72
- # Returns an interval of historic for the one month
73
- #
74
- # @param [Integer] id Cryptocurrency identifier
75
- def history_one_month(id)
76
- history(id, '1M')
77
- end
78
- # Returns an interval of historic for the three months
79
- #
80
- # @param [Integer] id Cryptocurrency identifier
81
- def history_three_months(id)
82
- history(id, '3M')
83
- end
84
- # Returns an interval of historic for the one year
85
- #
86
- # @param [Integer] id Cryptocurrency identifier
87
- def history_one_year(id)
88
- history(id, '1Y')
89
- end
90
- # Returns an interval of historic for the current year
91
- #
92
- # @param [Integer] id Cryptocurrency identifier
93
- def history_current_year(id)
94
- history(id, 'YTD')
95
- end
96
- # Returns an interval of historic for the current year
97
- #
98
- # @param [Integer] id Cryptocurrency identifier
99
- def history_all(id)
100
- history(id, 'ALL')
101
- end
102
-
103
- # Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
104
- #
105
- # Unix Epoch. (SECONDS SINCE JAN 01 1970 (UTC))
106
- #
107
- # CoinmarketcapFree::Coin.history_custom_time(1, 1675085165, 1675105165)
108
- #
109
- # @param [Integer] id Cryptocurrency identifier
110
- # @param [Integer] from Enter a Timestamp
111
- # @param [Integer] to Enter a Timestamp
112
- def history_custom_time(id, from, to)
113
- history(id, "#{from}~#{to}")
114
- end
115
-
116
- private def history(id, range_time)
117
- @@coin.id = id
118
- @@coin.range_time = range_time
119
- @@coin.update ? @@coin.get_data : nil
120
- end
121
- end
122
57
 
123
58
  private
124
59
  def generate_uri_for_data
@@ -114,40 +114,53 @@ module CoinmarketcapFree
114
114
  URL_API = 'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/listing'.freeze
115
115
  private_constant :URL_API
116
116
 
117
- # Returns the CoinmarketcapFree::Cryptocurrencies that's dictated by the options hash. The primary options are:
117
+ # Returns the CoinmarketcapFree::Cryptocurrencies that's dictated by the options hash.
118
118
  #
119
- # @param [Hash] options the parameters for creating a request to the server
120
- # @option options [Integer] :start (1) Optionally offset the start (1-based index) of the paginated list of items to return.
121
- # @option options [Integer] :limit (100) Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
122
- # @option options [String] :sortBy ('market_cap') What field to sort the list of cryptocurrencies by. ('rank', 'name', 'symbol', 'date_added', 'market_cap', 'market_cap_strict', 'price', 'circulating_supply', 'total_supply', 'max_supply', 'num_market_pairs', 'volume_24h', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d', 'market_cap_by_total_supply_strict', 'volume_7d', 'volume_30d")
123
- # @option options [String] :sortType ('desc') The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
124
- # @option options [String] :convert ('USD') Select cryptocurrencies to exchange ('AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'). For example, many 'USD,BTC,ETH' to convert or only one 'USD'
125
- # @option options [String] :cryptoType ('all') The type of cryptocurrency to include. ('all', 'coins', 'tokens')
126
- # @option options [String] :tagType ('all') The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
127
- # @option options [false, true] :audited Show audited 'true' or not 'false'
128
- # @option options [String] :aux Optionally specify a comma-separated list of supplemental data fields to return. Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
129
- # @option options [String] :tags If you want to see cryptocurrencies that can be mined, just type 'mineable'.
130
- # @option options [String] :volume24hRange Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
131
- # @option options [String] :percentChange24hRange Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
132
- # @option options [String] :circulatingSupplyRange Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
133
- # @option options [String] :priceRange Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
134
- # @option options [String] :marketCapRange Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
135
- def initialize(options = {})
136
- @limit = options[:limit].nil? ? 100 : options[:limit] # Integer
137
- @start = options[:start].nil? ? 1 : options[:start] # Integer
138
- @sortBy = options[:sortBy] # String
139
- @sortType = options[:sortType] # String
140
- @convert = options[:convert] # String
141
- @cryptoType = options[:cryptoType] # String
142
- @tagType = options[:tagType] # String
143
- @audited = options[:audited] # Boolean
144
- @aux = options[:aux] # String
145
- @tags = options[:tags] # String
146
- @volume24hRange = options[:volume24hRange] # String
147
- @percentChange24hRange = options[:percentChange24hRange] # String
148
- @circulatingSupplyRange = options[:circulatingSupplyRange] # String
149
- @priceRange = options[:priceRange] # String
150
- @marketCapRange = options[:marketCapRange] # String
119
+ # @param [Integer] start Optionally offset the start (1-based index) of the paginated list of items to return.
120
+ # @param [Integer] limit Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
121
+ # @param [String (frozen)] sortBy What field to sort the list of cryptocurrencies by. ('rank', 'name', 'symbol', 'date_added', 'market_cap', 'market_cap_strict', 'price', 'circulating_supply', 'total_supply', 'max_supply', 'num_market_pairs', 'volume_24h', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d', 'market_cap_by_total_supply_strict', 'volume_7d', 'volume_30d")
122
+ # @param [String (frozen)] sortType The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
123
+ # @param [String (frozen)] convert Select cryptocurrencies to exchange ('AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'). For example, many 'USD,BTC,ETH' to convert or only one 'USD'
124
+ # @param [String (frozen)] cryptoType The type of cryptocurrency to include. ('all', 'coins', 'tokens')
125
+ # @param [String (frozen)] tagType The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
126
+ # @param [TrueClass, FalseClass] audited Show audited 'true' or not 'false'
127
+ # @param [String (frozen)] aux Optionally specify a comma-separated list of supplemental data fields to return. Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
128
+ # @param [String (frozen)] tags If you want to see cryptocurrencies that can be mined, just type 'mineable'.
129
+ # @param [String (frozen)] volume24hRange Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
130
+ # @param [String (frozen)] percentChange24hRange Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
131
+ # @param [String (frozen)] circulatingSupplyRange Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
132
+ # @param [String (frozen)] priceRange Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
133
+ # @param [String (frozen)] marketCapRange Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
134
+ def initialize(start:1,
135
+ limit:100,
136
+ sortBy: 'market_cap',
137
+ sortType:'desc',
138
+ convert:'USD',
139
+ cryptoType:'all',
140
+ tagType:'all',
141
+ audited:false,
142
+ aux:nil,
143
+ tags:nil,
144
+ volume24hRange:nil,
145
+ percentChange24hRange:nil,
146
+ circulatingSupplyRange:nil,
147
+ priceRange:nil,
148
+ marketCapRange:nil)
149
+ @limit = limit # Integer
150
+ @start = start # Integer
151
+ @sortBy = sortBy # String
152
+ @sortType = sortType # String
153
+ @convert = convert # String
154
+ @cryptoType = cryptoType # String
155
+ @tagType = tagType # String
156
+ @audited = audited # Boolean
157
+ @aux = aux # String
158
+ @tags = tags # String
159
+ @volume24hRange = volume24hRange # String
160
+ @percentChange24hRange = percentChange24hRange # String
161
+ @circulatingSupplyRange = circulatingSupplyRange # String
162
+ @priceRange = priceRange # String
163
+ @marketCapRange = marketCapRange # String
151
164
  end
152
165
 
153
166
  attr_accessor :limit,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CoinmarketcapFree
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -58,6 +58,68 @@ module CoinmarketcapFree
58
58
  @@coin.update ? @@coin.get_data : nil
59
59
  end
60
60
 
61
+ # Returns an interval of historic for the day
62
+ #
63
+ # @param [Integer] id Cryptocurrency identifier
64
+ def coin_history_day(id)
65
+ coin_history(id, '1D')
66
+ end
67
+
68
+ # Returns an interval of historic for the seven days
69
+ #
70
+ # @param [Integer] id Cryptocurrency identifier
71
+ def coin_history_seven_days(id)
72
+ coin_history(id, '7D')
73
+ end
74
+
75
+ # Returns an interval of historic for the one month
76
+ #
77
+ # @param [Integer] id Cryptocurrency identifier
78
+ def coin_history_one_month(id)
79
+ coin_history(id, '1M')
80
+ end
81
+
82
+ # Returns an interval of historic for the three months
83
+ #
84
+ # @param [Integer] id Cryptocurrency identifier
85
+ def coin_history_three_months(id)
86
+ coin_history(id, '3M')
87
+ end
88
+
89
+ # Returns an interval of historic for the one year
90
+ #
91
+ # @param [Integer] id Cryptocurrency identifier
92
+ def coin_history_one_year(id)
93
+ coin_history(id, '1Y')
94
+ end
95
+
96
+ # Returns an interval of historic for the current year
97
+ #
98
+ # @param [Integer] id Cryptocurrency identifier
99
+ def coin_history_current_year(id)
100
+ coin_history(id, 'YTD')
101
+ end
102
+
103
+ # Returns an interval of historic for the current year
104
+ #
105
+ # @param [Integer] id Cryptocurrency identifier
106
+ def coin_history_all(id)
107
+ coin_history(id, 'ALL')
108
+ end
109
+
110
+ # Returns an interval of historic market quotes for any cryptocurrency based on time and interval parameters.
111
+ #
112
+ # Unix Epoch. (SECONDS SINCE JAN 01 1970 (UTC))
113
+ #
114
+ # CoinmarketcapFree.coin_history_custom_time(1, 1675085165, 1675105165)
115
+ #
116
+ # @param [Integer] id Cryptocurrency identifier
117
+ # @param [Integer] from Enter a Timestamp
118
+ # @param [Integer] to Enter a Timestamp
119
+ def coin_history_custom_time(id, from, to)
120
+ coin_history(id, "#{from}~#{to}")
121
+ end
122
+
61
123
  # Get a list of cryptocurrencies
62
124
  #
63
125
  # list = CoinmarketcapFree.coins(limit: 100, start: 1)
@@ -168,28 +230,52 @@ module CoinmarketcapFree
168
230
  # list = CoinmarketcapFree.coins(limit: 100, start: 1, convert: 'USD,BTC,ETH')
169
231
  #
170
232
  #
171
- # @param [Hash] options the parameters for creating a request to the server
172
233
  # @return [String, nil]
173
- # @option options [Integer] :start (1) Optionally offset the start (1-based index) of the paginated list of items to return.
174
- # @option options [Integer] :limit (100) Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
175
- # @option options [String] :sortBy ('market_cap') What field to sort the list of cryptocurrencies by. ('rank', 'name', 'symbol', 'date_added', 'market_cap', 'market_cap_strict', 'price', 'circulating_supply', 'total_supply', 'max_supply', 'num_market_pairs', 'volume_24h', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d', 'market_cap_by_total_supply_strict', 'volume_7d', 'volume_30d")
176
- # @option options [String] :sortType ('desc') The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
177
- # @option options [String] :convert ('USD') Select cryptocurrencies to exchange ('AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'). For example, many 'USD,BTC,ETH' to convert or only one 'USD'
178
- # @option options [String] :cryptoType ('all') The type of cryptocurrency to include. ('all', 'coins', 'tokens')
179
- # @option options [String] :tagType ('all') The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
180
- # @option options [false, true] :audited Show audited 'true' or not 'false'
181
- # @option options [String] :aux Optionally specify a comma-separated list of supplemental data fields to return. Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
182
- # @option options [String] :tags If you want to see cryptocurrencies that can be mined, just type 'mineable'.
183
- # @option options [String] :volume24hRange Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
184
- # @option options [String] :percentChange24hRange Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
185
- # @option options [String] :circulatingSupplyRange Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
186
- # @option options [String] :priceRange Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
187
- # @option options [String] :marketCapRange Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
188
- def coins(options = {})
189
- @@cryptocurrencies.instance_variables.each do |var_name|
190
- value = options[var_name.to_s.delete('@').to_sym]
191
- @@cryptocurrencies.instance_variable_set(var_name, value) unless value.nil?
192
- end
234
+ # @param [Integer] start Optionally offset the start (1-based index) of the paginated list of items to return.
235
+ # @param [Integer] limit Optionally specify the number of results to return. Use this parameter and the 'start' parameter to determine your own pagination size.
236
+ # @param [String (frozen)] sortBy What field to sort the list of cryptocurrencies by. ('rank', 'name', 'symbol', 'date_added', 'market_cap', 'market_cap_strict', 'price', 'circulating_supply', 'total_supply', 'max_supply', 'num_market_pairs', 'volume_24h', 'percent_change_1h', 'percent_change_24h', 'percent_change_7d', 'market_cap_by_total_supply_strict', 'volume_7d', 'volume_30d")
237
+ # @param [String (frozen)] sortType The direction in which to order cryptocurrencies against the specified sort. ('asc', 'desc')
238
+ # @param [String (frozen)] convert Select cryptocurrencies to exchange ('AUD', 'BRL', 'CAD', 'CHF', 'CLP', 'CNY', 'CZK', 'DKK', 'EUR', 'GBP', 'HKD', 'HUF', 'IDR', 'ILS', 'INR', 'JPY', 'KRW', 'MXN', 'MYR', 'NOK', 'NZD', 'PHP', 'PKR', 'PLN', 'RUB', 'SEK', 'SGD', 'THB', 'TRY', 'TWD', 'ZAR'). For example, many 'USD,BTC,ETH' to convert or only one 'USD'
239
+ # @param [String (frozen)] cryptoType The type of cryptocurrency to include. ('all', 'coins', 'tokens')
240
+ # @param [String (frozen)] tagType The tag of cryptocurrency to include. ('all', 'defi', 'filesharing')
241
+ # @param [TrueClass, FalseClass] audited Show audited 'true' or not 'false'
242
+ # @param [String (frozen)] aux Optionally specify a comma-separated list of supplemental data fields to return. Pass 'ath, atl, high24h, low24h, num_market_pairs, cmc_rank, date_added, max_supply, circulating_supply, total_supply, volume_7d, volume_30d, self_reported_circulating_supply, self_reported_market_cap' to include all auxiliary fields.
243
+ # @param [String (frozen)] tags If you want to see cryptocurrencies that can be mined, just type 'mineable'.
244
+ # @param [String (frozen)] volume24hRange Optionally specify a threshold 24 hour USD volume to filter results by. For example, '0~100000000000000000'
245
+ # @param [String (frozen)] percentChange24hRange Optionally specify a threshold 24 hour percent change to filter results by. For example, '0~100' or '-10~100'
246
+ # @param [String (frozen)] circulatingSupplyRange Optionally specify a threshold circulating supply to filter results by. For example, '0~100000000000000000'
247
+ # @param [String (frozen)] priceRange Optionally specify a threshold USD price to filter results by. For example, '0~100000000000000000'
248
+ # @param [String (frozen)] marketCapRange Optionally specify a threshold market cap to filter results by. For example, '0~100000000000000000'
249
+ def coins(start: 1,
250
+ limit: 100,
251
+ sortBy: 'market_cap',
252
+ sortType: 'desc',
253
+ convert: 'USD',
254
+ cryptoType: 'all',
255
+ tagType: 'all',
256
+ audited: false,
257
+ aux: nil,
258
+ tags: nil,
259
+ volume24hRange: nil,
260
+ percentChange24hRange: nil,
261
+ circulatingSupplyRange: nil,
262
+ priceRange: nil,
263
+ marketCapRange: nil)
264
+ @@cryptocurrencies.limit = limit # Integer
265
+ @@cryptocurrencies.start = start # Integer
266
+ @@cryptocurrencies.sortBy = sortBy # String
267
+ @@cryptocurrencies.sortType = sortType # String
268
+ @@cryptocurrencies.convert = convert # String
269
+ @@cryptocurrencies.cryptoType = cryptoType # String
270
+ @@cryptocurrencies.tagType = tagType # String
271
+ @@cryptocurrencies.audited = audited # Boolean
272
+ @@cryptocurrencies.aux = aux # String
273
+ @@cryptocurrencies.tags = tags # String
274
+ @@cryptocurrencies.volume24hRange = volume24hRange # String
275
+ @@cryptocurrencies.percentChange24hRange = percentChange24hRange # String
276
+ @@cryptocurrencies.circulatingSupplyRange = circulatingSupplyRange # String
277
+ @@cryptocurrencies.priceRange = priceRange # String
278
+ @@cryptocurrencies.marketCapRange = marketCapRange # String
193
279
 
194
280
  @@cryptocurrencies.update ? @@cryptocurrencies.get_data : nil
195
281
  end
@@ -208,7 +294,8 @@ module CoinmarketcapFree
208
294
  size_x_size = case size
209
295
  when 64, 128, 200
210
296
  "#{size}x#{size}"
211
- else raise ArgumentError
297
+ else
298
+ raise ArgumentError, "Can't find this value: #{size}"
212
299
  end
213
300
  "https://s2.coinmarketcap.com/static/img/coins/#{size_x_size}/#{id_coin}.png"
214
301
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coinmarketcap_free
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - cosmic-1
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-30 00:00:00.000000000 Z
11
+ date: 2023-02-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Cryptocurrency information from the Coinmarketcap site without a key.
14
14
  email: