coincap 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa1a230a189db830d8bf24f43c48312c5645841537e2222164b10d73250e6407
4
- data.tar.gz: 38b15fd2c64ee1534519000d99301394903f43b9365c8a5dec9cab2dcf471f76
3
+ metadata.gz: 5f64f28f94bf1c7bfc899d6493f0f9e2512ce9f413adad7073d5cbd3b3aeb510
4
+ data.tar.gz: 7d5ac910e50b8c06611849fe7859d0a30bfa9d017cb7b33b2890c292b52eef67
5
5
  SHA512:
6
- metadata.gz: 837299ff2ce6a3614a95f70990249690ba81fef73de6e7e248bda5f0379a2502f69463534432f1f0f837de4a9b637993a263c38639a2469ddb014e05d6a42a8a
7
- data.tar.gz: d2b1616ead42dc7428353ec929b8146efff1025bd9b21a1a26fb7153cc8a14dbe3ac2a059db108c01b2101e10ac40ac57152b53e58c9015306316db5fc45578a
6
+ metadata.gz: e5b4e8f2fda02bc248ddd777eaeccdaa20950980a3039e90572e4e9daeaf58bf001a734fdc925e0d1414cc9af6b0221bb420fe0f626d0267e9553bf253881e9b
7
+ data.tar.gz: fa99b3052e9dd464070aee8465fbd7d8ae45fd5a6a2d457d34a78dd9ef2f3d72f37e3fa63654a200c49e96401560cd1a8ba3db5ee8d3c054783456fed01401ce
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coincap (0.1.1)
4
+ coincap (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -4,6 +4,7 @@ CoinCap is a useful tool for real-time pricing and market activity for over 1,00
4
4
  If you want to add 'api key' or change 'accept encoding', just call the 'configure' method.
5
5
 
6
6
  No API Key: 200 requests per minute
7
+
7
8
  API Key: 500 requests per minute
8
9
 
9
10
  Generate API KEY [here](https://coincap.io/api-key).
@@ -211,4 +212,4 @@ data = Coincap::Markets.list
211
212
  ],
212
213
  "timestamp": 1533581173350
213
214
  }
214
- ```
215
+ ```
data/coincap.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/coincap/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'coincap'
7
+ spec.version = Coincap::VERSION
8
+ spec.authors = ['cosmic-1']
9
+ spec.email = ['crossdoh@gmail.com']
10
+
11
+ spec.summary = 'CoinCap is a useful tool for real-time pricing and market activity for over 1,000 cryptocurrencies.'
12
+ spec.description = 'CoinCap is a useful tool for real-time pricing and market activity for over 1,000 cryptocurrencies.'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = '>= 2.6.0'
15
+
16
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
+
18
+ spec.metadata['source_code_uri'] = 'https://github.com/Cosmic-1/coincap'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
30
+
31
+ # Uncomment to register a new dependency of your gem
32
+ # spec.add_dependency "example-gem", "~> 1.0"
33
+
34
+ # For more information and examples about making a new gem, check out our
35
+ # guide at: https://bundler.io/guides/creating_gem.html
36
+ end
@@ -45,20 +45,13 @@ module Coincap
45
45
  # "timestamp": 1533581088278
46
46
  # }
47
47
  #
48
- # @param [Hash] options
49
- # @option options [String] :search (nil) Search by asset id (bitcoin) or symbol (BTC)
50
- # @option options [String] :ids (nil) Query with multiple ids=bitcoin,ethereum,monero
51
- # @option options [Integer] :limit (nil) Max limit of 2000
52
- # @option options [Integer] :offset (nil) Offset
53
- # @return [Hash]
54
- def self.cryptocurrencies(**options)
55
- quries = {
56
- 'search': options[:search],
57
- 'ids': options[:ids],
58
- 'limit': options[:limit],
59
- 'offset': options[:offset]
60
- }
61
- Helper.request_to_read_data(URI_API, **quries)
48
+ # @param [String] search (nil) Search by asset id (bitcoin) or symbol (BTC)
49
+ # @param [String] ids (nil) Query with multiple ids=bitcoin,ethereum,monero
50
+ # @param [Integer] limit (nil) Max limit of 2000
51
+ # @param [Integer] offset (nil) Offset
52
+ # @return [String]
53
+ def self.cryptocurrencies(search: nil, ids: nil, limit: nil, offset: nil)
54
+ Helper.request_to_read_data(URI_API, search: search, ids: ids, limit: limit, offset: offset)
62
55
  end
