chargebee 2.25.0 → 2.26.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/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +77 -0
- data/chargebee.gemspec +3 -2
- data/lib/chargebee/list_result.rb +6 -1
- data/lib/chargebee/request.rb +3 -3
- data/lib/chargebee/rest.rb +2 -1
- data/lib/chargebee/result.rb +18 -2
- data/lib/chargebee.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47e67b64038c0962879a8cdc8b5fcfdb9188f7a6
|
4
|
+
data.tar.gz: 21248229802c3b25e40c6a43a7ccc1a0d23b7fb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c5dc16a5704ca0b088200f37d95b03d36c5e94e4723f21f636037c883e2073e1ce7d2191a8d0633f9e5549aea03dfbcf3a285aefa799051ee03fea8d7c69e73
|
7
|
+
data.tar.gz: 8809d69227fe4269056c867f8f98965195f34ea454f2deb0c843eb268c99060ad0b0f5d2b6d4dcc8ece1b0b75d4d4f9226ce5b33104f5e1354a402c668069567
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
### v2.26.0 (2023-05-16)
|
2
|
+
* * *
|
3
|
+
|
4
|
+
#### New Feature:
|
5
|
+
* Added utility to pass **Idempotency key** along with request headers to allow a safe retry of POST requests.
|
6
|
+
* Added is_idempotency_replayed() utility to differentiate between original and replayed requests.
|
7
|
+
* Added get_response_headers() utility to fetch the response headers.
|
8
|
+
|
9
|
+
|
1
10
|
### v2.25.0 (2023-04-28)
|
2
11
|
* * *
|
3
12
|
|
data/Gemfile.lock
CHANGED
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Chargebee Ruby Client Library - API V2
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/chargebee)
|
4
|
+
[](https://rubygems.org/gems/chargebee)
|
5
|
+
|
6
|
+
This is the Ruby Library for integrating with Chargebee. Sign up for a Chargebee account {here}[https://www.chargebee.com].
|
7
|
+
|
8
|
+
Chargebee now supports two API versions - [V1](https://apidocs.chargebee.com/docs/api/v1) and [V2](https://apidocs.chargebee.com/docs/api), of which V2 is the latest release and all future developments will happen in V2. This library is for <b>API version V2</b>. If you’re looking for V1, head to [chargebee-v1 branch](https://github.com/chargebee/chargebee-ruby/tree/chargebee-v1).
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Install the latest version of the gem with the following command...
|
13
|
+
|
14
|
+
$ sudo gem install chargebee -v '~>2'
|
15
|
+
|
16
|
+
|
17
|
+
## Requirements
|
18
|
+
|
19
|
+
* Ruby 1.9.3 or above.
|
20
|
+
* rest-client
|
21
|
+
|
22
|
+
## Documentation
|
23
|
+
|
24
|
+
See our [Ruby API Reference](https://apidocs.chargebee.com/docs/api?lang=ruby "API Reference").
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
### To create a new subscription:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
|
32
|
+
result = ChargeBee::Subscription.create({
|
33
|
+
:id => "sub_KyVqDh__dev__NTn4VZZ1",
|
34
|
+
:plan_id => "basic",
|
35
|
+
})
|
36
|
+
subscription = result.subscription
|
37
|
+
puts "created subscription is #{subscription}"
|
38
|
+
```
|
39
|
+
|
40
|
+
### Create an Idempotent Request
|
41
|
+
|
42
|
+
[Idempotency keys](https://apidocs.chargebee.com/docs/api) are passed along with request headers to allow a safe retry of POST requests.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'chargebee'
|
46
|
+
ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
|
47
|
+
result = ChargeBee::Customer.create({
|
48
|
+
:first_name => "John",
|
49
|
+
:last_name => "Doe",
|
50
|
+
:email => "john@test.com",
|
51
|
+
:locale => "fr-CA",
|
52
|
+
:billing_address => {
|
53
|
+
:first_name => "John",
|
54
|
+
:last_name => "Doe",
|
55
|
+
:line1 => "PO Box 9999",
|
56
|
+
:city => "Walnut",
|
57
|
+
:state => "California",
|
58
|
+
:zip => "91789",
|
59
|
+
:country => "US"
|
60
|
+
}
|
61
|
+
},
|
62
|
+
nil,
|
63
|
+
{"chargebee-idempotency-key" => "<<UUID>>"} # Replace <<UUID>> with a unique string
|
64
|
+
)
|
65
|
+
customer = result.customer
|
66
|
+
card = result.card
|
67
|
+
responseHeader = result.get_response_headers # Retrieves response headers
|
68
|
+
puts(responseHeader)
|
69
|
+
idempotencyReplayedValue = result.is_idempotency_replayed # Retrieves Idempotency replayed header value
|
70
|
+
puts(idempotencyReplayedValue)
|
71
|
+
```
|
72
|
+
`is_idempotency_replayed` method can be accessed to differentiate between original and replayed requests.
|
73
|
+
|
74
|
+
## License
|
75
|
+
|
76
|
+
See the LICENSE file.
|
77
|
+
|
data/chargebee.gemspec
CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
s.required_ruby_version = '>= 1.9.3'
|
6
6
|
s.name = 'chargebee'
|
7
|
-
s.version = '2.
|
8
|
-
s.date = '2023-
|
7
|
+
s.version = '2.26.0'
|
8
|
+
s.date = '2023-05-16'
|
9
9
|
s.summary = "Ruby client for Chargebee API."
|
10
10
|
s.description = "Subscription Billing - Simple. Secure. Affordable. More details at www.chargebee.com."
|
11
11
|
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
Gemfile
|
32
32
|
Gemfile.lock
|
33
33
|
LICENSE
|
34
|
+
README.md
|
34
35
|
README.rdoc
|
35
36
|
Rakefile
|
36
37
|
chargebee.gemspec
|
@@ -10,12 +10,17 @@ module ChargeBee
|
|
10
10
|
|
11
11
|
attr_reader :next_offset
|
12
12
|
|
13
|
-
def initialize(response, next_offset=nil)
|
13
|
+
def initialize(response, next_offset=nil, rheaders = nil)
|
14
14
|
@response = response
|
15
|
+
@rheaders = rheaders
|
15
16
|
@list = Array.new
|
16
17
|
@next_offset = JSON.parse(next_offset).to_s if next_offset
|
17
18
|
initItems()
|
18
19
|
end
|
20
|
+
|
21
|
+
def get_response_headers()
|
22
|
+
@rheaders
|
23
|
+
end
|
19
24
|
|
20
25
|
private
|
21
26
|
def initItems()
|
data/lib/chargebee/request.rb
CHANGED
@@ -15,11 +15,11 @@ module ChargeBee
|
|
15
15
|
def self.send(method, url, params={}, env=nil, headers={})
|
16
16
|
env ||= ChargeBee.default_env
|
17
17
|
ser_params = Util.serialize(params)
|
18
|
-
resp = Rest.request(method, url, env, ser_params||={}, headers)
|
18
|
+
resp, rheaders = Rest.request(method, url, env, ser_params||={}, headers)
|
19
19
|
if resp.has_key?(:list)
|
20
|
-
ListResult.new(resp[:list], resp[:next_offset])
|
20
|
+
ListResult.new(resp[:list], resp[:next_offset], rheaders)
|
21
21
|
else
|
22
|
-
Result.new(resp)
|
22
|
+
Result.new(resp, rheaders)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/lib/chargebee/rest.rb
CHANGED
@@ -54,6 +54,7 @@ module ChargeBee
|
|
54
54
|
rescue Exception => e
|
55
55
|
raise IOError.new("IO Exception when trying to connect to chargebee with url #{opts[:url]} . Reason #{e}",e)
|
56
56
|
end
|
57
|
+
rheaders = response.headers
|
57
58
|
rbody = response.body
|
58
59
|
rcode = response.code
|
59
60
|
begin
|
@@ -68,7 +69,7 @@ module ChargeBee
|
|
68
69
|
end
|
69
70
|
end
|
70
71
|
resp = Util.symbolize_keys(resp)
|
71
|
-
resp
|
72
|
+
return resp, rheaders
|
72
73
|
end
|
73
74
|
|
74
75
|
def self.handle_for_error(e, rcode=nil, rbody=nil)
|
data/lib/chargebee/result.rb
CHANGED
@@ -1,10 +1,26 @@
|
|
1
1
|
module ChargeBee
|
2
2
|
class Result
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
IDEMPOTENCY_REPLAYED_HEADER = :chargebee_idempotency_replayed
|
5
|
+
|
6
|
+
def initialize(response, rheaders = nil)
|
7
|
+
@response = response
|
8
|
+
@rheaders = rheaders
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_response_headers()
|
12
|
+
@rheaders
|
6
13
|
end
|
7
14
|
|
15
|
+
def is_idempotency_replayed()
|
16
|
+
replayed_header = get_response_headers[IDEMPOTENCY_REPLAYED_HEADER]
|
17
|
+
if replayed_header != nil
|
18
|
+
return !!replayed_header
|
19
|
+
else
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
8
24
|
def subscription()
|
9
25
|
subscription = get(:subscription, Subscription,
|
10
26
|
{:subscription_items => Subscription::SubscriptionItem, :item_tiers => Subscription::ItemTier, :charged_items => Subscription::ChargedItem, :addons => Subscription::Addon, :event_based_addons => Subscription::EventBasedAddon, :charged_event_based_addons => Subscription::ChargedEventBasedAddon, :coupons => Subscription::Coupon, :shipping_address => Subscription::ShippingAddress, :referral_info => Subscription::ReferralInfo, :contract_term => Subscription::ContractTerm, :discounts => Subscription::Discount});
|
data/lib/chargebee.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chargebee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajaraman S
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- Gemfile
|
108
108
|
- Gemfile.lock
|
109
109
|
- LICENSE
|
110
|
+
- README.md
|
110
111
|
- README.rdoc
|
111
112
|
- Rakefile
|
112
113
|
- chargebee.gemspec
|