recurly 2.17.0 → 3.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bumpversion.cfg +15 -0
- data/.changelog_config.yaml +11 -0
- data/.github/ISSUE_TEMPLATE/bug-report.md +30 -0
- data/.github/ISSUE_TEMPLATE/question-or-other.md +10 -0
- data/.github/workflows/ci.yml +29 -0
- data/.github/workflows/docs.yml +28 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.yardopts +2 -0
- data/CHANGELOG.md +496 -0
- data/CODE_OF_CONDUCT.md +130 -0
- data/CONTRIBUTING.md +106 -0
- data/GETTING_STARTED.md +319 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +9 -153
- data/Rakefile +6 -0
- data/benchmark.rb +16 -0
- data/lib/data/ca-certificates.crt +3466 -0
- data/lib/recurly/client/operations.rb +3868 -0
- data/lib/recurly/client.rb +355 -0
- data/lib/recurly/connection_pool.rb +40 -0
- data/lib/recurly/errors/api_errors.rb +87 -0
- data/lib/recurly/errors/network_errors.rb +10 -0
- data/lib/recurly/errors.rb +68 -0
- data/lib/recurly/http.rb +50 -0
- data/lib/recurly/pager.rb +146 -0
- data/lib/recurly/request.rb +31 -0
- data/lib/recurly/requests/account_acquisition_cost.rb +18 -0
- data/lib/recurly/requests/account_acquisition_updatable.rb +26 -0
- data/lib/recurly/requests/account_create.rb +94 -0
- data/lib/recurly/requests/account_purchase.rb +94 -0
- data/lib/recurly/requests/account_update.rb +82 -0
- data/lib/recurly/requests/add_on_create.rb +94 -0
- data/lib/recurly/requests/add_on_pricing.rb +22 -0
- data/lib/recurly/requests/add_on_update.rb +74 -0
- data/lib/recurly/requests/address.rb +46 -0
- data/lib/recurly/requests/billing_info_create.rb +126 -0
- data/lib/recurly/requests/billing_info_verify.rb +14 -0
- data/lib/recurly/requests/coupon_bulk_create.rb +14 -0
- data/lib/recurly/requests/coupon_create.rb +102 -0
- data/lib/recurly/requests/coupon_pricing.rb +18 -0
- data/lib/recurly/requests/coupon_redemption_create.rb +22 -0
- data/lib/recurly/requests/coupon_update.rb +34 -0
- data/lib/recurly/requests/custom_field.rb +18 -0
- data/lib/recurly/requests/dunning_campaigns_bulk_update.rb +18 -0
- data/lib/recurly/requests/external_refund.rb +22 -0
- data/lib/recurly/requests/external_transaction.rb +26 -0
- data/lib/recurly/requests/invoice_address.rb +54 -0
- data/lib/recurly/requests/invoice_collect.rb +22 -0
- data/lib/recurly/requests/invoice_create.rb +42 -0
- data/lib/recurly/requests/invoice_refund.rb +34 -0
- data/lib/recurly/requests/invoice_updatable.rb +34 -0
- data/lib/recurly/requests/item_create.rb +58 -0
- data/lib/recurly/requests/item_update.rb +58 -0
- data/lib/recurly/requests/line_item_create.rb +86 -0
- data/lib/recurly/requests/line_item_refund.rb +26 -0
- data/lib/recurly/requests/measured_unit_create.rb +22 -0
- data/lib/recurly/requests/measured_unit_update.rb +22 -0
- data/lib/recurly/requests/plan_create.rb +114 -0
- data/lib/recurly/requests/plan_hosted_pages.rb +26 -0
- data/lib/recurly/requests/plan_pricing.rb +26 -0
- data/lib/recurly/requests/plan_ramp_interval.rb +18 -0
- data/lib/recurly/requests/plan_ramp_pricing.rb +18 -0
- data/lib/recurly/requests/plan_update.rb +102 -0
- data/lib/recurly/requests/pricing.rb +22 -0
- data/lib/recurly/requests/purchase_create.rb +78 -0
- data/lib/recurly/requests/shipping_address_create.rb +62 -0
- data/lib/recurly/requests/shipping_address_update.rb +66 -0
- data/lib/recurly/requests/shipping_fee_create.rb +22 -0
- data/lib/recurly/requests/shipping_method_create.rb +26 -0
- data/lib/recurly/requests/shipping_method_update.rb +26 -0
- data/lib/recurly/requests/shipping_purchase.rb +22 -0
- data/lib/recurly/requests/subscription_add_on_create.rb +38 -0
- data/lib/recurly/requests/subscription_add_on_tier.rb +18 -0
- data/lib/recurly/requests/subscription_add_on_update.rb +42 -0
- data/lib/recurly/requests/subscription_cancel.rb +14 -0
- data/lib/recurly/requests/subscription_change_billing_info_create.rb +14 -0
- data/lib/recurly/requests/subscription_change_create.rb +78 -0
- data/lib/recurly/requests/subscription_change_shipping_create.rb +22 -0
- data/lib/recurly/requests/subscription_create.rb +118 -0
- data/lib/recurly/requests/subscription_pause.rb +14 -0
- data/lib/recurly/requests/subscription_purchase.rb +74 -0
- data/lib/recurly/requests/subscription_ramp_interval.rb +18 -0
- data/lib/recurly/requests/subscription_shipping_create.rb +30 -0
- data/lib/recurly/requests/subscription_shipping_purchase.rb +22 -0
- data/lib/recurly/requests/subscription_shipping_update.rb +22 -0
- data/lib/recurly/requests/subscription_update.rb +66 -0
- data/lib/recurly/requests/tier.rb +18 -0
- data/lib/recurly/requests/usage_create.rb +26 -0
- data/lib/recurly/requests.rb +8 -0
- data/lib/recurly/resource.rb +23 -1082
- data/lib/recurly/resources/account.rb +134 -0
- data/lib/recurly/resources/account_acquisition.rb +46 -0
- data/lib/recurly/resources/account_acquisition_cost.rb +18 -0
- data/lib/recurly/resources/account_balance.rb +26 -0
- data/lib/recurly/resources/account_balance_amount.rb +26 -0
- data/lib/recurly/resources/account_mini.rb +50 -0
- data/lib/recurly/resources/account_note.rb +34 -0
- data/lib/recurly/resources/add_on.rb +114 -0
- data/lib/recurly/resources/add_on_mini.rb +54 -0
- data/lib/recurly/resources/add_on_pricing.rb +22 -0
- data/lib/recurly/resources/address.rb +46 -0
- data/lib/recurly/resources/billing_info.rb +74 -0
- data/lib/recurly/resources/billing_info_updated_by.rb +18 -0
- data/lib/recurly/resources/binary_file.rb +14 -0
- data/lib/recurly/resources/coupon.rb +138 -0
- data/lib/recurly/resources/coupon_discount.rb +26 -0
- data/lib/recurly/resources/coupon_discount_pricing.rb +18 -0
- data/lib/recurly/resources/coupon_discount_trial.rb +18 -0
- data/lib/recurly/resources/coupon_mini.rb +42 -0
- data/lib/recurly/resources/coupon_redemption.rb +54 -0
- data/lib/recurly/resources/coupon_redemption_mini.rb +34 -0
- data/lib/recurly/resources/credit_payment.rb +66 -0
- data/lib/recurly/resources/custom_field.rb +18 -0
- data/lib/recurly/resources/custom_field_definition.rb +50 -0
- data/lib/recurly/resources/dunning_campaign.rb +50 -0
- data/lib/recurly/resources/dunning_campaigns_bulk_update_response.rb +18 -0
- data/lib/recurly/resources/dunning_cycle.rb +58 -0
- data/lib/recurly/resources/dunning_interval.rb +18 -0
- data/lib/recurly/resources/error.rb +22 -0
- data/lib/recurly/resources/error_may_have_transaction.rb +26 -0
- data/lib/recurly/resources/export_dates.rb +18 -0
- data/lib/recurly/resources/export_file.rb +22 -0
- data/lib/recurly/resources/export_files.rb +18 -0
- data/lib/recurly/resources/fraud_info.rb +22 -0
- data/lib/recurly/resources/invoice.rb +154 -0
- data/lib/recurly/resources/invoice_address.rb +54 -0
- data/lib/recurly/resources/invoice_collection.rb +22 -0
- data/lib/recurly/resources/invoice_mini.rb +30 -0
- data/lib/recurly/resources/item.rb +82 -0
- data/lib/recurly/resources/item_mini.rb +34 -0
- data/lib/recurly/resources/line_item.rb +214 -0
- data/lib/recurly/resources/line_item_list.rb +26 -0
- data/lib/recurly/resources/measured_unit.rb +46 -0
- data/lib/recurly/resources/payment_method.rb +70 -0
- data/lib/recurly/resources/plan.rb +134 -0
- data/lib/recurly/resources/plan_hosted_pages.rb +26 -0
- data/lib/recurly/resources/plan_mini.rb +26 -0
- data/lib/recurly/resources/plan_pricing.rb +26 -0
- data/lib/recurly/resources/plan_ramp_interval.rb +18 -0
- data/lib/recurly/resources/plan_ramp_pricing.rb +18 -0
- data/lib/recurly/resources/pricing.rb +22 -0
- data/lib/recurly/resources/settings.rb +22 -0
- data/lib/recurly/resources/shipping_address.rb +82 -0
- data/lib/recurly/resources/shipping_method.rb +46 -0
- data/lib/recurly/resources/shipping_method_mini.rb +26 -0
- data/lib/recurly/resources/site.rb +54 -0
- data/lib/recurly/resources/subscription.rb +190 -0
- data/lib/recurly/resources/subscription_add_on.rb +66 -0
- data/lib/recurly/resources/subscription_add_on_tier.rb +18 -0
- data/lib/recurly/resources/subscription_change.rb +90 -0
- data/lib/recurly/resources/subscription_change_billing_info.rb +14 -0
- data/lib/recurly/resources/subscription_change_preview.rb +90 -0
- data/lib/recurly/resources/subscription_ramp_interval_response.rb +22 -0
- data/lib/recurly/resources/subscription_shipping.rb +26 -0
- data/lib/recurly/resources/tax_detail.rb +26 -0
- data/lib/recurly/resources/tax_info.rb +26 -0
- data/lib/recurly/resources/tier.rb +18 -0
- data/lib/recurly/resources/transaction.rb +162 -0
- data/lib/recurly/resources/transaction_error.rb +38 -0
- data/lib/recurly/resources/transaction_payment_gateway.rb +26 -0
- data/lib/recurly/resources/unique_coupon_code.rb +50 -0
- data/lib/recurly/resources/usage.rb +70 -0
- data/lib/recurly/resources/user.rb +42 -0
- data/lib/recurly/resources.rb +18 -0
- data/lib/recurly/schema/file_parser.rb +13 -0
- data/lib/recurly/schema/json_parser.rb +72 -0
- data/lib/recurly/schema/request_caster.rb +60 -0
- data/lib/recurly/schema/resource_caster.rb +46 -0
- data/lib/recurly/schema/schema_factory.rb +48 -0
- data/lib/recurly/schema/schema_validator.rb +144 -0
- data/lib/recurly/schema.rb +156 -0
- data/lib/recurly/version.rb +1 -15
- data/lib/recurly.rb +15 -137
- data/openapi/api.yaml +22373 -0
- data/recurly.gemspec +39 -0
- data/scripts/build +5 -0
- data/scripts/clean +6 -0
- data/scripts/format +12 -0
- data/scripts/prepare-release +50 -0
- data/scripts/release +17 -0
- data/scripts/test +15 -0
- metadata +216 -165
- data/lib/recurly/account.rb +0 -169
- data/lib/recurly/account_balance.rb +0 -21
- data/lib/recurly/add_on.rb +0 -30
- data/lib/recurly/address.rb +0 -25
- data/lib/recurly/adjustment.rb +0 -76
- data/lib/recurly/api/errors.rb +0 -206
- data/lib/recurly/api/net_http_adapter.rb +0 -111
- data/lib/recurly/api.rb +0 -101
- data/lib/recurly/billing_info.rb +0 -80
- data/lib/recurly/coupon.rb +0 -134
- data/lib/recurly/credit_payment.rb +0 -28
- data/lib/recurly/custom_field.rb +0 -15
- data/lib/recurly/delivery.rb +0 -19
- data/lib/recurly/error.rb +0 -13
- data/lib/recurly/gift_card.rb +0 -79
- data/lib/recurly/helper.rb +0 -51
- data/lib/recurly/invoice.rb +0 -268
- data/lib/recurly/invoice_collection.rb +0 -14
- data/lib/recurly/js.rb +0 -14
- data/lib/recurly/juris_detail.rb +0 -14
- data/lib/recurly/measured_unit.rb +0 -16
- data/lib/recurly/money.rb +0 -120
- data/lib/recurly/plan.rb +0 -40
- data/lib/recurly/purchase.rb +0 -219
- data/lib/recurly/redemption.rb +0 -46
- data/lib/recurly/resource/association.rb +0 -16
- data/lib/recurly/resource/errors.rb +0 -20
- data/lib/recurly/resource/pager.rb +0 -314
- data/lib/recurly/shipping_address.rb +0 -22
- data/lib/recurly/subscription/add_ons.rb +0 -77
- data/lib/recurly/subscription.rb +0 -325
- data/lib/recurly/subscription_add_on.rb +0 -50
- data/lib/recurly/tax_detail.rb +0 -14
- data/lib/recurly/tax_type.rb +0 -12
- data/lib/recurly/transaction/errors.rb +0 -107
- data/lib/recurly/transaction.rb +0 -116
- data/lib/recurly/usage.rb +0 -24
- data/lib/recurly/webhook/account_notification.rb +0 -10
- data/lib/recurly/webhook/billing_info_updated_notification.rb +0 -6
- data/lib/recurly/webhook/canceled_account_notification.rb +0 -6
- data/lib/recurly/webhook/canceled_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/closed_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/closed_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/credit_payment_notification.rb +0 -12
- data/lib/recurly/webhook/dunning_notification.rb +0 -14
- data/lib/recurly/webhook/expired_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/failed_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/failed_payment_notification.rb +0 -6
- data/lib/recurly/webhook/gift_card_notification.rb +0 -8
- data/lib/recurly/webhook/invoice_notification.rb +0 -12
- data/lib/recurly/webhook/new_account_notification.rb +0 -6
- data/lib/recurly/webhook/new_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/new_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/new_credit_payment_notification.rb +0 -6
- data/lib/recurly/webhook/new_dunning_event_notification.rb +0 -6
- data/lib/recurly/webhook/new_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/new_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/new_usage_notification.rb +0 -8
- data/lib/recurly/webhook/notification.rb +0 -18
- data/lib/recurly/webhook/paid_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/past_due_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/past_due_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/processing_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/processing_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/processing_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/processing_payment_notification.rb +0 -6
- data/lib/recurly/webhook/purchased_gift_card_notification.rb +0 -7
- data/lib/recurly/webhook/reactivated_account_notification.rb +0 -6
- data/lib/recurly/webhook/redeemed_gift_card_notification.rb +0 -7
- data/lib/recurly/webhook/renewed_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/reopened_charge_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/reopened_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/scheduled_payment_notification.rb +0 -6
- data/lib/recurly/webhook/subscription_notification.rb +0 -12
- data/lib/recurly/webhook/successful_payment_notification.rb +0 -6
- data/lib/recurly/webhook/successful_refund_notification.rb +0 -6
- data/lib/recurly/webhook/transaction_authorized_notification.rb +0 -6
- data/lib/recurly/webhook/transaction_notification.rb +0 -12
- data/lib/recurly/webhook/updated_account_notification.rb +0 -6
- data/lib/recurly/webhook/updated_balance_gift_card_notification.rb +0 -7
- data/lib/recurly/webhook/updated_subscription_notification.rb +0 -6
- data/lib/recurly/webhook/void_payment_notification.rb +0 -6
- data/lib/recurly/webhook/voided_credit_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/voided_credit_payment_notification.rb +0 -6
- data/lib/recurly/webhook.rb +0 -88
- data/lib/recurly/xml/nokogiri.rb +0 -58
- data/lib/recurly/xml/rexml.rb +0 -50
- data/lib/recurly/xml.rb +0 -120
@@ -0,0 +1,3868 @@
|
|
1
|
+
# This file is automatically created by Recurly's OpenAPI generation process
|
2
|
+
# and thus any edits you make by hand will be lost. If you wish to make a
|
3
|
+
# change to this file, please create a Github issue explaining the changes you
|
4
|
+
# need and we will usher them to the appropriate places.
|
5
|
+
module Recurly
|
6
|
+
class Client
|
7
|
+
def api_version
|
8
|
+
"v2019-10-10"
|
9
|
+
end
|
10
|
+
|
11
|
+
# List sites
|
12
|
+
#
|
13
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_sites list_sites api documentation}
|
14
|
+
#
|
15
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
16
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
17
|
+
#
|
18
|
+
# *Important notes:*
|
19
|
+
#
|
20
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
21
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
22
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
23
|
+
# results correspond to your request.
|
24
|
+
# * Records are returned in an arbitrary order. Since results are all
|
25
|
+
# returned at once you can sort the records yourself.
|
26
|
+
#
|
27
|
+
# @param limit [Integer] Limit number of records 1-200.
|
28
|
+
# @param order [String] Sort order.
|
29
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
30
|
+
# order. In descending order updated records will move behind the cursor and could
|
31
|
+
# prevent some records from being returned.
|
32
|
+
#
|
33
|
+
# @param state [String] Filter by state.
|
34
|
+
#
|
35
|
+
# @return [Pager<Resources::Site>] A list of sites.
|
36
|
+
# @example
|
37
|
+
# sites = @client.list_sites(limit: 200)
|
38
|
+
# sites.each do |site|
|
39
|
+
# puts "Site: #{site.subdomain}"
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
def list_sites(**options)
|
43
|
+
path = "/sites"
|
44
|
+
pager(path, **options)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Fetch a site
|
48
|
+
#
|
49
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_site get_site api documentation}
|
50
|
+
#
|
51
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
52
|
+
#
|
53
|
+
# @return [Resources::Site] A site.
|
54
|
+
# @example
|
55
|
+
# begin
|
56
|
+
# site = @client.get_site(site_id: site_id)
|
57
|
+
# puts "Got Site #{site}"
|
58
|
+
# rescue Recurly::Errors::NotFoundError
|
59
|
+
# # If the resource was not found, you may want to alert the user or
|
60
|
+
# # just return nil
|
61
|
+
# puts "Resource Not Found"
|
62
|
+
# end
|
63
|
+
#
|
64
|
+
def get_site(site_id:)
|
65
|
+
path = interpolate_path("/sites/{site_id}", site_id: site_id)
|
66
|
+
get(path)
|
67
|
+
end
|
68
|
+
|
69
|
+
# List a site's accounts
|
70
|
+
#
|
71
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_accounts list_accounts api documentation}
|
72
|
+
#
|
73
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
74
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
75
|
+
#
|
76
|
+
# *Important notes:*
|
77
|
+
#
|
78
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
79
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
80
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
81
|
+
# results correspond to your request.
|
82
|
+
# * Records are returned in an arbitrary order. Since results are all
|
83
|
+
# returned at once you can sort the records yourself.
|
84
|
+
#
|
85
|
+
# @param limit [Integer] Limit number of records 1-200.
|
86
|
+
# @param order [String] Sort order.
|
87
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
88
|
+
# order. In descending order updated records will move behind the cursor and could
|
89
|
+
# prevent some records from being returned.
|
90
|
+
#
|
91
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
92
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
93
|
+
#
|
94
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
95
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
96
|
+
#
|
97
|
+
# @param email [String] Filter for accounts with this exact email address. A blank value will return accounts with both +null+ and +""+ email addresses. Note that multiple accounts can share one email address.
|
98
|
+
# @param subscriber [Boolean] Filter for accounts with or without a subscription in the +active+,
|
99
|
+
# +canceled+, or +future+ state.
|
100
|
+
#
|
101
|
+
# @param past_due [String] Filter for accounts with an invoice in the +past_due+ state.
|
102
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
103
|
+
#
|
104
|
+
# @return [Pager<Resources::Account>] A list of the site's accounts.
|
105
|
+
# @example
|
106
|
+
# accounts = @client.list_accounts(limit: 200)
|
107
|
+
# accounts.each do |account|
|
108
|
+
# puts "Account: #{account.code}"
|
109
|
+
# end
|
110
|
+
#
|
111
|
+
def list_accounts(**options)
|
112
|
+
path = interpolate_path("/accounts")
|
113
|
+
pager(path, **options)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Create an account
|
117
|
+
#
|
118
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_account create_account api documentation}
|
119
|
+
#
|
120
|
+
# @param body [Requests::AccountCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountCreate}
|
121
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
122
|
+
#
|
123
|
+
# @return [Resources::Account] An account.
|
124
|
+
# @example
|
125
|
+
# begin
|
126
|
+
# account_create = {
|
127
|
+
# code: account_code,
|
128
|
+
# first_name: "Benjamin",
|
129
|
+
# last_name: "Du Monde",
|
130
|
+
# acquisition: {
|
131
|
+
# campaign: "podcast-marketing",
|
132
|
+
# channel: "social_media",
|
133
|
+
# subchannel: "twitter",
|
134
|
+
# cost: {
|
135
|
+
# currency: "USD",
|
136
|
+
# amount: 0.50
|
137
|
+
# }
|
138
|
+
# },
|
139
|
+
# shipping_addresses: [
|
140
|
+
# {
|
141
|
+
# nickname: "Home",
|
142
|
+
# street1: "1 Tchoupitoulas St",
|
143
|
+
# city: "New Orleans",
|
144
|
+
# region: "LA",
|
145
|
+
# country: "US",
|
146
|
+
# postal_code: "70115",
|
147
|
+
# first_name: "Benjamin",
|
148
|
+
# last_name: "Du Monde"
|
149
|
+
# }
|
150
|
+
# ]
|
151
|
+
# }
|
152
|
+
# account = @client.create_account(body: account_create)
|
153
|
+
# puts "Created Account #{account}"
|
154
|
+
# rescue Recurly::Errors::ValidationError => e
|
155
|
+
# # If the request was invalid, you may want to tell your user
|
156
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
157
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
158
|
+
# end
|
159
|
+
#
|
160
|
+
def create_account(body:, **options)
|
161
|
+
path = interpolate_path("/accounts")
|
162
|
+
post(path, body, Requests::AccountCreate, **options)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Fetch an account
|
166
|
+
#
|
167
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_account get_account api documentation}
|
168
|
+
#
|
169
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
170
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
171
|
+
#
|
172
|
+
# @return [Resources::Account] An account.
|
173
|
+
# @example
|
174
|
+
# begin
|
175
|
+
# account = @client.get_account(account_id: account_id)
|
176
|
+
# puts "Got Account #{account}"
|
177
|
+
# rescue Recurly::Errors::NotFoundError
|
178
|
+
# # If the resource was not found, you may want to alert the user or
|
179
|
+
# # just return nil
|
180
|
+
# puts "Resource Not Found"
|
181
|
+
# end
|
182
|
+
#
|
183
|
+
def get_account(account_id:, **options)
|
184
|
+
path = interpolate_path("/accounts/{account_id}", account_id: account_id)
|
185
|
+
get(path, **options)
|
186
|
+
end
|
187
|
+
|
188
|
+
# Modify an account
|
189
|
+
#
|
190
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_account update_account api documentation}
|
191
|
+
#
|
192
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
193
|
+
# @param body [Requests::AccountUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountUpdate}
|
194
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
195
|
+
#
|
196
|
+
# @return [Resources::Account] An account.
|
197
|
+
# @example
|
198
|
+
# begin
|
199
|
+
# account_update = {
|
200
|
+
# first_name: "Aaron",
|
201
|
+
# last_name: "Du Monde",
|
202
|
+
# }
|
203
|
+
# account = @client.update_account(
|
204
|
+
# account_id: account_id,
|
205
|
+
# body: account_update
|
206
|
+
# )
|
207
|
+
# puts "Updated Account #{account}"
|
208
|
+
# rescue Recurly::Errors::ValidationError => e
|
209
|
+
# # If the request was invalid, you may want to tell your user
|
210
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
211
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
212
|
+
# end
|
213
|
+
#
|
214
|
+
def update_account(account_id:, body:, **options)
|
215
|
+
path = interpolate_path("/accounts/{account_id}", account_id: account_id)
|
216
|
+
put(path, body, Requests::AccountUpdate, **options)
|
217
|
+
end
|
218
|
+
|
219
|
+
# Deactivate an account
|
220
|
+
#
|
221
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/deactivate_account deactivate_account api documentation}
|
222
|
+
#
|
223
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
224
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
225
|
+
#
|
226
|
+
# @return [Resources::Account] An account.
|
227
|
+
# @example
|
228
|
+
# begin
|
229
|
+
# account = @client.deactivate_account(account_id: account_id)
|
230
|
+
# puts "Deactivated Account #{account}"
|
231
|
+
# rescue Recurly::Errors::NotFoundError
|
232
|
+
# # If the resource was not found, you may want to alert the user or
|
233
|
+
# # just return nil
|
234
|
+
# puts "Resource Not Found"
|
235
|
+
# end
|
236
|
+
#
|
237
|
+
def deactivate_account(account_id:, **options)
|
238
|
+
path = interpolate_path("/accounts/{account_id}", account_id: account_id)
|
239
|
+
delete(path, **options)
|
240
|
+
end
|
241
|
+
|
242
|
+
# Fetch an account's acquisition data
|
243
|
+
#
|
244
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_account_acquisition get_account_acquisition api documentation}
|
245
|
+
#
|
246
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
247
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
248
|
+
#
|
249
|
+
# @return [Resources::AccountAcquisition] An account's acquisition data.
|
250
|
+
# @example
|
251
|
+
# begin
|
252
|
+
# @client.get_account_acquisition(account_id: account_id)
|
253
|
+
# puts "Got AccountAcquisition"
|
254
|
+
# rescue Recurly::Errors::NotFoundError
|
255
|
+
# # If the resource was not found, you may want to alert the user or
|
256
|
+
# # just return nil
|
257
|
+
# puts "Resource Not Found"
|
258
|
+
# end
|
259
|
+
#
|
260
|
+
def get_account_acquisition(account_id:, **options)
|
261
|
+
path = interpolate_path("/accounts/{account_id}/acquisition", account_id: account_id)
|
262
|
+
get(path, **options)
|
263
|
+
end
|
264
|
+
|
265
|
+
# Update an account's acquisition data
|
266
|
+
#
|
267
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_account_acquisition update_account_acquisition api documentation}
|
268
|
+
#
|
269
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
270
|
+
# @param body [Requests::AccountAcquisitionUpdatable] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountAcquisitionUpdatable}
|
271
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
272
|
+
#
|
273
|
+
# @return [Resources::AccountAcquisition] An account's updated acquisition data.
|
274
|
+
# @example
|
275
|
+
# begin
|
276
|
+
# acquisition_update = {
|
277
|
+
# campaign: "podcast-marketing",
|
278
|
+
# channel: "social_media",
|
279
|
+
# subchannel: "twitter",
|
280
|
+
# cost: {
|
281
|
+
# currency: "USD",
|
282
|
+
# amount: 0.50
|
283
|
+
# }
|
284
|
+
# }
|
285
|
+
# acquisition = @client.update_account_acquisition(
|
286
|
+
# account_id: account_id,
|
287
|
+
# body: acquisition_update
|
288
|
+
# )
|
289
|
+
# puts "Updated AccountAcqusition #{acquisition}"
|
290
|
+
# rescue Recurly::Errors::ValidationError => e
|
291
|
+
# # If the request was invalid, you may want to tell your user
|
292
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
293
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
294
|
+
# end
|
295
|
+
#
|
296
|
+
def update_account_acquisition(account_id:, body:, **options)
|
297
|
+
path = interpolate_path("/accounts/{account_id}/acquisition", account_id: account_id)
|
298
|
+
put(path, body, Requests::AccountAcquisitionUpdatable, **options)
|
299
|
+
end
|
300
|
+
|
301
|
+
# Remove an account's acquisition data
|
302
|
+
#
|
303
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_account_acquisition remove_account_acquisition api documentation}
|
304
|
+
#
|
305
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
306
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
307
|
+
#
|
308
|
+
# @return [Resources::Empty] Acquisition data was succesfully deleted.
|
309
|
+
# @example
|
310
|
+
# begin
|
311
|
+
# acquisition = @client.remove_account_acquisition(account_id: account_id)
|
312
|
+
# puts "Removed AccountAcqusition #{acquisition}"
|
313
|
+
# rescue Recurly::Errors::NotFoundError
|
314
|
+
# # If the resource was not found, you may want to alert the user or
|
315
|
+
# # just return nil
|
316
|
+
# puts "Resource Not Found"
|
317
|
+
# end
|
318
|
+
#
|
319
|
+
def remove_account_acquisition(account_id:, **options)
|
320
|
+
path = interpolate_path("/accounts/{account_id}/acquisition", account_id: account_id)
|
321
|
+
delete(path, **options)
|
322
|
+
end
|
323
|
+
|
324
|
+
# Reactivate an inactive account
|
325
|
+
#
|
326
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/reactivate_account reactivate_account api documentation}
|
327
|
+
#
|
328
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
329
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
330
|
+
#
|
331
|
+
# @return [Resources::Account] An account.
|
332
|
+
# @example
|
333
|
+
# begin
|
334
|
+
# account = @client.reactivate_account(account_id: account_id)
|
335
|
+
# puts "Reactivated account #{account}"
|
336
|
+
# rescue Recurly::Errors::NotFoundError
|
337
|
+
# # If the resource was not found, you may want to alert the user or
|
338
|
+
# # just return nil
|
339
|
+
# puts "Resource Not Found"
|
340
|
+
# end
|
341
|
+
#
|
342
|
+
def reactivate_account(account_id:, **options)
|
343
|
+
path = interpolate_path("/accounts/{account_id}/reactivate", account_id: account_id)
|
344
|
+
put(path, **options)
|
345
|
+
end
|
346
|
+
|
347
|
+
# Fetch an account's balance and past due status
|
348
|
+
#
|
349
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_account_balance get_account_balance api documentation}
|
350
|
+
#
|
351
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
352
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
353
|
+
#
|
354
|
+
# @return [Resources::AccountBalance] An account's balance.
|
355
|
+
# @example
|
356
|
+
# begin
|
357
|
+
# balance = @client.get_account_balance(account_id: account_id)
|
358
|
+
# puts "Got AccountBalance #{balance}"
|
359
|
+
# rescue Recurly::Errors::NotFoundError
|
360
|
+
# # If the resource was not found, you may want to alert the user or
|
361
|
+
# # just return nil
|
362
|
+
# puts "Resource Not Found"
|
363
|
+
# end
|
364
|
+
#
|
365
|
+
def get_account_balance(account_id:, **options)
|
366
|
+
path = interpolate_path("/accounts/{account_id}/balance", account_id: account_id)
|
367
|
+
get(path, **options)
|
368
|
+
end
|
369
|
+
|
370
|
+
# Fetch an account's billing information
|
371
|
+
#
|
372
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_billing_info get_billing_info api documentation}
|
373
|
+
#
|
374
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
375
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
376
|
+
#
|
377
|
+
# @return [Resources::BillingInfo] An account's billing information.
|
378
|
+
# @example
|
379
|
+
# begin
|
380
|
+
# billing = @client.get_billing_info(account_id: account_id)
|
381
|
+
# puts "Got BillingInfo #{billing}"
|
382
|
+
# rescue Recurly::Errors::NotFoundError
|
383
|
+
# # If the resource was not found, you may want to alert the user or
|
384
|
+
# # just return nil
|
385
|
+
# puts "Resource Not Found"
|
386
|
+
# end
|
387
|
+
#
|
388
|
+
def get_billing_info(account_id:, **options)
|
389
|
+
path = interpolate_path("/accounts/{account_id}/billing_info", account_id: account_id)
|
390
|
+
get(path, **options)
|
391
|
+
end
|
392
|
+
|
393
|
+
# Set an account's billing information
|
394
|
+
#
|
395
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_billing_info update_billing_info api documentation}
|
396
|
+
#
|
397
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
398
|
+
# @param body [Requests::BillingInfoCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoCreate}
|
399
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
400
|
+
#
|
401
|
+
# @return [Resources::BillingInfo] Updated billing information.
|
402
|
+
# @example
|
403
|
+
# begin
|
404
|
+
# billing_update = {
|
405
|
+
# first_name: "Aaron",
|
406
|
+
# last_name: "Du Monde",
|
407
|
+
# }
|
408
|
+
# billing = @client.update_billing_info(
|
409
|
+
# account_id: account_id,
|
410
|
+
# body: billing_update
|
411
|
+
# )
|
412
|
+
# puts "Updated BillingInfo #{billing}"
|
413
|
+
# rescue Recurly::Errors::ValidationError => e
|
414
|
+
# # If the request was invalid, you may want to tell your user
|
415
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
416
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
417
|
+
# end
|
418
|
+
#
|
419
|
+
def update_billing_info(account_id:, body:, **options)
|
420
|
+
path = interpolate_path("/accounts/{account_id}/billing_info", account_id: account_id)
|
421
|
+
put(path, body, Requests::BillingInfoCreate, **options)
|
422
|
+
end
|
423
|
+
|
424
|
+
# Remove an account's billing information
|
425
|
+
#
|
426
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_billing_info remove_billing_info api documentation}
|
427
|
+
#
|
428
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
429
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
430
|
+
#
|
431
|
+
# @return [Resources::Empty] Billing information deleted
|
432
|
+
# @example
|
433
|
+
# begin
|
434
|
+
# @client.remove_billing_info(account_id: account_id)
|
435
|
+
# puts "Removed BillingInfo #{account_id}"
|
436
|
+
# rescue Recurly::Errors::NotFoundError
|
437
|
+
# # If the resource was not found, you may want to alert the user or
|
438
|
+
# # just return nil
|
439
|
+
# puts "Resource Not Found"
|
440
|
+
# end
|
441
|
+
#
|
442
|
+
def remove_billing_info(account_id:, **options)
|
443
|
+
path = interpolate_path("/accounts/{account_id}/billing_info", account_id: account_id)
|
444
|
+
delete(path, **options)
|
445
|
+
end
|
446
|
+
|
447
|
+
# Verify an account's credit card billing information
|
448
|
+
#
|
449
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/verify_billing_info verify_billing_info api documentation}
|
450
|
+
#
|
451
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
452
|
+
# @param body [Requests::BillingInfoVerify] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoVerify}
|
453
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
454
|
+
#
|
455
|
+
# @return [Resources::Transaction] Transaction information from verify.
|
456
|
+
# @example
|
457
|
+
# begin
|
458
|
+
# transaction = @client.verify_billing_info(account_id: account_id)
|
459
|
+
# puts "Got Transaction #{transaction}"
|
460
|
+
# rescue Recurly::Errors::NotFoundError
|
461
|
+
# # If the resource was not found, you may want to alert the user or
|
462
|
+
# # just return nil
|
463
|
+
# puts "Resource Not Found"
|
464
|
+
# end
|
465
|
+
#
|
466
|
+
def verify_billing_info(account_id:, **options)
|
467
|
+
path = interpolate_path("/accounts/{account_id}/billing_info/verify", account_id: account_id)
|
468
|
+
post(path, options[:body], Requests::BillingInfoVerify, **options)
|
469
|
+
end
|
470
|
+
|
471
|
+
# Get the list of billing information associated with an account
|
472
|
+
#
|
473
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_billing_infos list_billing_infos api documentation}
|
474
|
+
#
|
475
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
476
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
477
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
478
|
+
#
|
479
|
+
# *Important notes:*
|
480
|
+
#
|
481
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
482
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
483
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
484
|
+
# results correspond to your request.
|
485
|
+
# * Records are returned in an arbitrary order. Since results are all
|
486
|
+
# returned at once you can sort the records yourself.
|
487
|
+
#
|
488
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
489
|
+
# order. In descending order updated records will move behind the cursor and could
|
490
|
+
# prevent some records from being returned.
|
491
|
+
#
|
492
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
493
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
494
|
+
#
|
495
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
496
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
497
|
+
#
|
498
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
499
|
+
#
|
500
|
+
# @return [Pager<Resources::BillingInfo>] A list of the the billing information for an account's
|
501
|
+
#
|
502
|
+
def list_billing_infos(account_id:, **options)
|
503
|
+
path = interpolate_path("/accounts/{account_id}/billing_infos", account_id: account_id)
|
504
|
+
pager(path, **options)
|
505
|
+
end
|
506
|
+
|
507
|
+
# Add new billing information on an account
|
508
|
+
#
|
509
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_billing_info create_billing_info api documentation}
|
510
|
+
#
|
511
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
512
|
+
# @param body [Requests::BillingInfoCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoCreate}
|
513
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
514
|
+
#
|
515
|
+
# @return [Resources::BillingInfo] Updated billing information.
|
516
|
+
#
|
517
|
+
def create_billing_info(account_id:, body:, **options)
|
518
|
+
path = interpolate_path("/accounts/{account_id}/billing_infos", account_id: account_id)
|
519
|
+
post(path, body, Requests::BillingInfoCreate, **options)
|
520
|
+
end
|
521
|
+
|
522
|
+
# Fetch a billing info
|
523
|
+
#
|
524
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_a_billing_info get_a_billing_info api documentation}
|
525
|
+
#
|
526
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
527
|
+
# @param billing_info_id [String] Billing Info ID. Can ONLY be used for sites utilizing the Wallet feature.
|
528
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
529
|
+
#
|
530
|
+
# @return [Resources::BillingInfo] A billing info.
|
531
|
+
#
|
532
|
+
def get_a_billing_info(account_id:, billing_info_id:, **options)
|
533
|
+
path = interpolate_path("/accounts/{account_id}/billing_infos/{billing_info_id}", account_id: account_id, billing_info_id: billing_info_id)
|
534
|
+
get(path, **options)
|
535
|
+
end
|
536
|
+
|
537
|
+
# Update an account's billing information
|
538
|
+
#
|
539
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_a_billing_info update_a_billing_info api documentation}
|
540
|
+
#
|
541
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
542
|
+
# @param billing_info_id [String] Billing Info ID. Can ONLY be used for sites utilizing the Wallet feature.
|
543
|
+
# @param body [Requests::BillingInfoCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoCreate}
|
544
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
545
|
+
#
|
546
|
+
# @return [Resources::BillingInfo] Updated billing information.
|
547
|
+
#
|
548
|
+
def update_a_billing_info(account_id:, billing_info_id:, body:, **options)
|
549
|
+
path = interpolate_path("/accounts/{account_id}/billing_infos/{billing_info_id}", account_id: account_id, billing_info_id: billing_info_id)
|
550
|
+
put(path, body, Requests::BillingInfoCreate, **options)
|
551
|
+
end
|
552
|
+
|
553
|
+
# Remove an account's billing information
|
554
|
+
#
|
555
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_a_billing_info remove_a_billing_info api documentation}
|
556
|
+
#
|
557
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
558
|
+
# @param billing_info_id [String] Billing Info ID. Can ONLY be used for sites utilizing the Wallet feature.
|
559
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
560
|
+
#
|
561
|
+
# @return [Resources::Empty] Billing information deleted
|
562
|
+
#
|
563
|
+
def remove_a_billing_info(account_id:, billing_info_id:, **options)
|
564
|
+
path = interpolate_path("/accounts/{account_id}/billing_infos/{billing_info_id}", account_id: account_id, billing_info_id: billing_info_id)
|
565
|
+
delete(path, **options)
|
566
|
+
end
|
567
|
+
|
568
|
+
# List the coupon redemptions for an account
|
569
|
+
#
|
570
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_account_coupon_redemptions list_account_coupon_redemptions api documentation}
|
571
|
+
#
|
572
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
573
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
574
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
575
|
+
#
|
576
|
+
# *Important notes:*
|
577
|
+
#
|
578
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
579
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
580
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
581
|
+
# results correspond to your request.
|
582
|
+
# * Records are returned in an arbitrary order. Since results are all
|
583
|
+
# returned at once you can sort the records yourself.
|
584
|
+
#
|
585
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
586
|
+
# order. In descending order updated records will move behind the cursor and could
|
587
|
+
# prevent some records from being returned.
|
588
|
+
#
|
589
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
590
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
591
|
+
#
|
592
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
593
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
594
|
+
#
|
595
|
+
# @param state [String] Filter by state.
|
596
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
597
|
+
#
|
598
|
+
# @return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions on an account.
|
599
|
+
# @example
|
600
|
+
# redemptions = @client.list_account_coupon_redemptions(
|
601
|
+
# account_id: account_id,
|
602
|
+
# limit: 200
|
603
|
+
# )
|
604
|
+
# redemptions.each do |redemption|
|
605
|
+
# puts "CouponRedemption: #{redemption.id}"
|
606
|
+
# end
|
607
|
+
#
|
608
|
+
def list_account_coupon_redemptions(account_id:, **options)
|
609
|
+
path = interpolate_path("/accounts/{account_id}/coupon_redemptions", account_id: account_id)
|
610
|
+
pager(path, **options)
|
611
|
+
end
|
612
|
+
|
613
|
+
# Fetch the coupon redemption that is active on an account
|
614
|
+
#
|
615
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_active_coupon_redemption get_active_coupon_redemption api documentation}
|
616
|
+
#
|
617
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
618
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
619
|
+
#
|
620
|
+
# @return [Resources::CouponRedemption] An active coupon redemption on an account.
|
621
|
+
# @example
|
622
|
+
# begin
|
623
|
+
# redemption = @client.get_active_coupon_redemption(account_id: account_id)
|
624
|
+
# puts "Got CouponRedemption #{redemption}"
|
625
|
+
# rescue Recurly::Errors::NotFoundError
|
626
|
+
# # If the resource was not found, you may want to alert the user or
|
627
|
+
# # just return nil
|
628
|
+
# puts "Resource Not Found"
|
629
|
+
# end
|
630
|
+
#
|
631
|
+
def get_active_coupon_redemption(account_id:, **options)
|
632
|
+
path = interpolate_path("/accounts/{account_id}/coupon_redemptions/active", account_id: account_id)
|
633
|
+
get(path, **options)
|
634
|
+
end
|
635
|
+
|
636
|
+
# Generate an active coupon redemption on an account or subscription
|
637
|
+
#
|
638
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_coupon_redemption create_coupon_redemption api documentation}
|
639
|
+
#
|
640
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
641
|
+
# @param body [Requests::CouponRedemptionCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponRedemptionCreate}
|
642
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
643
|
+
#
|
644
|
+
# @return [Resources::CouponRedemption] Returns the new coupon redemption.
|
645
|
+
# @example
|
646
|
+
# begin
|
647
|
+
# redemption_create = {
|
648
|
+
# currency: 'USD',
|
649
|
+
# coupon_id: coupon_id
|
650
|
+
# }
|
651
|
+
# redemption = @client.create_coupon_redemption(
|
652
|
+
# account_id: account_id,
|
653
|
+
# body: redemption_create
|
654
|
+
# )
|
655
|
+
# puts "Created CouponRedemption #{redemption}"
|
656
|
+
# rescue Recurly::Errors::ValidationError => e
|
657
|
+
# # If the request was invalid, you may want to tell your user
|
658
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
659
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
660
|
+
# end
|
661
|
+
#
|
662
|
+
def create_coupon_redemption(account_id:, body:, **options)
|
663
|
+
path = interpolate_path("/accounts/{account_id}/coupon_redemptions/active", account_id: account_id)
|
664
|
+
post(path, body, Requests::CouponRedemptionCreate, **options)
|
665
|
+
end
|
666
|
+
|
667
|
+
# Delete the active coupon redemption from an account
|
668
|
+
#
|
669
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_coupon_redemption remove_coupon_redemption api documentation}
|
670
|
+
#
|
671
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
672
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
673
|
+
#
|
674
|
+
# @return [Resources::CouponRedemption] Coupon redemption deleted.
|
675
|
+
# @example
|
676
|
+
# begin
|
677
|
+
# @client.remove_coupon_redemption(account_id: account_id)
|
678
|
+
# puts "Removed CouponRedemption #{account_id}"
|
679
|
+
# rescue Recurly::Errors::NotFoundError
|
680
|
+
# # If the resource was not found, you may want to alert the user or
|
681
|
+
# # just return nil
|
682
|
+
# puts "Resource Not Found"
|
683
|
+
# end
|
684
|
+
#
|
685
|
+
def remove_coupon_redemption(account_id:, **options)
|
686
|
+
path = interpolate_path("/accounts/{account_id}/coupon_redemptions/active", account_id: account_id)
|
687
|
+
delete(path, **options)
|
688
|
+
end
|
689
|
+
|
690
|
+
# List an account's credit payments
|
691
|
+
#
|
692
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_account_credit_payments list_account_credit_payments api documentation}
|
693
|
+
#
|
694
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
695
|
+
# @param limit [Integer] Limit number of records 1-200.
|
696
|
+
# @param order [String] Sort order.
|
697
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
698
|
+
# order. In descending order updated records will move behind the cursor and could
|
699
|
+
# prevent some records from being returned.
|
700
|
+
#
|
701
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
702
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
703
|
+
#
|
704
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
705
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
706
|
+
#
|
707
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
708
|
+
#
|
709
|
+
# @return [Pager<Resources::CreditPayment>] A list of the account's credit payments.
|
710
|
+
# @example
|
711
|
+
# payments = @client.list_account_credit_payments(
|
712
|
+
# account_id: account_id,
|
713
|
+
# limit: 200
|
714
|
+
# )
|
715
|
+
# payments.each do |payment|
|
716
|
+
# puts "CreditPayment: #{payment.id}"
|
717
|
+
# end
|
718
|
+
#
|
719
|
+
def list_account_credit_payments(account_id:, **options)
|
720
|
+
path = interpolate_path("/accounts/{account_id}/credit_payments", account_id: account_id)
|
721
|
+
pager(path, **options)
|
722
|
+
end
|
723
|
+
|
724
|
+
# List an account's invoices
|
725
|
+
#
|
726
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_account_invoices list_account_invoices api documentation}
|
727
|
+
#
|
728
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
729
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
730
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
731
|
+
#
|
732
|
+
# *Important notes:*
|
733
|
+
#
|
734
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
735
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
736
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
737
|
+
# results correspond to your request.
|
738
|
+
# * Records are returned in an arbitrary order. Since results are all
|
739
|
+
# returned at once you can sort the records yourself.
|
740
|
+
#
|
741
|
+
# @param limit [Integer] Limit number of records 1-200.
|
742
|
+
# @param order [String] Sort order.
|
743
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
744
|
+
# order. In descending order updated records will move behind the cursor and could
|
745
|
+
# prevent some records from being returned.
|
746
|
+
#
|
747
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
748
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
749
|
+
#
|
750
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
751
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
752
|
+
#
|
753
|
+
# @param type [String] Filter by type when:
|
754
|
+
# - +type=charge+, only charge invoices will be returned.
|
755
|
+
# - +type=credit+, only credit invoices will be returned.
|
756
|
+
# - +type=non-legacy+, only charge and credit invoices will be returned.
|
757
|
+
# - +type=legacy+, only legacy invoices will be returned.
|
758
|
+
#
|
759
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
760
|
+
#
|
761
|
+
# @return [Pager<Resources::Invoice>] A list of the account's invoices.
|
762
|
+
# @example
|
763
|
+
# invoices = @client.list_account_invoices(
|
764
|
+
# account_id: account_id,
|
765
|
+
# limit: 200
|
766
|
+
# )
|
767
|
+
# invoices.each do |invoice|
|
768
|
+
# puts "Invoice: #{invoice.number}"
|
769
|
+
# end
|
770
|
+
#
|
771
|
+
def list_account_invoices(account_id:, **options)
|
772
|
+
path = interpolate_path("/accounts/{account_id}/invoices", account_id: account_id)
|
773
|
+
pager(path, **options)
|
774
|
+
end
|
775
|
+
|
776
|
+
# Create an invoice for pending line items
|
777
|
+
#
|
778
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_invoice create_invoice api documentation}
|
779
|
+
#
|
780
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
781
|
+
# @param body [Requests::InvoiceCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceCreate}
|
782
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
783
|
+
#
|
784
|
+
# @return [Resources::InvoiceCollection] Returns the new invoices.
|
785
|
+
# @example
|
786
|
+
# begin
|
787
|
+
# invoice_create = {
|
788
|
+
# currency: 'USD',
|
789
|
+
# collection_method: 'automatic'
|
790
|
+
# }
|
791
|
+
# collection = @client.create_invoice(
|
792
|
+
# account_id: account_id,
|
793
|
+
# body: invoice_create
|
794
|
+
# )
|
795
|
+
# puts "Created InvoiceCollection #{collection}"
|
796
|
+
# rescue Recurly::Errors::ValidationError => e
|
797
|
+
# # If the request was invalid, you may want to tell your user
|
798
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
799
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
800
|
+
# end
|
801
|
+
#
|
802
|
+
def create_invoice(account_id:, body:, **options)
|
803
|
+
path = interpolate_path("/accounts/{account_id}/invoices", account_id: account_id)
|
804
|
+
post(path, body, Requests::InvoiceCreate, **options)
|
805
|
+
end
|
806
|
+
|
807
|
+
# Preview new invoice for pending line items
|
808
|
+
#
|
809
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/preview_invoice preview_invoice api documentation}
|
810
|
+
#
|
811
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
812
|
+
# @param body [Requests::InvoiceCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceCreate}
|
813
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
814
|
+
#
|
815
|
+
# @return [Resources::InvoiceCollection] Returns the invoice previews.
|
816
|
+
# @example
|
817
|
+
# begin
|
818
|
+
# invoice_preview = {
|
819
|
+
# currency: "USD",
|
820
|
+
# collection_method: "automatic"
|
821
|
+
# }
|
822
|
+
# collection = @client.create_invoice(
|
823
|
+
# account_id: account_id,
|
824
|
+
# body: invoice_preview
|
825
|
+
# )
|
826
|
+
# puts "Created InvoiceCollection #{collection}"
|
827
|
+
# rescue Recurly::Errors::ValidationError => e
|
828
|
+
# # If the request was invalid, you may want to tell your user
|
829
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
830
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
831
|
+
# end
|
832
|
+
#
|
833
|
+
def preview_invoice(account_id:, body:, **options)
|
834
|
+
path = interpolate_path("/accounts/{account_id}/invoices/preview", account_id: account_id)
|
835
|
+
post(path, body, Requests::InvoiceCreate, **options)
|
836
|
+
end
|
837
|
+
|
838
|
+
# List an account's line items
|
839
|
+
#
|
840
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_account_line_items list_account_line_items api documentation}
|
841
|
+
#
|
842
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
843
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
844
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
845
|
+
#
|
846
|
+
# *Important notes:*
|
847
|
+
#
|
848
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
849
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
850
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
851
|
+
# results correspond to your request.
|
852
|
+
# * Records are returned in an arbitrary order. Since results are all
|
853
|
+
# returned at once you can sort the records yourself.
|
854
|
+
#
|
855
|
+
# @param limit [Integer] Limit number of records 1-200.
|
856
|
+
# @param order [String] Sort order.
|
857
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
858
|
+
# order. In descending order updated records will move behind the cursor and could
|
859
|
+
# prevent some records from being returned.
|
860
|
+
#
|
861
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
862
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
863
|
+
#
|
864
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
865
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
866
|
+
#
|
867
|
+
# @param original [String] Filter by original field.
|
868
|
+
# @param state [String] Filter by state field.
|
869
|
+
# @param type [String] Filter by type field.
|
870
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
871
|
+
#
|
872
|
+
# @return [Pager<Resources::LineItem>] A list of the account's line items.
|
873
|
+
# @example
|
874
|
+
# line_items = @client.list_account_line_items(
|
875
|
+
# account_id: account_id,
|
876
|
+
# limit: 200
|
877
|
+
# )
|
878
|
+
# line_items.each do |line_item|
|
879
|
+
# puts "LineItem: #{line_item.id}"
|
880
|
+
# end
|
881
|
+
#
|
882
|
+
def list_account_line_items(account_id:, **options)
|
883
|
+
path = interpolate_path("/accounts/{account_id}/line_items", account_id: account_id)
|
884
|
+
pager(path, **options)
|
885
|
+
end
|
886
|
+
|
887
|
+
# Create a new line item for the account
|
888
|
+
#
|
889
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_line_item create_line_item api documentation}
|
890
|
+
#
|
891
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
892
|
+
# @param body [Requests::LineItemCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::LineItemCreate}
|
893
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
894
|
+
#
|
895
|
+
# @return [Resources::LineItem] Returns the new line item.
|
896
|
+
# @example
|
897
|
+
# begin
|
898
|
+
# line_item_create = {
|
899
|
+
# currency: 'USD',
|
900
|
+
# unit_amount: 1_000,
|
901
|
+
# type: :charge
|
902
|
+
# }
|
903
|
+
# line_item = @client.create_line_item(
|
904
|
+
# account_id: account_id,
|
905
|
+
# body: line_item_create
|
906
|
+
# )
|
907
|
+
# puts "Created LineItem #{line_item}"
|
908
|
+
# rescue Recurly::Errors::ValidationError => e
|
909
|
+
# # If the request was invalid, you may want to tell your user
|
910
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
911
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
912
|
+
# end
|
913
|
+
#
|
914
|
+
def create_line_item(account_id:, body:, **options)
|
915
|
+
path = interpolate_path("/accounts/{account_id}/line_items", account_id: account_id)
|
916
|
+
post(path, body, Requests::LineItemCreate, **options)
|
917
|
+
end
|
918
|
+
|
919
|
+
# List an account's notes
|
920
|
+
#
|
921
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_account_notes list_account_notes api documentation}
|
922
|
+
#
|
923
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
924
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
925
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
926
|
+
#
|
927
|
+
# *Important notes:*
|
928
|
+
#
|
929
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
930
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
931
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
932
|
+
# results correspond to your request.
|
933
|
+
# * Records are returned in an arbitrary order. Since results are all
|
934
|
+
# returned at once you can sort the records yourself.
|
935
|
+
#
|
936
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
937
|
+
#
|
938
|
+
# @return [Pager<Resources::AccountNote>] A list of an account's notes.
|
939
|
+
# @example
|
940
|
+
# account_notes = @client.list_account_notes(account_id: account_id, limit: 200)
|
941
|
+
# account_notes.each do |note|
|
942
|
+
# puts "AccountNote: #{note.message}"
|
943
|
+
# end
|
944
|
+
#
|
945
|
+
def list_account_notes(account_id:, **options)
|
946
|
+
path = interpolate_path("/accounts/{account_id}/notes", account_id: account_id)
|
947
|
+
pager(path, **options)
|
948
|
+
end
|
949
|
+
|
950
|
+
# Fetch an account note
|
951
|
+
#
|
952
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_account_note get_account_note api documentation}
|
953
|
+
#
|
954
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
955
|
+
# @param account_note_id [String] Account Note ID.
|
956
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
957
|
+
#
|
958
|
+
# @return [Resources::AccountNote] An account note.
|
959
|
+
# @example
|
960
|
+
# begin
|
961
|
+
# note = @client.get_account_note(
|
962
|
+
# account_id: account_id,
|
963
|
+
# account_note_id: note_id
|
964
|
+
# )
|
965
|
+
# puts "Got AccountNote #{note}"
|
966
|
+
# rescue Recurly::Errors::NotFoundError
|
967
|
+
# # If the resource was not found, you may want to alert the user or
|
968
|
+
# # just return nil
|
969
|
+
# puts "Resource Not Found"
|
970
|
+
# end
|
971
|
+
#
|
972
|
+
def get_account_note(account_id:, account_note_id:, **options)
|
973
|
+
path = interpolate_path("/accounts/{account_id}/notes/{account_note_id}", account_id: account_id, account_note_id: account_note_id)
|
974
|
+
get(path, **options)
|
975
|
+
end
|
976
|
+
|
977
|
+
# Fetch a list of an account's shipping addresses
|
978
|
+
#
|
979
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_shipping_addresses list_shipping_addresses api documentation}
|
980
|
+
#
|
981
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
982
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
983
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
984
|
+
#
|
985
|
+
# *Important notes:*
|
986
|
+
#
|
987
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
988
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
989
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
990
|
+
# results correspond to your request.
|
991
|
+
# * Records are returned in an arbitrary order. Since results are all
|
992
|
+
# returned at once you can sort the records yourself.
|
993
|
+
#
|
994
|
+
# @param limit [Integer] Limit number of records 1-200.
|
995
|
+
# @param order [String] Sort order.
|
996
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
997
|
+
# order. In descending order updated records will move behind the cursor and could
|
998
|
+
# prevent some records from being returned.
|
999
|
+
#
|
1000
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1001
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1002
|
+
#
|
1003
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1004
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1005
|
+
#
|
1006
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1007
|
+
#
|
1008
|
+
# @return [Pager<Resources::ShippingAddress>] A list of an account's shipping addresses.
|
1009
|
+
# @example
|
1010
|
+
# shipping_addresses = @client.list_shipping_addresses(
|
1011
|
+
# account_id: account_id,
|
1012
|
+
# limit: 200
|
1013
|
+
# )
|
1014
|
+
# shipping_addresses.each do |addr|
|
1015
|
+
# puts "ShippingAddress: #{addr.nickname} - #{addr.street1}"
|
1016
|
+
# end
|
1017
|
+
#
|
1018
|
+
def list_shipping_addresses(account_id:, **options)
|
1019
|
+
path = interpolate_path("/accounts/{account_id}/shipping_addresses", account_id: account_id)
|
1020
|
+
pager(path, **options)
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
# Create a new shipping address for the account
|
1024
|
+
#
|
1025
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_shipping_address create_shipping_address api documentation}
|
1026
|
+
#
|
1027
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
1028
|
+
# @param body [Requests::ShippingAddressCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingAddressCreate}
|
1029
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1030
|
+
#
|
1031
|
+
# @return [Resources::ShippingAddress] Returns the new shipping address.
|
1032
|
+
# @example
|
1033
|
+
# begin
|
1034
|
+
# shipping_address_create = {
|
1035
|
+
# nickname: 'Work',
|
1036
|
+
# street1: '900 Camp St',
|
1037
|
+
# city: 'New Orleans',
|
1038
|
+
# region: 'LA',
|
1039
|
+
# country: 'US',
|
1040
|
+
# postal_code: '70115',
|
1041
|
+
# first_name: 'Joanna',
|
1042
|
+
# last_name: 'Du Monde'
|
1043
|
+
# }
|
1044
|
+
# shipping_address = @client.create_shipping_address(account_id: account_id, body: shipping_address_create)
|
1045
|
+
# puts "Created Shipping Address #{shipping_address}"
|
1046
|
+
# rescue Recurly::Errors::NotFoundError
|
1047
|
+
# # If the resource was not found, you may want to alert the user or
|
1048
|
+
# # just return nil
|
1049
|
+
# puts "Resource Not Found"
|
1050
|
+
# end
|
1051
|
+
#
|
1052
|
+
def create_shipping_address(account_id:, body:, **options)
|
1053
|
+
path = interpolate_path("/accounts/{account_id}/shipping_addresses", account_id: account_id)
|
1054
|
+
post(path, body, Requests::ShippingAddressCreate, **options)
|
1055
|
+
end
|
1056
|
+
|
1057
|
+
# Fetch an account's shipping address
|
1058
|
+
#
|
1059
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_shipping_address get_shipping_address api documentation}
|
1060
|
+
#
|
1061
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
1062
|
+
# @param shipping_address_id [String] Shipping Address ID.
|
1063
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1064
|
+
#
|
1065
|
+
# @return [Resources::ShippingAddress] A shipping address.
|
1066
|
+
# @example
|
1067
|
+
# begin
|
1068
|
+
# address = @client.get_shipping_address(
|
1069
|
+
# account_id: account_id,
|
1070
|
+
# shipping_address_id: shipping_address_id
|
1071
|
+
# )
|
1072
|
+
# puts "Got ShippingAddress #{address}"
|
1073
|
+
# rescue Recurly::Errors::NotFoundError
|
1074
|
+
# # If the resource was not found, you may want to alert the user or
|
1075
|
+
# # just return nil
|
1076
|
+
# puts "Resource Not Found"
|
1077
|
+
# end
|
1078
|
+
#
|
1079
|
+
def get_shipping_address(account_id:, shipping_address_id:, **options)
|
1080
|
+
path = interpolate_path("/accounts/{account_id}/shipping_addresses/{shipping_address_id}", account_id: account_id, shipping_address_id: shipping_address_id)
|
1081
|
+
get(path, **options)
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
# Update an account's shipping address
|
1085
|
+
#
|
1086
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_shipping_address update_shipping_address api documentation}
|
1087
|
+
#
|
1088
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
1089
|
+
# @param shipping_address_id [String] Shipping Address ID.
|
1090
|
+
# @param body [Requests::ShippingAddressUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingAddressUpdate}
|
1091
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1092
|
+
#
|
1093
|
+
# @return [Resources::ShippingAddress] The updated shipping address.
|
1094
|
+
# @example
|
1095
|
+
# begin
|
1096
|
+
# address_update = {
|
1097
|
+
# first_name: "Aaron",
|
1098
|
+
# last_name: "Du Monde",
|
1099
|
+
# postal_code: "70130"
|
1100
|
+
# }
|
1101
|
+
# address = @client.update_shipping_address(
|
1102
|
+
# account_id: account_id,
|
1103
|
+
# shipping_address_id: shipping_address_id,
|
1104
|
+
# body: address_update
|
1105
|
+
# )
|
1106
|
+
# puts "Updated ShippingAddress #{address}"
|
1107
|
+
# rescue Recurly::Errors::ValidationError => e
|
1108
|
+
# # If the request was invalid, you may want to tell your user
|
1109
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
1110
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
1111
|
+
# end
|
1112
|
+
#
|
1113
|
+
def update_shipping_address(account_id:, shipping_address_id:, body:, **options)
|
1114
|
+
path = interpolate_path("/accounts/{account_id}/shipping_addresses/{shipping_address_id}", account_id: account_id, shipping_address_id: shipping_address_id)
|
1115
|
+
put(path, body, Requests::ShippingAddressUpdate, **options)
|
1116
|
+
end
|
1117
|
+
|
1118
|
+
# Remove an account's shipping address
|
1119
|
+
#
|
1120
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_shipping_address remove_shipping_address api documentation}
|
1121
|
+
#
|
1122
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
1123
|
+
# @param shipping_address_id [String] Shipping Address ID.
|
1124
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1125
|
+
#
|
1126
|
+
# @return [Resources::Empty] Shipping address deleted.
|
1127
|
+
# @example
|
1128
|
+
# begin
|
1129
|
+
# @client.remove_shipping_address(
|
1130
|
+
# account_id: account_id,
|
1131
|
+
# shipping_address_id: shipping_address_id
|
1132
|
+
# )
|
1133
|
+
# puts "Removed ShippingAddress #{shipping_address_id}"
|
1134
|
+
# rescue Recurly::Errors::NotFoundError
|
1135
|
+
# # If the resource was not found, you may want to alert the user or
|
1136
|
+
# # just return nil
|
1137
|
+
# puts "Resource Not Found"
|
1138
|
+
# end
|
1139
|
+
#
|
1140
|
+
def remove_shipping_address(account_id:, shipping_address_id:, **options)
|
1141
|
+
path = interpolate_path("/accounts/{account_id}/shipping_addresses/{shipping_address_id}", account_id: account_id, shipping_address_id: shipping_address_id)
|
1142
|
+
delete(path, **options)
|
1143
|
+
end
|
1144
|
+
|
1145
|
+
# List an account's subscriptions
|
1146
|
+
#
|
1147
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_account_subscriptions list_account_subscriptions api documentation}
|
1148
|
+
#
|
1149
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
1150
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1151
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1152
|
+
#
|
1153
|
+
# *Important notes:*
|
1154
|
+
#
|
1155
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1156
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1157
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1158
|
+
# results correspond to your request.
|
1159
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1160
|
+
# returned at once you can sort the records yourself.
|
1161
|
+
#
|
1162
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1163
|
+
# @param order [String] Sort order.
|
1164
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1165
|
+
# order. In descending order updated records will move behind the cursor and could
|
1166
|
+
# prevent some records from being returned.
|
1167
|
+
#
|
1168
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1169
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1170
|
+
#
|
1171
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1172
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1173
|
+
#
|
1174
|
+
# @param state [String] Filter by state.
|
1175
|
+
#
|
1176
|
+
# - When +state=active+, +state=canceled+, +state=expired+, or +state=future+, subscriptions with states that match the query and only those subscriptions will be returned.
|
1177
|
+
# - When +state=in_trial+, only subscriptions that have a trial_started_at date earlier than now and a trial_ends_at date later than now will be returned.
|
1178
|
+
# - When +state=live+, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.
|
1179
|
+
#
|
1180
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1181
|
+
#
|
1182
|
+
# @return [Pager<Resources::Subscription>] A list of the account's subscriptions.
|
1183
|
+
# @example
|
1184
|
+
# subscriptions = @client.list_account_subscriptions(
|
1185
|
+
# account_id: account_id,
|
1186
|
+
# limit: 200
|
1187
|
+
# )
|
1188
|
+
# subscriptions.each do |subscription|
|
1189
|
+
# puts "Subscription: #{subscription.uuid}"
|
1190
|
+
# end
|
1191
|
+
#
|
1192
|
+
def list_account_subscriptions(account_id:, **options)
|
1193
|
+
path = interpolate_path("/accounts/{account_id}/subscriptions", account_id: account_id)
|
1194
|
+
pager(path, **options)
|
1195
|
+
end
|
1196
|
+
|
1197
|
+
# List an account's transactions
|
1198
|
+
#
|
1199
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_account_transactions list_account_transactions api documentation}
|
1200
|
+
#
|
1201
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
1202
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1203
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1204
|
+
#
|
1205
|
+
# *Important notes:*
|
1206
|
+
#
|
1207
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1208
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1209
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1210
|
+
# results correspond to your request.
|
1211
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1212
|
+
# returned at once you can sort the records yourself.
|
1213
|
+
#
|
1214
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1215
|
+
# @param order [String] Sort order.
|
1216
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1217
|
+
# order. In descending order updated records will move behind the cursor and could
|
1218
|
+
# prevent some records from being returned.
|
1219
|
+
#
|
1220
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1221
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1222
|
+
#
|
1223
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1224
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1225
|
+
#
|
1226
|
+
# @param type [String] Filter by type field. The value +payment+ will return both +purchase+ and +capture+ transactions.
|
1227
|
+
# @param success [String] Filter by success field.
|
1228
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1229
|
+
#
|
1230
|
+
# @return [Pager<Resources::Transaction>] A list of the account's transactions.
|
1231
|
+
# @example
|
1232
|
+
# transactions = @client.list_account_transactions(
|
1233
|
+
# account_id: account_id,
|
1234
|
+
# limit: 200
|
1235
|
+
# )
|
1236
|
+
# transactions.each do |transaction|
|
1237
|
+
# puts "Transaction: #{transaction.uuid}"
|
1238
|
+
# end
|
1239
|
+
#
|
1240
|
+
def list_account_transactions(account_id:, **options)
|
1241
|
+
path = interpolate_path("/accounts/{account_id}/transactions", account_id: account_id)
|
1242
|
+
pager(path, **options)
|
1243
|
+
end
|
1244
|
+
|
1245
|
+
# List an account's child accounts
|
1246
|
+
#
|
1247
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_child_accounts list_child_accounts api documentation}
|
1248
|
+
#
|
1249
|
+
# @param account_id [String] Account ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-bob+.
|
1250
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1251
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1252
|
+
#
|
1253
|
+
# *Important notes:*
|
1254
|
+
#
|
1255
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1256
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1257
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1258
|
+
# results correspond to your request.
|
1259
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1260
|
+
# returned at once you can sort the records yourself.
|
1261
|
+
#
|
1262
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1263
|
+
# @param order [String] Sort order.
|
1264
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1265
|
+
# order. In descending order updated records will move behind the cursor and could
|
1266
|
+
# prevent some records from being returned.
|
1267
|
+
#
|
1268
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1269
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1270
|
+
#
|
1271
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1272
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1273
|
+
#
|
1274
|
+
# @param email [String] Filter for accounts with this exact email address. A blank value will return accounts with both +null+ and +""+ email addresses. Note that multiple accounts can share one email address.
|
1275
|
+
# @param subscriber [Boolean] Filter for accounts with or without a subscription in the +active+,
|
1276
|
+
# +canceled+, or +future+ state.
|
1277
|
+
#
|
1278
|
+
# @param past_due [String] Filter for accounts with an invoice in the +past_due+ state.
|
1279
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1280
|
+
#
|
1281
|
+
# @return [Pager<Resources::Account>] A list of an account's child accounts.
|
1282
|
+
# @example
|
1283
|
+
# child_accounts = @client.list_child_accounts(
|
1284
|
+
# account_id: account_id,
|
1285
|
+
# limit: 200
|
1286
|
+
# )
|
1287
|
+
# child_accounts.each do |child|
|
1288
|
+
# puts "Account: #{child.code}"
|
1289
|
+
# end
|
1290
|
+
#
|
1291
|
+
def list_child_accounts(account_id:, **options)
|
1292
|
+
path = interpolate_path("/accounts/{account_id}/accounts", account_id: account_id)
|
1293
|
+
pager(path, **options)
|
1294
|
+
end
|
1295
|
+
|
1296
|
+
# List a site's account acquisition data
|
1297
|
+
#
|
1298
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_account_acquisition list_account_acquisition api documentation}
|
1299
|
+
#
|
1300
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1301
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1302
|
+
#
|
1303
|
+
# *Important notes:*
|
1304
|
+
#
|
1305
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1306
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1307
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1308
|
+
# results correspond to your request.
|
1309
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1310
|
+
# returned at once you can sort the records yourself.
|
1311
|
+
#
|
1312
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1313
|
+
# @param order [String] Sort order.
|
1314
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1315
|
+
# order. In descending order updated records will move behind the cursor and could
|
1316
|
+
# prevent some records from being returned.
|
1317
|
+
#
|
1318
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1319
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1320
|
+
#
|
1321
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1322
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1323
|
+
#
|
1324
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1325
|
+
#
|
1326
|
+
# @return [Pager<Resources::AccountAcquisition>] A list of the site's account acquisition data.
|
1327
|
+
# @example
|
1328
|
+
# acquisitions = @client.list_account_acquisition(limit: 200)
|
1329
|
+
# acquisitions.each do |acquisition|
|
1330
|
+
# puts "AccountAcquisition: #{acquisition.cost}"
|
1331
|
+
# end
|
1332
|
+
#
|
1333
|
+
def list_account_acquisition(**options)
|
1334
|
+
path = interpolate_path("/acquisitions")
|
1335
|
+
pager(path, **options)
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
# List a site's coupons
|
1339
|
+
#
|
1340
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_coupons list_coupons api documentation}
|
1341
|
+
#
|
1342
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1343
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1344
|
+
#
|
1345
|
+
# *Important notes:*
|
1346
|
+
#
|
1347
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1348
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1349
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1350
|
+
# results correspond to your request.
|
1351
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1352
|
+
# returned at once you can sort the records yourself.
|
1353
|
+
#
|
1354
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1355
|
+
# @param order [String] Sort order.
|
1356
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1357
|
+
# order. In descending order updated records will move behind the cursor and could
|
1358
|
+
# prevent some records from being returned.
|
1359
|
+
#
|
1360
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1361
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1362
|
+
#
|
1363
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1364
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1365
|
+
#
|
1366
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1367
|
+
#
|
1368
|
+
# @return [Pager<Resources::Coupon>] A list of the site's coupons.
|
1369
|
+
# @example
|
1370
|
+
# coupons = @client.list_coupons(limit: 200)
|
1371
|
+
# coupons.each do |coupon|
|
1372
|
+
# puts "coupon: #{coupon.code}"
|
1373
|
+
# end
|
1374
|
+
#
|
1375
|
+
def list_coupons(**options)
|
1376
|
+
path = interpolate_path("/coupons")
|
1377
|
+
pager(path, **options)
|
1378
|
+
end
|
1379
|
+
|
1380
|
+
# Create a new coupon
|
1381
|
+
#
|
1382
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_coupon create_coupon api documentation}
|
1383
|
+
#
|
1384
|
+
# @param body [Requests::CouponCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponCreate}
|
1385
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1386
|
+
#
|
1387
|
+
# @return [Resources::Coupon] A new coupon.
|
1388
|
+
# @example
|
1389
|
+
# begin
|
1390
|
+
# coupon_create = {
|
1391
|
+
# name: "Promotional Coupon",
|
1392
|
+
# code: coupon_code,
|
1393
|
+
# discount_type: 'fixed',
|
1394
|
+
# currencies: [
|
1395
|
+
# {
|
1396
|
+
# currency: 'USD',
|
1397
|
+
# discount: 10_000
|
1398
|
+
# }
|
1399
|
+
# ]
|
1400
|
+
# }
|
1401
|
+
# coupon = @client.create_coupon(
|
1402
|
+
# body: coupon_create
|
1403
|
+
# )
|
1404
|
+
# puts "Created Coupon #{coupon}"
|
1405
|
+
# rescue Recurly::Errors::ValidationError => e
|
1406
|
+
# # If the request was invalid, you may want to tell your user
|
1407
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
1408
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
1409
|
+
# end
|
1410
|
+
#
|
1411
|
+
def create_coupon(body:, **options)
|
1412
|
+
path = interpolate_path("/coupons")
|
1413
|
+
post(path, body, Requests::CouponCreate, **options)
|
1414
|
+
end
|
1415
|
+
|
1416
|
+
# Fetch a coupon
|
1417
|
+
#
|
1418
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_coupon get_coupon api documentation}
|
1419
|
+
#
|
1420
|
+
# @param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-10off+.
|
1421
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1422
|
+
#
|
1423
|
+
# @return [Resources::Coupon] A coupon.
|
1424
|
+
# @example
|
1425
|
+
# begin
|
1426
|
+
# coupon = @client.get_coupon(coupon_id: coupon_id)
|
1427
|
+
# puts "Got Coupon #{coupon}"
|
1428
|
+
# rescue Recurly::Errors::NotFoundError
|
1429
|
+
# # If the resource was not found, you may want to alert the user or
|
1430
|
+
# # just return nil
|
1431
|
+
# puts "Resource Not Found"
|
1432
|
+
# end
|
1433
|
+
#
|
1434
|
+
def get_coupon(coupon_id:, **options)
|
1435
|
+
path = interpolate_path("/coupons/{coupon_id}", coupon_id: coupon_id)
|
1436
|
+
get(path, **options)
|
1437
|
+
end
|
1438
|
+
|
1439
|
+
# Update an active coupon
|
1440
|
+
#
|
1441
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_coupon update_coupon api documentation}
|
1442
|
+
#
|
1443
|
+
# @param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-10off+.
|
1444
|
+
# @param body [Requests::CouponUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponUpdate}
|
1445
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1446
|
+
#
|
1447
|
+
# @return [Resources::Coupon] The updated coupon.
|
1448
|
+
# @example
|
1449
|
+
# begin
|
1450
|
+
# coupon_update = {
|
1451
|
+
# name: "New Coupon Name"
|
1452
|
+
# }
|
1453
|
+
# coupon = @client.update_coupon(coupon_id: coupon_id, body: coupon_update)
|
1454
|
+
# puts "Updated Coupon #{coupon}"
|
1455
|
+
# rescue Recurly::Errors::NotFoundError
|
1456
|
+
# # If the resource was not found, you may want to alert the user or
|
1457
|
+
# # just return nil
|
1458
|
+
# puts "Resource Not Found"
|
1459
|
+
# end
|
1460
|
+
#
|
1461
|
+
def update_coupon(coupon_id:, body:, **options)
|
1462
|
+
path = interpolate_path("/coupons/{coupon_id}", coupon_id: coupon_id)
|
1463
|
+
put(path, body, Requests::CouponUpdate, **options)
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
# Expire a coupon
|
1467
|
+
#
|
1468
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/deactivate_coupon deactivate_coupon api documentation}
|
1469
|
+
#
|
1470
|
+
# @param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-10off+.
|
1471
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1472
|
+
#
|
1473
|
+
# @return [Resources::Coupon] The expired Coupon
|
1474
|
+
# @example
|
1475
|
+
# begin
|
1476
|
+
# coupon = @client.deactivate_coupon(coupon_id: coupon_id)
|
1477
|
+
# puts "Deactivated Coupon #{coupon}"
|
1478
|
+
# rescue Recurly::Errors::NotFoundError
|
1479
|
+
# # If the resource was not found, you may want to alert the user or
|
1480
|
+
# # just return nil
|
1481
|
+
# puts "Resource Not Found"
|
1482
|
+
# end
|
1483
|
+
#
|
1484
|
+
def deactivate_coupon(coupon_id:, **options)
|
1485
|
+
path = interpolate_path("/coupons/{coupon_id}", coupon_id: coupon_id)
|
1486
|
+
delete(path, **options)
|
1487
|
+
end
|
1488
|
+
|
1489
|
+
# Restore an inactive coupon
|
1490
|
+
#
|
1491
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/restore_coupon restore_coupon api documentation}
|
1492
|
+
#
|
1493
|
+
# @param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-10off+.
|
1494
|
+
# @param body [Requests::CouponUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponUpdate}
|
1495
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1496
|
+
#
|
1497
|
+
# @return [Resources::Coupon] The restored coupon.
|
1498
|
+
# @example
|
1499
|
+
# begin
|
1500
|
+
# coupon = @client.restore_coupon(coupon_id: coupon_id, body: {
|
1501
|
+
# name: "New Coupon Name"
|
1502
|
+
# })
|
1503
|
+
# puts "Restored coupon #{coupon}"
|
1504
|
+
# rescue Recurly::Errors::NotFoundError
|
1505
|
+
# # If the resource was not found, you may want to alert the user or
|
1506
|
+
# # just return nil
|
1507
|
+
# puts "Resource Not Found"
|
1508
|
+
# end
|
1509
|
+
#
|
1510
|
+
def restore_coupon(coupon_id:, body:, **options)
|
1511
|
+
path = interpolate_path("/coupons/{coupon_id}/restore", coupon_id: coupon_id)
|
1512
|
+
put(path, body, Requests::CouponUpdate, **options)
|
1513
|
+
end
|
1514
|
+
|
1515
|
+
# List unique coupon codes associated with a bulk coupon
|
1516
|
+
#
|
1517
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_unique_coupon_codes list_unique_coupon_codes api documentation}
|
1518
|
+
#
|
1519
|
+
# @param coupon_id [String] Coupon ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-10off+.
|
1520
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1521
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1522
|
+
#
|
1523
|
+
# *Important notes:*
|
1524
|
+
#
|
1525
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1526
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1527
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1528
|
+
# results correspond to your request.
|
1529
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1530
|
+
# returned at once you can sort the records yourself.
|
1531
|
+
#
|
1532
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1533
|
+
# @param order [String] Sort order.
|
1534
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1535
|
+
# order. In descending order updated records will move behind the cursor and could
|
1536
|
+
# prevent some records from being returned.
|
1537
|
+
#
|
1538
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1539
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1540
|
+
#
|
1541
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1542
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1543
|
+
#
|
1544
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1545
|
+
#
|
1546
|
+
# @return [Pager<Resources::UniqueCouponCode>] A list of unique coupon codes that were generated
|
1547
|
+
#
|
1548
|
+
def list_unique_coupon_codes(coupon_id:, **options)
|
1549
|
+
path = interpolate_path("/coupons/{coupon_id}/unique_coupon_codes", coupon_id: coupon_id)
|
1550
|
+
pager(path, **options)
|
1551
|
+
end
|
1552
|
+
|
1553
|
+
# List a site's credit payments
|
1554
|
+
#
|
1555
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_credit_payments list_credit_payments api documentation}
|
1556
|
+
#
|
1557
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1558
|
+
# @param order [String] Sort order.
|
1559
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1560
|
+
# order. In descending order updated records will move behind the cursor and could
|
1561
|
+
# prevent some records from being returned.
|
1562
|
+
#
|
1563
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1564
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1565
|
+
#
|
1566
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1567
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1568
|
+
#
|
1569
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1570
|
+
#
|
1571
|
+
# @return [Pager<Resources::CreditPayment>] A list of the site's credit payments.
|
1572
|
+
# @example
|
1573
|
+
# payments = @client.list_credit_payments(limit: 200)
|
1574
|
+
# payments.each do |payment|
|
1575
|
+
# puts "CreditPayment: #{payment.id}"
|
1576
|
+
# end
|
1577
|
+
#
|
1578
|
+
def list_credit_payments(**options)
|
1579
|
+
path = interpolate_path("/credit_payments")
|
1580
|
+
pager(path, **options)
|
1581
|
+
end
|
1582
|
+
|
1583
|
+
# Fetch a credit payment
|
1584
|
+
#
|
1585
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_credit_payment get_credit_payment api documentation}
|
1586
|
+
#
|
1587
|
+
# @param credit_payment_id [String] Credit Payment ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
1588
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1589
|
+
#
|
1590
|
+
# @return [Resources::CreditPayment] A credit payment.
|
1591
|
+
#
|
1592
|
+
def get_credit_payment(credit_payment_id:, **options)
|
1593
|
+
path = interpolate_path("/credit_payments/{credit_payment_id}", credit_payment_id: credit_payment_id)
|
1594
|
+
get(path, **options)
|
1595
|
+
end
|
1596
|
+
|
1597
|
+
# List a site's custom field definitions
|
1598
|
+
#
|
1599
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_custom_field_definitions list_custom_field_definitions api documentation}
|
1600
|
+
#
|
1601
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1602
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1603
|
+
#
|
1604
|
+
# *Important notes:*
|
1605
|
+
#
|
1606
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1607
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1608
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1609
|
+
# results correspond to your request.
|
1610
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1611
|
+
# returned at once you can sort the records yourself.
|
1612
|
+
#
|
1613
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1614
|
+
# @param order [String] Sort order.
|
1615
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1616
|
+
# order. In descending order updated records will move behind the cursor and could
|
1617
|
+
# prevent some records from being returned.
|
1618
|
+
#
|
1619
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1620
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1621
|
+
#
|
1622
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1623
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1624
|
+
#
|
1625
|
+
# @param related_type [String] Filter by related type.
|
1626
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1627
|
+
#
|
1628
|
+
# @return [Pager<Resources::CustomFieldDefinition>] A list of the site's custom field definitions.
|
1629
|
+
# @example
|
1630
|
+
# custom_fields = @client.list_custom_field_definitions(limit: 200)
|
1631
|
+
# custom_fields.each do |field|
|
1632
|
+
# puts "CustomFieldDefinition: #{field.name}"
|
1633
|
+
# end
|
1634
|
+
#
|
1635
|
+
def list_custom_field_definitions(**options)
|
1636
|
+
path = interpolate_path("/custom_field_definitions")
|
1637
|
+
pager(path, **options)
|
1638
|
+
end
|
1639
|
+
|
1640
|
+
# Fetch an custom field definition
|
1641
|
+
#
|
1642
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_custom_field_definition get_custom_field_definition api documentation}
|
1643
|
+
#
|
1644
|
+
# @param custom_field_definition_id [String] Custom Field Definition ID
|
1645
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1646
|
+
#
|
1647
|
+
# @return [Resources::CustomFieldDefinition] An custom field definition.
|
1648
|
+
# @example
|
1649
|
+
# begin
|
1650
|
+
# custom_field_definition = @client.get_custom_field_definition(
|
1651
|
+
# custom_field_definition_id: custom_field_definition_id
|
1652
|
+
# )
|
1653
|
+
# puts "Got Custom Field Definition #{custom_field_definition}"
|
1654
|
+
# rescue Recurly::Errors::NotFoundError
|
1655
|
+
# # If the resource was not found, you may want to alert the user or
|
1656
|
+
# # just return nil
|
1657
|
+
# puts "Resource Not Found"
|
1658
|
+
# end
|
1659
|
+
#
|
1660
|
+
def get_custom_field_definition(custom_field_definition_id:, **options)
|
1661
|
+
path = interpolate_path("/custom_field_definitions/{custom_field_definition_id}", custom_field_definition_id: custom_field_definition_id)
|
1662
|
+
get(path, **options)
|
1663
|
+
end
|
1664
|
+
|
1665
|
+
# List a site's items
|
1666
|
+
#
|
1667
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_items list_items api documentation}
|
1668
|
+
#
|
1669
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1670
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1671
|
+
#
|
1672
|
+
# *Important notes:*
|
1673
|
+
#
|
1674
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1675
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1676
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1677
|
+
# results correspond to your request.
|
1678
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1679
|
+
# returned at once you can sort the records yourself.
|
1680
|
+
#
|
1681
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1682
|
+
# @param order [String] Sort order.
|
1683
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1684
|
+
# order. In descending order updated records will move behind the cursor and could
|
1685
|
+
# prevent some records from being returned.
|
1686
|
+
#
|
1687
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1688
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1689
|
+
#
|
1690
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1691
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1692
|
+
#
|
1693
|
+
# @param state [String] Filter by state.
|
1694
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1695
|
+
#
|
1696
|
+
# @return [Pager<Resources::Item>] A list of the site's items.
|
1697
|
+
# @example
|
1698
|
+
# items = @client.list_items(limit: 200)
|
1699
|
+
# items.each do |item|
|
1700
|
+
# puts "Item: #{item.code}"
|
1701
|
+
# end
|
1702
|
+
#
|
1703
|
+
def list_items(**options)
|
1704
|
+
path = interpolate_path("/items")
|
1705
|
+
pager(path, **options)
|
1706
|
+
end
|
1707
|
+
|
1708
|
+
# Create a new item
|
1709
|
+
#
|
1710
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_item create_item api documentation}
|
1711
|
+
#
|
1712
|
+
# @param body [Requests::ItemCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ItemCreate}
|
1713
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1714
|
+
#
|
1715
|
+
# @return [Resources::Item] A new item.
|
1716
|
+
# @example
|
1717
|
+
# begin
|
1718
|
+
# item_create = {
|
1719
|
+
# code: item_code,
|
1720
|
+
# name: "Item Name",
|
1721
|
+
# description: "Item Description",
|
1722
|
+
# external_sku: "a35JE-44",
|
1723
|
+
# accounting_code: "item-code-127",
|
1724
|
+
# revenue_schedule_type: "at_range_end",
|
1725
|
+
# custom_fields: [{
|
1726
|
+
# name: "custom-field-1",
|
1727
|
+
# value: "Custom Field 1 value"
|
1728
|
+
# }]
|
1729
|
+
# }
|
1730
|
+
# item = @client.create_item(body: item_create)
|
1731
|
+
# puts "Created Item #{item}"
|
1732
|
+
# rescue Recurly::Errors::ValidationError => e
|
1733
|
+
# # If the request was invalid, you may want to tell your user
|
1734
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
1735
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
1736
|
+
# end
|
1737
|
+
#
|
1738
|
+
def create_item(body:, **options)
|
1739
|
+
path = interpolate_path("/items")
|
1740
|
+
post(path, body, Requests::ItemCreate, **options)
|
1741
|
+
end
|
1742
|
+
|
1743
|
+
# Fetch an item
|
1744
|
+
#
|
1745
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_item get_item api documentation}
|
1746
|
+
#
|
1747
|
+
# @param item_id [String] Item ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-red+.
|
1748
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1749
|
+
#
|
1750
|
+
# @return [Resources::Item] An item.
|
1751
|
+
# @example
|
1752
|
+
# begin
|
1753
|
+
# item = @client.get_item(item_id: item_id)
|
1754
|
+
# puts "Got Item #{item}"
|
1755
|
+
# rescue Recurly::Errors::NotFoundError
|
1756
|
+
# # If the resource was not found, you may want to alert the user or
|
1757
|
+
# # just return nil
|
1758
|
+
# puts "Resource Not Found"
|
1759
|
+
# end
|
1760
|
+
#
|
1761
|
+
def get_item(item_id:, **options)
|
1762
|
+
path = interpolate_path("/items/{item_id}", item_id: item_id)
|
1763
|
+
get(path, **options)
|
1764
|
+
end
|
1765
|
+
|
1766
|
+
# Update an active item
|
1767
|
+
#
|
1768
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_item update_item api documentation}
|
1769
|
+
#
|
1770
|
+
# @param item_id [String] Item ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-red+.
|
1771
|
+
# @param body [Requests::ItemUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ItemUpdate}
|
1772
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1773
|
+
#
|
1774
|
+
# @return [Resources::Item] The updated item.
|
1775
|
+
# @example
|
1776
|
+
# begin
|
1777
|
+
# item_update = {
|
1778
|
+
# name: "New Item Name",
|
1779
|
+
# description: "New Item Description"
|
1780
|
+
# }
|
1781
|
+
# item = @client.update_item(
|
1782
|
+
# item_id: item_id,
|
1783
|
+
# body: item_update
|
1784
|
+
# )
|
1785
|
+
# puts "Updated Item #{item}"
|
1786
|
+
# rescue Recurly::Errors::ValidationError => e
|
1787
|
+
# # If the request was invalid, you may want to tell your user
|
1788
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
1789
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
1790
|
+
# end
|
1791
|
+
#
|
1792
|
+
def update_item(item_id:, body:, **options)
|
1793
|
+
path = interpolate_path("/items/{item_id}", item_id: item_id)
|
1794
|
+
put(path, body, Requests::ItemUpdate, **options)
|
1795
|
+
end
|
1796
|
+
|
1797
|
+
# Deactivate an item
|
1798
|
+
#
|
1799
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/deactivate_item deactivate_item api documentation}
|
1800
|
+
#
|
1801
|
+
# @param item_id [String] Item ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-red+.
|
1802
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1803
|
+
#
|
1804
|
+
# @return [Resources::Item] An item.
|
1805
|
+
# @example
|
1806
|
+
# begin
|
1807
|
+
# item = @client.deactivate_item(item_id: item_id)
|
1808
|
+
# puts "Deactivated Item #{item}"
|
1809
|
+
# rescue Recurly::Errors::NotFoundError
|
1810
|
+
# # If the resource was not found, you may want to alert the user or
|
1811
|
+
# # just return nil
|
1812
|
+
# puts "Resource Not Found"
|
1813
|
+
# end
|
1814
|
+
#
|
1815
|
+
def deactivate_item(item_id:, **options)
|
1816
|
+
path = interpolate_path("/items/{item_id}", item_id: item_id)
|
1817
|
+
delete(path, **options)
|
1818
|
+
end
|
1819
|
+
|
1820
|
+
# Reactivate an inactive item
|
1821
|
+
#
|
1822
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/reactivate_item reactivate_item api documentation}
|
1823
|
+
#
|
1824
|
+
# @param item_id [String] Item ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-red+.
|
1825
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1826
|
+
#
|
1827
|
+
# @return [Resources::Item] An item.
|
1828
|
+
# @example
|
1829
|
+
# begin
|
1830
|
+
# item = @client.reactivate_item(item_id: item_id)
|
1831
|
+
# puts "Reactivated Item #{item}"
|
1832
|
+
# rescue Recurly::Errors::NotFoundError
|
1833
|
+
# # If the resource was not found, you may want to alert the user or
|
1834
|
+
# # just return nil
|
1835
|
+
# puts "Resource Not Found"
|
1836
|
+
# end
|
1837
|
+
#
|
1838
|
+
def reactivate_item(item_id:, **options)
|
1839
|
+
path = interpolate_path("/items/{item_id}/reactivate", item_id: item_id)
|
1840
|
+
put(path, **options)
|
1841
|
+
end
|
1842
|
+
|
1843
|
+
# List a site's measured units
|
1844
|
+
#
|
1845
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_measured_unit list_measured_unit api documentation}
|
1846
|
+
#
|
1847
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1848
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1849
|
+
#
|
1850
|
+
# *Important notes:*
|
1851
|
+
#
|
1852
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1853
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1854
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1855
|
+
# results correspond to your request.
|
1856
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1857
|
+
# returned at once you can sort the records yourself.
|
1858
|
+
#
|
1859
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1860
|
+
# @param order [String] Sort order.
|
1861
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1862
|
+
# order. In descending order updated records will move behind the cursor and could
|
1863
|
+
# prevent some records from being returned.
|
1864
|
+
#
|
1865
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1866
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1867
|
+
#
|
1868
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1869
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1870
|
+
#
|
1871
|
+
# @param state [String] Filter by state.
|
1872
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1873
|
+
#
|
1874
|
+
# @return [Pager<Resources::MeasuredUnit>] A list of the site's measured units.
|
1875
|
+
#
|
1876
|
+
def list_measured_unit(**options)
|
1877
|
+
path = interpolate_path("/measured_units")
|
1878
|
+
pager(path, **options)
|
1879
|
+
end
|
1880
|
+
|
1881
|
+
# Create a new measured unit
|
1882
|
+
#
|
1883
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_measured_unit create_measured_unit api documentation}
|
1884
|
+
#
|
1885
|
+
# @param body [Requests::MeasuredUnitCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::MeasuredUnitCreate}
|
1886
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1887
|
+
#
|
1888
|
+
# @return [Resources::MeasuredUnit] A new measured unit.
|
1889
|
+
#
|
1890
|
+
def create_measured_unit(body:, **options)
|
1891
|
+
path = interpolate_path("/measured_units")
|
1892
|
+
post(path, body, Requests::MeasuredUnitCreate, **options)
|
1893
|
+
end
|
1894
|
+
|
1895
|
+
# Fetch a measured unit
|
1896
|
+
#
|
1897
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_measured_unit get_measured_unit api documentation}
|
1898
|
+
#
|
1899
|
+
# @param measured_unit_id [String] Measured unit ID or name. For ID no prefix is used e.g. +e28zov4fw0v2+. For name use prefix +name-+, e.g. +name-Storage+.
|
1900
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1901
|
+
#
|
1902
|
+
# @return [Resources::MeasuredUnit] An item.
|
1903
|
+
#
|
1904
|
+
def get_measured_unit(measured_unit_id:, **options)
|
1905
|
+
path = interpolate_path("/measured_units/{measured_unit_id}", measured_unit_id: measured_unit_id)
|
1906
|
+
get(path, **options)
|
1907
|
+
end
|
1908
|
+
|
1909
|
+
# Update a measured unit
|
1910
|
+
#
|
1911
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_measured_unit update_measured_unit api documentation}
|
1912
|
+
#
|
1913
|
+
# @param measured_unit_id [String] Measured unit ID or name. For ID no prefix is used e.g. +e28zov4fw0v2+. For name use prefix +name-+, e.g. +name-Storage+.
|
1914
|
+
# @param body [Requests::MeasuredUnitUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::MeasuredUnitUpdate}
|
1915
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1916
|
+
#
|
1917
|
+
# @return [Resources::MeasuredUnit] The updated measured_unit.
|
1918
|
+
#
|
1919
|
+
def update_measured_unit(measured_unit_id:, body:, **options)
|
1920
|
+
path = interpolate_path("/measured_units/{measured_unit_id}", measured_unit_id: measured_unit_id)
|
1921
|
+
put(path, body, Requests::MeasuredUnitUpdate, **options)
|
1922
|
+
end
|
1923
|
+
|
1924
|
+
# Remove a measured unit
|
1925
|
+
#
|
1926
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_measured_unit remove_measured_unit api documentation}
|
1927
|
+
#
|
1928
|
+
# @param measured_unit_id [String] Measured unit ID or name. For ID no prefix is used e.g. +e28zov4fw0v2+. For name use prefix +name-+, e.g. +name-Storage+.
|
1929
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1930
|
+
#
|
1931
|
+
# @return [Resources::MeasuredUnit] A measured unit.
|
1932
|
+
#
|
1933
|
+
def remove_measured_unit(measured_unit_id:, **options)
|
1934
|
+
path = interpolate_path("/measured_units/{measured_unit_id}", measured_unit_id: measured_unit_id)
|
1935
|
+
delete(path, **options)
|
1936
|
+
end
|
1937
|
+
|
1938
|
+
# List a site's invoices
|
1939
|
+
#
|
1940
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_invoices list_invoices api documentation}
|
1941
|
+
#
|
1942
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
1943
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
1944
|
+
#
|
1945
|
+
# *Important notes:*
|
1946
|
+
#
|
1947
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
1948
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
1949
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
1950
|
+
# results correspond to your request.
|
1951
|
+
# * Records are returned in an arbitrary order. Since results are all
|
1952
|
+
# returned at once you can sort the records yourself.
|
1953
|
+
#
|
1954
|
+
# @param limit [Integer] Limit number of records 1-200.
|
1955
|
+
# @param order [String] Sort order.
|
1956
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
1957
|
+
# order. In descending order updated records will move behind the cursor and could
|
1958
|
+
# prevent some records from being returned.
|
1959
|
+
#
|
1960
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
1961
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1962
|
+
#
|
1963
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
1964
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
1965
|
+
#
|
1966
|
+
# @param type [String] Filter by type when:
|
1967
|
+
# - +type=charge+, only charge invoices will be returned.
|
1968
|
+
# - +type=credit+, only credit invoices will be returned.
|
1969
|
+
# - +type=non-legacy+, only charge and credit invoices will be returned.
|
1970
|
+
# - +type=legacy+, only legacy invoices will be returned.
|
1971
|
+
#
|
1972
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1973
|
+
#
|
1974
|
+
# @return [Pager<Resources::Invoice>] A list of the site's invoices.
|
1975
|
+
# @example
|
1976
|
+
# invoices = @client.list_invoices(limit: 200)
|
1977
|
+
# invoices.each do |invoice|
|
1978
|
+
# puts "Invoice: #{invoice.number}"
|
1979
|
+
# end
|
1980
|
+
#
|
1981
|
+
def list_invoices(**options)
|
1982
|
+
path = interpolate_path("/invoices")
|
1983
|
+
pager(path, **options)
|
1984
|
+
end
|
1985
|
+
|
1986
|
+
# Fetch an invoice
|
1987
|
+
#
|
1988
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_invoice get_invoice api documentation}
|
1989
|
+
#
|
1990
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
1991
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
1992
|
+
#
|
1993
|
+
# @return [Resources::Invoice] An invoice.
|
1994
|
+
# @example
|
1995
|
+
# begin
|
1996
|
+
# invoice = @client.get_invoice(invoice_id: invoice_id)
|
1997
|
+
# puts "Got invoice #{invoice}"
|
1998
|
+
# rescue Recurly::Errors::NotFoundError
|
1999
|
+
# # If the resource was not found, you may want to alert the user or
|
2000
|
+
# # just return nil
|
2001
|
+
# puts "Resource Not Found"
|
2002
|
+
# end
|
2003
|
+
#
|
2004
|
+
def get_invoice(invoice_id:, **options)
|
2005
|
+
path = interpolate_path("/invoices/{invoice_id}", invoice_id: invoice_id)
|
2006
|
+
get(path, **options)
|
2007
|
+
end
|
2008
|
+
|
2009
|
+
# Update an invoice
|
2010
|
+
#
|
2011
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/put_invoice put_invoice api documentation}
|
2012
|
+
#
|
2013
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2014
|
+
# @param body [Requests::InvoiceUpdatable] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceUpdatable}
|
2015
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2016
|
+
#
|
2017
|
+
# @return [Resources::Invoice] An invoice.
|
2018
|
+
# @example
|
2019
|
+
# begin
|
2020
|
+
# invoice_update = {
|
2021
|
+
# customer_notes: "New Notes",
|
2022
|
+
# terms_and_conditions: "New Terms and Conditions"
|
2023
|
+
# }
|
2024
|
+
# invoice = @client.put_invoice(invoice_id: invoice_id, body: invoice_update)
|
2025
|
+
# puts "Updated invoice #{invoice}"
|
2026
|
+
# rescue Recurly::Errors::NotFoundError
|
2027
|
+
# # If the resource was not found, you may want to alert the user or
|
2028
|
+
# # just return nil
|
2029
|
+
# puts "Resource Not Found"
|
2030
|
+
# end
|
2031
|
+
#
|
2032
|
+
def put_invoice(invoice_id:, body:, **options)
|
2033
|
+
path = interpolate_path("/invoices/{invoice_id}", invoice_id: invoice_id)
|
2034
|
+
put(path, body, Requests::InvoiceUpdatable, **options)
|
2035
|
+
end
|
2036
|
+
|
2037
|
+
# Fetch an invoice as a PDF
|
2038
|
+
#
|
2039
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_invoice_pdf get_invoice_pdf api documentation}
|
2040
|
+
#
|
2041
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2042
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2043
|
+
#
|
2044
|
+
# @return [Resources::BinaryFile] An invoice as a PDF.
|
2045
|
+
# @example
|
2046
|
+
# begin
|
2047
|
+
# invoice = @client.get_invoice_pdf(invoice_id: invoice_id)
|
2048
|
+
# puts "Got invoice #{invoice}"
|
2049
|
+
# filename = "#{download_directory}/rubyinvoice-#{invoice_id}.pdf"
|
2050
|
+
# IO.write(filename, invoice.data)
|
2051
|
+
# puts "Saved Invoice PDF to #{filename}"
|
2052
|
+
# rescue Recurly::Errors::NotFoundError
|
2053
|
+
# # If the resource was not found, you may want to alert the user or
|
2054
|
+
# # just return nil
|
2055
|
+
# puts "Resource Not Found"
|
2056
|
+
# end
|
2057
|
+
#
|
2058
|
+
def get_invoice_pdf(invoice_id:, **options)
|
2059
|
+
path = interpolate_path("/invoices/{invoice_id}.pdf", invoice_id: invoice_id)
|
2060
|
+
get(path, **options)
|
2061
|
+
end
|
2062
|
+
|
2063
|
+
# Apply available credit to a pending or past due charge invoice
|
2064
|
+
#
|
2065
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/apply_credit_balance apply_credit_balance api documentation}
|
2066
|
+
#
|
2067
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2068
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2069
|
+
#
|
2070
|
+
# @return [Resources::Invoice] The updated invoice.
|
2071
|
+
#
|
2072
|
+
def apply_credit_balance(invoice_id:, **options)
|
2073
|
+
path = interpolate_path("/invoices/{invoice_id}/apply_credit_balance", invoice_id: invoice_id)
|
2074
|
+
put(path, **options)
|
2075
|
+
end
|
2076
|
+
|
2077
|
+
# Collect a pending or past due, automatic invoice
|
2078
|
+
#
|
2079
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/collect_invoice collect_invoice api documentation}
|
2080
|
+
#
|
2081
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2082
|
+
# @param body [Requests::InvoiceCollect] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceCollect}
|
2083
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2084
|
+
#
|
2085
|
+
# @return [Resources::Invoice] The updated invoice.
|
2086
|
+
# @example
|
2087
|
+
# begin
|
2088
|
+
# invoice = @client.collect_invoice(invoice_id: invoice_id)
|
2089
|
+
# puts "Collected invoice #{invoice}"
|
2090
|
+
# rescue Recurly::Errors::NotFoundError
|
2091
|
+
# # If the resource was not found, you may want to alert the user or
|
2092
|
+
# # just return nil
|
2093
|
+
# puts "Resource Not Found"
|
2094
|
+
# end
|
2095
|
+
#
|
2096
|
+
def collect_invoice(invoice_id:, **options)
|
2097
|
+
path = interpolate_path("/invoices/{invoice_id}/collect", invoice_id: invoice_id)
|
2098
|
+
put(path, options[:body], Requests::InvoiceCollect, **options)
|
2099
|
+
end
|
2100
|
+
|
2101
|
+
# Mark an open invoice as failed
|
2102
|
+
#
|
2103
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/fail_invoice fail_invoice api documentation}
|
2104
|
+
#
|
2105
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2106
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2107
|
+
#
|
2108
|
+
# @return [Resources::Invoice] The updated invoice.
|
2109
|
+
# @example
|
2110
|
+
# begin
|
2111
|
+
# invoice = @client.fail_invoice(invoice_id: invoice_id)
|
2112
|
+
# puts "Failed invoice #{invoice}"
|
2113
|
+
# rescue Recurly::Errors::NotFoundError
|
2114
|
+
# # If the resource was not found, you may want to alert the user or
|
2115
|
+
# # just return nil
|
2116
|
+
# puts "Resource Not Found"
|
2117
|
+
# end
|
2118
|
+
#
|
2119
|
+
def fail_invoice(invoice_id:, **options)
|
2120
|
+
path = interpolate_path("/invoices/{invoice_id}/mark_failed", invoice_id: invoice_id)
|
2121
|
+
put(path, **options)
|
2122
|
+
end
|
2123
|
+
|
2124
|
+
# Mark an open invoice as successful
|
2125
|
+
#
|
2126
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/mark_invoice_successful mark_invoice_successful api documentation}
|
2127
|
+
#
|
2128
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2129
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2130
|
+
#
|
2131
|
+
# @return [Resources::Invoice] The updated invoice.
|
2132
|
+
# @example
|
2133
|
+
# begin
|
2134
|
+
# invoice = @client.mark_invoice_successful(invoice_id: invoice_id)
|
2135
|
+
# puts "Marked invoice sucessful #{invoice}"
|
2136
|
+
# rescue Recurly::Errors::NotFoundError
|
2137
|
+
# # If the resource was not found, you may want to alert the user or
|
2138
|
+
# # just return nil
|
2139
|
+
# puts "Resource Not Found"
|
2140
|
+
# end
|
2141
|
+
#
|
2142
|
+
def mark_invoice_successful(invoice_id:, **options)
|
2143
|
+
path = interpolate_path("/invoices/{invoice_id}/mark_successful", invoice_id: invoice_id)
|
2144
|
+
put(path, **options)
|
2145
|
+
end
|
2146
|
+
|
2147
|
+
# Reopen a closed, manual invoice
|
2148
|
+
#
|
2149
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/reopen_invoice reopen_invoice api documentation}
|
2150
|
+
#
|
2151
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2152
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2153
|
+
#
|
2154
|
+
# @return [Resources::Invoice] The updated invoice.
|
2155
|
+
# @example
|
2156
|
+
# begin
|
2157
|
+
# invoice = @client.reopen_invoice(invoice_id: invoice_id)
|
2158
|
+
# puts "Reopened invoice #{invoice}"
|
2159
|
+
# rescue Recurly::Errors::NotFoundError
|
2160
|
+
# # If the resource was not found, you may want to alert the user or
|
2161
|
+
# # just return nil
|
2162
|
+
# puts "Resource Not Found"
|
2163
|
+
# end
|
2164
|
+
#
|
2165
|
+
def reopen_invoice(invoice_id:, **options)
|
2166
|
+
path = interpolate_path("/invoices/{invoice_id}/reopen", invoice_id: invoice_id)
|
2167
|
+
put(path, **options)
|
2168
|
+
end
|
2169
|
+
|
2170
|
+
# Void a credit invoice.
|
2171
|
+
#
|
2172
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/void_invoice void_invoice api documentation}
|
2173
|
+
#
|
2174
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2175
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2176
|
+
#
|
2177
|
+
# @return [Resources::Invoice] The updated invoice.
|
2178
|
+
# @example
|
2179
|
+
# begin
|
2180
|
+
# invoice = @client.void_invoice(invoice_id: invoice_id)
|
2181
|
+
# puts "Voided invoice #{invoice}"
|
2182
|
+
# rescue Recurly::Errors::NotFoundError
|
2183
|
+
# # If the resource was not found, you may want to alert the user or
|
2184
|
+
# # just return nil
|
2185
|
+
# puts "Resource Not Found"
|
2186
|
+
# end
|
2187
|
+
#
|
2188
|
+
def void_invoice(invoice_id:, **options)
|
2189
|
+
path = interpolate_path("/invoices/{invoice_id}/void", invoice_id: invoice_id)
|
2190
|
+
put(path, **options)
|
2191
|
+
end
|
2192
|
+
|
2193
|
+
# Record an external payment for a manual invoices.
|
2194
|
+
#
|
2195
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/record_external_transaction record_external_transaction api documentation}
|
2196
|
+
#
|
2197
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2198
|
+
# @param body [Requests::ExternalTransaction] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ExternalTransaction}
|
2199
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2200
|
+
#
|
2201
|
+
# @return [Resources::Transaction] The recorded transaction.
|
2202
|
+
#
|
2203
|
+
def record_external_transaction(invoice_id:, body:, **options)
|
2204
|
+
path = interpolate_path("/invoices/{invoice_id}/transactions", invoice_id: invoice_id)
|
2205
|
+
post(path, body, Requests::ExternalTransaction, **options)
|
2206
|
+
end
|
2207
|
+
|
2208
|
+
# List an invoice's line items
|
2209
|
+
#
|
2210
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_invoice_line_items list_invoice_line_items api documentation}
|
2211
|
+
#
|
2212
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2213
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
2214
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
2215
|
+
#
|
2216
|
+
# *Important notes:*
|
2217
|
+
#
|
2218
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
2219
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
2220
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
2221
|
+
# results correspond to your request.
|
2222
|
+
# * Records are returned in an arbitrary order. Since results are all
|
2223
|
+
# returned at once you can sort the records yourself.
|
2224
|
+
#
|
2225
|
+
# @param limit [Integer] Limit number of records 1-200.
|
2226
|
+
# @param order [String] Sort order.
|
2227
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
2228
|
+
# order. In descending order updated records will move behind the cursor and could
|
2229
|
+
# prevent some records from being returned.
|
2230
|
+
#
|
2231
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
2232
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2233
|
+
#
|
2234
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
2235
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2236
|
+
#
|
2237
|
+
# @param original [String] Filter by original field.
|
2238
|
+
# @param state [String] Filter by state field.
|
2239
|
+
# @param type [String] Filter by type field.
|
2240
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2241
|
+
#
|
2242
|
+
# @return [Pager<Resources::LineItem>] A list of the invoice's line items.
|
2243
|
+
# @example
|
2244
|
+
# line_items = @client.list_invoice_line_items(
|
2245
|
+
# invoice_id: invoice_id,
|
2246
|
+
# limit: 200
|
2247
|
+
# )
|
2248
|
+
# line_items.each do |line_item|
|
2249
|
+
# puts "Line Item: #{line_item.id}"
|
2250
|
+
# end
|
2251
|
+
#
|
2252
|
+
def list_invoice_line_items(invoice_id:, **options)
|
2253
|
+
path = interpolate_path("/invoices/{invoice_id}/line_items", invoice_id: invoice_id)
|
2254
|
+
pager(path, **options)
|
2255
|
+
end
|
2256
|
+
|
2257
|
+
# List the coupon redemptions applied to an invoice
|
2258
|
+
#
|
2259
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_invoice_coupon_redemptions list_invoice_coupon_redemptions api documentation}
|
2260
|
+
#
|
2261
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2262
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
2263
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
2264
|
+
#
|
2265
|
+
# *Important notes:*
|
2266
|
+
#
|
2267
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
2268
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
2269
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
2270
|
+
# results correspond to your request.
|
2271
|
+
# * Records are returned in an arbitrary order. Since results are all
|
2272
|
+
# returned at once you can sort the records yourself.
|
2273
|
+
#
|
2274
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
2275
|
+
# order. In descending order updated records will move behind the cursor and could
|
2276
|
+
# prevent some records from being returned.
|
2277
|
+
#
|
2278
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
2279
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2280
|
+
#
|
2281
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
2282
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2283
|
+
#
|
2284
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2285
|
+
#
|
2286
|
+
# @return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions associated with the invoice.
|
2287
|
+
# @example
|
2288
|
+
# coupon_redemptions = @client.list_invoice_coupon_redemptions(
|
2289
|
+
# invoice_id: invoice_id,
|
2290
|
+
# limit: 200
|
2291
|
+
# )
|
2292
|
+
# coupon_redemptions.each do |redemption|
|
2293
|
+
# puts "CouponRedemption: #{redemption.id}"
|
2294
|
+
# end
|
2295
|
+
#
|
2296
|
+
def list_invoice_coupon_redemptions(invoice_id:, **options)
|
2297
|
+
path = interpolate_path("/invoices/{invoice_id}/coupon_redemptions", invoice_id: invoice_id)
|
2298
|
+
pager(path, **options)
|
2299
|
+
end
|
2300
|
+
|
2301
|
+
# List an invoice's related credit or charge invoices
|
2302
|
+
#
|
2303
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_related_invoices list_related_invoices api documentation}
|
2304
|
+
#
|
2305
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2306
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2307
|
+
#
|
2308
|
+
# @return [Pager<Resources::Invoice>] A list of the credit or charge invoices associated with the invoice.
|
2309
|
+
# @example
|
2310
|
+
# invoices = @client.list_related_invoices(
|
2311
|
+
# invoice_id: invoice_id,
|
2312
|
+
# limit: 200
|
2313
|
+
# )
|
2314
|
+
# invoices.each do |invoice|
|
2315
|
+
# puts "Invoice: #{invoice.number}"
|
2316
|
+
# end
|
2317
|
+
#
|
2318
|
+
def list_related_invoices(invoice_id:, **options)
|
2319
|
+
path = interpolate_path("/invoices/{invoice_id}/related_invoices", invoice_id: invoice_id)
|
2320
|
+
pager(path, **options)
|
2321
|
+
end
|
2322
|
+
|
2323
|
+
# Refund an invoice
|
2324
|
+
#
|
2325
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/refund_invoice refund_invoice api documentation}
|
2326
|
+
#
|
2327
|
+
# @param invoice_id [String] Invoice ID or number. For ID no prefix is used e.g. +e28zov4fw0v2+. For number use prefix +number-+, e.g. +number-1000+.
|
2328
|
+
# @param body [Requests::InvoiceRefund] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceRefund}
|
2329
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2330
|
+
#
|
2331
|
+
# @return [Resources::Invoice] Returns the new credit invoice.
|
2332
|
+
# @example
|
2333
|
+
# begin
|
2334
|
+
# invoice_refund = {
|
2335
|
+
# type: "amount",
|
2336
|
+
# amount: 100,
|
2337
|
+
# }
|
2338
|
+
# invoice = @client.refund_invoice(
|
2339
|
+
# invoice_id: invoice_id,
|
2340
|
+
# body: invoice_refund
|
2341
|
+
# )
|
2342
|
+
# puts "Refunded invoice #{invoice}"
|
2343
|
+
# rescue Recurly::Errors::ValidationError => e
|
2344
|
+
# # If the request was invalid, you may want to tell your user
|
2345
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
2346
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
2347
|
+
# end
|
2348
|
+
#
|
2349
|
+
def refund_invoice(invoice_id:, body:, **options)
|
2350
|
+
path = interpolate_path("/invoices/{invoice_id}/refund", invoice_id: invoice_id)
|
2351
|
+
post(path, body, Requests::InvoiceRefund, **options)
|
2352
|
+
end
|
2353
|
+
|
2354
|
+
# List a site's line items
|
2355
|
+
#
|
2356
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_line_items list_line_items api documentation}
|
2357
|
+
#
|
2358
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
2359
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
2360
|
+
#
|
2361
|
+
# *Important notes:*
|
2362
|
+
#
|
2363
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
2364
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
2365
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
2366
|
+
# results correspond to your request.
|
2367
|
+
# * Records are returned in an arbitrary order. Since results are all
|
2368
|
+
# returned at once you can sort the records yourself.
|
2369
|
+
#
|
2370
|
+
# @param limit [Integer] Limit number of records 1-200.
|
2371
|
+
# @param order [String] Sort order.
|
2372
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
2373
|
+
# order. In descending order updated records will move behind the cursor and could
|
2374
|
+
# prevent some records from being returned.
|
2375
|
+
#
|
2376
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
2377
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2378
|
+
#
|
2379
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
2380
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2381
|
+
#
|
2382
|
+
# @param original [String] Filter by original field.
|
2383
|
+
# @param state [String] Filter by state field.
|
2384
|
+
# @param type [String] Filter by type field.
|
2385
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2386
|
+
#
|
2387
|
+
# @return [Pager<Resources::LineItem>] A list of the site's line items.
|
2388
|
+
# @example
|
2389
|
+
# line_items = @client.list_line_items(
|
2390
|
+
# limit: 200
|
2391
|
+
# )
|
2392
|
+
# line_items.each do |line_item|
|
2393
|
+
# puts "LineItem: #{line_item.id}"
|
2394
|
+
# end
|
2395
|
+
#
|
2396
|
+
def list_line_items(**options)
|
2397
|
+
path = interpolate_path("/line_items")
|
2398
|
+
pager(path, **options)
|
2399
|
+
end
|
2400
|
+
|
2401
|
+
# Fetch a line item
|
2402
|
+
#
|
2403
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_line_item get_line_item api documentation}
|
2404
|
+
#
|
2405
|
+
# @param line_item_id [String] Line Item ID.
|
2406
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2407
|
+
#
|
2408
|
+
# @return [Resources::LineItem] A line item.
|
2409
|
+
# @example
|
2410
|
+
# begin
|
2411
|
+
# line_item = @client.get_line_item(line_item_id: line_item_id)
|
2412
|
+
# puts "Got LineItem #{line_item}"
|
2413
|
+
# rescue Recurly::Errors::NotFoundError
|
2414
|
+
# # If the resource was not found, you may want to alert the user or
|
2415
|
+
# # just return nil
|
2416
|
+
# puts "Resource Not Found"
|
2417
|
+
# end
|
2418
|
+
#
|
2419
|
+
def get_line_item(line_item_id:, **options)
|
2420
|
+
path = interpolate_path("/line_items/{line_item_id}", line_item_id: line_item_id)
|
2421
|
+
get(path, **options)
|
2422
|
+
end
|
2423
|
+
|
2424
|
+
# Delete an uninvoiced line item
|
2425
|
+
#
|
2426
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_line_item remove_line_item api documentation}
|
2427
|
+
#
|
2428
|
+
# @param line_item_id [String] Line Item ID.
|
2429
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2430
|
+
#
|
2431
|
+
# @return [Resources::Empty] Line item deleted.
|
2432
|
+
# @example
|
2433
|
+
# begin
|
2434
|
+
# @client.remove_line_item(
|
2435
|
+
# line_item_id: line_item_id
|
2436
|
+
# )
|
2437
|
+
# puts "Removed LineItem #{line_item_id}"
|
2438
|
+
# rescue Recurly::Errors::NotFoundError
|
2439
|
+
# # If the resource was not found, you may want to alert the user or
|
2440
|
+
# # just return nil
|
2441
|
+
# puts "Resource Not Found"
|
2442
|
+
# end
|
2443
|
+
#
|
2444
|
+
def remove_line_item(line_item_id:, **options)
|
2445
|
+
path = interpolate_path("/line_items/{line_item_id}", line_item_id: line_item_id)
|
2446
|
+
delete(path, **options)
|
2447
|
+
end
|
2448
|
+
|
2449
|
+
# List a site's plans
|
2450
|
+
#
|
2451
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_plans list_plans api documentation}
|
2452
|
+
#
|
2453
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
2454
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
2455
|
+
#
|
2456
|
+
# *Important notes:*
|
2457
|
+
#
|
2458
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
2459
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
2460
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
2461
|
+
# results correspond to your request.
|
2462
|
+
# * Records are returned in an arbitrary order. Since results are all
|
2463
|
+
# returned at once you can sort the records yourself.
|
2464
|
+
#
|
2465
|
+
# @param limit [Integer] Limit number of records 1-200.
|
2466
|
+
# @param order [String] Sort order.
|
2467
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
2468
|
+
# order. In descending order updated records will move behind the cursor and could
|
2469
|
+
# prevent some records from being returned.
|
2470
|
+
#
|
2471
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
2472
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2473
|
+
#
|
2474
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
2475
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2476
|
+
#
|
2477
|
+
# @param state [String] Filter by state.
|
2478
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2479
|
+
#
|
2480
|
+
# @return [Pager<Resources::Plan>] A list of plans.
|
2481
|
+
# @example
|
2482
|
+
# plans = @client.list_plans(limit: 200)
|
2483
|
+
# plans.each do |plan|
|
2484
|
+
# puts "Plan: #{plan.code}"
|
2485
|
+
# end
|
2486
|
+
#
|
2487
|
+
def list_plans(**options)
|
2488
|
+
path = interpolate_path("/plans")
|
2489
|
+
pager(path, **options)
|
2490
|
+
end
|
2491
|
+
|
2492
|
+
# Create a plan
|
2493
|
+
#
|
2494
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_plan create_plan api documentation}
|
2495
|
+
#
|
2496
|
+
# @param body [Requests::PlanCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PlanCreate}
|
2497
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2498
|
+
#
|
2499
|
+
# @return [Resources::Plan] A plan.
|
2500
|
+
# @example
|
2501
|
+
# begin
|
2502
|
+
# plan_create = {
|
2503
|
+
# code: plan_code,
|
2504
|
+
# name: plan_name,
|
2505
|
+
# currencies: [
|
2506
|
+
# currency: "USD",
|
2507
|
+
# setup_fee: 1_000
|
2508
|
+
# ],
|
2509
|
+
# add_ons: [
|
2510
|
+
# {
|
2511
|
+
# name: 'Extra User',
|
2512
|
+
# code: 'extra_user',
|
2513
|
+
# currencies: [
|
2514
|
+
# { currency: 'USD', unit_amount: 10_000 }
|
2515
|
+
# ]
|
2516
|
+
# }
|
2517
|
+
# ]
|
2518
|
+
# }
|
2519
|
+
# plan = @client.create_plan(body: plan_create)
|
2520
|
+
# puts "Created Plan #{plan}"
|
2521
|
+
# rescue Recurly::Errors::ValidationError => e
|
2522
|
+
# # If the request was invalid, you may want to tell your user
|
2523
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
2524
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
2525
|
+
# end
|
2526
|
+
#
|
2527
|
+
def create_plan(body:, **options)
|
2528
|
+
path = interpolate_path("/plans")
|
2529
|
+
post(path, body, Requests::PlanCreate, **options)
|
2530
|
+
end
|
2531
|
+
|
2532
|
+
# Fetch a plan
|
2533
|
+
#
|
2534
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_plan get_plan api documentation}
|
2535
|
+
#
|
2536
|
+
# @param plan_id [String] Plan ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2537
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2538
|
+
#
|
2539
|
+
# @return [Resources::Plan] A plan.
|
2540
|
+
# @example
|
2541
|
+
# begin
|
2542
|
+
# plan = @client.get_plan(plan_id: plan_id)
|
2543
|
+
# puts "Got plan #{plan}"
|
2544
|
+
# rescue Recurly::Errors::NotFoundError
|
2545
|
+
# # If the resource was not found, you may want to alert the user or
|
2546
|
+
# # just return nil
|
2547
|
+
# puts "Resource Not Found"
|
2548
|
+
# end
|
2549
|
+
#
|
2550
|
+
def get_plan(plan_id:, **options)
|
2551
|
+
path = interpolate_path("/plans/{plan_id}", plan_id: plan_id)
|
2552
|
+
get(path, **options)
|
2553
|
+
end
|
2554
|
+
|
2555
|
+
# Update a plan
|
2556
|
+
#
|
2557
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_plan update_plan api documentation}
|
2558
|
+
#
|
2559
|
+
# @param plan_id [String] Plan ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2560
|
+
# @param body [Requests::PlanUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PlanUpdate}
|
2561
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2562
|
+
#
|
2563
|
+
# @return [Resources::Plan] A plan.
|
2564
|
+
# @example
|
2565
|
+
# begin
|
2566
|
+
# plan_update = {
|
2567
|
+
# name: "Monthly Kombucha Subscription"
|
2568
|
+
# }
|
2569
|
+
# plan = @client.update_plan(plan_id: plan_id, body: plan_update)
|
2570
|
+
# puts "Updated plan #{plan}"
|
2571
|
+
# rescue Recurly::Errors::NotFoundError
|
2572
|
+
# # If the resource was not found, you may want to alert the user or
|
2573
|
+
# # just return nil
|
2574
|
+
# puts "Resource Not Found"
|
2575
|
+
# end
|
2576
|
+
#
|
2577
|
+
def update_plan(plan_id:, body:, **options)
|
2578
|
+
path = interpolate_path("/plans/{plan_id}", plan_id: plan_id)
|
2579
|
+
put(path, body, Requests::PlanUpdate, **options)
|
2580
|
+
end
|
2581
|
+
|
2582
|
+
# Remove a plan
|
2583
|
+
#
|
2584
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_plan remove_plan api documentation}
|
2585
|
+
#
|
2586
|
+
# @param plan_id [String] Plan ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2587
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2588
|
+
#
|
2589
|
+
# @return [Resources::Plan] Plan deleted
|
2590
|
+
# @example
|
2591
|
+
# begin
|
2592
|
+
# plan = @client.remove_plan(plan_id: plan_id)
|
2593
|
+
# puts "Removed plan #{plan}"
|
2594
|
+
# rescue Recurly::Errors::NotFoundError
|
2595
|
+
# # If the resource was not found, you may want to alert the user or
|
2596
|
+
# # just return nil
|
2597
|
+
# puts "Resource Not Found"
|
2598
|
+
# end
|
2599
|
+
#
|
2600
|
+
def remove_plan(plan_id:, **options)
|
2601
|
+
path = interpolate_path("/plans/{plan_id}", plan_id: plan_id)
|
2602
|
+
delete(path, **options)
|
2603
|
+
end
|
2604
|
+
|
2605
|
+
# List a plan's add-ons
|
2606
|
+
#
|
2607
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_plan_add_ons list_plan_add_ons api documentation}
|
2608
|
+
#
|
2609
|
+
# @param plan_id [String] Plan ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2610
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
2611
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
2612
|
+
#
|
2613
|
+
# *Important notes:*
|
2614
|
+
#
|
2615
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
2616
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
2617
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
2618
|
+
# results correspond to your request.
|
2619
|
+
# * Records are returned in an arbitrary order. Since results are all
|
2620
|
+
# returned at once you can sort the records yourself.
|
2621
|
+
#
|
2622
|
+
# @param limit [Integer] Limit number of records 1-200.
|
2623
|
+
# @param order [String] Sort order.
|
2624
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
2625
|
+
# order. In descending order updated records will move behind the cursor and could
|
2626
|
+
# prevent some records from being returned.
|
2627
|
+
#
|
2628
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
2629
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2630
|
+
#
|
2631
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
2632
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2633
|
+
#
|
2634
|
+
# @param state [String] Filter by state.
|
2635
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2636
|
+
#
|
2637
|
+
# @return [Pager<Resources::AddOn>] A list of add-ons.
|
2638
|
+
# @example
|
2639
|
+
# add_ons = @client.list_plan_add_ons(
|
2640
|
+
# plan_id: plan_id,
|
2641
|
+
# limit: 200
|
2642
|
+
# )
|
2643
|
+
# add_ons.each do |add_on|
|
2644
|
+
# puts "AddOn: #{add_on.code}"
|
2645
|
+
# end
|
2646
|
+
#
|
2647
|
+
def list_plan_add_ons(plan_id:, **options)
|
2648
|
+
path = interpolate_path("/plans/{plan_id}/add_ons", plan_id: plan_id)
|
2649
|
+
pager(path, **options)
|
2650
|
+
end
|
2651
|
+
|
2652
|
+
# Create an add-on
|
2653
|
+
#
|
2654
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_plan_add_on create_plan_add_on api documentation}
|
2655
|
+
#
|
2656
|
+
# @param plan_id [String] Plan ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2657
|
+
# @param body [Requests::AddOnCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AddOnCreate}
|
2658
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2659
|
+
#
|
2660
|
+
# @return [Resources::AddOn] An add-on.
|
2661
|
+
# @example
|
2662
|
+
# begin
|
2663
|
+
# new_add_on = {
|
2664
|
+
# code: 'coffee_grinder',
|
2665
|
+
# name: 'A quality grinder for your beans',
|
2666
|
+
# default_quantity: 1,
|
2667
|
+
# currencies: [
|
2668
|
+
# {
|
2669
|
+
# currency: 'USD',
|
2670
|
+
# unit_amount: 10_000
|
2671
|
+
# }
|
2672
|
+
# ]
|
2673
|
+
# }
|
2674
|
+
# add_on = @client.create_plan_add_on(plan_id: plan_id, body: new_add_on)
|
2675
|
+
# puts "Created plan add-on #{add_on}"
|
2676
|
+
# rescue Recurly::Errors::NotFoundError
|
2677
|
+
# # If the resource was not found, you may want to alert the user or
|
2678
|
+
# # just return nil
|
2679
|
+
# puts "Resource Not Found"
|
2680
|
+
# end
|
2681
|
+
#
|
2682
|
+
def create_plan_add_on(plan_id:, body:, **options)
|
2683
|
+
path = interpolate_path("/plans/{plan_id}/add_ons", plan_id: plan_id)
|
2684
|
+
post(path, body, Requests::AddOnCreate, **options)
|
2685
|
+
end
|
2686
|
+
|
2687
|
+
# Fetch a plan's add-on
|
2688
|
+
#
|
2689
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_plan_add_on get_plan_add_on api documentation}
|
2690
|
+
#
|
2691
|
+
# @param plan_id [String] Plan ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2692
|
+
# @param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2693
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2694
|
+
#
|
2695
|
+
# @return [Resources::AddOn] An add-on.
|
2696
|
+
# @example
|
2697
|
+
# begin
|
2698
|
+
# add_on = @client.get_plan_add_on(
|
2699
|
+
# plan_id: plan_id, add_on_id: add_on_id
|
2700
|
+
# )
|
2701
|
+
# puts "Got plan add-on #{add_on}"
|
2702
|
+
# rescue Recurly::Errors::NotFoundError
|
2703
|
+
# # If the resource was not found, you may want to alert the user or
|
2704
|
+
# # just return nil
|
2705
|
+
# puts "Resource Not Found"
|
2706
|
+
# end
|
2707
|
+
#
|
2708
|
+
def get_plan_add_on(plan_id:, add_on_id:, **options)
|
2709
|
+
path = interpolate_path("/plans/{plan_id}/add_ons/{add_on_id}", plan_id: plan_id, add_on_id: add_on_id)
|
2710
|
+
get(path, **options)
|
2711
|
+
end
|
2712
|
+
|
2713
|
+
# Update an add-on
|
2714
|
+
#
|
2715
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_plan_add_on update_plan_add_on api documentation}
|
2716
|
+
#
|
2717
|
+
# @param plan_id [String] Plan ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2718
|
+
# @param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2719
|
+
# @param body [Requests::AddOnUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AddOnUpdate}
|
2720
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2721
|
+
#
|
2722
|
+
# @return [Resources::AddOn] An add-on.
|
2723
|
+
# @example
|
2724
|
+
# begin
|
2725
|
+
# add_on_update = {
|
2726
|
+
# name: "A quality grinder for your finest beans"
|
2727
|
+
# }
|
2728
|
+
# add_on = @client.update_plan_add_on(
|
2729
|
+
# plan_id: plan_id,
|
2730
|
+
# add_on_id: add_on_id,
|
2731
|
+
# body: add_on_update
|
2732
|
+
# )
|
2733
|
+
# puts "Updated add-on #{add_on}"
|
2734
|
+
# rescue Recurly::Errors::NotFoundError
|
2735
|
+
# # If the resource was not found, you may want to alert the user or
|
2736
|
+
# # just return nil
|
2737
|
+
# puts "Resource Not Found"
|
2738
|
+
# end
|
2739
|
+
#
|
2740
|
+
def update_plan_add_on(plan_id:, add_on_id:, body:, **options)
|
2741
|
+
path = interpolate_path("/plans/{plan_id}/add_ons/{add_on_id}", plan_id: plan_id, add_on_id: add_on_id)
|
2742
|
+
put(path, body, Requests::AddOnUpdate, **options)
|
2743
|
+
end
|
2744
|
+
|
2745
|
+
# Remove an add-on
|
2746
|
+
#
|
2747
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_plan_add_on remove_plan_add_on api documentation}
|
2748
|
+
#
|
2749
|
+
# @param plan_id [String] Plan ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2750
|
+
# @param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2751
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2752
|
+
#
|
2753
|
+
# @return [Resources::AddOn] Add-on deleted
|
2754
|
+
# @example
|
2755
|
+
# begin
|
2756
|
+
# add_on = @client.remove_plan_add_on(
|
2757
|
+
# plan_id: plan_id,
|
2758
|
+
# add_on_id: add_on_id
|
2759
|
+
# )
|
2760
|
+
# puts "Removed add-on #{add_on}"
|
2761
|
+
# rescue Recurly::Errors::NotFoundError
|
2762
|
+
# # If the resource was not found, you may want to alert the user or
|
2763
|
+
# # just return nil
|
2764
|
+
# puts "Resource Not Found"
|
2765
|
+
# end
|
2766
|
+
#
|
2767
|
+
def remove_plan_add_on(plan_id:, add_on_id:, **options)
|
2768
|
+
path = interpolate_path("/plans/{plan_id}/add_ons/{add_on_id}", plan_id: plan_id, add_on_id: add_on_id)
|
2769
|
+
delete(path, **options)
|
2770
|
+
end
|
2771
|
+
|
2772
|
+
# List a site's add-ons
|
2773
|
+
#
|
2774
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_add_ons list_add_ons api documentation}
|
2775
|
+
#
|
2776
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
2777
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
2778
|
+
#
|
2779
|
+
# *Important notes:*
|
2780
|
+
#
|
2781
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
2782
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
2783
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
2784
|
+
# results correspond to your request.
|
2785
|
+
# * Records are returned in an arbitrary order. Since results are all
|
2786
|
+
# returned at once you can sort the records yourself.
|
2787
|
+
#
|
2788
|
+
# @param limit [Integer] Limit number of records 1-200.
|
2789
|
+
# @param order [String] Sort order.
|
2790
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
2791
|
+
# order. In descending order updated records will move behind the cursor and could
|
2792
|
+
# prevent some records from being returned.
|
2793
|
+
#
|
2794
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
2795
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2796
|
+
#
|
2797
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
2798
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2799
|
+
#
|
2800
|
+
# @param state [String] Filter by state.
|
2801
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2802
|
+
#
|
2803
|
+
# @return [Pager<Resources::AddOn>] A list of add-ons.
|
2804
|
+
# @example
|
2805
|
+
# add_ons = @client.list_add_ons(
|
2806
|
+
# limit: 200
|
2807
|
+
# )
|
2808
|
+
# add_ons.each do |add_on|
|
2809
|
+
# puts "AddOn: #{add_on.code}"
|
2810
|
+
# end
|
2811
|
+
#
|
2812
|
+
def list_add_ons(**options)
|
2813
|
+
path = interpolate_path("/add_ons")
|
2814
|
+
pager(path, **options)
|
2815
|
+
end
|
2816
|
+
|
2817
|
+
# Fetch an add-on
|
2818
|
+
#
|
2819
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_add_on get_add_on api documentation}
|
2820
|
+
#
|
2821
|
+
# @param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
2822
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2823
|
+
#
|
2824
|
+
# @return [Resources::AddOn] An add-on.
|
2825
|
+
# @example
|
2826
|
+
# begin
|
2827
|
+
# add_on = @client.get_add_on(add_on_id: add_on_id)
|
2828
|
+
# puts "Got add-on #{add_on}"
|
2829
|
+
# rescue Recurly::Errors::NotFoundError
|
2830
|
+
# # If the resource was not found, you may want to alert the user or
|
2831
|
+
# # just return nil
|
2832
|
+
# puts "Resource Not Found"
|
2833
|
+
# end
|
2834
|
+
#
|
2835
|
+
def get_add_on(add_on_id:, **options)
|
2836
|
+
path = interpolate_path("/add_ons/{add_on_id}", add_on_id: add_on_id)
|
2837
|
+
get(path, **options)
|
2838
|
+
end
|
2839
|
+
|
2840
|
+
# List a site's shipping methods
|
2841
|
+
#
|
2842
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_shipping_methods list_shipping_methods api documentation}
|
2843
|
+
#
|
2844
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
2845
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
2846
|
+
#
|
2847
|
+
# *Important notes:*
|
2848
|
+
#
|
2849
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
2850
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
2851
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
2852
|
+
# results correspond to your request.
|
2853
|
+
# * Records are returned in an arbitrary order. Since results are all
|
2854
|
+
# returned at once you can sort the records yourself.
|
2855
|
+
#
|
2856
|
+
# @param limit [Integer] Limit number of records 1-200.
|
2857
|
+
# @param order [String] Sort order.
|
2858
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
2859
|
+
# order. In descending order updated records will move behind the cursor and could
|
2860
|
+
# prevent some records from being returned.
|
2861
|
+
#
|
2862
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
2863
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2864
|
+
#
|
2865
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
2866
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2867
|
+
#
|
2868
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2869
|
+
#
|
2870
|
+
# @return [Pager<Resources::ShippingMethod>] A list of the site's shipping methods.
|
2871
|
+
# @example
|
2872
|
+
# shipping_methods = @client.list_shipping_methods(
|
2873
|
+
# limit: 200
|
2874
|
+
# )
|
2875
|
+
# shipping_methods.each do |shipping_method|
|
2876
|
+
# puts "Shipping Method: #{shipping_method.code}"
|
2877
|
+
# end
|
2878
|
+
#
|
2879
|
+
def list_shipping_methods(**options)
|
2880
|
+
path = interpolate_path("/shipping_methods")
|
2881
|
+
pager(path, **options)
|
2882
|
+
end
|
2883
|
+
|
2884
|
+
# Create a new shipping method
|
2885
|
+
#
|
2886
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_shipping_method create_shipping_method api documentation}
|
2887
|
+
#
|
2888
|
+
# @param body [Requests::ShippingMethodCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingMethodCreate}
|
2889
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2890
|
+
#
|
2891
|
+
# @return [Resources::ShippingMethod] A new shipping method.
|
2892
|
+
#
|
2893
|
+
def create_shipping_method(body:, **options)
|
2894
|
+
path = interpolate_path("/shipping_methods")
|
2895
|
+
post(path, body, Requests::ShippingMethodCreate, **options)
|
2896
|
+
end
|
2897
|
+
|
2898
|
+
# Fetch a shipping method
|
2899
|
+
#
|
2900
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_shipping_method get_shipping_method api documentation}
|
2901
|
+
#
|
2902
|
+
# @param id [String] Shipping Method ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-usps_2-day+.
|
2903
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2904
|
+
#
|
2905
|
+
# @return [Resources::ShippingMethod] A shipping method.
|
2906
|
+
#
|
2907
|
+
def get_shipping_method(id:, **options)
|
2908
|
+
path = interpolate_path("/shipping_methods/{id}", id: id)
|
2909
|
+
get(path, **options)
|
2910
|
+
end
|
2911
|
+
|
2912
|
+
# Update an active Shipping Method
|
2913
|
+
#
|
2914
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_shipping_method update_shipping_method api documentation}
|
2915
|
+
#
|
2916
|
+
# @param shipping_method_id [String] Shipping Method ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-usps_2-day+.
|
2917
|
+
# @param body [Requests::ShippingMethodUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingMethodUpdate}
|
2918
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2919
|
+
#
|
2920
|
+
# @return [Resources::ShippingMethod] The updated shipping method.
|
2921
|
+
#
|
2922
|
+
def update_shipping_method(shipping_method_id:, body:, **options)
|
2923
|
+
path = interpolate_path("/shipping_methods/{shipping_method_id}", shipping_method_id: shipping_method_id)
|
2924
|
+
put(path, body, Requests::ShippingMethodUpdate, **options)
|
2925
|
+
end
|
2926
|
+
|
2927
|
+
# Deactivate a shipping method
|
2928
|
+
#
|
2929
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/deactivate_shipping_method deactivate_shipping_method api documentation}
|
2930
|
+
#
|
2931
|
+
# @param shipping_method_id [String] Shipping Method ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-usps_2-day+.
|
2932
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2933
|
+
#
|
2934
|
+
# @return [Resources::ShippingMethod] A shipping method.
|
2935
|
+
#
|
2936
|
+
def deactivate_shipping_method(shipping_method_id:, **options)
|
2937
|
+
path = interpolate_path("/shipping_methods/{shipping_method_id}", shipping_method_id: shipping_method_id)
|
2938
|
+
delete(path, **options)
|
2939
|
+
end
|
2940
|
+
|
2941
|
+
# List a site's subscriptions
|
2942
|
+
#
|
2943
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_subscriptions list_subscriptions api documentation}
|
2944
|
+
#
|
2945
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
2946
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
2947
|
+
#
|
2948
|
+
# *Important notes:*
|
2949
|
+
#
|
2950
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
2951
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
2952
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
2953
|
+
# results correspond to your request.
|
2954
|
+
# * Records are returned in an arbitrary order. Since results are all
|
2955
|
+
# returned at once you can sort the records yourself.
|
2956
|
+
#
|
2957
|
+
# @param limit [Integer] Limit number of records 1-200.
|
2958
|
+
# @param order [String] Sort order.
|
2959
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
2960
|
+
# order. In descending order updated records will move behind the cursor and could
|
2961
|
+
# prevent some records from being returned.
|
2962
|
+
#
|
2963
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
2964
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2965
|
+
#
|
2966
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
2967
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
2968
|
+
#
|
2969
|
+
# @param state [String] Filter by state.
|
2970
|
+
#
|
2971
|
+
# - When +state=active+, +state=canceled+, +state=expired+, or +state=future+, subscriptions with states that match the query and only those subscriptions will be returned.
|
2972
|
+
# - When +state=in_trial+, only subscriptions that have a trial_started_at date earlier than now and a trial_ends_at date later than now will be returned.
|
2973
|
+
# - When +state=live+, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.
|
2974
|
+
#
|
2975
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2976
|
+
#
|
2977
|
+
# @return [Pager<Resources::Subscription>] A list of the site's subscriptions.
|
2978
|
+
# @example
|
2979
|
+
# subscriptions = @client.list_subscriptions(limit: 200)
|
2980
|
+
# subscriptions.each do |subscription|
|
2981
|
+
# puts "Subscription: #{subscription.uuid}"
|
2982
|
+
# end
|
2983
|
+
#
|
2984
|
+
def list_subscriptions(**options)
|
2985
|
+
path = interpolate_path("/subscriptions")
|
2986
|
+
pager(path, **options)
|
2987
|
+
end
|
2988
|
+
|
2989
|
+
# Create a new subscription
|
2990
|
+
#
|
2991
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_subscription create_subscription api documentation}
|
2992
|
+
#
|
2993
|
+
# @param body [Requests::SubscriptionCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionCreate}
|
2994
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
2995
|
+
#
|
2996
|
+
# @return [Resources::Subscription] A subscription.
|
2997
|
+
# @example
|
2998
|
+
# begin
|
2999
|
+
# subscription_create = {
|
3000
|
+
# plan_code: plan_code,
|
3001
|
+
# currency: "USD",
|
3002
|
+
# # This can be an existing account or a new account
|
3003
|
+
# account: {
|
3004
|
+
# code: account_code,
|
3005
|
+
# }
|
3006
|
+
# }
|
3007
|
+
# subscription = @client.create_subscription(
|
3008
|
+
# body: subscription_create
|
3009
|
+
# )
|
3010
|
+
# puts "Created Subscription #{subscription}"
|
3011
|
+
# rescue Recurly::Errors::ValidationError => e
|
3012
|
+
# # If the request was invalid, you may want to tell your user
|
3013
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
3014
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
3015
|
+
# end
|
3016
|
+
#
|
3017
|
+
def create_subscription(body:, **options)
|
3018
|
+
path = interpolate_path("/subscriptions")
|
3019
|
+
post(path, body, Requests::SubscriptionCreate, **options)
|
3020
|
+
end
|
3021
|
+
|
3022
|
+
# Fetch a subscription
|
3023
|
+
#
|
3024
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_subscription get_subscription api documentation}
|
3025
|
+
#
|
3026
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3027
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3028
|
+
#
|
3029
|
+
# @return [Resources::Subscription] A subscription.
|
3030
|
+
# @example
|
3031
|
+
# begin
|
3032
|
+
# subscription = @client.get_subscription(
|
3033
|
+
# subscription_id: subscription_id
|
3034
|
+
# )
|
3035
|
+
# puts "Got Subscription #{subscription}"
|
3036
|
+
# rescue Recurly::Errors::NotFoundError
|
3037
|
+
# # If the resource was not found, you may want to alert the user or
|
3038
|
+
# # just return nil
|
3039
|
+
# puts "Resource Not Found"
|
3040
|
+
# end
|
3041
|
+
#
|
3042
|
+
def get_subscription(subscription_id:, **options)
|
3043
|
+
path = interpolate_path("/subscriptions/{subscription_id}", subscription_id: subscription_id)
|
3044
|
+
get(path, **options)
|
3045
|
+
end
|
3046
|
+
|
3047
|
+
# Modify a subscription
|
3048
|
+
#
|
3049
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/modify_subscription modify_subscription api documentation}
|
3050
|
+
#
|
3051
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3052
|
+
# @param body [Requests::SubscriptionUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionUpdate}
|
3053
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3054
|
+
#
|
3055
|
+
# @return [Resources::Subscription] A subscription.
|
3056
|
+
# @example
|
3057
|
+
# begin
|
3058
|
+
# subscription_update = {
|
3059
|
+
# customer_notes: "New Notes",
|
3060
|
+
# terms_and_conditions: "New ToC"
|
3061
|
+
# }
|
3062
|
+
# subscription = @client.modify_subscription(
|
3063
|
+
# subscription_id: subscription_id,
|
3064
|
+
# body: subscription_update
|
3065
|
+
# )
|
3066
|
+
# puts "Modified Subscription #{subscription}"
|
3067
|
+
# rescue Recurly::Errors::ValidationError => e
|
3068
|
+
# # If the request was invalid, you may want to tell your user
|
3069
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
3070
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
3071
|
+
# end
|
3072
|
+
#
|
3073
|
+
def modify_subscription(subscription_id:, body:, **options)
|
3074
|
+
path = interpolate_path("/subscriptions/{subscription_id}", subscription_id: subscription_id)
|
3075
|
+
put(path, body, Requests::SubscriptionUpdate, **options)
|
3076
|
+
end
|
3077
|
+
|
3078
|
+
# Terminate a subscription
|
3079
|
+
#
|
3080
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/terminate_subscription terminate_subscription api documentation}
|
3081
|
+
#
|
3082
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3083
|
+
# @param refund [String] The type of refund to perform:
|
3084
|
+
#
|
3085
|
+
# * +full+ - Performs a full refund of the last invoice for the current subscription term.
|
3086
|
+
# * +partial+ - Prorates a refund based on the amount of time remaining in the current bill cycle.
|
3087
|
+
# * +none+ - Terminates the subscription without a refund.
|
3088
|
+
#
|
3089
|
+
# In the event that the most recent invoice is a $0 invoice paid entirely by credit, Recurly will apply the credit back to the customer’s account.
|
3090
|
+
#
|
3091
|
+
# You may also terminate a subscription with no refund and then manually refund specific invoices.
|
3092
|
+
#
|
3093
|
+
# @param charge [Boolean] Applicable only if the subscription has usage based add-ons and unbilled usage logged for the current billing cycle. If true, current billing cycle unbilled usage is billed on the final invoice. If false, Recurly will create a negative usage record for current billing cycle usage that will zero out the final invoice line items.
|
3094
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3095
|
+
#
|
3096
|
+
# @return [Resources::Subscription] An expired subscription.
|
3097
|
+
# @example
|
3098
|
+
# begin
|
3099
|
+
# subscription = @client.terminate_subscription(
|
3100
|
+
# subscription_id: subscription_id,
|
3101
|
+
# )
|
3102
|
+
# puts "Terminated Subscription #{subscription}"
|
3103
|
+
# rescue Recurly::Errors::NotFoundError
|
3104
|
+
# # If the resource was not found, you may want to alert the user or
|
3105
|
+
# # just return nil
|
3106
|
+
# puts "Resource Not Found"
|
3107
|
+
# end
|
3108
|
+
#
|
3109
|
+
def terminate_subscription(subscription_id:, **options)
|
3110
|
+
path = interpolate_path("/subscriptions/{subscription_id}", subscription_id: subscription_id)
|
3111
|
+
delete(path, **options)
|
3112
|
+
end
|
3113
|
+
|
3114
|
+
# Cancel a subscription
|
3115
|
+
#
|
3116
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/cancel_subscription cancel_subscription api documentation}
|
3117
|
+
#
|
3118
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3119
|
+
# @param body [Requests::SubscriptionCancel] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionCancel}
|
3120
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3121
|
+
#
|
3122
|
+
# @return [Resources::Subscription] A canceled or failed subscription.
|
3123
|
+
# @example
|
3124
|
+
# begin
|
3125
|
+
# subscription = @client.cancel_subscription(
|
3126
|
+
# subscription_id: subscription_id
|
3127
|
+
# )
|
3128
|
+
# puts "Canceled Subscription #{subscription}"
|
3129
|
+
# rescue Recurly::Errors::NotFoundError
|
3130
|
+
# # If the resource was not found, you may want to alert the user or
|
3131
|
+
# # just return nil
|
3132
|
+
# puts "Resource Not Found"
|
3133
|
+
# end
|
3134
|
+
#
|
3135
|
+
def cancel_subscription(subscription_id:, **options)
|
3136
|
+
path = interpolate_path("/subscriptions/{subscription_id}/cancel", subscription_id: subscription_id)
|
3137
|
+
put(path, options[:body], Requests::SubscriptionCancel, **options)
|
3138
|
+
end
|
3139
|
+
|
3140
|
+
# Reactivate a canceled subscription
|
3141
|
+
#
|
3142
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/reactivate_subscription reactivate_subscription api documentation}
|
3143
|
+
#
|
3144
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3145
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3146
|
+
#
|
3147
|
+
# @return [Resources::Subscription] An active subscription.
|
3148
|
+
# @example
|
3149
|
+
# begin
|
3150
|
+
# subscription = @client.reactivate_subscription(
|
3151
|
+
# subscription_id: subscription_id
|
3152
|
+
# )
|
3153
|
+
# puts "Reactivated Canceled Subscription #{subscription}"
|
3154
|
+
# rescue Recurly::Errors::NotFoundError
|
3155
|
+
# # If the resource was not found, you may want to alert the user or
|
3156
|
+
# # just return nil
|
3157
|
+
# puts "Resource Not Found"
|
3158
|
+
# end
|
3159
|
+
#
|
3160
|
+
def reactivate_subscription(subscription_id:, **options)
|
3161
|
+
path = interpolate_path("/subscriptions/{subscription_id}/reactivate", subscription_id: subscription_id)
|
3162
|
+
put(path, **options)
|
3163
|
+
end
|
3164
|
+
|
3165
|
+
# Pause subscription
|
3166
|
+
#
|
3167
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/pause_subscription pause_subscription api documentation}
|
3168
|
+
#
|
3169
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3170
|
+
# @param body [Requests::SubscriptionPause] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionPause}
|
3171
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3172
|
+
#
|
3173
|
+
# @return [Resources::Subscription] A subscription.
|
3174
|
+
# @example
|
3175
|
+
# begin
|
3176
|
+
# subscription_pause = {
|
3177
|
+
# remaining_pause_cycles: 10
|
3178
|
+
# }
|
3179
|
+
# subscription = @client.pause_subscription(
|
3180
|
+
# subscription_id: subscription_id,
|
3181
|
+
# body: subscription_pause
|
3182
|
+
# )
|
3183
|
+
# puts "Paused Subscription #{subscription}"
|
3184
|
+
# rescue Recurly::Errors::NotFoundError
|
3185
|
+
# # If the resource was not found, you may want to alert the user or
|
3186
|
+
# # just return nil
|
3187
|
+
# puts "Resource Not Found"
|
3188
|
+
# end
|
3189
|
+
#
|
3190
|
+
def pause_subscription(subscription_id:, body:, **options)
|
3191
|
+
path = interpolate_path("/subscriptions/{subscription_id}/pause", subscription_id: subscription_id)
|
3192
|
+
put(path, body, Requests::SubscriptionPause, **options)
|
3193
|
+
end
|
3194
|
+
|
3195
|
+
# Resume subscription
|
3196
|
+
#
|
3197
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/resume_subscription resume_subscription api documentation}
|
3198
|
+
#
|
3199
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3200
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3201
|
+
#
|
3202
|
+
# @return [Resources::Subscription] A subscription.
|
3203
|
+
# @example
|
3204
|
+
# begin
|
3205
|
+
# subscription = @client.resume_subscription(
|
3206
|
+
# subscription_id: subscription_id
|
3207
|
+
# )
|
3208
|
+
# puts "Resumed Subscription #{subscription}"
|
3209
|
+
# rescue Recurly::Errors::NotFoundError
|
3210
|
+
# # If the resource was not found, you may want to alert the user or
|
3211
|
+
# # just return nil
|
3212
|
+
# puts "Resource Not Found"
|
3213
|
+
# end
|
3214
|
+
#
|
3215
|
+
def resume_subscription(subscription_id:, **options)
|
3216
|
+
path = interpolate_path("/subscriptions/{subscription_id}/resume", subscription_id: subscription_id)
|
3217
|
+
put(path, **options)
|
3218
|
+
end
|
3219
|
+
|
3220
|
+
# Convert trial subscription
|
3221
|
+
#
|
3222
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/convert_trial convert_trial api documentation}
|
3223
|
+
#
|
3224
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3225
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3226
|
+
#
|
3227
|
+
# @return [Resources::Subscription] A subscription.
|
3228
|
+
#
|
3229
|
+
def convert_trial(subscription_id:, **options)
|
3230
|
+
path = interpolate_path("/subscriptions/{subscription_id}/convert_trial", subscription_id: subscription_id)
|
3231
|
+
put(path, **options)
|
3232
|
+
end
|
3233
|
+
|
3234
|
+
# Fetch a preview of a subscription's renewal invoice(s)
|
3235
|
+
#
|
3236
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_preview_renewal get_preview_renewal api documentation}
|
3237
|
+
#
|
3238
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3239
|
+
#
|
3240
|
+
# @return [Resources::InvoiceCollection] A preview of the subscription's renewal invoice(s).
|
3241
|
+
#
|
3242
|
+
def get_preview_renewal(subscription_id:)
|
3243
|
+
path = interpolate_path("/subscriptions/{subscription_id}/preview_renewal", subscription_id: subscription_id)
|
3244
|
+
get(path)
|
3245
|
+
end
|
3246
|
+
|
3247
|
+
# Fetch a subscription's pending change
|
3248
|
+
#
|
3249
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_subscription_change get_subscription_change api documentation}
|
3250
|
+
#
|
3251
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3252
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3253
|
+
#
|
3254
|
+
# @return [Resources::SubscriptionChange] A subscription's pending change.
|
3255
|
+
# @example
|
3256
|
+
# begin
|
3257
|
+
# change = @client.get_subscription_change(
|
3258
|
+
# subscription_id: subscription_id
|
3259
|
+
# )
|
3260
|
+
# puts "Got SubscriptionChange #{change}"
|
3261
|
+
# rescue Recurly::Errors::NotFoundError
|
3262
|
+
# # If the resource was not found, you may want to alert the user or
|
3263
|
+
# # just return nil
|
3264
|
+
# puts "Resource Not Found"
|
3265
|
+
# end
|
3266
|
+
#
|
3267
|
+
def get_subscription_change(subscription_id:, **options)
|
3268
|
+
path = interpolate_path("/subscriptions/{subscription_id}/change", subscription_id: subscription_id)
|
3269
|
+
get(path, **options)
|
3270
|
+
end
|
3271
|
+
|
3272
|
+
# Create a new subscription change
|
3273
|
+
#
|
3274
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_subscription_change create_subscription_change api documentation}
|
3275
|
+
#
|
3276
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3277
|
+
# @param body [Requests::SubscriptionChangeCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionChangeCreate}
|
3278
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3279
|
+
#
|
3280
|
+
# @return [Resources::SubscriptionChange] A subscription change.
|
3281
|
+
# @example
|
3282
|
+
# begin
|
3283
|
+
# change_create = {
|
3284
|
+
# timeframe: "now",
|
3285
|
+
# plan_code: new_plan_code
|
3286
|
+
# }
|
3287
|
+
# change = @client.create_subscription_change(
|
3288
|
+
# subscription_id: subscription_id,
|
3289
|
+
# body: change_create
|
3290
|
+
# )
|
3291
|
+
# puts "Created SubscriptionChange #{change}"
|
3292
|
+
# rescue Recurly::Errors::ValidationError => e
|
3293
|
+
# # If the request was invalid, you may want to tell your user
|
3294
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
3295
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
3296
|
+
# end
|
3297
|
+
#
|
3298
|
+
def create_subscription_change(subscription_id:, body:, **options)
|
3299
|
+
path = interpolate_path("/subscriptions/{subscription_id}/change", subscription_id: subscription_id)
|
3300
|
+
post(path, body, Requests::SubscriptionChangeCreate, **options)
|
3301
|
+
end
|
3302
|
+
|
3303
|
+
# Delete the pending subscription change
|
3304
|
+
#
|
3305
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_subscription_change remove_subscription_change api documentation}
|
3306
|
+
#
|
3307
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3308
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3309
|
+
#
|
3310
|
+
# @return [Resources::Empty] Subscription change was deleted.
|
3311
|
+
# @example
|
3312
|
+
# begin
|
3313
|
+
# @client.remove_subscription_change(
|
3314
|
+
# subscription_id: subscription_id
|
3315
|
+
# )
|
3316
|
+
# puts "Removed SubscriptionChange #{subscription_id}"
|
3317
|
+
# rescue Recurly::Errors::NotFoundError
|
3318
|
+
# # If the resource was not found, you may want to alert the user or
|
3319
|
+
# # just return nil
|
3320
|
+
# puts "Resource Not Found"
|
3321
|
+
# end
|
3322
|
+
#
|
3323
|
+
def remove_subscription_change(subscription_id:, **options)
|
3324
|
+
path = interpolate_path("/subscriptions/{subscription_id}/change", subscription_id: subscription_id)
|
3325
|
+
delete(path, **options)
|
3326
|
+
end
|
3327
|
+
|
3328
|
+
# Preview a new subscription change
|
3329
|
+
#
|
3330
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/preview_subscription_change preview_subscription_change api documentation}
|
3331
|
+
#
|
3332
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3333
|
+
# @param body [Requests::SubscriptionChangeCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionChangeCreate}
|
3334
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3335
|
+
#
|
3336
|
+
# @return [Resources::SubscriptionChangePreview] A subscription change.
|
3337
|
+
#
|
3338
|
+
def preview_subscription_change(subscription_id:, body:, **options)
|
3339
|
+
path = interpolate_path("/subscriptions/{subscription_id}/change/preview", subscription_id: subscription_id)
|
3340
|
+
post(path, body, Requests::SubscriptionChangeCreate, **options)
|
3341
|
+
end
|
3342
|
+
|
3343
|
+
# List a subscription's invoices
|
3344
|
+
#
|
3345
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_subscription_invoices list_subscription_invoices api documentation}
|
3346
|
+
#
|
3347
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3348
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
3349
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
3350
|
+
#
|
3351
|
+
# *Important notes:*
|
3352
|
+
#
|
3353
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
3354
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
3355
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
3356
|
+
# results correspond to your request.
|
3357
|
+
# * Records are returned in an arbitrary order. Since results are all
|
3358
|
+
# returned at once you can sort the records yourself.
|
3359
|
+
#
|
3360
|
+
# @param limit [Integer] Limit number of records 1-200.
|
3361
|
+
# @param order [String] Sort order.
|
3362
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
3363
|
+
# order. In descending order updated records will move behind the cursor and could
|
3364
|
+
# prevent some records from being returned.
|
3365
|
+
#
|
3366
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
3367
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3368
|
+
#
|
3369
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
3370
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3371
|
+
#
|
3372
|
+
# @param type [String] Filter by type when:
|
3373
|
+
# - +type=charge+, only charge invoices will be returned.
|
3374
|
+
# - +type=credit+, only credit invoices will be returned.
|
3375
|
+
# - +type=non-legacy+, only charge and credit invoices will be returned.
|
3376
|
+
# - +type=legacy+, only legacy invoices will be returned.
|
3377
|
+
#
|
3378
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3379
|
+
#
|
3380
|
+
# @return [Pager<Resources::Invoice>] A list of the subscription's invoices.
|
3381
|
+
# @example
|
3382
|
+
# invoices = @client.list_subscription_invoices(
|
3383
|
+
# subscription_id: subscription_id,
|
3384
|
+
# limit: 200
|
3385
|
+
# )
|
3386
|
+
# invoices.each do |invoice|
|
3387
|
+
# puts "Invoice: #{invoice.number}"
|
3388
|
+
# end
|
3389
|
+
#
|
3390
|
+
def list_subscription_invoices(subscription_id:, **options)
|
3391
|
+
path = interpolate_path("/subscriptions/{subscription_id}/invoices", subscription_id: subscription_id)
|
3392
|
+
pager(path, **options)
|
3393
|
+
end
|
3394
|
+
|
3395
|
+
# List a subscription's line items
|
3396
|
+
#
|
3397
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_subscription_line_items list_subscription_line_items api documentation}
|
3398
|
+
#
|
3399
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3400
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
3401
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
3402
|
+
#
|
3403
|
+
# *Important notes:*
|
3404
|
+
#
|
3405
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
3406
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
3407
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
3408
|
+
# results correspond to your request.
|
3409
|
+
# * Records are returned in an arbitrary order. Since results are all
|
3410
|
+
# returned at once you can sort the records yourself.
|
3411
|
+
#
|
3412
|
+
# @param limit [Integer] Limit number of records 1-200.
|
3413
|
+
# @param order [String] Sort order.
|
3414
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
3415
|
+
# order. In descending order updated records will move behind the cursor and could
|
3416
|
+
# prevent some records from being returned.
|
3417
|
+
#
|
3418
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
3419
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3420
|
+
#
|
3421
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
3422
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3423
|
+
#
|
3424
|
+
# @param original [String] Filter by original field.
|
3425
|
+
# @param state [String] Filter by state field.
|
3426
|
+
# @param type [String] Filter by type field.
|
3427
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3428
|
+
#
|
3429
|
+
# @return [Pager<Resources::LineItem>] A list of the subscription's line items.
|
3430
|
+
# @example
|
3431
|
+
# line_items = @client.list_subscription_line_items(
|
3432
|
+
# subscription_id: subscription_id,
|
3433
|
+
# limit: 200
|
3434
|
+
# )
|
3435
|
+
# line_items.each do |line_item|
|
3436
|
+
# puts "LineItem: #{line_item.id}"
|
3437
|
+
# end
|
3438
|
+
#
|
3439
|
+
def list_subscription_line_items(subscription_id:, **options)
|
3440
|
+
path = interpolate_path("/subscriptions/{subscription_id}/line_items", subscription_id: subscription_id)
|
3441
|
+
pager(path, **options)
|
3442
|
+
end
|
3443
|
+
|
3444
|
+
# List the coupon redemptions for a subscription
|
3445
|
+
#
|
3446
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_subscription_coupon_redemptions list_subscription_coupon_redemptions api documentation}
|
3447
|
+
#
|
3448
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3449
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
3450
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
3451
|
+
#
|
3452
|
+
# *Important notes:*
|
3453
|
+
#
|
3454
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
3455
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
3456
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
3457
|
+
# results correspond to your request.
|
3458
|
+
# * Records are returned in an arbitrary order. Since results are all
|
3459
|
+
# returned at once you can sort the records yourself.
|
3460
|
+
#
|
3461
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
3462
|
+
# order. In descending order updated records will move behind the cursor and could
|
3463
|
+
# prevent some records from being returned.
|
3464
|
+
#
|
3465
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
3466
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3467
|
+
#
|
3468
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
3469
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3470
|
+
#
|
3471
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3472
|
+
#
|
3473
|
+
# @return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions on a subscription.
|
3474
|
+
# @example
|
3475
|
+
# coupon_redemptions = @client.list_subscription_coupon_redemptions(
|
3476
|
+
# subscription_id: subscription_id,
|
3477
|
+
# limit: 200
|
3478
|
+
# )
|
3479
|
+
# coupon_redemptions.each do |redemption|
|
3480
|
+
# puts "CouponRedemption: #{redemption.id}"
|
3481
|
+
# end
|
3482
|
+
#
|
3483
|
+
def list_subscription_coupon_redemptions(subscription_id:, **options)
|
3484
|
+
path = interpolate_path("/subscriptions/{subscription_id}/coupon_redemptions", subscription_id: subscription_id)
|
3485
|
+
pager(path, **options)
|
3486
|
+
end
|
3487
|
+
|
3488
|
+
# List a subscription add-on's usage records
|
3489
|
+
#
|
3490
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_usage list_usage api documentation}
|
3491
|
+
#
|
3492
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3493
|
+
# @param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
3494
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
3495
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
3496
|
+
#
|
3497
|
+
# *Important notes:*
|
3498
|
+
#
|
3499
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
3500
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
3501
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
3502
|
+
# results correspond to your request.
|
3503
|
+
# * Records are returned in an arbitrary order. Since results are all
|
3504
|
+
# returned at once you can sort the records yourself.
|
3505
|
+
#
|
3506
|
+
# @param limit [Integer] Limit number of records 1-200.
|
3507
|
+
# @param order [String] Sort order.
|
3508
|
+
# @param sort [String] Sort field. You *really* only want to sort by +usage_timestamp+ in ascending
|
3509
|
+
# order. In descending order updated records will move behind the cursor and could
|
3510
|
+
# prevent some records from being returned.
|
3511
|
+
#
|
3512
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=usage_timestamp+ or +sort=recorded_timestamp+.
|
3513
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3514
|
+
#
|
3515
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=usage_timestamp+ or +sort=recorded_timestamp+.
|
3516
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3517
|
+
#
|
3518
|
+
# @param billing_status [String] Filter by usage record's billing status
|
3519
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3520
|
+
#
|
3521
|
+
# @return [Pager<Resources::Usage>] A list of the subscription add-on's usage records.
|
3522
|
+
#
|
3523
|
+
def list_usage(subscription_id:, add_on_id:, **options)
|
3524
|
+
path = interpolate_path("/subscriptions/{subscription_id}/add_ons/{add_on_id}/usage", subscription_id: subscription_id, add_on_id: add_on_id)
|
3525
|
+
pager(path, **options)
|
3526
|
+
end
|
3527
|
+
|
3528
|
+
# Log a usage record on this subscription add-on
|
3529
|
+
#
|
3530
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_usage create_usage api documentation}
|
3531
|
+
#
|
3532
|
+
# @param subscription_id [String] Subscription ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3533
|
+
# @param add_on_id [String] Add-on ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-gold+.
|
3534
|
+
# @param body [Requests::UsageCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::UsageCreate}
|
3535
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3536
|
+
#
|
3537
|
+
# @return [Resources::Usage] The created usage record.
|
3538
|
+
#
|
3539
|
+
def create_usage(subscription_id:, add_on_id:, body:, **options)
|
3540
|
+
path = interpolate_path("/subscriptions/{subscription_id}/add_ons/{add_on_id}/usage", subscription_id: subscription_id, add_on_id: add_on_id)
|
3541
|
+
post(path, body, Requests::UsageCreate, **options)
|
3542
|
+
end
|
3543
|
+
|
3544
|
+
# Get a usage record
|
3545
|
+
#
|
3546
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_usage get_usage api documentation}
|
3547
|
+
#
|
3548
|
+
# @param usage_id [String] Usage Record ID.
|
3549
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3550
|
+
#
|
3551
|
+
# @return [Resources::Usage] The usage record.
|
3552
|
+
#
|
3553
|
+
def get_usage(usage_id:, **options)
|
3554
|
+
path = interpolate_path("/usage/{usage_id}", usage_id: usage_id)
|
3555
|
+
get(path, **options)
|
3556
|
+
end
|
3557
|
+
|
3558
|
+
# Update a usage record
|
3559
|
+
#
|
3560
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/update_usage update_usage api documentation}
|
3561
|
+
#
|
3562
|
+
# @param usage_id [String] Usage Record ID.
|
3563
|
+
# @param body [Requests::UsageCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::UsageCreate}
|
3564
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3565
|
+
#
|
3566
|
+
# @return [Resources::Usage] The updated usage record.
|
3567
|
+
#
|
3568
|
+
def update_usage(usage_id:, body:, **options)
|
3569
|
+
path = interpolate_path("/usage/{usage_id}", usage_id: usage_id)
|
3570
|
+
put(path, body, Requests::UsageCreate, **options)
|
3571
|
+
end
|
3572
|
+
|
3573
|
+
# Delete a usage record.
|
3574
|
+
#
|
3575
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/remove_usage remove_usage api documentation}
|
3576
|
+
#
|
3577
|
+
# @param usage_id [String] Usage Record ID.
|
3578
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3579
|
+
#
|
3580
|
+
# @return [Resources::Empty] Usage was successfully deleted.
|
3581
|
+
#
|
3582
|
+
def remove_usage(usage_id:, **options)
|
3583
|
+
path = interpolate_path("/usage/{usage_id}", usage_id: usage_id)
|
3584
|
+
delete(path, **options)
|
3585
|
+
end
|
3586
|
+
|
3587
|
+
# List a site's transactions
|
3588
|
+
#
|
3589
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_transactions list_transactions api documentation}
|
3590
|
+
#
|
3591
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
|
3592
|
+
# commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
|
3593
|
+
#
|
3594
|
+
# *Important notes:*
|
3595
|
+
#
|
3596
|
+
# * The +ids+ parameter cannot be used with any other ordering or filtering
|
3597
|
+
# parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
|
3598
|
+
# * Invalid or unknown IDs will be ignored, so you should check that the
|
3599
|
+
# results correspond to your request.
|
3600
|
+
# * Records are returned in an arbitrary order. Since results are all
|
3601
|
+
# returned at once you can sort the records yourself.
|
3602
|
+
#
|
3603
|
+
# @param limit [Integer] Limit number of records 1-200.
|
3604
|
+
# @param order [String] Sort order.
|
3605
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
3606
|
+
# order. In descending order updated records will move behind the cursor and could
|
3607
|
+
# prevent some records from being returned.
|
3608
|
+
#
|
3609
|
+
# @param begin_time [DateTime] Inclusively filter by begin_time when +sort=created_at+ or +sort=updated_at+.
|
3610
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3611
|
+
#
|
3612
|
+
# @param end_time [DateTime] Inclusively filter by end_time when +sort=created_at+ or +sort=updated_at+.
|
3613
|
+
# *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
3614
|
+
#
|
3615
|
+
# @param type [String] Filter by type field. The value +payment+ will return both +purchase+ and +capture+ transactions.
|
3616
|
+
# @param success [String] Filter by success field.
|
3617
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3618
|
+
#
|
3619
|
+
# @return [Pager<Resources::Transaction>] A list of the site's transactions.
|
3620
|
+
# @example
|
3621
|
+
# transactions = @client.list_transactions(limit: 200)
|
3622
|
+
# transactions.each do |transaction|
|
3623
|
+
# puts "Transaction: #{transaction.uuid}"
|
3624
|
+
# end
|
3625
|
+
#
|
3626
|
+
def list_transactions(**options)
|
3627
|
+
path = interpolate_path("/transactions")
|
3628
|
+
pager(path, **options)
|
3629
|
+
end
|
3630
|
+
|
3631
|
+
# Fetch a transaction
|
3632
|
+
#
|
3633
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_transaction get_transaction api documentation}
|
3634
|
+
#
|
3635
|
+
# @param transaction_id [String] Transaction ID or UUID. For ID no prefix is used e.g. +e28zov4fw0v2+. For UUID use prefix +uuid-+, e.g. +uuid-123457890+.
|
3636
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3637
|
+
#
|
3638
|
+
# @return [Resources::Transaction] A transaction.
|
3639
|
+
# @example
|
3640
|
+
# begin
|
3641
|
+
# transaction = @client.get_transaction(transaction_id: transaction_id)
|
3642
|
+
# puts "Got Transaction #{transaction}"
|
3643
|
+
# rescue Recurly::Errors::NotFoundError
|
3644
|
+
# # If the resource was not found, you may want to alert the user or
|
3645
|
+
# # just return nil
|
3646
|
+
# puts "Resource Not Found"
|
3647
|
+
# end
|
3648
|
+
#
|
3649
|
+
def get_transaction(transaction_id:, **options)
|
3650
|
+
path = interpolate_path("/transactions/{transaction_id}", transaction_id: transaction_id)
|
3651
|
+
get(path, **options)
|
3652
|
+
end
|
3653
|
+
|
3654
|
+
# Fetch a unique coupon code
|
3655
|
+
#
|
3656
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_unique_coupon_code get_unique_coupon_code api documentation}
|
3657
|
+
#
|
3658
|
+
# @param unique_coupon_code_id [String] Unique Coupon Code ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-abc-8dh2-def+.
|
3659
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3660
|
+
#
|
3661
|
+
# @return [Resources::UniqueCouponCode] A unique coupon code.
|
3662
|
+
#
|
3663
|
+
def get_unique_coupon_code(unique_coupon_code_id:, **options)
|
3664
|
+
path = interpolate_path("/unique_coupon_codes/{unique_coupon_code_id}", unique_coupon_code_id: unique_coupon_code_id)
|
3665
|
+
get(path, **options)
|
3666
|
+
end
|
3667
|
+
|
3668
|
+
# Deactivate a unique coupon code
|
3669
|
+
#
|
3670
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/deactivate_unique_coupon_code deactivate_unique_coupon_code api documentation}
|
3671
|
+
#
|
3672
|
+
# @param unique_coupon_code_id [String] Unique Coupon Code ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-abc-8dh2-def+.
|
3673
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3674
|
+
#
|
3675
|
+
# @return [Resources::UniqueCouponCode] A unique coupon code.
|
3676
|
+
#
|
3677
|
+
def deactivate_unique_coupon_code(unique_coupon_code_id:, **options)
|
3678
|
+
path = interpolate_path("/unique_coupon_codes/{unique_coupon_code_id}", unique_coupon_code_id: unique_coupon_code_id)
|
3679
|
+
delete(path, **options)
|
3680
|
+
end
|
3681
|
+
|
3682
|
+
# Restore a unique coupon code
|
3683
|
+
#
|
3684
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/reactivate_unique_coupon_code reactivate_unique_coupon_code api documentation}
|
3685
|
+
#
|
3686
|
+
# @param unique_coupon_code_id [String] Unique Coupon Code ID or code. For ID no prefix is used e.g. +e28zov4fw0v2+. For code use prefix +code-+, e.g. +code-abc-8dh2-def+.
|
3687
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3688
|
+
#
|
3689
|
+
# @return [Resources::UniqueCouponCode] A unique coupon code.
|
3690
|
+
#
|
3691
|
+
def reactivate_unique_coupon_code(unique_coupon_code_id:, **options)
|
3692
|
+
path = interpolate_path("/unique_coupon_codes/{unique_coupon_code_id}/restore", unique_coupon_code_id: unique_coupon_code_id)
|
3693
|
+
put(path, **options)
|
3694
|
+
end
|
3695
|
+
|
3696
|
+
# Create a new purchase
|
3697
|
+
#
|
3698
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/create_purchase create_purchase api documentation}
|
3699
|
+
#
|
3700
|
+
# @param body [Requests::PurchaseCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PurchaseCreate}
|
3701
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3702
|
+
#
|
3703
|
+
# @return [Resources::InvoiceCollection] Returns the new invoices
|
3704
|
+
# @example
|
3705
|
+
# begin
|
3706
|
+
# purchase = {
|
3707
|
+
# currency: "USD",
|
3708
|
+
# account: {
|
3709
|
+
# code: account_code,
|
3710
|
+
# first_name: "Benjamin",
|
3711
|
+
# last_name: "Du Monde",
|
3712
|
+
# billing_info: {
|
3713
|
+
# token_id: rjs_token_id
|
3714
|
+
# },
|
3715
|
+
# },
|
3716
|
+
# subscriptions: [
|
3717
|
+
# { plan_code: plan_code }
|
3718
|
+
# ]
|
3719
|
+
# }
|
3720
|
+
# invoice_collection = @client.create_purchase(
|
3721
|
+
# body: purchase
|
3722
|
+
# )
|
3723
|
+
# puts "Created Charge Invoice #{invoice_collection.charge_invoice}"
|
3724
|
+
# puts "Created Credit Invoices #{invoice_collection.credit_invoices}"
|
3725
|
+
# rescue Recurly::Errors::ValidationError => e
|
3726
|
+
# # If the request was invalid, you may want to tell your user
|
3727
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
3728
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
3729
|
+
# end
|
3730
|
+
#
|
3731
|
+
def create_purchase(body:, **options)
|
3732
|
+
path = interpolate_path("/purchases")
|
3733
|
+
post(path, body, Requests::PurchaseCreate, **options)
|
3734
|
+
end
|
3735
|
+
|
3736
|
+
# Preview a new purchase
|
3737
|
+
#
|
3738
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/preview_purchase preview_purchase api documentation}
|
3739
|
+
#
|
3740
|
+
# @param body [Requests::PurchaseCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PurchaseCreate}
|
3741
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3742
|
+
#
|
3743
|
+
# @return [Resources::InvoiceCollection] Returns preview of the new invoices
|
3744
|
+
# @example
|
3745
|
+
# begin
|
3746
|
+
# purchase = {
|
3747
|
+
# currency: "USD",
|
3748
|
+
# account: {
|
3749
|
+
# code: account_code,
|
3750
|
+
# first_name: "Benjamin",
|
3751
|
+
# last_name: "Du Monde",
|
3752
|
+
# billing_info: {
|
3753
|
+
# token_id: rjs_token_id
|
3754
|
+
# },
|
3755
|
+
# },
|
3756
|
+
# subscriptions: [
|
3757
|
+
# { plan_code: plan_code }
|
3758
|
+
# ]
|
3759
|
+
# }
|
3760
|
+
# invoice_collection = @client.preview_purchase(
|
3761
|
+
# body: purchase
|
3762
|
+
# )
|
3763
|
+
# puts "Preview Charge Invoice #{invoice_collection.charge_invoice}"
|
3764
|
+
# puts "Preview Credit Invoices #{invoice_collection.credit_invoices}"
|
3765
|
+
# rescue Recurly::Errors::ValidationError => e
|
3766
|
+
# # If the request was invalid, you may want to tell your user
|
3767
|
+
# # why. You can find the invalid params and reasons in e.recurly_error.params
|
3768
|
+
# puts "ValidationError: #{e.recurly_error.params}"
|
3769
|
+
# end
|
3770
|
+
#
|
3771
|
+
def preview_purchase(body:, **options)
|
3772
|
+
path = interpolate_path("/purchases/preview")
|
3773
|
+
post(path, body, Requests::PurchaseCreate, **options)
|
3774
|
+
end
|
3775
|
+
|
3776
|
+
# List the dates that have an available export to download.
|
3777
|
+
#
|
3778
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_export_dates get_export_dates api documentation}
|
3779
|
+
#
|
3780
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3781
|
+
#
|
3782
|
+
# @return [Resources::ExportDates] Returns a list of dates.
|
3783
|
+
# @example
|
3784
|
+
# begin
|
3785
|
+
# export_dates = @client.get_export_dates()
|
3786
|
+
# export_dates.dates.each do |date|
|
3787
|
+
# puts "Exports are available for: #{date}"
|
3788
|
+
# end
|
3789
|
+
# rescue Recurly::Errors::NotFoundError
|
3790
|
+
# # If the resource was not found, you may want to alert the user or
|
3791
|
+
# # just return nil
|
3792
|
+
# puts "Resource Not Found"
|
3793
|
+
# end
|
3794
|
+
#
|
3795
|
+
def get_export_dates(**options)
|
3796
|
+
path = interpolate_path("/export_dates")
|
3797
|
+
get(path, **options)
|
3798
|
+
end
|
3799
|
+
|
3800
|
+
# List of the export files that are available to download.
|
3801
|
+
#
|
3802
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_export_files get_export_files api documentation}
|
3803
|
+
#
|
3804
|
+
# @param export_date [String] Date for which to get a list of available automated export files. Date must be in YYYY-MM-DD format.
|
3805
|
+
# @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
|
3806
|
+
#
|
3807
|
+
# @return [Resources::ExportFiles] Returns a list of export files to download.
|
3808
|
+
# @example
|
3809
|
+
# begin
|
3810
|
+
# export_files = @client.get_export_files(export_date: export_date)
|
3811
|
+
# export_files.files.each do |file|
|
3812
|
+
# puts "Export file download URL: #{file.href}"
|
3813
|
+
# end
|
3814
|
+
# rescue Recurly::Errors::NotFoundError
|
3815
|
+
# # If the resource was not found, you may want to alert the user or
|
3816
|
+
# # just return nil
|
3817
|
+
# puts "Resource Not Found"
|
3818
|
+
# end
|
3819
|
+
#
|
3820
|
+
def get_export_files(export_date:, **options)
|
3821
|
+
path = interpolate_path("/export_dates/{export_date}/export_files", export_date: export_date)
|
3822
|
+
get(path, **options)
|
3823
|
+
end
|
3824
|
+
|
3825
|
+
# List the dunning campaigns for a site
|
3826
|
+
#
|
3827
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/list_dunning_campaigns list_dunning_campaigns api documentation}
|
3828
|
+
#
|
3829
|
+
# @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
|
3830
|
+
# order. In descending order updated records will move behind the cursor and could
|
3831
|
+
# prevent some records from being returned.
|
3832
|
+
#
|
3833
|
+
#
|
3834
|
+
# @return [Pager<Resources::DunningCampaign>] A list of the the dunning_campaigns on an account.
|
3835
|
+
#
|
3836
|
+
def list_dunning_campaigns(**options)
|
3837
|
+
path = "/dunning_campaigns"
|
3838
|
+
pager(path, **options)
|
3839
|
+
end
|
3840
|
+
|
3841
|
+
# Fetch a dunning campaign
|
3842
|
+
#
|
3843
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/get_dunning_campaign get_dunning_campaign api documentation}
|
3844
|
+
#
|
3845
|
+
# @param dunning_campaign_id [String] Dunning Campaign ID, e.g. +e28zov4fw0v2+.
|
3846
|
+
#
|
3847
|
+
# @return [Resources::DunningCampaign] Settings for a dunning campaign.
|
3848
|
+
#
|
3849
|
+
def get_dunning_campaign(dunning_campaign_id:)
|
3850
|
+
path = interpolate_path("/dunning_campaigns/{dunning_campaign_id}", dunning_campaign_id: dunning_campaign_id)
|
3851
|
+
get(path)
|
3852
|
+
end
|
3853
|
+
|
3854
|
+
# Assign a dunning campaign to multiple plans
|
3855
|
+
#
|
3856
|
+
# {https://developers.recurly.com/api/v2019-10-10#operation/put_dunning_campaign_bulk_update put_dunning_campaign_bulk_update api documentation}
|
3857
|
+
#
|
3858
|
+
# @param dunning_campaign_id [String] Dunning Campaign ID, e.g. +e28zov4fw0v2+.
|
3859
|
+
# @param body [Requests::DunningCampaignsBulkUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::DunningCampaignsBulkUpdate}
|
3860
|
+
#
|
3861
|
+
# @return [Resources::DunningCampaignsBulkUpdateResponse] A list of updated plans.
|
3862
|
+
#
|
3863
|
+
def put_dunning_campaign_bulk_update(dunning_campaign_id:, body:)
|
3864
|
+
path = interpolate_path("/dunning_campaigns/{dunning_campaign_id}/bulk_update", dunning_campaign_id: dunning_campaign_id)
|
3865
|
+
put(path, body, Requests::DunningCampaignsBulkUpdate)
|
3866
|
+
end
|
3867
|
+
end
|
3868
|
+
end
|