63
56
 
64
57
  # Get single cryptocurrency
@@ -81,7 +74,7 @@ module Coincap
81
74
  # }
82
75
  #
83
76
  # @param [String] asset_id Asset id, for example, bitcoin
84
- # @return [Hash]
77
+ # @return [String]
85
78
  def self.cryptocurrency(asset_id)
86
79
  Helper.request_to_read_data("#{URI_API}/#{asset_id}")
87
80
  end
@@ -101,6 +94,7 @@ module Coincap
101
94
  #
102
95
  # @param [String] asset_id Asset id, for example, bitcoin
103
96
  # @param [Symbol] interval Select one from the list m1,m5,m15,m30,h1,h2,h6,h12,d1, for example, m1 or write a symbol, for example, :one_minute
97
+ # @return [String]
104
98
  def self.cryptocurrency_history(asset_id, interval)
105
99
  Helper.request_to_read_data("#{URI_API}/#{asset_id}/history",
106
100
  interval: interval.is_a?(Symbol) ? TIME_INTERVAL[interval] : interval)
@@ -128,6 +122,7 @@ module Coincap
128
122
  # @param [String] asset_id Asset id, for example, bitcoin
129
123
  # @param [Integer] limit Max limit of 2000
130
124
  # @param [Integer] offset Offset
125
+ # @return [String]
131
126
  def self.cryptocurrency_with_markets(asset_id, limit: nil, offset: nil)
132
127
  Helper.request_to_read_data("#{URI_API}/#{asset_id}/markets", limit: limit, offset: offset)
133
128
  end
@@ -33,7 +33,7 @@ module Coincap
33
33
  # "timestamp": 1536605835421
34
34
  # }
35
35
  #
36
- # @return [Hash]
36
+ # @return [String]
37
37
  def self.list
38
38
  Helper.request_to_read_data(URI_API)
39
39
  end
@@ -56,7 +56,7 @@ module Coincap
56
56
  # }
57
57
  #
58
58
  # @param exchange_id [String]
59
- # @return [Hash]
59
+ # @return [String]
60
60
  def self.single(exchange_id)
61
61
  Helper.request_to_read_data("#{URI_API}/#{exchange_id}")
62
62
  end
@@ -8,10 +8,14 @@ require 'openssl'
8
8
  module Coincap
9
9
  # Helper module
10
10
  module Helper
11
- def self.request_to_read_data(uri_string, **queries_hash)
12
- uri = convert_hash_to_uri(uri_string, **queries_hash)
13
-
14
- data_str = http_get(uri)
11
+ class << self
12
+ # Request to read data
13
+ # @param uri_string [String] string of the uri
14
+ # @param queries_hash [Hash] queries hash for the request
15
+ # @return [String]
16
+ def request_to_read_data(uri_string, **queries_hash)
17
+ http_get convert_hash_to_uri(uri_string, **queries_hash)
18
+ end
15
19
 
16
20
  JSON.parse(data_str)
17
21
  end
@@ -23,11 +27,9 @@ module Coincap
23
27
  config = Coincap.instance_variable_get(:@config)
24
28
 
25
29
  headers = {
26
- 'Accept-Encoding': config.accept_encoding,
30
+ 'Accept-Encoding': config.accept_encoding.nil? ? nil : config.accept_encoding,
27
31
  'Authorization': config.api_key.nil? ? nil : "Bearer #{config.api_key}"
28
- }
29
-
30
- headers.compact!
32
+ }.compact
31
33
 
32
34
  Net::HTTP.get(uri, headers)
33
35
  end
@@ -35,30 +35,27 @@ module Coincap
35
35
  # "timestamp": 1533581173350
36
36
  # }
37
37
  #
