Skip to content

Commit

Permalink
Add support for subscription sets [ch16168] (#64)
Browse files Browse the repository at this point in the history
* Add support for subscription sets

* Update changelog.md

Co-Authored-By: Petr Kopac <pkopac@users.noreply.github.com>
  • Loading branch information
Thomas Carney and pkopac committed Sep 20, 2019
1 parent 800e953 commit f6ab7a9
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# chartmogul-ruby Change Log

## Version 1.4.0 - 20 September 2019
- Add support for subscription sets

## Version 1.3.1 - 6 May 2019
- Add #last method to Entries

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/chartmogul/line_items/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Subscription < ChartMogul::Object
writeable_attr :tax_amount_in_cents
writeable_attr :transaction_fees_in_cents
writeable_attr :external_id
writeable_attr :subscription_set_external_id

readonly_attr :subscription_uuid
writeable_attr :invoice_uuid
Expand Down
1 change: 1 addition & 0 deletions lib/chartmogul/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Subscription < APIResource

readonly_attr :uuid
writeable_attr :external_id
writeable_attr :subscription_set_external_id
readonly_attr :cancellation_dates, default: []

readonly_attr :plan_uuid
Expand Down
2 changes: 1 addition & 1 deletion lib/chartmogul/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ChartMogul
VERSION = '1.3.3'.freeze
VERSION = '1.4.0'.freeze
end
3 changes: 3 additions & 0 deletions spec/chartmogul/invoice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{
type: 'subscription',
subscription_external_id: 'sub_ext_id',
subscription_set_external_id: 'set_ext_id',
plan_uuid: 'pl_1234-5678-9012-34567',
service_period_start: '2016-01-01 12:00:00',
service_period_end: '2016-02-01 12:00:00',
Expand Down Expand Up @@ -64,6 +65,7 @@
line_items: [
ChartMogul::LineItems::Subscription.new(
subscription_external_id: 'sub_ext_id',
subscription_set_external_id: 'set_ext_id',
plan_uuid: 'pl_1234-5678-9012-34567',
service_period_start: '2016-01-01 12:00:00',
service_period_end: '2016-02-01 12:00:00',
Expand Down Expand Up @@ -183,6 +185,7 @@
{
type: 'subscription',
subscription_external_id: 'sub_ext_id',
subscription_set_external_id: 'set_ext_id',
plan_uuid: 'pl_1234-5678-9012-34567',
service_period_start: '2016-01-01 12:00:00',
service_period_end: '2016-02-01 12:00:00',
Expand Down
9 changes: 9 additions & 0 deletions spec/chartmogul/line_items/subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
type: 'subscription',
subscription_external_id: 'sub_ext_id',
subscription_set_external_id: 'set_ext_id',
plan_uuid: 'pl_1234-5678-9012-34567',
service_period_start: '2016-01-01 12:00:00',
service_period_end: '2016-02-01 12:00:00',
Expand Down Expand Up @@ -40,6 +41,10 @@
expect(subject.subscription_external_id).to eq('sub_ext_id')
end

it 'sets the subscription_set_external_id attribute' do
expect(subject.subscription_set_external_id).to eq('set_ext_id')
end

it 'sets the plan_uuid attribute' do
expect(subject.plan_uuid).to eq('pl_1234-5678-9012-34567')
end
Expand Down Expand Up @@ -104,6 +109,10 @@
expect(subject.subscription_external_id).to eq('sub_ext_id')
end

it 'sets the subscription_set_external_id attribute' do
expect(subject.subscription_set_external_id).to eq('set_ext_id')
end

it 'sets the plan_uuid attribute' do
expect(subject.plan_uuid).to eq('pl_1234-5678-9012-34567')
end
Expand Down
2 changes: 2 additions & 0 deletions spec/chartmogul/subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

line_item = ChartMogul::LineItems::Subscription.new(
subscription_external_id: 'test_cus_sub_ext_id',
subscription_set_external_id: 'test_cus_set_ext_id',
plan_uuid: plan.uuid,
service_period_start: Time.utc(2016, 1, 1, 12),
service_period_end: Time.utc(2016, 2, 1, 12),
Expand All @@ -44,6 +45,7 @@
expect(customer.subscriptions.first.uuid).to eq('sub_9b3ccf25-4613-4af6-84b3-12026cfa4b7c')
expect(customer.subscriptions.first.data_source_uuid).to eq('ds_55ab11fb-53e6-4468-aa95-bd582f14cac6')
expect(customer.subscriptions.first.external_id).to eq('test_cus_sub_ext_id')
expect(customer.subscriptions.first.subscription_set_external_id).to eq('test_cus_set_ext_id')

customer.subscriptions.first.cancel(Time.utc(2016, 1, 15, 12))

Expand Down

0 comments on commit f6ab7a9

Please sign in to comment.