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 +4 -4
- data/lib/gecko/resources/coin.rb +35 -5
- data/lib/gecko/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75fd410bcdffbc57d9d7bdafd06c16fd404d64d62b8389045c685fb5ebcdc3c2
|
4
|
+
data.tar.gz: 58267568634e24d3bd6b7e4d89a2e36f8ef79ff2ddc8940c005a016e0fcb4bea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9283c7bdf0942cc04fe36cf14b802106c7fa311838a54e5588bfc9dc8e21a07b2bab9db59e2fd223e47431b77420140332e287ec4161b0a33ea6a87b1a7e9cd9
|
7
|
+
data.tar.gz: c04370217ec3f52194be9f064b1395c8fdc9894dd14ba28c8db3c687f20fc16559cb651e8153c1da78fe2c641522dd0aeeb561e6bf2e3e5d18e47c4a7f1147df
|
data/lib/gecko/resources/coin.rb
CHANGED
@@ -7,18 +7,44 @@ module Gecko
|
|
7
7
|
# Description: Acquire data of a crypto
|
8
8
|
# Parameter: /
|
9
9
|
|
10
|
-
def
|
11
|
-
formatting(
|
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(
|
17
|
-
uri =
|
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
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.
|
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:
|
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.
|
175
|
+
summary: gecko0.0.1
|
176
176
|
test_files: []
|