38
- # @param options [Hash] options for the request
39
- # @option options [String] :exchange_id (nil) Search by exchange id (e.g. 'binance')
40
- # @option options [String] :base_symbol (nil) Returns all containing the base symbol
41
- # @option options [String] :quote_symbol (nil) Returns all containing the quote symbol
42
- # @option options [String] :base_id (nil) Returns all containing the base id
43
- # @option options [String] :quote_id (nil) Returns all containing the quote id
44
- # @option options [String] :asset_symbol (nil) Returns all assets containing symbol (base and quote)
45
- # @option options [String] :asset_id (nil) Returns all assets containing id (base and quote)
46
- # @option options [Integer] :limit (nil) Max limit of 2000
47
- # @option options [Integer] :offset (nil) The number of results to skip
48
- # @return [Hash]
38
+ # @param [String] exchange_id (nil) Search by exchange id (e.g. 'binance')
39
+ # @param [String] base_symbol (nil) Returns all containing the base symbol
40
+ # @param [String] quote_symbol (nil) Returns all containing the quote symbol
41
+ # @param [String] base_id (nil) Returns all containing the base id
42
+ # @param [String] quote_id (nil) Returns all containing the quote id
43
+ # @param [String] asset_symbol (nil) Returns all assets containing symbol (base and quote)
44
+ # @param [String] asset_id (nil) Returns all assets containing id (base and quote)
45
+ # @param [Integer] limit (nil) Max limit of 2000
46
+ # @param [Integer] offset (nil) The number of results to skip
47
+ # @return [String]
49
48
  def self.list(**options)
50
- queries = {
51
- 'exchangeId': options[:exchange_id],
52
- 'baseSymbol': options[:base_symbol],
53
- 'quoteSymbol': options[:quote_symbol],
54
- 'baseId': options[:base_id],
55
- 'quoteId': options[:quote_id],
56
- 'assetSymbol': options[:asset_symbol],
57
- 'assetId': options[:asset_id],
58
- 'limit': options[:limit],
59
- 'offset': options[:offset]
60
- }
61
- Helper.request_to_read_data(URI_API, **queries)
49
+ Helper.request_to_read_data(URI_API,
50
+ 'exchangeId': options[:exchange_id],
51
+ 'baseSymbol': options[:base_symbol],
52
+ 'quoteSymbol': options[:quote_symbol],
53
+ 'baseId': options[:base_id],
54
+ 'quoteId': options[:quote_id],
55
+ 'assetSymbol': options[:asset_symbol],
56
+ 'assetId': options[:asset_id],
57
+ 'limit': options[:limit],
58
+ 'offset': options[:offset])
62
59
  end
63
60
  end
64
61
  end
data/lib/coincap/rates.rb CHANGED
@@ -26,7 +26,7 @@ module Coincap
26
26
  # "timestamp": 1536347807471
27
27
  # }
28
28
  #
29
- # @return [Hash]
29
+ # @return [String]
30
30
  def self.list
31
31
  Helper.request_to_read_data(URI_API)
32
32
  end
@@ -45,7 +45,7 @@ module Coincap
45
45
  # }
46
46
  #
47
47
  # @param asset_id [String] The asset id (bitcoin)
48
- # @return [Hash]
48
+ # @return [String]
49
49
  def self.single(asset_id)
50
50
  Helper.request_to_read_data("#{URI_API}/#{asset_id}")
51
51
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coincap
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
data/lib/coincap.rb CHANGED
@@ -31,9 +31,8 @@ module Coincap
31
31
 
32
32
  @config = Configuration.new
33
33
 
34
+ # Configuration the Coincap API
34
35
  def self.configure
35
- # @yield [Coincap::Configuration]
36
36
  yield @config
37
- @config.accept_encoding
38
37
  end
39
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coincap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
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-04-12 00:00:00.000000000 Z
11
+ date: 2023-05-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: CoinCap is a useful tool for real-time pricing and market activity for
14
14
  over 1,000 cryptocurrencies.
@@ -23,6 +23,7 @@ files:
23
23
  - LICENSE.txt
24
24
  - README.md
25
25
  - Rakefile
26
+ - coincap.gemspec
26
27
  - lib/coincap.rb
27
28
  - lib/coincap/assets_price.rb
28
29
  - lib/coincap/exchanges.rb