gecko-api 0.0.0 → 0.0.1

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: f500a52fbca5e1a944d3d8be977d633c60e4834114bd79c97e4b5841299887d0
4
- data.tar.gz: f37c9108cc676e90c4176742cd650a2efee136f57b74c089ee982765a961f30c
3
+ metadata.gz: 75fd410bcdffbc57d9d7bdafd06c16fd404d64d62b8389045c685fb5ebcdc3c2
4
+ data.tar.gz: 58267568634e24d3bd6b7e4d89a2e36f8ef79ff2ddc8940c005a016e0fcb4bea
5
5
  SHA512:
6
- metadata.gz: 4aff1156a513baa6f522f332c91305b9b747f4e85b2fcd900982a619b0b5e8c757228187103b7bacbdac0608ff8d50e90d5de70bb582b5e9499415b2e7892279
7
- data.tar.gz: e6e7af0fa4f580be0944f253187c7d3174c345d5a7f1d7ff77f7cc41ef744253f5ac3ced2c255117525aad0d5875e13876b9afcd010ca3615ae1b8e04d86a2de
6
+ metadata.gz: 9283c7bdf0942cc04fe36cf14b802106c7fa311838a54e5588bfc9dc8e21a07b2bab9db59e2fd223e47431b77420140332e287ec4161b0a33ea6a87b1a7e9cd9
7
+ data.tar.gz: c04370217ec3f52194be9f064b1395c8fdc9894dd14ba28c8db3c687f20fc16559cb651e8153c1da78fe2c641522dd0aeeb561e6bf2e3e5d18e47c4a7f1147df
@@ -7,18 +7,44 @@ module Gecko
7
7
  # Description: Acquire data of a crypto
8
8
  # Parameter: /
9
9
 
10
- def exchanges(name)
11
- formatting(detail(name.downcase))
10
+ def info(symbol)
11
+ formatting(
12
+ payload: detail(symbol: symbol.downcase),
13
+ symbol: symbol.downcase
14
+ )
15
+ end
16
+
17
+ def exchanges(id)
18
+ formatting(payload: detail(id: split_words(id.downcase)))
12
19
  end
13
20
 
14
21
  private
15
22
 
16
- def detail(name)
17
- uri = URI("https://api.coingecko.com/api/v3/coins/#{name}")
23
+ def detail(id: nil, symbol: nil)
24
+ uri = if symbol.nil?
25
+ URI("https://api.coingecko.com/api/v3/coins/#{id}")
26
+ else
27
+ URI('https://api.coingecko.com/api/v3/coins/list')
28
+ end
18
29
  Gecko::Request.request(uri: uri, method: 'GET')
19
30
  end
20
31
 
21
- def formatting(payload)
32
+ def formatting(payload:, symbol: nil)
33
+ if symbol.nil?
34
+ formatting_ex(payload)
35
+ else
36
+ formatting_info(payload: payload, symbol: symbol)
37
+ end
38
+ end
39
+
40
+ def formatting_info(payload:, symbol:)
41
+ info = payload.select { |x| x['symbol'] == symbol }.first
42
+ info = {} if info.nil?
43
+
44
+ info
45
+ end
46
+
47
+ def formatting_ex(payload)
22
48
  tickers = payload['tickers']
23
49
  if !tickers.nil?
24
50
  tickers.map { |x| x.dig('market', 'name') }.uniq
@@ -26,6 +52,10 @@ module Gecko
26
52
  []
27
53
  end
28
54
  end
55
+
56
+ def split_words(id)
57
+ id.split(/\W+/).join('-')
58
+ end
29
59
  end
30
60
  end
31
61
  end
data/lib/gecko/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Gecko
4
- VERSION = '0.0.0'
4
+ VERSION = '0.0.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gecko-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Baldazzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-30 00:00:00.000000000 Z
11
+ date: 2023-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -172,5 +172,5 @@ requirements: []
172
172
  rubygems_version: 3.3.24
173
173
  signing_key:
174
174
  specification_version: 4
175
- summary: gecko0.0.0
175
+ summary: gecko0.0.1
176
176
  test_files: []