gecko-api 0.0.0 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gecko/base.rb +1 -0
- data/lib/gecko/resources/coin.rb +36 -6
- data/lib/gecko/version.rb +1 -1
- metadata +17 -4
- data/lib/gecko/resources/request.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61ffdf08d3a65fede9683de62508685f402b55792921443523edbd23090f045d
|
4
|
+
data.tar.gz: 35e51bc05884ec9413869fa741df4f3c3b06d72a21e3901ee820abc0d08cdfab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05ffe0cb0ef6a244aa1330b1236927a6024dba2328696bbaa2cde84736f565e3908803834be8077ec4f8edb829485904112d810938738d2bf3f7a85bb5cc33bf
|
7
|
+
data.tar.gz: e5d08d5723f40b7006164ab71b5533ff90d2b6718ecda49a090103185bbb5620f431298d07a368021714065756c72cf9d7883b38bcb186f0ac084e46e601f248
|
data/lib/gecko/base.rb
CHANGED
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 =
|
18
|
-
|
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
|
29
|
+
Request::Http.request(uri: uri, method: 'GET')
|
30
|
+
end
|
31
|
+
|
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
|
19
38
|
end
|
20
39
|
|
21
|
-
def
|
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.2
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aga-request
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bump
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,7 +162,6 @@ files:
|
|
148
162
|
- lib/gecko/autoloader.rb
|
149
163
|
- lib/gecko/base.rb
|
150
164
|
- lib/gecko/resources/coin.rb
|
151
|
-
- lib/gecko/resources/request.rb
|
152
165
|
- lib/gecko/version.rb
|
153
166
|
homepage: https://github.com/Baldaz02/gecko-ruby
|
154
167
|
licenses:
|
@@ -172,5 +185,5 @@ requirements: []
|
|
172
185
|
rubygems_version: 3.3.24
|
173
186
|
signing_key:
|
174
187
|
specification_version: 4
|
175
|
-
summary: gecko0.0.
|
188
|
+
summary: gecko0.0.2
|
176
189
|
test_files: []
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Gecko
|
4
|
-
class Request < Base
|
5
|
-
class << self
|
6
|
-
def request(uri:, method:)
|
7
|
-
req = get_method(name: method, uri: uri)
|
8
|
-
req['Content-Type'] = 'application/json'
|
9
|
-
|
10
|
-
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
11
|
-
http.request(req)
|
12
|
-
end
|
13
|
-
|
14
|
-
JSON.parse(res.body)
|
15
|
-
end
|
16
|
-
|
17
|
-
def get_method(name:, uri:)
|
18
|
-
case name
|
19
|
-
when 'GET'
|
20
|
-
req = Net::HTTP::Get.new(uri)
|
21
|
-
# when 'POST'
|
22
|
-
# req = Net::HTTP::Post.new(uri)
|
23
|
-
# when 'DELETE'
|
24
|
-
# req = Net::HTTP::Delete.new(uri)
|
25
|
-
end
|
26
|
-
|
27
|
-
req
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|