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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2879a58b22740c55d8f4f433ad17d903c1d60fb4ffb7474f3e38eafd4de34c70
4
- data.tar.gz: 2a37091f3541e6d44bf132532a0f77b3d813dbfad4e3a2b2d602419d5e48be43
3
+ metadata.gz: 102f1f667778ab016dbcb328c251859992b339619e0355bbc7b292a1ddf3edc6
4
+ data.tar.gz: 4dbe3a09900095fb952b587c7700ad802a83fe609da9fa450996369143abb413
5
5
  SHA512:
6
- metadata.gz: d10abffe172d128c5cf4b0e15db6e24236378d4a13e8ce0ce4d303807c949196ac00b90daae47993250fc6f4c4ae4c58472160fdd51ff0665975a850bff18117
7
- data.tar.gz: 634cf07d3c82b9685f46ced49044cf68c1f19c4a3e58a7e131a50e8f3d146cb33cc2011f641500b4c6ea2c930f0f896b624e347381845719b326390e33f238c8
6
+ metadata.gz: f9495291187768a2b0e5410ee1e2c84a880824b4bad8f8000a44c954c50317bac3a6351b6ebeead60d70d9ded1721aa09eb04b5b26155143f51b71c5469cb1bb
7
+ data.tar.gz: 3d015f15421fec85ec4b4308e328d735e936bd5d27241c43e89650feeeca7619e032347df02dd569b7786266432464a33517cc5c3d4f343920befc38e0948d4d
data/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/zerocracy/baza.rb/master/frames)
10
10
  [![Hits-of-Code](https://hitsofcode.com/github/zerocracy/baza.rb)](https://hitsofcode.com/view/github/zerocracy/baza.rb)
11
11
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/zerocracy/baza.rb/blob/master/LICENSE.txt)
12
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fzerocracy%2Fbaza.rb.svg?type=shield&issueType=license)](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
 
@@ -13,5 +13,5 @@
13
13
  # Copyright:: Copyright (c) 2024 Yegor Bugayenko
14
14
  # License:: MIT
15
15
  class BazaRb
16
- VERSION = '0.0.12'
16
+ VERSION = '0.0.13'
17
17
  end
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')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baza.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko