Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GET external_subscription by external_id #907

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/recurly/external_subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class ExternalSubscription < Resource
trial_ends_at
canceled_at
in_grace_period
imported
test
)

# We do not expose PUT or POST in the v2 API.
Expand All @@ -47,5 +49,9 @@ def get_external_payment_phase(external_payment_phase_uuid)
rescue Recurly::API::UnprocessableEntity => e
raise Invalid, e.message
end

def self.find_by_external_id(external_id)
self.find("external-id-#{external_id}")
end
end
end
2 changes: 2 additions & 0 deletions spec/fixtures/accounts/external_subscriptions/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Content-Type: application/xml; charset=utf-8
<trial_ends_at nil="nil"></trial_ends_at>
<canceled_at nil="nil"></canceled_at>
<in_grace_period>false</in_grace_period>
<imported>false</imported>
<test>false</test>
<created_at type="datetime">2022-11-04T20:33:29Z</created_at>
<updated_at type="datetime">2022-11-04T20:33:29Z</updated_at>
</external_subscription>
Expand Down
2 changes: 2 additions & 0 deletions spec/fixtures/external_subscriptions/show-200.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Content-Type: application/xml; charset=utf-8
<trial_ends_at nil="nil"></trial_ends_at>
<canceled_at nil="nil"></canceled_at>
<in_grace_period>false</in_grace_period>
<imported>false</imported>
<test>false</test>
<created_at type="datetime">2023-02-08T23:02:30Z</created_at>
<updated_at type="datetime">2023-02-08T23:02:30Z</updated_at>
</external_subscription>
6 changes: 5 additions & 1 deletion spec/recurly/external_subscription_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
trial_started_at: "2022-11-07 17:08:18",
trial_ends_at: "2022-11-14 17:08:18",
canceled_at: "2022-11-15 17:08:18",
in_grace_period: false
in_grace_period: false,
imported: false,
test: false
)
}

Expand Down Expand Up @@ -64,10 +66,12 @@
<reference_code>reference_code 1</reference_code>\
<updated_at>2019-08-24T14:15:22Z</updated_at>\
</external_product_reference>\
<imported>false</imported>\
<in_grace_period>false</in_grace_period>\
<last_purchased>2022-11-07 17:08:18</last_purchased>\
<quantity>1</quantity>\
<state>active</state>\
<test>false</test>\
<trial_ends_at>2022-11-14 17:08:18</trial_ends_at>\
<trial_started_at>2022-11-07 17:08:18</trial_started_at>\
<updated_at>2022-11-07 17:08:18</updated_at>\
Expand Down
Loading