killbill-client 4.0.7 → 4.0.9

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
- SHA1:
3
- metadata.gz: 8e86e4cbc6c49a01a442aeb497caacd4a7893948
4
- data.tar.gz: f02a33231d29d69f6be5b5f8987b87cc7f62514f
2
+ SHA256:
3
+ metadata.gz: 11a2f2d816b6760f83780c36e6a29593b4cdccb6a79ad460fb1979906219ade1
4
+ data.tar.gz: 8a185dc1da51094b9d0243a4a29250938731218a8dd01d53a7db6d0628ab7357
5
5
  SHA512:
6
- metadata.gz: a5d298382c7555f66ce46ceae00be264f335a419682671ec1233c9c3c22aa706f318563a287b270c638e815c8d09f8e152f9c6226ce6b349623762706d673ec4
7
- data.tar.gz: 8de6e6aea0a680b4301c1d8cb688a89b939ce68ee7b40b12f1acf34986b5e2d74dc79c5679046339c10a4d039bc7ed47eb027587070870658bfeec3c318cf178
6
+ metadata.gz: cc032642da6ee043bfbc755f4c79a4600ecd9d5531f52de4cd12650beb13efda7deb3a558096840952b86a26c4a8d84798d99e81a625f11015258be2705b1bd5
7
+ data.tar.gz: 462ecd2739ec571c2d72f0a7265f037609c8021c5d416b9df2618fa1689fa6beaa93158d2a6ec89525f62a6d7303099119d86943cc5e7bcdb5babef554e490b5
@@ -24,7 +24,7 @@ jobs:
24
24
  git config --global url."https://${BUILD_USER}:${BUILD_TOKEN}@github.com/".insteadOf "git@github.com:"
25
25
  - uses: ruby/setup-ruby@v1
26
26
  with:
27
- ruby-version: '2.4.2'
27
+ ruby-version: '3.2.2'
28
28
  - name: Download Ruby dependencies
29
29
  run: |
30
30
  bundle install
@@ -44,6 +44,13 @@ module KillBillClient
44
44
  from_response clazz, response
45
45
  end
46
46
 
47
+ # Performs a GET request and returns the raw response body as received
48
+ # from Kill Bill, without any model parsing or re-serialization.
49
+ def raw_get(uri, params = {}, options = {})
50
+ response = KillBillClient::API.get uri, params, options
51
+ response.body
52
+ end
53
+
47
54
  def post(uri, body = nil, params = {}, options = {}, clazz = self)
48
55
  response = KillBillClient::API.post uri, body, params, options
49
56
  from_response clazz, response
@@ -26,6 +26,16 @@ module KillBillClient
26
26
  options
27
27
  end
28
28
 
29
+ # Returns the raw JSON response body from Kill Bill for the given
30
+ # subscription, without any model parsing or re-serialization.
31
+ def find_raw_by_id(subscription_id, audit = "NONE", options = {})
32
+ raw_get "#{KILLBILL_API_ENTITLEMENT_PREFIX}/#{subscription_id}",
33
+ {
34
+ :audit => audit
35
+ },
36
+ options
37
+ end
38
+
29
39
  def find_by_external_key(external_key, audit = "NONE", options = {})
30
40
  get "#{KILLBILL_API_ENTITLEMENT_PREFIX}",
