baza.rb 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c49b2f9e56518856e9b940ced30762aef5b5fbe261664e7a706da01cd0f6863d
4
- data.tar.gz: 05b2facb756676b39d9260ba98f9b40a8ed8298fee49fab796134f23b9533343
3
+ metadata.gz: c5ee76f53a0b65c13bb293ebcb18de358f7f7f0d0262b06e1b23c56b337ceefc
4
+ data.tar.gz: 064dbdd35e38b6fae3a53c8e2f17abe06927043d0234d182c2b161e1ffed97ba
5
5
  SHA512:
6
- metadata.gz: 321b9183088c669b9a81c9526f8315a33c744897ee28bc5e82bc2e0e6145d3159e55e3777dc742c571aedef03e6101894d9089c0da5593a2e4554ab6b882646b
7
- data.tar.gz: eb58d54e0ce574a1583fe4a4d2048ea7a78c806311076a7e86f4cf0012d7ea32e67f269ae7b72d42c70da9f7840de990e6e6027c031b6684e54a9172e67435e5
6
+ metadata.gz: e76efbc00aa6c55fba368681dda4ec7560fb7f655f5824bd510bd2fc9da0c23405495f3e7a759655cedcc4dba9a650fc1cdbb9dc8aa0489d873b8f8a7718f0b6
7
+ data.tar.gz: 2b908d30e84c97e384e48f99f38dee3fc3f05889cc443711b57ef7dfaf749589a390da4fbb5027fc299d8c460861798e038b876a31a94f7bbdb0fef3a24e9756
data/Gemfile.lock CHANGED
@@ -107,7 +107,7 @@ GEM
107
107
  regexp_parser (2.10.0)
108
108
  retries (0.0.5)
109
109
  rexml (3.4.1)
110
- rubocop (1.75.1)
110
+ rubocop (1.75.2)
111
111
  json (~> 2.3)
112
112
  language_server-protocol (~> 3.17.0.2)
113
113
  lint_roller (~> 1.1.0)
@@ -115,10 +115,10 @@ GEM
115
115
  parser (>= 3.3.0.2)
116
116
  rainbow (>= 2.2.2, < 4.0)
117
117
  regexp_parser (>= 2.9.3, < 3.0)
118
- rubocop-ast (>= 1.43.0, < 2.0)
118
+ rubocop-ast (>= 1.44.0, < 2.0)
119
119
  ruby-progressbar (~> 1.7)
120
120
  unicode-display_width (>= 2.4.0, < 4.0)
121
- rubocop-ast (1.43.0)
121
+ rubocop-ast (1.44.0)
122
122
  parser (>= 3.3.7.2)
123
123
  prism (~> 1.4)
124
124
  rubocop-minitest (0.38.0)
data/lib/baza-rb/fake.rb CHANGED
@@ -160,11 +160,15 @@ class BazaRb::Fake
160
160
  # @param [String] recipient GitHub name (e.g. "yegor256") of the recipient
161
161
  # @param [Float] amount The amount in Z/USDT (not zents!)
162
162
  # @param [String] summary The description of the payment
163
- def transfer(recipient, amount, summary, *)
163
+ # @param [Integer] job The ID of the job or NIL
164
+ # @param [Integer] job The amount of points just rewarded
165
+ # @return [Integer] Receipt ID
166
+ def transfer(recipient, amount, summary, job: nil, points: nil)
164
167
  raise "The receipient #{recipient.inspect} is not valid" unless recipient.match?(/^[a-zA-Z0-9-]+$/)
165
168
  raise "The amount #{amount} must be a Float" unless amount.is_a?(Float)
166
169
  raise "The amount #{amount} must be positive" unless amount.positive?
167
170
  raise "The summary #{summary.inspect} is empty" if summary.empty?
171
+ raise 'The job must go together with points' if !job.nil? && points.nil?
168
172
  42
169
173
  end
170
174
 
@@ -13,5 +13,5 @@
13
13
  # Copyright:: Copyright (c) 2024 Yegor Bugayenko
14
14
  # License:: MIT
15
15
  class BazaRb
16
- VERSION = '0.1.0'
16
+ VERSION = '0.2.0'
17
17
  end
data/lib/baza-rb.rb CHANGED
@@ -467,8 +467,9 @@ class BazaRb
467
467
  # @param [Float] amount The amount in Z/USDT (not zents!)
468
468
  # @param [String] summary The description of the payment
469
469
  # @param [Integer] job The ID of the job or NIL
470
+ # @param [Integer] job The amount of points just rewarded
470
471
  # @return [Integer] Receipt ID
471
- def transfer(recipient, amount, summary, job: nil)
472
+ def transfer(recipient, amount, summary, job: nil, points: nil)
472
473
  raise 'The "recipient" is nil' if recipient.nil?
473
474
  raise 'The "amount" is nil' if amount.nil?
474
475
  raise 'The "amount" must be Float' unless amount.is_a?(Float)
@@ -480,7 +481,11 @@ class BazaRb
480
481
  'amount' => amount.to_s,
481
482
  'summary' => summary
482
483
  }
483
- body['job'] = job unless job.nil?
484
+ unless job.nil?
485
+ body['job'] = job
486
+ raise 'The "points" must be Integer' unless points.is_a?(Integer)
487
+ body['points'] = points.to_s
488
+ end
484
489
  elapsed(@loog) do
485
490
  ret =
486
491
  with_retries(max_tries: @retries, rescue: TimedOut) do
data/test/test_baza-rb.rb CHANGED
@@ -110,7 +110,7 @@ class TestBazaRb < Minitest::Test
110
110
  stub_request(:post, 'https://example.org/account/transfer').to_return(
111
111
  status: 302, headers: { 'X-Zerocracy-ReceiptId' => '42' }
112
112
  )
113
- id = BazaRb.new('example.org', 443, '000').transfer('jeff', 42.50, 'for fun', job: 555)
113
+ id = BazaRb.new('example.org', 443, '000').transfer('jeff', 42.50, 'for fun', job: 555, points: 88)
114
114
  assert_equal(42, id)
115
115
  end
116
116
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baza.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-02 00:00:00.000000000 Z
10
+ date: 2025-04-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: backtrace