baza.rb 0.0.12 → 0.0.13
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/README.md +1 -0
- data/lib/baza-rb/fake.rb +1 -1
- data/lib/baza-rb/version.rb +1 -1
- data/lib/baza-rb.rb +10 -7
- data/test/test_baza-rb.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 102f1f667778ab016dbcb328c251859992b339619e0355bbc7b292a1ddf3edc6
|
4
|
+
data.tar.gz: 4dbe3a09900095fb952b587c7700ad802a83fe609da9fa450996369143abb413
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9495291187768a2b0e5410ee1e2c84a880824b4bad8f8000a44c954c50317bac3a6351b6ebeead60d70d9ded1721aa09eb04b5b26155143f51b71c5469cb1bb
|
7
|
+
data.tar.gz: 3d015f15421fec85ec4b4308e328d735e936bd5d27241c43e89650feeeca7619e032347df02dd569b7786266432464a33517cc5c3d4f343920befc38e0948d4d
|
data/README.md
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
[](http://rubydoc.info/github/zerocracy/baza.rb/master/frames)
|
10
10
|
[](https://hitsofcode.com/view/github/zerocracy/baza.rb)
|
11
11
|
[](https://github.com/zerocracy/baza.rb/blob/master/LICENSE.txt)
|
12
|
+
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fzerocracy%2Fbaza.rb?ref=badge_shield&issueType=license)
|
12
13
|
|
13
14
|
It's an client for [Zerocracy API](https://www.zerocracy.com), in Ruby.
|
14
15
|
|
data/lib/baza-rb/fake.rb
CHANGED
@@ -143,7 +143,7 @@ class BazaRb::Fake
|
|
143
143
|
# @param [String] recipient GitHub name (e.g. "yegor256") of the recipient
|
144
144
|
# @param [Float] amount The amount in Z/USDT (not zents!)
|
145
145
|
# @param [String] summary The description of the payment
|
146
|
-
def transfer(_recipient, _amount, _summary)
|
146
|
+
def transfer(_recipient, _amount, _summary, *)
|
147
147
|
42
|
148
148
|
end
|
149
149
|
|
data/lib/baza-rb/version.rb
CHANGED
data/lib/baza-rb.rb
CHANGED
@@ -466,25 +466,28 @@ class BazaRb
|
|
466
466
|
# @param [String] recipient GitHub name (e.g. "yegor256") of the recipient
|
467
467
|
# @param [Float] amount The amount in Z/USDT (not zents!)
|
468
468
|
# @param [String] summary The description of the payment
|
469
|
+
# @param [Integer] job The ID of the job or NIL
|
469
470
|
# @return [Integer] Receipt ID
|
470
|
-
def transfer(recipient, amount, summary)
|
471
|
+
def transfer(recipient, amount, summary, job: nil)
|
471
472
|
raise 'The "recipient" is nil' if recipient.nil?
|
472
473
|
raise 'The "amount" is nil' if amount.nil?
|
473
474
|
raise 'The "amount" must be Float' unless amount.is_a?(Float)
|
474
475
|
raise 'The "summary" is nil' if summary.nil?
|
475
476
|
id = nil
|
477
|
+
body = {
|
478
|
+
'_csrf' => csrf,
|
479
|
+
'human' => recipient,
|
480
|
+
'amount' => amount.to_s,
|
481
|
+
'summary' => summary
|
482
|
+
}
|
483
|
+
body['job'] = job unless job.nil?
|
476
484
|
elapsed(@loog) do
|
477
485
|
ret =
|
478
486
|
with_retries(max_tries: @retries, rescue: TimedOut) do
|
479
487
|
checked(
|
480
488
|
Typhoeus::Request.post(
|
481
489
|
home.append('account').append('transfer').to_s,
|
482
|
-
body
|
483
|
-
'_csrf' => csrf,
|
484
|
-
'human' => recipient,
|
485
|
-
'amount' => amount.to_s,
|
486
|
-
'summary' => summary
|
487
|
-
},
|
490
|
+
body:,
|
488
491
|
headers:,
|
489
492
|
connecttimeout: @timeout,
|
490
493
|
timeout: @timeout
|
data/test/test_baza-rb.rb
CHANGED
@@ -105,6 +105,16 @@ class TestBazaRb < Minitest::Test
|
|
105
105
|
assert_equal(42, id)
|
106
106
|
end
|
107
107
|
|
108
|
+
def test_transfer_payment_with_job
|
109
|
+
WebMock.disable_net_connect!
|
110
|
+
stub_request(:get, 'https://example.org/csrf').to_return(body: 'token')
|
111
|
+
stub_request(:post, 'https://example.org/account/transfer').to_return(
|
112
|
+
status: 302, headers: { 'X-Zerocracy-ReceiptId' => '42' }
|
113
|
+
)
|
114
|
+
id = BazaRb.new('example.org', 443, '000').transfer('jeff', 42.50, 'for fun', job: 555)
|
115
|
+
assert_equal(42, id)
|
116
|
+
end
|
117
|
+
|
108
118
|
def test_durable_place
|
109
119
|
WebMock.disable_net_connect!
|
110
120
|
stub_request(:get, 'https://example.org/csrf').to_return(body: 'token')
|