-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
355552e
commit e731340
Showing
13 changed files
with
186 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Recurly | ||
class ExternalPaymentPhase < Resource | ||
|
||
# @return [ExternalSubscription] | ||
belongs_to :external_subscription | ||
|
||
define_attribute_methods %w( | ||
id | ||
started_at | ||
ends_at | ||
starting_billing_period_index | ||
ending_billing_period_index | ||
offer_type | ||
offer_name | ||
period_count | ||
period_length | ||
amount | ||
currency | ||
created_at | ||
updated_at | ||
) | ||
|
||
# We do not expose POST or PUT via the v2 API | ||
protected(*%w(save save!)) | ||
private_class_method(*%w(create! create)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/xml; charset=utf-8 | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<external_payment_phases type="array"> | ||
<external_payment_phase href="https://pcc.recurly.dev:3000/v2/external_payment_phases/sk0bmpw0wbby"> | ||
<id>sk0bmpw0wbby</id> | ||
<started_at type="datetime">2023-03-14T19:55:07Z</started_at> | ||
<ends_at type="datetime">2023-04-14T19:55:07Z</ends_at> | ||
<starting_billing_period_index></starting_billing_period_index> | ||
<ending_billing_period_index>4</ending_billing_period_index> | ||
<offer_type></offer_type> | ||
<offer_name></offer_name> | ||
<period_count>1</period_count> | ||
<period_length>2 MONTHS</period_length> | ||
<amount>0.00</amount> | ||
<currency>USD</currency> | ||
<created_at type="datetime">2023-03-14T19:55:07Z</created_at> | ||
<updated_at type="datetime">2023-03-14T19:55:07Z</updated_at> | ||
</external_payment_phase> | ||
</external_payment_phases> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
spec/fixtures/external_subscriptions/external_payment_phases/index-200.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/xml; charset=utf-8 | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<external_payment_phases type="array"> | ||
<external_payment_phase href="https://pcc.recurly.dev:3000/v2/external_payment_phases/sk0bmpw0wbby"> | ||
<id>sk0bmpw0wbby</id> | ||
<started_at type="datetime">2023-03-14T19:55:07Z</started_at> | ||
<ends_at type="datetime">2023-04-14T19:55:07Z</ends_at> | ||
<starting_billing_period_index></starting_billing_period_index> | ||
<ending_billing_period_index>4</ending_billing_period_index> | ||
<offer_type></offer_type> | ||
<offer_name></offer_name> | ||
<period_count>1</period_count> | ||
<period_length>2 MONTHS</period_length> | ||
<amount>0.00</amount> | ||
<currency>USD</currency> | ||
<created_at type="datetime">2023-03-14T19:55:07Z</created_at> | ||
<updated_at type="datetime">2023-04-14T19:55:07Z</updated_at> | ||
</external_payment_phase> | ||
</external_payment_phases> |
19 changes: 19 additions & 0 deletions
19
spec/fixtures/external_subscriptions/external_payment_phases/show-200.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/xml; charset=utf-8 | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<external_payment_phase href="https://pcc.recurly.dev:3000/v2/external_payment_phases/sk0bmpw0wbby"> | ||
<id>sk0bmpw0wbby</id> | ||
<started_at type="datetime">2023-03-14T19:55:07Z</started_at> | ||
<ends_at type="datetime">2023-04-14T19:55:07Z</ends_at> | ||
<starting_billing_period_index></starting_billing_period_index> | ||
<ending_billing_period_index>4</ending_billing_period_index> | ||
<offer_type></offer_type> | ||
<offer_name></offer_name> | ||
<period_count>1</period_count> | ||
<period_length>2 MONTHS</period_length> | ||
<amount>0.00</amount> | ||
<currency>USD</currency> | ||
<created_at type="datetime">2023-03-14T19:55:07Z</created_at> | ||
<updated_at type="datetime">2023-04-14T19:55:07Z</updated_at> | ||
</external_payment_phase> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
require 'spec_helper' | ||
|
||
describe ExternalPaymentPhase do | ||
let(:external_payment_phase) { | ||
ExternalPaymentPhase.new( | ||
id: 'sd28t3zdm59p', | ||
external_subscription: ExternalSubscription.new(id: '123abc'), | ||
started_at: '2023-01-23T19:02:40Z', | ||
ends_at: '2023-02-23T19:02:40Z', | ||
starting_billing_period_index: 1, | ||
ending_billing_period_index: 4, | ||
period_count: 1, | ||
period_length: '2 MONTHS', | ||
amount: 0.00, | ||
currency: 'USD', | ||
created_at: '2023-01-23T19:02:40Z', | ||
updated_at: '2023-02-23T19:02:40Z' | ||
) | ||
} | ||
let(:external_subscription) { | ||
stub_api_request :get, 'external_subscriptions/sdam2lfeop3e', 'external_subscriptions/show-200' | ||
ExternalSubscription.find('sdam2lfeop3e') | ||
} | ||
|
||
describe "#associations" do | ||
it "has correct associations" do | ||
expect(external_payment_phase.external_subscription).must_be_instance_of ExternalSubscription | ||
end | ||
end | ||
|
||
describe "#methods" do | ||
it "has correct attributes" do | ||
expect(external_payment_phase.id).must_equal('sd28t3zdm59p') | ||
expect(external_payment_phase.starting_billing_period_index).must_equal(1) | ||
expect(external_payment_phase.created_at).must_equal('2023-01-23T19:02:40Z') | ||
expect(external_payment_phase.updated_at).must_equal('2023-02-23T19:02:40Z') | ||
end | ||
end | ||
|
||
describe ".get_external_payment_phases" do | ||
before do | ||
stub_api_request( | ||
:get, "https://api.recurly.com/v2/external_subscriptions/sdam2lfeop3e/external_payment_phases", | ||
"external_subscriptions/external_payment_phases/index-200" | ||
) | ||
end | ||
|
||
it "returns external_payment_phases" do | ||
external_payment_phase = external_subscription.get_external_payment_phases[0] | ||
|
||
external_payment_phase.must_be_instance_of(ExternalPaymentPhase) | ||
external_payment_phase.id.must_equal('sk0bmpw0wbby') | ||
external_payment_phase.created_at.must_equal(DateTime.new(2023, 3, 14, 19, 55, 7)) | ||
external_payment_phase.updated_at.must_equal(DateTime.new(2023, 4, 14, 19, 55, 7)) | ||
end | ||
end | ||
|
||
describe ".get_external_payment_phase" do | ||
before do | ||
stub_api_request( | ||
:get, "https://api.recurly.com/v2/external_subscriptions/sdam2lfeop3e/external_payment_phases/sk0bmpw0wbby", | ||
"external_subscriptions/external_payment_phases/show-200" | ||
) | ||
end | ||
|
||
it "returns an external payment phase" do | ||
external_payment_phase = external_subscription.get_external_payment_phase('sk0bmpw0wbby') | ||
|
||
external_payment_phase.must_be_instance_of(ExternalPaymentPhase) | ||
external_payment_phase.id.must_equal('sk0bmpw0wbby') | ||
external_payment_phase.created_at.must_equal(DateTime.new(2023, 3, 14, 19, 55, 7)) | ||
external_payment_phase.updated_at.must_equal(DateTime.new(2023, 4, 14, 19, 55, 7)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters