zold-ruby-sdk 0.1.0 → 0.2.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 +4 -4
- data/.rubocop.yml +2 -0
- data/.rultor.yml +7 -10
- data/.travis.yml +3 -7
- data/README.md +9 -5
- data/lib/zold/wts.rb +167 -139
- data/test/test__helper.rb +32 -0
- data/test/zold/test_wts.rb +20 -10
- data/zold-ruby-sdk.gemspec +3 -2
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce7aea32407824fee9aaac411bc6ffaf1bbc34d4ab5c6b11d8cbf90c76b2af3b
|
4
|
+
data.tar.gz: 914288435490d8e465b10698890e95e45cfbd6f4a4ff6e604382fff67ba9e7ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39a715a9c6a203b6fcc7a6b80b58d70550940c287754dad1adbf6afe1ff142f8f793ddd9238d639073124c527fa682ec8733c1a3179c4eb9a1372deef3c4dca7
|
7
|
+
data.tar.gz: e71cf1f3c7a711eddc44b81a30d0ff2f06ba6844665d977dc825ed7297b571e6abd5e082cc25cce5288303b262ce9de0c33da6a24396c53f47fe11bcd3f96172
|
data/.rubocop.yml
CHANGED
data/.rultor.yml
CHANGED
@@ -3,10 +3,10 @@ assets:
|
|
3
3
|
install: |-
|
4
4
|
export GEM_HOME=~/.ruby
|
5
5
|
export GEM_PATH=$GEM_HOME:$GEM_PATH
|
6
|
+
bundle install
|
6
7
|
release:
|
7
8
|
script: |-
|
8
|
-
bundle
|
9
|
-
rake
|
9
|
+
bundle exec rake
|
10
10
|
rm -rf *.gem
|
11
11
|
sed -i "s/0\.0\.0/${tag}/g" zold-ruby-sdk.gemspec
|
12
12
|
git add zold-ruby-sdk.gemspec
|
@@ -14,13 +14,10 @@ release:
|
|
14
14
|
gem build zold-ruby-sdk.gemspec
|
15
15
|
chmod 0600 ../rubygems.yml
|
16
16
|
gem push *.gem --config-file ../rubygems.yml
|
17
|
-
commanders:
|
18
|
-
- yegor256
|
19
|
-
architect:
|
20
|
-
- yegor256
|
21
17
|
merge:
|
22
|
-
commanders: []
|
23
18
|
script: |-
|
24
|
-
bundle
|
25
|
-
|
26
|
-
|
19
|
+
bundle exec rake
|
20
|
+
deploy:
|
21
|
+
script: |-
|
22
|
+
echo 'There is nothing to deploy'
|
23
|
+
exit -1
|
data/.travis.yml
CHANGED
@@ -1,20 +1,16 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.3.3
|
5
|
-
- 2.4.5
|
3
|
+
- 2.6.0
|
6
4
|
cache: bundler
|
7
5
|
branches:
|
8
6
|
only:
|
9
7
|
- master
|
10
8
|
install:
|
11
9
|
- travis_retry bundle update
|
12
|
-
- gem install pdd
|
13
|
-
- sudo apt-get install cppcheck
|
10
|
+
- gem install pdd -v 0.20.5
|
14
11
|
script:
|
15
12
|
- pdd -f /dev/null
|
16
|
-
- cppcheck --enable=all --quiet --suppress=unusedFunction .
|
17
13
|
- export RUBYOPT="-W0"
|
18
|
-
- rake --quiet
|
14
|
+
- bundle exec rake --quiet
|
19
15
|
after_success:
|
20
16
|
- "bash <(curl -s https://codecov.io/bash)"
|
data/README.md
CHANGED
@@ -11,19 +11,23 @@
|
|
11
11
|
[](http://www.0pdd.com/p?name=zold-io/zold-ruby-sdk)
|
12
12
|
[](http://badge.fury.io/rb/zold-ruby-sdk)
|
13
13
|
[](https://codecov.io/github/zold-io/zold-ruby-sdk?branch=master)
|
14
|
+
[](http://rubydoc.info/github/zold-io/zold-ruby-sdk/master/frames)
|
15
|
+
|
16
|
+
[](https://github.com/yegor256/takes/blob/master/LICENSE.txt)
|
17
|
+
[](https://hitsofcode.com/view/github/zold-io/zold-ruby-sdk)
|
14
18
|
|
15
19
|
Here is the [White Paper](https://papers.zold.io/wp.pdf).
|
16
20
|
|
17
21
|
Join our [Telegram group](https://t.me/zold_io) to discuss it all live.
|
18
22
|
|
19
|
-
The license is [MIT](https://github.com/zold-io/zold-ruby-sdk/blob/master/LICENSE.txt).
|
20
|
-
|
21
23
|
This is a simple Ruby SDK for making payments, checking balances, and finding transactions in
|
22
24
|
Zold wallets via [WTS](https://wts.zold.io) system.
|
23
25
|
|
26
|
+
There are other languages too: [Java SDK](https://github.com/amihaiemil/zold-java-client).
|
27
|
+
|
24
28
|
First, you install it:
|
25
29
|
|
26
|
-
```
|
30
|
+
```bash
|
27
31
|
gem install zold-ruby-sdk
|
28
32
|
```
|
29
33
|
|
@@ -63,7 +67,7 @@ txns = wts.find(id: '123', details: /pizza/)
|
|
63
67
|
|
64
68
|
That's it.
|
65
69
|
|
66
|
-
|
70
|
+
## How to contribute
|
67
71
|
|
68
72
|
Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
69
73
|
Make sure you build is green before you contribute
|
@@ -72,7 +76,7 @@ your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2
|
|
72
76
|
|
73
77
|
```
|
74
78
|
$ bundle update
|
75
|
-
$ rake
|
79
|
+
$ bundle exec rake
|
76
80
|
```
|
77
81
|
|
78
82
|
If it's clean and you don't see any error messages, submit your pull request.
|
data/lib/zold/wts.rb
CHANGED
@@ -22,6 +22,7 @@
|
|
22
22
|
|
23
23
|
require 'typhoeus'
|
24
24
|
require 'cgi'
|
25
|
+
require 'loog'
|
25
26
|
require 'zold/age'
|
26
27
|
require 'zold/amount'
|
27
28
|
require 'zold/id'
|
@@ -32,168 +33,195 @@ require 'zold/txn'
|
|
32
33
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
33
34
|
# Copyright:: Copyright (c) 2018-2019 Yegor Bugayenko
|
34
35
|
# License:: MIT
|
35
|
-
|
36
|
-
#
|
37
|
-
class
|
38
|
-
# Makes a new object of the class. The <tt>key</tt> you are supposed
|
39
|
-
# to obtain at this page: https://wts.zold.io/api. You will have to login
|
40
|
-
# and confirm your account first. Keep this key secret, to avoid
|
41
|
-
# information lost. However, even knowing the secret no payments can
|
42
|
-
# be sent without they keygap.
|
43
|
-
def initialize(key, log: STDOUT)
|
44
|
-
raise 'Key can\'t be nil' if key.nil?
|
45
|
-
@key = key
|
46
|
-
raise 'Log can\'t be nil' if log.nil?
|
47
|
-
@log = log
|
48
|
-
end
|
49
|
-
|
50
|
-
# Initiate PULL request. The server will pull your wallet form the network,
|
51
|
-
# and make it ready for future requests. Without this operation you won't
|
52
|
-
# be able to perform <tt>find()</tt> or <tt>balance()</tt> requests.
|
53
|
-
#
|
54
|
-
# The method returns the job ID, which you should wait for completion
|
55
|
-
# using the method <tt>wait()</tt>.
|
36
|
+
class Zold::WTS
|
37
|
+
# Fake implementation.
|
38
|
+
class Fake
|
56
39
|
def pull
|
57
|
-
|
58
|
-
job = job_of(
|
59
|
-
clean(
|
60
|
-
Typhoeus::Request.get(
|
61
|
-
'https://wts.zold.io/pull',
|
62
|
-
headers: headers
|
63
|
-
)
|
64
|
-
)
|
65
|
-
)
|
66
|
-
debug("PULL job #{job} started in #{Zold::Age.new(start)}")
|
67
|
-
job
|
40
|
+
'job-id'
|
68
41
|
end
|
69
42
|
|
70
|
-
# Get wallet balance.
|
71
43
|
def balance
|
72
|
-
|
73
|
-
http = clean(
|
74
|
-
Typhoeus::Request.get(
|
75
|
-
'https://wts.zold.io/balance',
|
76
|
-
headers: headers
|
77
|
-
)
|
78
|
-
)
|
79
|
-
balance = Zold::Amount.new(zents: http.body.to_i)
|
80
|
-
debug("Wallet balance #{balance} retrieved in #{Zold::Age.new(start)}")
|
81
|
-
balance
|
44
|
+
Zold::Amount.new(zld: 4.0)
|
82
45
|
end
|
83
46
|
|
84
|
-
# Get wallet ID.
|
85
47
|
def id
|
86
|
-
|
87
|
-
http = clean(
|
88
|
-
Typhoeus::Request.get(
|
89
|
-
'https://wts.zold.io/id',
|
90
|
-
headers: headers
|
91
|
-
)
|
92
|
-
)
|
93
|
-
id = Zold::Id.new(http.body.to_s)
|
94
|
-
debug("Wallet ID #{id} retrieved in #{Zold::Age.new(start)}")
|
95
|
-
id
|
48
|
+
Zold::Id::ROOT
|
96
49
|
end
|
97
50
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
# The method returns the job ID, which you should wait for completion
|
105
|
-
# using the method <tt>wait()</tt>.
|
106
|
-
def pay(keygap, bnf, amount, details)
|
107
|
-
start = Time.now
|
108
|
-
job = job_of(
|
109
|
-
clean(
|
110
|
-
Typhoeus::Request.post(
|
111
|
-
'https://wts.zold.io/do-pay',
|
112
|
-
headers: headers,
|
113
|
-
body: { keygap: keygap, bnf: bnf, amount: amount, details: details }
|
114
|
-
)
|
115
|
-
)
|
116
|
-
)
|
117
|
-
debug("PAY job #{job} started in #{Zold::Age.new(start)}")
|
118
|
-
job
|
51
|
+
def pay(_keygap, _bnf, _amount, _details)
|
52
|
+
'job-id'
|
53
|
+
end
|
54
|
+
|
55
|
+
def find(_query)
|
56
|
+
[]
|
119
57
|
end
|
120
58
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
59
|
+
def wait(_job, time: 5 * 60)
|
60
|
+
raise 'Time must be positive' if time.negative?
|
61
|
+
'OK'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Makes a new object of the class. The <tt>key</tt> you are supposed
|
66
|
+
# to obtain at this page: https://wts.zold.io/api. You will have to login
|
67
|
+
# and confirm your account first. Keep this key secret, to avoid
|
68
|
+
# information lost. However, even knowing the secret no payments can
|
69
|
+
# be sent without they keygap.
|
70
|
+
def initialize(key, log: Loog::NULL)
|
71
|
+
raise 'Key can\'t be nil' if key.nil?
|
72
|
+
@key = key
|
73
|
+
raise 'Log can\'t be nil' if log.nil?
|
74
|
+
@log = log
|
75
|
+
end
|
76
|
+
|
77
|
+
# Initiate PULL request. The server will pull your wallet form the network,
|
78
|
+
# and make it ready for future requests. Without this operation you won't
|
79
|
+
# be able to perform <tt>find()</tt> or <tt>balance()</tt> requests.
|
80
|
+
#
|
81
|
+
# The method returns the job ID, which you should wait for completion
|
82
|
+
# using the method <tt>wait()</tt>.
|
83
|
+
def pull
|
84
|
+
start = Time.now
|
85
|
+
job = job_of(
|
86
|
+
clean(
|
132
87
|
Typhoeus::Request.get(
|
133
|
-
'https://wts.zold.io/
|
134
|
-
"#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"
|
135
|
-
end.join('&'),
|
88
|
+
'https://wts.zold.io/pull',
|
136
89
|
headers: headers
|
137
90
|
)
|
138
91
|
)
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
92
|
+
)
|
93
|
+
@log.debug("PULL job #{job} started in #{Zold::Age.new(start)}")
|
94
|
+
job
|
95
|
+
end
|
143
96
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
raise "Job #{job} not found on the server" if http.code == 404
|
158
|
-
raise "Unpredictable response code #{http.code}" unless http.code == 200
|
159
|
-
next if http.body == 'Running'
|
160
|
-
raise http.body unless http.body == 'OK'
|
161
|
-
debug("Job #{job} completed, in #{Zold::Age.new(start)}")
|
162
|
-
return http.body
|
163
|
-
end
|
164
|
-
end
|
97
|
+
# Get wallet balance.
|
98
|
+
def balance
|
99
|
+
start = Time.now
|
100
|
+
http = clean(
|
101
|
+
Typhoeus::Request.get(
|
102
|
+
'https://wts.zold.io/balance',
|
103
|
+
headers: headers
|
104
|
+
)
|
105
|
+
)
|
106
|
+
balance = Zold::Amount.new(zents: http.body.to_i)
|
107
|
+
@log.debug("The balance #{balance} retrieved in #{Zold::Age.new(start)}")
|
108
|
+
balance
|
109
|
+
end
|
165
110
|
|
166
|
-
|
111
|
+
# Get wallet ID.
|
112
|
+
def id
|
113
|
+
start = Time.now
|
114
|
+
http = clean(
|
115
|
+
Typhoeus::Request.get(
|
116
|
+
'https://wts.zold.io/id',
|
117
|
+
headers: headers
|
118
|
+
)
|
119
|
+
)
|
120
|
+
id = Zold::Id.new(http.body.to_s)
|
121
|
+
@log.debug("Wallet ID #{id} retrieved in #{Zold::Age.new(start)}")
|
122
|
+
id
|
123
|
+
end
|
167
124
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
125
|
+
# Initiate PAY request. The <tt>keygap</tt> is a string you get
|
126
|
+
# when you confirm the account. The <tt>bnf</tt> is the name of the
|
127
|
+
# GitHub account, the wallet ID or the invoice (up to you). The
|
128
|
+
# <tt>amount</tt> is the amount in ZLD, e.g. "19.99". The <tt>details</tt>
|
129
|
+
# is the text to add to the transaction.
|
130
|
+
#
|
131
|
+
# The method returns the job ID, which you should wait for completion
|
132
|
+
# using the method <tt>wait()</tt>.
|
133
|
+
def pay(keygap, bnf, amount, details)
|
134
|
+
start = Time.now
|
135
|
+
job = job_of(
|
136
|
+
clean(
|
137
|
+
Typhoeus::Request.post(
|
138
|
+
'https://wts.zold.io/do-pay',
|
139
|
+
headers: headers,
|
140
|
+
body: { keygap: keygap, bnf: bnf, amount: amount, details: details }
|
141
|
+
)
|
142
|
+
)
|
143
|
+
)
|
144
|
+
@log.debug("PAY job #{job} started in #{Zold::Age.new(start)}")
|
145
|
+
job
|
146
|
+
end
|
174
147
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
end
|
148
|
+
# Returns current USD rate of one ZLD.
|
149
|
+
def usd_rate
|
150
|
+
clean(Typhoeus::Request.get('https://wts.zold.io/usd_rate')).body.to_f
|
151
|
+
end
|
180
152
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
153
|
+
# Find transactions by the criteria. All criterias are regular expressions
|
154
|
+
# and their summary result is concatenated by OR. For example, this request
|
155
|
+
# will return all transactions that have "pizza" in details OR which
|
156
|
+
# are coming from the root wallet:
|
157
|
+
#
|
158
|
+
# find(details: /pizza/, bnf: '0000000000000000')
|
159
|
+
#
|
160
|
+
# The method returns an array of Zold::Txn objects.
|
161
|
+
def find(query)
|
162
|
+
start = Time.now
|
163
|
+
http = clean(
|
164
|
+
Typhoeus::Request.get(
|
165
|
+
'https://wts.zold.io/find?' + query.map do |k, v|
|
166
|
+
"#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"
|
167
|
+
end.join('&'),
|
168
|
+
headers: headers
|
169
|
+
)
|
170
|
+
)
|
171
|
+
txns = http.body.split("\n").map { |t| Zold::Txn.parse(t) }
|
172
|
+
@log.debug("#{txns.count} transactions found in #{Zold::Age.new(start)}")
|
173
|
+
txns
|
174
|
+
end
|
175
|
+
|
176
|
+
# Wait for the job to complete. If the job completes successfully, the
|
177
|
+
# method returns 'OK' in a few seconds (up to a few minutes). If the
|
178
|
+
# is some error, the exception will be raised.
|
179
|
+
def wait(job, time: 5 * 60)
|
180
|
+
start = Time.now
|
181
|
+
loop do
|
182
|
+
if Time.now - start > time
|
183
|
+
raise "Can't wait any longer for the job #{job} to complete"
|
187
184
|
end
|
188
|
-
http
|
185
|
+
http = Typhoeus::Request.get(
|
186
|
+
'https://wts.zold.io/job?id=' + job,
|
187
|
+
headers: headers
|
188
|
+
)
|
189
|
+
raise "Job #{job} not found on the server" if http.code == 404
|
190
|
+
raise "Unpredictable response code #{http.code}" unless http.code == 200
|
191
|
+
if http.body == 'Running'
|
192
|
+
@log.debug("Job #{job} is still running, \
|
193
|
+
#{Zold::Age.new(start)} already...")
|
194
|
+
sleep 1
|
195
|
+
next
|
196
|
+
end
|
197
|
+
raise http.body unless http.body == 'OK'
|
198
|
+
@log.debug("Job #{job} completed, in #{Zold::Age.new(start)}")
|
199
|
+
return http.body
|
189
200
|
end
|
201
|
+
end
|
190
202
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
203
|
+
private
|
204
|
+
|
205
|
+
def headers
|
206
|
+
{
|
207
|
+
'X-Zold-WTS': @key,
|
208
|
+
'User-Agent': 'zold-ruby-sdk'
|
209
|
+
}
|
210
|
+
end
|
211
|
+
|
212
|
+
def job_of(http)
|
213
|
+
job = http.headers['X-Zold-Job']
|
214
|
+
raise 'Job ID is not returned, for some reason' if job.nil?
|
215
|
+
job
|
216
|
+
end
|
217
|
+
|
218
|
+
def clean(http)
|
219
|
+
error = http.headers['X-Zold-Error']
|
220
|
+
raise error unless error.nil?
|
221
|
+
unless http.code == 200 || http.code == 302
|
222
|
+
@log.debug(http.body)
|
223
|
+
raise "Unexpected response code #{http.code}"
|
197
224
|
end
|
225
|
+
http
|
198
226
|
end
|
199
227
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2018-2019 Yegor Bugayenko
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
STDOUT.sync = true
|
24
|
+
|
25
|
+
require 'simplecov'
|
26
|
+
SimpleCov.start
|
27
|
+
if ENV['CI'] == 'true'
|
28
|
+
require 'codecov'
|
29
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'minitest/autorun'
|
data/test/zold/test_wts.rb
CHANGED
@@ -20,6 +20,7 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
+
require 'loog'
|
23
24
|
require 'minitest/autorun'
|
24
25
|
require_relative '../../lib/zold/wts'
|
25
26
|
|
@@ -28,33 +29,42 @@ require_relative '../../lib/zold/wts'
|
|
28
29
|
# Copyright:: Copyright (c) 2018-2019 Yegor Bugayenko
|
29
30
|
# License:: MIT
|
30
31
|
class TestWTS < Minitest::Test
|
31
|
-
KEY = '
|
32
|
+
KEY = '0000000000000000-b416493aefae4ca487c4739050aaec15'
|
32
33
|
|
33
34
|
def test_pulls
|
34
|
-
|
35
|
-
wts = Zold::WTS.new(KEY)
|
35
|
+
wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
|
36
36
|
job = wts.pull
|
37
37
|
wts.wait(job)
|
38
38
|
assert(!job.nil?)
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_finds_transactions
|
42
|
-
|
43
|
-
wts = Zold::WTS.new(KEY)
|
42
|
+
wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
|
44
43
|
job = wts.pull
|
45
44
|
wts.wait(job)
|
46
|
-
assert_equal(
|
45
|
+
assert_equal(0, wts.find(details: /^for hosting$/).count)
|
47
46
|
end
|
48
47
|
|
49
48
|
def test_retrieves_wallet_id
|
50
|
-
|
51
|
-
wts = Zold::WTS.new(KEY)
|
49
|
+
wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
|
52
50
|
assert(!wts.id.nil?)
|
53
51
|
end
|
54
52
|
|
55
53
|
def test_retrieves_balance
|
56
|
-
|
57
|
-
|
54
|
+
wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
|
55
|
+
job = wts.pull
|
56
|
+
wts.wait(job)
|
57
|
+
assert(!wts.balance.nil?)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_retrieves_usd_rate
|
61
|
+
wts = Zold::WTS.new(KEY, log: Loog::VERBOSE)
|
62
|
+
rate = wts.usd_rate
|
63
|
+
assert(!rate.nil?)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_works_with_fake
|
67
|
+
wts = Zold::WTS::Fake.new
|
58
68
|
job = wts.pull
|
59
69
|
wts.wait(job)
|
60
70
|
assert(!wts.balance.zero?)
|
data/zold-ruby-sdk.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.rubygems_version = '2.2'
|
30
30
|
s.required_ruby_version = '>=2.5'
|
31
31
|
s.name = 'zold-ruby-sdk'
|
32
|
-
s.version = '0.
|
32
|
+
s.version = '0.2.0'
|
33
33
|
s.license = 'MIT'
|
34
34
|
s.summary = 'Zold score'
|
35
35
|
s.description = 'Ruby SDK for Zold online wallets management system (WTS)'
|
@@ -41,8 +41,9 @@ Gem::Specification.new do |s|
|
|
41
41
|
s.test_files = s.files.grep(%r{^(test|features)/})
|
42
42
|
s.rdoc_options = ['--charset=UTF-8']
|
43
43
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
44
|
+
s.add_runtime_dependency 'loog', '~>0.2'
|
44
45
|
s.add_runtime_dependency 'typhoeus', '1.3.1'
|
45
|
-
s.add_runtime_dependency 'zold', '0.21
|
46
|
+
s.add_runtime_dependency 'zold', '~>0.21'
|
46
47
|
s.add_development_dependency 'codecov', '0.1.14'
|
47
48
|
s.add_development_dependency 'minitest', '5.11.3'
|
48
49
|
s.add_development_dependency 'minitest-hooks', '1.5.0'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zold-ruby-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: loog
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: typhoeus
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -28,16 +42,16 @@ dependencies:
|
|
28
42
|
name: zold
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.21
|
47
|
+
version: '0.21'
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.21
|
54
|
+
version: '0.21'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: codecov
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,6 +185,7 @@ files:
|
|
171
185
|
- README.md
|
172
186
|
- Rakefile
|
173
187
|
- lib/zold/wts.rb
|
188
|
+
- test/test__helper.rb
|
174
189
|
- test/zold/test_wts.rb
|
175
190
|
- zold-ruby-sdk.gemspec
|
176
191
|
homepage: http://github.com/zold-io/zold-ruby-sdk
|
@@ -198,4 +213,5 @@ signing_key:
|
|
198
213
|
specification_version: 2
|
199
214
|
summary: Zold score
|
200
215
|
test_files:
|
216
|
+
- test/test__helper.rb
|
201
217
|
- test/zold/test_wts.rb
|