Skip to content

Commit

Permalink
GET external_subscription by external_id
Browse files Browse the repository at this point in the history
Added new method to get external_subscription by external_id.
  • Loading branch information
paulorbpinho-fullstacklabs committed Jun 21, 2024
1 parent f92bbec commit fb7dd20
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
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

0 comments on commit fb7dd20

Please sign in to comment.