coin360api21 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6a834ea56c7e8155f4116fa5fe39d95c015060b12ed592292ca85b7f77a3e22b
4
+ data.tar.gz: 5d989ae646416a9b6970d1004d4418f4e4a2c0d79c2ea15d85c32ec5099953a5
5
+ SHA512:
6
+ metadata.gz: 3d6fc3919159c226faf3db3f446dc29f1195f5b898ef472ad2a2d719a4abfb115e8b477f1e05596d6fcc02864dbf7e90c9bba125004971784eba360b7bbe5249
7
+ data.tar.gz: 95902115381648c630cc076f4003f9a85440b8f1b5ef5a001492c6186ac724264c9cfffdfffaf801e2673d04a4d930a187ae98ceeebb84bd62176747898f785a
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ ��7ΐ6�i�-���j���x(G��34���cJ�Md�f�FA*���3����X�{�x�i�΃��_v!�]Vq�ub'�r�5��� �9�1�
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ $ 0��e�"|�W�Ҟ6(����.<��7���A.a8���t9��s�*�)H�8w�ni"eY�g�F��;�]����B)߶m��y��j�� ={(�i�VeZ0;[�n�*�HE��#P>�LxA�O������?�4��|�.�B)x�����S����L��u�V)���ׯ�#}8���g�7�����r�s^)f)6���HtB=>� ]��*�����_D}
2
+ ��X�U$�, ���nz���m��,��/�Oj�]~��.��-K:x5��r���Ji#O鱪B�Oh@�<��������2䃘��+�'��Ob��P��V��AL�釞"���j�]\�(4Qud۝��%o��x�r��1c�a��a�����
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: coin360api21.rb
4
+
5
+ require 'json'
6
+ require 'excon'
7
+ require 'unichron'
8
+
9
+
10
+ module Coin360Api21
11
+
12
+ class Coin
13
+
14
+ def initialize()
15
+ @url_base = 'https://api.coin360.com'
16
+ end
17
+
18
+ # returns the historical price for a given coin
19
+ # if no date is provided, returns the previous 17 days
20
+ # if no period is provided, defaults to a 5 minute period
21
+ #
22
+ # Examples
23
+ # historical :btc
24
+ # historical :btc, date_start: 1620120300
25
+ # historical :btc, date_start: 1620120300, period: '1h'
26
+ # historical :btc, date_start: 1620120300, date_end: 1620121200
27
+ #
28
+ def historical(coin, date_start: nil, date_end: nil, period: nil)
29
+
30
+ params = ['coin=' + coin.to_s]
31
+ params << 'start=' + timeify(date_start) if date_start
32
+ params << 'end=' + timeify(date_end) if date_end
33
+ params << 'period=' + period if period
34
+ api_call "/coin/historical?%s" % [params.join('&')]
35
+
36
+ end
37
+
38
+ private
39
+
40
+ def api_call(api_request)
41
+
42
+ response = Excon.get(@url_base + api_request)
43
+ JSON.parse(response.body)
44
+
45
+ end
46
+
47
+ def timeify(obj)
48
+ Unichron.new(obj).to_time.to_i.to_s
49
+ end
50
+
51
+ end
52
+
53
+ class Global
54
+
55
+ def initialize()
56
+ @url_base = 'https://api.coin360.com'
57
+ end
58
+
59
+ def latest()
60
+ api_call '/global/latest'
61
+ end
62
+
63
+ private
64
+
65
+ def api_call(api_request)
66
+
67
+ response = Excon.get(@url_base + api_request)
68
+ JSON.parse(response.body)
69
+
70
+ end
71
+
72
+ end
73
+ end
74
+
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coin360api21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwNTA0MTEzNjI0WhcN
15
+ MjIwNTA0MTEzNjI0WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvRE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eozV//3EAvH5tlCqiKiYbxjpIvHYO8W61QQwrXYfUBkCHuXw/J79
32
+ Wh62x3zxaKEv1E07kyjPpVYy2C5gwj+xErYAUvZhBEKU7AoN/ArTAcf65A+sFIgA
33
+ mogOrBiu5VmgyEXZRQZmHFBBFnbyLDeDtWAQv7JvqSf4BpDWujimfUQqeUMinWPU
34
+ ybwdre1fIwPXNyyoHsqYtmO9nar3+YAhU+kjdid362nEYvARhjWAAmPD/af1kjvU
35
+ ft7SBJV4ZFBTQVtFgH1ibUvE4+oWidYI8Oj+U+3504P/dPB1SUqmYdSQ6kjBq73M
36
+ aPSefXvu4rOaSqRERvg49FSh
37
+ -----END CERTIFICATE-----
38
+ date: 2021-05-04 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: excon
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.81.0
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.81'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.81.0
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '0.81'
60
+ - !ruby/object:Gem::Dependency
61
+ name: unichron
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '0.3'
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.3.7
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.3'
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.3.7
80
+ description:
81
+ email: digital.robertson@gmail.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - lib/coin360api21.rb
87
+ homepage: https://github.com/jrobertson/coin360api21
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.7.10
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: 'Uses the Coin360 API; unofficial gem. #cryptocurrency'
111
+ test_files: []
metadata.gz.sig ADDED
Binary file