31
41
  {
@@ -1,3 +1,3 @@
1
1
  module KillBillClient
2
- VERSION = '4.0.7'
2
+ VERSION = '4.0.9'
3
3
  end
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Raw JSON responses' do
4
+ let(:raw_body) do
5
+ '{"subscriptionId":"abc-123","externalKey":"key-1","accountId":"acct-1","state":"ACTIVE"}'
6
+ end
7
+
8
+ let(:fake_response) do
9
+ response = double('Net::HTTPResponse')
10
+ allow(response).to receive(:body).and_return(raw_body)
11
+ response
12
+ end
13
+
14
+ describe KillBillClient::Model::Resource, '.raw_get' do
15
+ it 'returns the raw response body without parsing it into a model' do
16
+ uri = '/1.0/kb/some/endpoint'
17
+ params = { :foo => 'bar' }
18
+ options = { :api_key => 'k', :api_secret => 's' }
19
+
20
+ expect(KillBillClient::API).to receive(:get).with(uri, params, options).and_return(fake_response)
21
+ expect(KillBillClient::Model::Resource).not_to receive(:from_response)
22
+
23
+ result = KillBillClient::Model::Resource.raw_get(uri, params, options)
24
+
25
+ expect(result).to be_a(String)
26
+ expect(result).to eq(raw_body)
27
+ end
28
+
29
+ it 'defaults params and options to empty hashes' do
30
+ uri = '/1.0/kb/some/endpoint'
31
+
32
+ expect(KillBillClient::API).to receive(:get).with(uri, {}, {}).and_return(fake_response)
33
+
34
+ result = KillBillClient::Model::Resource.raw_get(uri)
35
+ expect(result).to eq(raw_body)
36
+ end
37
+
38
+ it 'propagates KillBillClient::API errors instead of swallowing them' do
39
+ uri = '/1.0/kb/missing'
40
+ api_request = double('Net::HTTPRequest')
41
+ api_response = double('Net::HTTPResponse',
42
+ :code => '404',
43
+ :body => '{"className":"NoSuchElementException"}')
44
+ response_error = KillBillClient::API::ResponseError.new(api_request, api_response)
45
+
46
+ expect(KillBillClient::API).to receive(:get).and_raise(response_error)
47
+
48
+ expect { KillBillClient::Model::Resource.raw_get(uri) }
49
+ .to raise_error(KillBillClient::API::ResponseError)
50
+ end
51
+ end
52
+
53
+ describe KillBillClient::Model::Subscription, '.find_raw_by_id' do
54
+ let(:subscription_id) { 'sub-1234' }
55
+ let(:expected_uri) { "/1.0/kb/subscriptions/#{subscription_id}" }
56
+
57
+ it 'GETs the subscription endpoint and returns the raw body' do
58
+ options = { :api_key => 'k', :api_secret => 's' }
59
+
60
+ expect(KillBillClient::API).to receive(:get)
61
+ .with(expected_uri, { :audit => 'NONE' }, options)
62
+ .and_return(fake_response)
63
+
64
+ result = KillBillClient::Model::Subscription.find_raw_by_id(subscription_id, 'NONE', options)
65
+
66
+ expect(result).to eq(raw_body)
67
+ end
68
+
69
+ it 'forwards the audit option to the API call' do
70
+ expect(KillBillClient::API).to receive(:get)
71
+ .with(expected_uri, { :audit => 'FULL' }, {})
72
+ .and_return(fake_response)
73
+
74
+ KillBillClient::Model::Subscription.find_raw_by_id(subscription_id, 'FULL')
75
+ end
76
+
77
+ it 'defaults the audit option to NONE' do
78
+ expect(KillBillClient::API).to receive(:get)
79
+ .with(expected_uri, { :audit => 'NONE' }, {})
80
+ .and_return(fake_response)
81
+
82
+ KillBillClient::Model::Subscription.find_raw_by_id(subscription_id)
83
+ end
84
+
85
+ it 'does not instantiate a Subscription model' do
86
+ expect(KillBillClient::API).to receive(:get).and_return(fake_response)
87
+ expect(KillBillClient::Model::Subscription).not_to receive(:from_response)
88
+ expect(KillBillClient::Model::Subscription).not_to receive(:from_json)
89
+
90
+ KillBillClient::Model::Subscription.find_raw_by_id(subscription_id)
91
+ end
92
+ end
93
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: killbill-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.7
4
+ version: 4.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Killbill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-07 00:00:00.000000000 Z
11
+ date: 2026-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem-release
@@ -205,6 +205,7 @@ files:
205
205
  - spec/killbill_client/errors_spec.rb
206
206
  - spec/killbill_client/http_adapter_spec.rb
207
207
  - spec/killbill_client/model_relation_spec.rb
208
+ - spec/killbill_client/raw_response_spec.rb
208
209
  - spec/killbill_client/remote/api_spec.rb
209
210
  - spec/killbill_client/remote/model_spec.rb
210
211
  - spec/killbill_client/resource_spec.rb
@@ -231,8 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
232
  - !ruby/object:Gem::Version
232
233
  version: '0'
233
234
  requirements: []
234
- rubyforge_project:
235
- rubygems_version: 2.6.13
235
+ rubygems_version: 3.4.10
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Kill Bill client library.