recurly 2.20.3 → 3.0.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +158 -110
- data/Rakefile +6 -0
- data/bin/bundle +105 -0
- data/bin/coderay +29 -0
- data/bin/console +14 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/pry +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/setup +8 -0
- data/bin/yard +29 -0
- data/bin/yardoc +29 -0
- data/bin/yri +29 -0
- data/lib/data/ca-certificates.crt +31 -0
- data/lib/recurly/client/operations.rb +935 -0
- data/lib/recurly/client.rb +198 -0
- data/lib/recurly/errors/api_errors.rb +35 -0
- data/lib/recurly/errors/network_errors.rb +8 -0
- data/lib/recurly/errors.rb +34 -0
- data/lib/recurly/pager.rb +119 -0
- data/lib/recurly/request.rb +30 -0
- data/lib/recurly/requests/account_acquisition_updatable.rb +22 -0
- data/lib/recurly/requests/account_create_only.rb +18 -0
- data/lib/recurly/requests/account_updatable.rb +50 -0
- data/lib/recurly/requests/add_on_create.rb +38 -0
- data/lib/recurly/requests/add_on_update.rb +38 -0
- data/lib/recurly/requests/address.rb +42 -0
- data/lib/recurly/requests/billing_info_create.rb +58 -0
- data/lib/recurly/requests/coupon_create_only.rb +66 -0
- data/lib/recurly/requests/coupon_updatable.rb +30 -0
- data/lib/recurly/requests/create_account.rb +62 -0
- data/lib/recurly/requests/create_coupon.rb +90 -0
- data/lib/recurly/requests/invoice_create.rb +42 -0
- data/lib/recurly/requests/invoice_refund.rb +30 -0
- data/lib/recurly/requests/line_item_create.rb +46 -0
- data/lib/recurly/requests/plan_create.rb +66 -0
- data/lib/recurly/requests/plan_update.rb +70 -0
- data/lib/recurly/requests/shipping_address_create.rb +58 -0
- data/lib/recurly/requests/shipping_address_update.rb +62 -0
- data/lib/recurly/requests/subscription_add_on_create.rb +22 -0
- data/lib/recurly/requests/subscription_change_create.rb +42 -0
- data/lib/recurly/requests/subscription_create.rb +86 -0
- data/lib/recurly/requests/subscription_update.rb +42 -0
- data/lib/recurly/requests/update_coupon.rb +30 -0
- data/lib/recurly/resource.rb +16 -1114
- data/lib/recurly/resources/account.rb +86 -0
- data/lib/recurly/resources/account_acquisition.rb +42 -0
- data/lib/recurly/resources/account_balance.rb +22 -0
- data/lib/recurly/resources/account_note.rb +30 -0
- data/lib/recurly/resources/add_on.rb +62 -0
- data/lib/recurly/resources/address.rb +42 -0
- data/lib/recurly/resources/billing_info.rb +62 -0
- data/lib/recurly/resources/coupon.rb +110 -0
- data/lib/recurly/resources/coupon_discount.rb +22 -0
- data/lib/recurly/resources/coupon_redemption.rb +46 -0
- data/lib/recurly/resources/credit_payment.rb +62 -0
- data/lib/recurly/resources/error.rb +18 -0
- data/lib/recurly/resources/error_may_have_transaction.rb +22 -0
- data/lib/recurly/resources/invoice.rb +138 -0
- data/lib/recurly/resources/invoice_collection.rb +18 -0
- data/lib/recurly/resources/line_item.rb +166 -0
- data/lib/recurly/resources/plan.rb +86 -0
- data/lib/recurly/resources/settings.rb +18 -0
- data/lib/recurly/resources/shipping_address.rb +74 -0
- data/lib/recurly/resources/site.rb +46 -0
- data/lib/recurly/resources/subscription.rb +134 -0
- data/lib/recurly/resources/subscription_add_on.rb +42 -0
- data/lib/recurly/resources/subscription_change.rb +54 -0
- data/lib/recurly/resources/tax_info.rb +18 -0
- data/lib/recurly/resources/transaction.rb +146 -0
- data/lib/recurly/resources/unique_coupon_code.rb +38 -0
- data/lib/recurly/resources/user.rb +38 -0
- data/lib/recurly/schema/json_deserializer.rb +53 -0
- data/lib/recurly/schema/json_parser.rb +71 -0
- data/lib/recurly/schema/request_caster.rb +66 -0
- data/lib/recurly/schema/schema_factory.rb +50 -0
- data/lib/recurly/schema/schema_validator.rb +125 -0
- data/lib/recurly/schema.rb +114 -0
- data/lib/recurly/version.rb +1 -10
- data/lib/recurly.rb +14 -167
- data/recurly.gemspec +32 -0
- data/scripts/build +4 -0
- data/scripts/clean +6 -0
- data/scripts/test +3 -0
- metadata +129 -196
- data/lib/recurly/account.rb +0 -230
- data/lib/recurly/account_acquisition.rb +0 -27
- data/lib/recurly/account_balance.rb +0 -23
- data/lib/recurly/add_on.rb +0 -52
- data/lib/recurly/address.rb +0 -25
- data/lib/recurly/adjustment.rb +0 -100
- data/lib/recurly/api/errors.rb +0 -208
- data/lib/recurly/api/net_http_adapter.rb +0 -111
- data/lib/recurly/api.rb +0 -110
- data/lib/recurly/billing_info.rb +0 -134
- data/lib/recurly/business_entity.rb +0 -35
- data/lib/recurly/coupon.rb +0 -136
- data/lib/recurly/credit_payment.rb +0 -32
- data/lib/recurly/currency_percentage_tier.rb +0 -17
- data/lib/recurly/custom_field.rb +0 -15
- data/lib/recurly/custom_field_definition.rb +0 -14
- data/lib/recurly/customer_permission.rb +0 -10
- data/lib/recurly/delivery.rb +0 -19
- data/lib/recurly/dunning_campaign.rb +0 -30
- data/lib/recurly/dunning_cycle.rb +0 -18
- data/lib/recurly/entitlement.rb +0 -19
- data/lib/recurly/error.rb +0 -13
- data/lib/recurly/external_account.rb +0 -17
- data/lib/recurly/external_charge.rb +0 -20
- data/lib/recurly/external_invoice.rb +0 -27
- data/lib/recurly/external_payment_phase.rb +0 -27
- data/lib/recurly/external_product.rb +0 -34
- data/lib/recurly/external_product_reference.rb +0 -18
- data/lib/recurly/external_subscription.rb +0 -62
- data/lib/recurly/gateway_attribute.rb +0 -10
- data/lib/recurly/general_ledger_account.rb +0 -16
- data/lib/recurly/gift_card.rb +0 -85
- data/lib/recurly/helper.rb +0 -51
- data/lib/recurly/invoice.rb +0 -354
- data/lib/recurly/invoice_collection.rb +0 -14
- data/lib/recurly/invoice_template.rb +0 -14
- data/lib/recurly/item.rb +0 -36
- data/lib/recurly/js.rb +0 -14
- data/lib/recurly/juris_detail.rb +0 -15
- data/lib/recurly/measured_unit.rb +0 -16
- data/lib/recurly/money.rb +0 -120
- data/lib/recurly/note.rb +0 -14
- data/lib/recurly/percentage_tier.rb +0 -17
- data/lib/recurly/performance_obligation.rb +0 -15
- data/lib/recurly/plan.rb +0 -59
- data/lib/recurly/plan_ramp_interval.rb +0 -10
- data/lib/recurly/purchase.rb +0 -239
- 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 -313
- data/lib/recurly/rev_rec.rb +0 -18
- data/lib/recurly/shipping_address.rb +0 -26
- data/lib/recurly/shipping_fee.rb +0 -17
- data/lib/recurly/shipping_method.rb +0 -13
- data/lib/recurly/sub_add_on_percentage_tier.rb +0 -17
- data/lib/recurly/subscription/add_ons.rb +0 -82
- data/lib/recurly/subscription.rb +0 -374
- data/lib/recurly/subscription_add_on.rb +0 -64
- data/lib/recurly/subscription_ramp_interval.rb +0 -12
- data/lib/recurly/tax_detail.rb +0 -18
- data/lib/recurly/tax_type.rb +0 -13
- data/lib/recurly/tier.rb +0 -18
- data/lib/recurly/transaction/errors.rb +0 -119
- data/lib/recurly/transaction.rb +0 -132
- data/lib/recurly/usage.rb +0 -29
- data/lib/recurly/verify.rb +0 -12
- data/lib/recurly/webhook/account_notification.rb +0 -13
- data/lib/recurly/webhook/billing_info_update_failed_notification.rb +0 -6
- 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_gift_card_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/deactivated_item_notification.rb +0 -6
- data/lib/recurly/webhook/deleted_shipping_address_notification.rb +0 -6
- 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/fraud_info_updated_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/item_notification.rb +0 -7
- data/lib/recurly/webhook/low_balance_gift_card_notification.rb +0 -6
- 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_item_notification.rb +0 -6
- data/lib/recurly/webhook/new_shipping_address_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/paused_subscription_renewal_notification.rb +0 -6
- data/lib/recurly/webhook/prerenewal_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/reactivated_item_notification.rb +0 -6
- data/lib/recurly/webhook/redeemed_gift_card_notification.rb +0 -7
- data/lib/recurly/webhook/regenerated_gift_card_notification.rb +0 -6
- 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/scheduled_subscription_pause_notification.rb +0 -6
- data/lib/recurly/webhook/scheduled_subscription_update_notification.rb +0 -6
- data/lib/recurly/webhook/subscription_notification.rb +0 -12
- data/lib/recurly/webhook/subscription_pause_canceled_notification.rb +0 -6
- data/lib/recurly/webhook/subscription_pause_modified_notification.rb +0 -6
- data/lib/recurly/webhook/subscription_paused_notification.rb +0 -6
- data/lib/recurly/webhook/subscription_resumed_notification.rb +0 -6
- 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/transaction_status_updated_notification.rb +0 -6
- 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_gift_card_notification.rb +0 -6
- data/lib/recurly/webhook/updated_invoice_notification.rb +0 -6
- data/lib/recurly/webhook/updated_item_notification.rb +0 -6
- data/lib/recurly/webhook/updated_shipping_address_notification.rb +0 -6
- 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 -113
- data/lib/recurly/xml/nokogiri.rb +0 -60
- data/lib/recurly/xml/rexml.rb +0 -52
- data/lib/recurly/xml.rb +0 -122
@@ -0,0 +1,935 @@
|
|
1
|
+
module Recurly
|
2
|
+
class Client
|
3
|
+
def api_version
|
4
|
+
"v2018-01-24"
|
5
|
+
end
|
6
|
+
|
7
|
+
# List sites
|
8
|
+
#
|
9
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
10
|
+
# @param limit [Integer] Limit number of records 1-200.
|
11
|
+
# @param order [String] Sort order.
|
12
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
13
|
+
# @return [Pager<Resources::Site>] A list of sites.
|
14
|
+
def list_sites(**options)
|
15
|
+
path = "/sites"
|
16
|
+
pager(path, **options)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Fetch a site
|
20
|
+
#
|
21
|
+
# @return [Resources::Site] A site.
|
22
|
+
def get_site()
|
23
|
+
path = interpolate_path("/sites/{site_id}", site_id: site_id)
|
24
|
+
get(path)
|
25
|
+
end
|
26
|
+
|
27
|
+
# List a site's accounts
|
28
|
+
#
|
29
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
30
|
+
# @param limit [Integer] Limit number of records 1-200.
|
31
|
+
# @param order [String] Sort order.
|
32
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
33
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
34
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
35
|
+
# @param subscriber [String] Filter accounts accounts with or without a subscription in the `active`, `canceled`, or `future` state.
|
36
|
+
# @param past_due [String] Filter for accounts with an invoice in the `past_due` state.
|
37
|
+
# @return [Pager<Resources::Account>] A list of the site's accounts.
|
38
|
+
def list_accounts(**options)
|
39
|
+
path = interpolate_path("/sites/{site_id}/accounts", site_id: site_id)
|
40
|
+
pager(path, **options)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Create an account
|
44
|
+
#
|
45
|
+
# @param body [Requests::CreateAccount] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::CreateAccount}
|
46
|
+
# @return [Resources::Account] An account.
|
47
|
+
def create_account(body:)
|
48
|
+
path = interpolate_path("/sites/{site_id}/accounts", site_id: site_id)
|
49
|
+
post(path, body, Requests::CreateAccount)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Fetch an account
|
53
|
+
#
|
54
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
55
|
+
# @return [Resources::Account] An account.
|
56
|
+
# @example
|
57
|
+
# begin
|
58
|
+
# # You can use the `id` field from an Account object
|
59
|
+
# account = @client.get_account(account_id: "hympfmab60ic")
|
60
|
+
# # If you only have the account code, you can prefix with `code-`
|
61
|
+
# account = @client.get_account(account_id: "code-benjamin.dumonde@example.com")
|
62
|
+
# rescue Recurly::Errors::NotFoundError => e
|
63
|
+
# puts e
|
64
|
+
# # => Recurly::NotFoundError: Couldn't find Account with code = benjamin.dumonde@example.com
|
65
|
+
# puts e.recurly_error
|
66
|
+
# # => #<Recurly::Error:0x007f8b29918618 @attributes={:type=>"not_found", :message=>"Couldn't find Account with code = benjamin.dumonde@example.com", :params=>[{"param"=>"account_id"}]}>
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
def get_account(account_id:)
|
70
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}", site_id: site_id, account_id: account_id)
|
71
|
+
get(path)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Modify an account
|
75
|
+
#
|
76
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
77
|
+
# @param body [Requests::AccountUpdatable] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::AccountUpdatable}
|
78
|
+
# @return [Resources::Account] An account.
|
79
|
+
def update_account(account_id:, body:)
|
80
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}", site_id: site_id, account_id: account_id)
|
81
|
+
put(path, body, Requests::AccountUpdatable)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Deactivate an account
|
85
|
+
#
|
86
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
87
|
+
# @return [Resources::Account] An account.
|
88
|
+
def deactivate_account(account_id:)
|
89
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}", site_id: site_id, account_id: account_id)
|
90
|
+
delete(path)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Fetch an account's acquisition data
|
94
|
+
#
|
95
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
96
|
+
# @return [Resources::AccountAcquisition] An account's acquisition data.
|
97
|
+
def get_account_acquisition(account_id:)
|
98
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/acquisition", site_id: site_id, account_id: account_id)
|
99
|
+
get(path)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Update an account's acquisition data
|
103
|
+
#
|
104
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
105
|
+
# @param body [Requests::AccountAcquisitionUpdatable] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::AccountAcquisitionUpdatable}
|
106
|
+
# @return [Resources::AccountAcquisition] An account's updated acquisition data.
|
107
|
+
def update_account_acquisition(account_id:, body:)
|
108
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/acquisition", site_id: site_id, account_id: account_id)
|
109
|
+
put(path, body, Requests::AccountAcquisitionUpdatable)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Remove an account's acquisition data
|
113
|
+
#
|
114
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
115
|
+
def remove_account_acquisition(account_id:)
|
116
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/acquisition", site_id: site_id, account_id: account_id)
|
117
|
+
delete(path)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Reactivate an inactive account
|
121
|
+
#
|
122
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
123
|
+
# @return [Resources::Account] An account.
|
124
|
+
def reactivate_account(account_id:)
|
125
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/reactivate", site_id: site_id, account_id: account_id)
|
126
|
+
put(path)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Fetch an account's balance and past due status
|
130
|
+
#
|
131
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
132
|
+
# @return [Resources::AccountBalance] An account's balance.
|
133
|
+
def get_account_balance(account_id:)
|
134
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/balance", site_id: site_id, account_id: account_id)
|
135
|
+
get(path)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Fetch an account's billing information
|
139
|
+
#
|
140
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
141
|
+
# @return [Resources::BillingInfo] An account's billing information.
|
142
|
+
def get_billing_info(account_id:)
|
143
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/billing_info", site_id: site_id, account_id: account_id)
|
144
|
+
get(path)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Set an account's billing information
|
148
|
+
#
|
149
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
150
|
+
# @param body [Requests::BillingInfoCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::BillingInfoCreate}
|
151
|
+
# @return [Resources::BillingInfo] Updated billing information.
|
152
|
+
def update_billing_info(account_id:, body:)
|
153
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/billing_info", site_id: site_id, account_id: account_id)
|
154
|
+
put(path, body, Requests::BillingInfoCreate)
|
155
|
+
end
|
156
|
+
|
157
|
+
# Remove an account's billing information
|
158
|
+
#
|
159
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
160
|
+
def remove_billing_info(account_id:)
|
161
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/billing_info", site_id: site_id, account_id: account_id)
|
162
|
+
delete(path)
|
163
|
+
end
|
164
|
+
|
165
|
+
# Show the coupon redemptions for an account
|
166
|
+
#
|
167
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
168
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
169
|
+
# @return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions on an account.
|
170
|
+
def list_account_coupon_redemptions(account_id:, **options)
|
171
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/coupon_redemptions", site_id: site_id, account_id: account_id)
|
172
|
+
pager(path, **options)
|
173
|
+
end
|
174
|
+
|
175
|
+
# Show the coupon redemption that is active on an account
|
176
|
+
#
|
177
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
178
|
+
# @return [Resources::CouponRedemption] An active coupon redemption on an account.
|
179
|
+
def get_active_coupon_redemption(account_id:)
|
180
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/coupon_redemptions/active", site_id: site_id, account_id: account_id)
|
181
|
+
get(path)
|
182
|
+
end
|
183
|
+
|
184
|
+
# Generate an active coupon redemption on an account
|
185
|
+
#
|
186
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
187
|
+
# @param body [Requests::CreateCouponRedemption] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::CreateCouponRedemption}
|
188
|
+
# @return [Resources::CouponRedemption] Returns the new coupon redemption.
|
189
|
+
def create_coupon_redemption(account_id:, body:)
|
190
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/coupon_redemptions/active", site_id: site_id, account_id: account_id)
|
191
|
+
post(path, body, Requests::CreateCouponRedemption)
|
192
|
+
end
|
193
|
+
|
194
|
+
# Delete the active coupon redemption from an account
|
195
|
+
#
|
196
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
197
|
+
# @return [Resources::CouponRedemption] Coupon redemption deleted.
|
198
|
+
def remove_coupon_redemption(account_id:)
|
199
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/coupon_redemptions/active", site_id: site_id, account_id: account_id)
|
200
|
+
delete(path)
|
201
|
+
end
|
202
|
+
|
203
|
+
# List an account's credit payments
|
204
|
+
#
|
205
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
206
|
+
# @param limit [Integer] Limit number of records 1-200.
|
207
|
+
# @param order [String] Sort order.
|
208
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
209
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
210
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
211
|
+
# @return [Pager<Resources::CreditPayment>] A list of the account's credit payments.
|
212
|
+
def list_account_credit_payments(account_id:, **options)
|
213
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/credit_payments", site_id: site_id, account_id: account_id)
|
214
|
+
pager(path, **options)
|
215
|
+
end
|
216
|
+
|
217
|
+
# List an account's invoices
|
218
|
+
#
|
219
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
220
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
221
|
+
# @param limit [Integer] Limit number of records 1-200.
|
222
|
+
# @param order [String] Sort order.
|
223
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
224
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
225
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
226
|
+
# @param type [String] Filter by type when: - `type=charge`, only charge invoices will be returned. - `type=credit`, only credit invoices will be returned. - `type=non-legacy`, only charge and credit invoices will be returned. - `type=legacy`, only legacy invoices will be returned.
|
227
|
+
# @return [Pager<Resources::Invoice>] A list of the account's invoices.
|
228
|
+
def list_account_invoices(account_id:, **options)
|
229
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/invoices", site_id: site_id, account_id: account_id)
|
230
|
+
pager(path, **options)
|
231
|
+
end
|
232
|
+
|
233
|
+
# Create an invoice for pending line items
|
234
|
+
#
|
235
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
236
|
+
# @param body [Requests::InvoiceCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::InvoiceCreate}
|
237
|
+
# @return [Resources::InvoiceCollection] Returns the new invoices.
|
238
|
+
def create_invoice(account_id:, body:)
|
239
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/invoices", site_id: site_id, account_id: account_id)
|
240
|
+
post(path, body, Requests::InvoiceCreate)
|
241
|
+
end
|
242
|
+
|
243
|
+
# Preview new invoice for pending line items
|
244
|
+
#
|
245
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
246
|
+
# @param body [Requests::InvoiceCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::InvoiceCreate}
|
247
|
+
# @return [Resources::InvoiceCollection] Returns the invoice previews.
|
248
|
+
def preview_invoice(account_id:, body:)
|
249
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/invoices/preview", site_id: site_id, account_id: account_id)
|
250
|
+
post(path, body, Requests::InvoiceCreate)
|
251
|
+
end
|
252
|
+
|
253
|
+
# List an account's line items
|
254
|
+
#
|
255
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
256
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
257
|
+
# @param limit [Integer] Limit number of records 1-200.
|
258
|
+
# @param order [String] Sort order.
|
259
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
260
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
261
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
262
|
+
# @param original [String] Filter by original field.
|
263
|
+
# @param state [String] Filter by state field.
|
264
|
+
# @param type [String] Filter by type field.
|
265
|
+
# @return [Pager<Resources::LineItem>] A list of the account's line items.
|
266
|
+
def list_account_line_items(account_id:, **options)
|
267
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/line_items", site_id: site_id, account_id: account_id)
|
268
|
+
pager(path, **options)
|
269
|
+
end
|
270
|
+
|
271
|
+
# Create a new line item for the account
|
272
|
+
#
|
273
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
274
|
+
# @param body [Requests::LineItemCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::LineItemCreate}
|
275
|
+
# @return [Resources::LineItem] Returns the new line item.
|
276
|
+
def create_line_item(account_id:, body:)
|
277
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/line_items", site_id: site_id, account_id: account_id)
|
278
|
+
post(path, body, Requests::LineItemCreate)
|
279
|
+
end
|
280
|
+
|
281
|
+
# Fetch a list of an account's notes
|
282
|
+
#
|
283
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
284
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
285
|
+
# @return [Pager<Resources::AccountNote>] A list of an account's notes.
|
286
|
+
def list_account_notes(account_id:, **options)
|
287
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/notes", site_id: site_id, account_id: account_id)
|
288
|
+
pager(path, **options)
|
289
|
+
end
|
290
|
+
|
291
|
+
# Fetch an account note
|
292
|
+
#
|
293
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
294
|
+
# @param account_note_id [String] Account Note ID.
|
295
|
+
# @return [Resources::AccountNote] An account note.
|
296
|
+
def get_account_note(account_id:, account_note_id:)
|
297
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/notes/{account_note_id}", site_id: site_id, account_id: account_id, account_note_id: account_note_id)
|
298
|
+
get(path)
|
299
|
+
end
|
300
|
+
|
301
|
+
# Fetch a list of an account's shipping addresses
|
302
|
+
#
|
303
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
304
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
305
|
+
# @param limit [Integer] Limit number of records 1-200.
|
306
|
+
# @param order [String] Sort order.
|
307
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
308
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
309
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
310
|
+
# @return [Pager<Resources::ShippingAddress>] A list of an account's shipping addresses.
|
311
|
+
def list_shipping_addresses(account_id:, **options)
|
312
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/shipping_addresses", site_id: site_id, account_id: account_id)
|
313
|
+
pager(path, **options)
|
314
|
+
end
|
315
|
+
|
316
|
+
# Create a new shipping address for the account
|
317
|
+
#
|
318
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
319
|
+
# @param body [Requests::ShippingAddressCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::ShippingAddressCreate}
|
320
|
+
# @return [Resources::ShippingAddress] Returns the new shipping address.
|
321
|
+
def create_shipping_address(account_id:, body:)
|
322
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/shipping_addresses", site_id: site_id, account_id: account_id)
|
323
|
+
post(path, body, Requests::ShippingAddressCreate)
|
324
|
+
end
|
325
|
+
|
326
|
+
# Fetch an account's shipping address
|
327
|
+
#
|
328
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
329
|
+
# @param shipping_address_id [String] Shipping Address ID.
|
330
|
+
# @return [Resources::ShippingAddress] A shipping address.
|
331
|
+
def get_shipping_address(account_id:, shipping_address_id:)
|
332
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/shipping_addresses/{shipping_address_id}", site_id: site_id, account_id: account_id, shipping_address_id: shipping_address_id)
|
333
|
+
get(path)
|
334
|
+
end
|
335
|
+
|
336
|
+
# Update an account's shipping address
|
337
|
+
#
|
338
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
339
|
+
# @param shipping_address_id [String] Shipping Address ID.
|
340
|
+
# @param body [Requests::ShippingAddressUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::ShippingAddressUpdate}
|
341
|
+
# @return [Resources::ShippingAddress] The updated shipping address.
|
342
|
+
def update_shipping_address(account_id:, shipping_address_id:, body:)
|
343
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/shipping_addresses/{shipping_address_id}", site_id: site_id, account_id: account_id, shipping_address_id: shipping_address_id)
|
344
|
+
put(path, body, Requests::ShippingAddressUpdate)
|
345
|
+
end
|
346
|
+
|
347
|
+
# Remove an account's shipping address
|
348
|
+
#
|
349
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
350
|
+
# @param shipping_address_id [String] Shipping Address ID.
|
351
|
+
def remove_shipping_address(account_id:, shipping_address_id:)
|
352
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/shipping_addresses/{shipping_address_id}", site_id: site_id, account_id: account_id, shipping_address_id: shipping_address_id)
|
353
|
+
delete(path)
|
354
|
+
end
|
355
|
+
|
356
|
+
# List an account's subscriptions
|
357
|
+
#
|
358
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
359
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
360
|
+
# @param limit [Integer] Limit number of records 1-200.
|
361
|
+
# @param order [String] Sort order.
|
362
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
363
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
364
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
365
|
+
# @param state [String] Filter by state. - When `state=active`, `state=canceled`, `state=expired`, or `state=future`, subscriptions with states that match the query and only those subscriptions will be returned. - 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. - When `state=live`, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.
|
366
|
+
# @return [Pager<Resources::Subscription>] A list of the account's subscriptions.
|
367
|
+
def list_account_subscriptions(account_id:, **options)
|
368
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/subscriptions", site_id: site_id, account_id: account_id)
|
369
|
+
pager(path, **options)
|
370
|
+
end
|
371
|
+
|
372
|
+
# List an account's transactions
|
373
|
+
#
|
374
|
+
# @param account_id [String] Account ID or code (use prefix: `code-`, e.g. `code-bob`).
|
375
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
376
|
+
# @param limit [Integer] Limit number of records 1-200.
|
377
|
+
# @param order [String] Sort order.
|
378
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
379
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
380
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
381
|
+
# @param type [String] Filter by type field.
|
382
|
+
# @param success [String] Filter by success field.
|
383
|
+
# @return [Pager<Resources::Transaction>] A list of the account's transactions.
|
384
|
+
def list_account_transactions(account_id:, **options)
|
385
|
+
path = interpolate_path("/sites/{site_id}/accounts/{account_id}/transactions", site_id: site_id, account_id: account_id)
|
386
|
+
pager(path, **options)
|
387
|
+
end
|
388
|
+
|
389
|
+
# List a site's account acquisition data
|
390
|
+
#
|
391
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
392
|
+
# @param limit [Integer] Limit number of records 1-200.
|
393
|
+
# @param order [String] Sort order.
|
394
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
395
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
396
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
397
|
+
# @return [Resources::AccountAcquisition] A list of the site's account acquisition data.
|
398
|
+
def list_account_acquisition(**options)
|
399
|
+
path = interpolate_path("/sites/{site_id}/acquisitions", site_id: site_id)
|
400
|
+
get(path, **options)
|
401
|
+
end
|
402
|
+
|
403
|
+
# List a site's coupons
|
404
|
+
#
|
405
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
406
|
+
# @param limit [Integer] Limit number of records 1-200.
|
407
|
+
# @param order [String] Sort order.
|
408
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
409
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
410
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
411
|
+
# @return [Pager<Resources::Coupon>] A list of the site's coupons.
|
412
|
+
def list_coupons(**options)
|
413
|
+
path = interpolate_path("/sites/{site_id}/coupons", site_id: site_id)
|
414
|
+
pager(path, **options)
|
415
|
+
end
|
416
|
+
|
417
|
+
# Create a new coupon
|
418
|
+
#
|
419
|
+
# @param body [Requests::CreateCoupon] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::CreateCoupon}
|
420
|
+
# @return [Resources::Coupon] A new coupon.
|
421
|
+
def create_coupon(body:)
|
422
|
+
path = interpolate_path("/sites/{site_id}/coupons", site_id: site_id)
|
423
|
+
post(path, body, Requests::CreateCoupon)
|
424
|
+
end
|
425
|
+
|
426
|
+
# Fetch a coupon
|
427
|
+
#
|
428
|
+
# @param coupon_id [String] Coupon ID or code (use prefix: `code-`, e.g. `code-10off`).
|
429
|
+
# @return [Resources::Coupon] A coupon.
|
430
|
+
def get_coupon(coupon_id:)
|
431
|
+
path = interpolate_path("/sites/{site_id}/coupons/{coupon_id}", site_id: site_id, coupon_id: coupon_id)
|
432
|
+
get(path)
|
433
|
+
end
|
434
|
+
|
435
|
+
# Update an active coupon
|
436
|
+
#
|
437
|
+
# @param coupon_id [String] Coupon ID or code (use prefix: `code-`, e.g. `code-10off`).
|
438
|
+
# @param body [Requests::UpdateCoupon] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::UpdateCoupon}
|
439
|
+
# @return [Resources::Coupon] The updated coupon.
|
440
|
+
def update_coupon(coupon_id:, body:)
|
441
|
+
path = interpolate_path("/sites/{site_id}/coupons/{coupon_id}", site_id: site_id, coupon_id: coupon_id)
|
442
|
+
put(path, body, Requests::UpdateCoupon)
|
443
|
+
end
|
444
|
+
|
445
|
+
# List unique coupon codes associated with a bulk coupon
|
446
|
+
#
|
447
|
+
# @param coupon_id [String] Coupon ID or code (use prefix: `code-`, e.g. `code-10off`).
|
448
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
449
|
+
# @param limit [Integer] Limit number of records 1-200.
|
450
|
+
# @param order [String] Sort order.
|
451
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
452
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
453
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
454
|
+
# @return [Pager<Resources::UniqueCouponCode>] A list of unique coupon codes that were generated
|
455
|
+
def list_unique_coupon_codes(coupon_id:, **options)
|
456
|
+
path = interpolate_path("/sites/{site_id}/coupons/{coupon_id}/unique_coupon_codes", site_id: site_id, coupon_id: coupon_id)
|
457
|
+
pager(path, **options)
|
458
|
+
end
|
459
|
+
|
460
|
+
# List a site's credit payments
|
461
|
+
#
|
462
|
+
# @param limit [Integer] Limit number of records 1-200.
|
463
|
+
# @param order [String] Sort order.
|
464
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
465
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
466
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
467
|
+
# @return [Pager<Resources::CreditPayment>] A list of the site's credit payments.
|
468
|
+
def list_credit_payments(**options)
|
469
|
+
path = interpolate_path("/sites/{site_id}/credit_payments", site_id: site_id)
|
470
|
+
pager(path, **options)
|
471
|
+
end
|
472
|
+
|
473
|
+
# Fetch a credit payment
|
474
|
+
#
|
475
|
+
# @param credit_payment_id [String] Credit Payment ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
476
|
+
# @return [Resources::CreditPayment] A credit payment.
|
477
|
+
def get_credit_payment(credit_payment_id:)
|
478
|
+
path = interpolate_path("/sites/{site_id}/credit_payments/{credit_payment_id}", site_id: site_id, credit_payment_id: credit_payment_id)
|
479
|
+
get(path)
|
480
|
+
end
|
481
|
+
|
482
|
+
# List a site's invoices
|
483
|
+
#
|
484
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
485
|
+
# @param limit [Integer] Limit number of records 1-200.
|
486
|
+
# @param order [String] Sort order.
|
487
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
488
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
489
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
490
|
+
# @param type [String] Filter by type when: - `type=charge`, only charge invoices will be returned. - `type=credit`, only credit invoices will be returned. - `type=non-legacy`, only charge and credit invoices will be returned. - `type=legacy`, only legacy invoices will be returned.
|
491
|
+
# @return [Pager<Resources::Invoice>] A list of the site's invoices.
|
492
|
+
def list_invoices(**options)
|
493
|
+
path = interpolate_path("/sites/{site_id}/invoices", site_id: site_id)
|
494
|
+
pager(path, **options)
|
495
|
+
end
|
496
|
+
|
497
|
+
# Fetch an invoice
|
498
|
+
#
|
499
|
+
# @param invoice_id [String] Invoice ID or number (use prefix: `number-`, e.g. `number-1000`).
|
500
|
+
# @return [Resources::Invoice] An invoice.
|
501
|
+
def get_invoice(invoice_id:)
|
502
|
+
path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}", site_id: site_id, invoice_id: invoice_id)
|
503
|
+
get(path)
|
504
|
+
end
|
505
|
+
|
506
|
+
# Collect a pending or past due, automatic invoice
|
507
|
+
#
|
508
|
+
# @param invoice_id [String] Invoice ID or number (use prefix: `number-`, e.g. `number-1000`).
|
509
|
+
# @return [Resources::Invoice] The updated invoice.
|
510
|
+
def collect_invoice(invoice_id:)
|
511
|
+
path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/collect", site_id: site_id, invoice_id: invoice_id)
|
512
|
+
put(path)
|
513
|
+
end
|
514
|
+
|
515
|
+
# Mark an open invoice as failed
|
516
|
+
#
|
517
|
+
# @param invoice_id [String] Invoice ID or number (use prefix: `number-`, e.g. `number-1000`).
|
518
|
+
# @return [Resources::Invoice] The updated invoice.
|
519
|
+
def fail_invoice(invoice_id:)
|
520
|
+
path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/mark_failed", site_id: site_id, invoice_id: invoice_id)
|
521
|
+
put(path)
|
522
|
+
end
|
523
|
+
|
524
|
+
# Mark an open invoice as successful
|
525
|
+
#
|
526
|
+
# @param invoice_id [String] Invoice ID or number (use prefix: `number-`, e.g. `number-1000`).
|
527
|
+
# @return [Resources::Invoice] The updated invoice.
|
528
|
+
def mark_invoice_successful(invoice_id:)
|
529
|
+
path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/mark_successful", site_id: site_id, invoice_id: invoice_id)
|
530
|
+
put(path)
|
531
|
+
end
|
532
|
+
|
533
|
+
# Reopen a closed, manual invoice
|
534
|
+
#
|
535
|
+
# @param invoice_id [String] Invoice ID or number (use prefix: `number-`, e.g. `number-1000`).
|
536
|
+
# @return [Resources::Invoice] The updated invoice.
|
537
|
+
def reopen_invoice(invoice_id:)
|
538
|
+
path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/reopen", site_id: site_id, invoice_id: invoice_id)
|
539
|
+
put(path)
|
540
|
+
end
|
541
|
+
|
542
|
+
# List a invoice's line items
|
543
|
+
#
|
544
|
+
# @param invoice_id [String] Invoice ID or number (use prefix: `number-`, e.g. `number-1000`).
|
545
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
546
|
+
# @param limit [Integer] Limit number of records 1-200.
|
547
|
+
# @param order [String] Sort order.
|
548
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
549
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
550
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
551
|
+
# @param original [String] Filter by original field.
|
552
|
+
# @param state [String] Filter by state field.
|
553
|
+
# @param type [String] Filter by type field.
|
554
|
+
# @return [Pager<Resources::LineItem>] A list of the invoice's line items.
|
555
|
+
def list_invoice_line_items(invoice_id:, **options)
|
556
|
+
path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/line_items", site_id: site_id, invoice_id: invoice_id)
|
557
|
+
pager(path, **options)
|
558
|
+
end
|
559
|
+
|
560
|
+
# Show the coupon redemptions applied to an invoice
|
561
|
+
#
|
562
|
+
# @param invoice_id [String] Invoice ID or number (use prefix: `number-`, e.g. `number-1000`).
|
563
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
564
|
+
# @return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions associated with the invoice.
|
565
|
+
def list_invoice_coupon_redemptions(invoice_id:, **options)
|
566
|
+
path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/coupon_redemptions", site_id: site_id, invoice_id: invoice_id)
|
567
|
+
pager(path, **options)
|
568
|
+
end
|
569
|
+
|
570
|
+
# List an invoice's related credit or charge invoices
|
571
|
+
#
|
572
|
+
# @param invoice_id [String] Invoice ID or number (use prefix: `number-`, e.g. `number-1000`).
|
573
|
+
# @return [Pager<Resources::Invoice>] A list of the credit or charge invoices associated with the invoice.
|
574
|
+
def list_related_invoices(invoice_id:)
|
575
|
+
path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/related_invoices", site_id: site_id, invoice_id: invoice_id)
|
576
|
+
pager(path)
|
577
|
+
end
|
578
|
+
|
579
|
+
# Refund an invoice
|
580
|
+
#
|
581
|
+
# @param invoice_id [String] Invoice ID or number (use prefix: `number-`, e.g. `number-1000`).
|
582
|
+
# @param body [Requests::InvoiceRefund] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::InvoiceRefund}
|
583
|
+
# @return [Resources::Invoice] Returns the new credit invoice.
|
584
|
+
def refund_invoice(invoice_id:, body:)
|
585
|
+
path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/refund", site_id: site_id, invoice_id: invoice_id)
|
586
|
+
post(path, body, Requests::InvoiceRefund)
|
587
|
+
end
|
588
|
+
|
589
|
+
# List a site's line items
|
590
|
+
#
|
591
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
592
|
+
# @param limit [Integer] Limit number of records 1-200.
|
593
|
+
# @param order [String] Sort order.
|
594
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
595
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
596
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
597
|
+
# @param original [String] Filter by original field.
|
598
|
+
# @param state [String] Filter by state field.
|
599
|
+
# @param type [String] Filter by type field.
|
600
|
+
# @return [Pager<Resources::LineItem>] A list of the site's line items.
|
601
|
+
def list_line_items(**options)
|
602
|
+
path = interpolate_path("/sites/{site_id}/line_items", site_id: site_id)
|
603
|
+
pager(path, **options)
|
604
|
+
end
|
605
|
+
|
606
|
+
# Fetch a line item
|
607
|
+
#
|
608
|
+
# @param line_item_id [String] Line Item ID.
|
609
|
+
# @return [Resources::LineItem] A line item.
|
610
|
+
def get_line_item(line_item_id:)
|
611
|
+
path = interpolate_path("/sites/{site_id}/line_items/{line_item_id}", site_id: site_id, line_item_id: line_item_id)
|
612
|
+
get(path)
|
613
|
+
end
|
614
|
+
|
615
|
+
# Delete an uninvoiced line item
|
616
|
+
#
|
617
|
+
# @param line_item_id [String] Line Item ID.
|
618
|
+
def remove_line_item(line_item_id:)
|
619
|
+
path = interpolate_path("/sites/{site_id}/line_items/{line_item_id}", site_id: site_id, line_item_id: line_item_id)
|
620
|
+
delete(path)
|
621
|
+
end
|
622
|
+
|
623
|
+
# List a site's plans
|
624
|
+
#
|
625
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
626
|
+
# @param limit [Integer] Limit number of records 1-200.
|
627
|
+
# @param order [String] Sort order.
|
628
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
629
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
630
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
631
|
+
# @param state [String] Filter by state.
|
632
|
+
# @return [Pager<Resources::Plan>] A list of plans.
|
633
|
+
def list_plans(**options)
|
634
|
+
path = interpolate_path("/sites/{site_id}/plans", site_id: site_id)
|
635
|
+
pager(path, **options)
|
636
|
+
end
|
637
|
+
|
638
|
+
# Create a plan
|
639
|
+
#
|
640
|
+
# @param body [Requests::PlanCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::PlanCreate}
|
641
|
+
# @return [Resources::Plan] A plan.
|
642
|
+
def create_plan(body:)
|
643
|
+
path = interpolate_path("/sites/{site_id}/plans", site_id: site_id)
|
644
|
+
post(path, body, Requests::PlanCreate)
|
645
|
+
end
|
646
|
+
|
647
|
+
# Fetch a plan
|
648
|
+
#
|
649
|
+
# @param plan_id [String] Plan ID or code (use prefix: `code-`, e.g. `code-gold`).
|
650
|
+
# @return [Resources::Plan] A plan.
|
651
|
+
def get_plan(plan_id:)
|
652
|
+
path = interpolate_path("/sites/{site_id}/plans/{plan_id}", site_id: site_id, plan_id: plan_id)
|
653
|
+
get(path)
|
654
|
+
end
|
655
|
+
|
656
|
+
# Update a plan
|
657
|
+
#
|
658
|
+
# @param plan_id [String] Plan ID or code (use prefix: `code-`, e.g. `code-gold`).
|
659
|
+
# @param body [Requests::PlanUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::PlanUpdate}
|
660
|
+
# @return [Resources::Plan] A plan.
|
661
|
+
def update_plan(plan_id:, body:)
|
662
|
+
path = interpolate_path("/sites/{site_id}/plans/{plan_id}", site_id: site_id, plan_id: plan_id)
|
663
|
+
put(path, body, Requests::PlanUpdate)
|
664
|
+
end
|
665
|
+
|
666
|
+
# Remove a plan
|
667
|
+
#
|
668
|
+
# @param plan_id [String] Plan ID or code (use prefix: `code-`, e.g. `code-gold`).
|
669
|
+
# @return [Resources::Plan] Plan deleted
|
670
|
+
def remove_plan(plan_id:)
|
671
|
+
path = interpolate_path("/sites/{site_id}/plans/{plan_id}", site_id: site_id, plan_id: plan_id)
|
672
|
+
delete(path)
|
673
|
+
end
|
674
|
+
|
675
|
+
# List a plan's add-ons
|
676
|
+
#
|
677
|
+
# @param plan_id [String] Plan ID or code (use prefix: `code-`, e.g. `code-gold`).
|
678
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
679
|
+
# @param limit [Integer] Limit number of records 1-200.
|
680
|
+
# @param order [String] Sort order.
|
681
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
682
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
683
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
684
|
+
# @param state [String] Filter by state.
|
685
|
+
# @return [Pager<Resources::AddOn>] A list of add-ons.
|
686
|
+
def list_plan_add_ons(plan_id:, **options)
|
687
|
+
path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons", site_id: site_id, plan_id: plan_id)
|
688
|
+
pager(path, **options)
|
689
|
+
end
|
690
|
+
|
691
|
+
# Create an add-on
|
692
|
+
#
|
693
|
+
# @param plan_id [String] Plan ID or code (use prefix: `code-`, e.g. `code-gold`).
|
694
|
+
# @param body [Requests::AddOnCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::AddOnCreate}
|
695
|
+
# @return [Resources::AddOn] An add-on.
|
696
|
+
def create_plan_add_on(plan_id:, body:)
|
697
|
+
path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons", site_id: site_id, plan_id: plan_id)
|
698
|
+
post(path, body, Requests::AddOnCreate)
|
699
|
+
end
|
700
|
+
|
701
|
+
# Fetch a plan's add-on
|
702
|
+
#
|
703
|
+
# @param add_on_id [String] Add-on ID or code (use prefix: `code-`, e.g. `code-gold`).
|
704
|
+
# @param plan_id [String] Plan ID or code (use prefix: `code-`, e.g. `code-gold`).
|
705
|
+
# @return [Resources::AddOn] An add-on.
|
706
|
+
def get_plan_add_on(add_on_id:, plan_id:)
|
707
|
+
path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}", site_id: site_id, add_on_id: add_on_id, plan_id: plan_id)
|
708
|
+
get(path)
|
709
|
+
end
|
710
|
+
|
711
|
+
# Update an add-on
|
712
|
+
#
|
713
|
+
# @param add_on_id [String] Add-on ID or code (use prefix: `code-`, e.g. `code-gold`).
|
714
|
+
# @param plan_id [String] Plan ID or code (use prefix: `code-`, e.g. `code-gold`).
|
715
|
+
# @param body [Requests::AddOnUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::AddOnUpdate}
|
716
|
+
# @return [Resources::AddOn] An add-on.
|
717
|
+
def update_plan_add_on(add_on_id:, plan_id:, body:)
|
718
|
+
path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}", site_id: site_id, add_on_id: add_on_id, plan_id: plan_id)
|
719
|
+
put(path, body, Requests::AddOnUpdate)
|
720
|
+
end
|
721
|
+
|
722
|
+
# Remove an add-on
|
723
|
+
#
|
724
|
+
# @param add_on_id [String] Add-on ID or code (use prefix: `code-`, e.g. `code-gold`).
|
725
|
+
# @param plan_id [String] Plan ID or code (use prefix: `code-`, e.g. `code-gold`).
|
726
|
+
# @return [Resources::AddOn] Add-on deleted
|
727
|
+
def remove_plan_add_on(add_on_id:, plan_id:)
|
728
|
+
path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}", site_id: site_id, add_on_id: add_on_id, plan_id: plan_id)
|
729
|
+
delete(path)
|
730
|
+
end
|
731
|
+
|
732
|
+
# List a site's add-ons
|
733
|
+
#
|
734
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
735
|
+
# @param limit [Integer] Limit number of records 1-200.
|
736
|
+
# @param order [String] Sort order.
|
737
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
738
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
739
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
740
|
+
# @param state [String] Filter by state.
|
741
|
+
# @return [Pager<Resources::AddOn>] A list of add-ons.
|
742
|
+
def list_add_ons(**options)
|
743
|
+
path = interpolate_path("/sites/{site_id}/add_ons", site_id: site_id)
|
744
|
+
pager(path, **options)
|
745
|
+
end
|
746
|
+
|
747
|
+
# Fetch an add-on
|
748
|
+
#
|
749
|
+
# @param add_on_id [String] Add-on ID or code (use prefix: `code-`, e.g. `code-gold`).
|
750
|
+
# @return [Resources::AddOn] An add-on.
|
751
|
+
def get_add_on(add_on_id:)
|
752
|
+
path = interpolate_path("/sites/{site_id}/add_ons/{add_on_id}", site_id: site_id, add_on_id: add_on_id)
|
753
|
+
get(path)
|
754
|
+
end
|
755
|
+
|
756
|
+
# List a site's subscriptions
|
757
|
+
#
|
758
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
759
|
+
# @param limit [Integer] Limit number of records 1-200.
|
760
|
+
# @param order [String] Sort order.
|
761
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
762
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
763
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
764
|
+
# @param state [String] Filter by state. - When `state=active`, `state=canceled`, `state=expired`, or `state=future`, subscriptions with states that match the query and only those subscriptions will be returned. - 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. - When `state=live`, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.
|
765
|
+
# @return [Pager<Resources::Subscription>] A list of the site's subscriptions.
|
766
|
+
def list_subscriptions(**options)
|
767
|
+
path = interpolate_path("/sites/{site_id}/subscriptions", site_id: site_id)
|
768
|
+
pager(path, **options)
|
769
|
+
end
|
770
|
+
|
771
|
+
# Create a new subscription
|
772
|
+
#
|
773
|
+
# @param body [Requests::SubscriptionCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::SubscriptionCreate}
|
774
|
+
# @return [Resources::Subscription] A subscription.
|
775
|
+
def create_subscription(body:)
|
776
|
+
path = interpolate_path("/sites/{site_id}/subscriptions", site_id: site_id)
|
777
|
+
post(path, body, Requests::SubscriptionCreate)
|
778
|
+
end
|
779
|
+
|
780
|
+
# Fetch a subscription
|
781
|
+
#
|
782
|
+
# @param subscription_id [String] Subscription ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
783
|
+
# @return [Resources::Subscription] A subscription.
|
784
|
+
# @example
|
785
|
+
# begin
|
786
|
+
# # You can use the `id` field from a Subscription object
|
787
|
+
# subscription = @client.get_subscription(subscription_id: "hympfmu77b4d")
|
788
|
+
# # If you have the uuid, you can prefix with `uuid-`
|
789
|
+
# subscription = @client.get_subscription(subscription_id: "uuid-419cd2effd49236e502ccc42db928280")
|
790
|
+
# rescue Recurly::Errors::NotFoundError => e
|
791
|
+
# puts e
|
792
|
+
# # => Recurly::NotFoundError: Couldn't Subscription with uuid = 419cd2effd49236e502ccc42db928280
|
793
|
+
# puts e.recurly_error
|
794
|
+
# # => #<Recurly::Error:0x007f8b29918618 @attributes={:type=>"not_found", :message=>"Couldn't find Subscription with uuid = 419cd2effd49236e502ccc42db928280", :params=>[{"param"=>"subscription_id"}]}>
|
795
|
+
# end
|
796
|
+
#
|
797
|
+
def get_subscription(subscription_id:)
|
798
|
+
path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}", site_id: site_id, subscription_id: subscription_id)
|
799
|
+
get(path)
|
800
|
+
end
|
801
|
+
|
802
|
+
# Modify a subscription
|
803
|
+
#
|
804
|
+
# @param subscription_id [String] Subscription ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
805
|
+
# @param body [Requests::SubscriptionUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::SubscriptionUpdate}
|
806
|
+
# @return [Resources::Subscription] A subscription.
|
807
|
+
def modify_subscription(subscription_id:, body:)
|
808
|
+
path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}", site_id: site_id, subscription_id: subscription_id)
|
809
|
+
put(path, body, Requests::SubscriptionUpdate)
|
810
|
+
end
|
811
|
+
|
812
|
+
# Terminate a subscription
|
813
|
+
#
|
814
|
+
# @param subscription_id [String] Subscription ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
815
|
+
# @param refund [String] The type of refund to perform: * `full` - Performs a full refund of the last invoice for the current subscription term. * `partial` - Prorates a refund based on the amount of time remaining in the current bill cycle. * `none` - Terminates the subscription without a refund. 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. You may also terminate a subscription with no refund and then manually refund specific invoices.
|
816
|
+
# @return [Resources::Subscription] An expired subscription.
|
817
|
+
def terminate_subscription(subscription_id:, **options)
|
818
|
+
path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}", site_id: site_id, subscription_id: subscription_id)
|
819
|
+
delete(path, **options)
|
820
|
+
end
|
821
|
+
|
822
|
+
# Cancel a subscription
|
823
|
+
#
|
824
|
+
# @param subscription_id [String] Subscription ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
825
|
+
# @return [Resources::Subscription] A canceled or failed subscription.
|
826
|
+
def cancel_subscription(subscription_id:)
|
827
|
+
path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/cancel", site_id: site_id, subscription_id: subscription_id)
|
828
|
+
put(path)
|
829
|
+
end
|
830
|
+
|
831
|
+
# Reactivate a canceled subscription
|
832
|
+
#
|
833
|
+
# @param subscription_id [String] Subscription ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
834
|
+
# @return [Resources::Subscription] An active subscription.
|
835
|
+
def reactivate_subscription(subscription_id:)
|
836
|
+
path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/reactivate", site_id: site_id, subscription_id: subscription_id)
|
837
|
+
put(path)
|
838
|
+
end
|
839
|
+
|
840
|
+
# Fetch a subscription's pending change
|
841
|
+
#
|
842
|
+
# @param subscription_id [String] Subscription ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
843
|
+
# @return [Resources::SubscriptionChange] A subscription's pending change.
|
844
|
+
def get_subscription_change(subscription_id:)
|
845
|
+
path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/change", site_id: site_id, subscription_id: subscription_id)
|
846
|
+
get(path)
|
847
|
+
end
|
848
|
+
|
849
|
+
# Create a new subscription change
|
850
|
+
#
|
851
|
+
# @param subscription_id [String] Subscription ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
852
|
+
# @param body [Requests::SubscriptionChangeCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::Requests::SubscriptionChangeCreate}
|
853
|
+
# @return [Resources::SubscriptionChange] A subscription change.
|
854
|
+
def create_subscription_change(subscription_id:, body:)
|
855
|
+
path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/change", site_id: site_id, subscription_id: subscription_id)
|
856
|
+
post(path, body, Requests::SubscriptionChangeCreate)
|
857
|
+
end
|
858
|
+
|
859
|
+
# Delete the pending subscription change
|
860
|
+
#
|
861
|
+
# @param subscription_id [String] Subscription ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
862
|
+
def remove_subscription_change(subscription_id:)
|
863
|
+
path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/change", site_id: site_id, subscription_id: subscription_id)
|
864
|
+
delete(path)
|
865
|
+
end
|
866
|
+
|
867
|
+
# List a subscription's invoices
|
868
|
+
#
|
869
|
+
# @param subscription_id [String] Subscription ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
870
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
871
|
+
# @param limit [Integer] Limit number of records 1-200.
|
872
|
+
# @param order [String] Sort order.
|
873
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
874
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
875
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
876
|
+
# @param type [String] Filter by type when: - `type=charge`, only charge invoices will be returned. - `type=credit`, only credit invoices will be returned. - `type=non-legacy`, only charge and credit invoices will be returned. - `type=legacy`, only legacy invoices will be returned.
|
877
|
+
# @return [Pager<Resources::Invoice>] A list of the subscription's invoices.
|
878
|
+
def list_subscription_invoices(subscription_id:, **options)
|
879
|
+
path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/invoices", site_id: site_id, subscription_id: subscription_id)
|
880
|
+
pager(path, **options)
|
881
|
+
end
|
882
|
+
|
883
|
+
# List a site's transactions
|
884
|
+
#
|
885
|
+
# @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using commas as separators, e.g. `ids=h1at4d57xlmy,gyqgg0d3v9n1`. **Important notes:** * The `ids` parameter cannot be used with any other ordering or filtering parameters (`limit`, `order`, `sort`, `begin_time`, `end_time`, etc) * Invalid or unknown IDs will be ignored, so you should check that the results correspond to your request. * Records are returned in an arbitrary order. Since results are all returned at once you can sort the records yourself.
|
886
|
+
# @param limit [Integer] Limit number of records 1-200.
|
887
|
+
# @param order [String] Sort order.
|
888
|
+
# @param sort [String] Sort field. You *really* only want to sort by `updated_at` in ascending order. In descending order updated records will move behind the cursor and could prevent some records from being returned.
|
889
|
+
# @param begin_time [DateTime] Filter by begin_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
890
|
+
# @param end_time [DateTime] Filter by end_time when `sort=created_at` or `sort=updated_at`. **Note:** this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
|
891
|
+
# @param type [String] Filter by type field.
|
892
|
+
# @param success [String] Filter by success field.
|
893
|
+
# @return [Pager<Resources::Transaction>] A list of the site's transactions.
|
894
|
+
def list_transactions(**options)
|
895
|
+
path = interpolate_path("/sites/{site_id}/transactions", site_id: site_id)
|
896
|
+
pager(path, **options)
|
897
|
+
end
|
898
|
+
|
899
|
+
# Fetch a transaction
|
900
|
+
#
|
901
|
+
# @param transaction_id [String] Transaction ID or UUID (use prefix: `uuid-`, e.g. `uuid-123457890`).
|
902
|
+
# @return [Resources::Transaction] A transaction.
|
903
|
+
def get_transaction(transaction_id:)
|
904
|
+
path = interpolate_path("/sites/{site_id}/transactions/{transaction_id}", site_id: site_id, transaction_id: transaction_id)
|
905
|
+
get(path)
|
906
|
+
end
|
907
|
+
|
908
|
+
# Fetch a unique coupon code
|
909
|
+
#
|
910
|
+
# @param unique_coupon_code_id [String] Unique Coupon Code ID or code (use prefix: `code-`, e.g. `code-abc-8dh2-def`).
|
911
|
+
# @return [Resources::UniqueCouponCode] A unique coupon code.
|
912
|
+
def get_unique_coupon_code(unique_coupon_code_id:)
|
913
|
+
path = interpolate_path("/sites/{site_id}/unique_coupon_codes/{unique_coupon_code_id}", site_id: site_id, unique_coupon_code_id: unique_coupon_code_id)
|
914
|
+
get(path)
|
915
|
+
end
|
916
|
+
|
917
|
+
# Deactivate a unique coupon code
|
918
|
+
#
|
919
|
+
# @param unique_coupon_code_id [String] Unique Coupon Code ID or code (use prefix: `code-`, e.g. `code-abc-8dh2-def`).
|
920
|
+
# @return [Resources::UniqueCouponCode] A unique coupon code.
|
921
|
+
def deactivate_unique_coupon_code(unique_coupon_code_id:)
|
922
|
+
path = interpolate_path("/sites/{site_id}/unique_coupon_codes/{unique_coupon_code_id}", site_id: site_id, unique_coupon_code_id: unique_coupon_code_id)
|
923
|
+
delete(path)
|
924
|
+
end
|
925
|
+
|
926
|
+
# Restore a unique coupon code
|
927
|
+
#
|
928
|
+
# @param unique_coupon_code_id [String] Unique Coupon Code ID or code (use prefix: `code-`, e.g. `code-abc-8dh2-def`).
|
929
|
+
# @return [Resources::UniqueCouponCode] A unique coupon code.
|
930
|
+
def reactivate_unique_coupon_code(unique_coupon_code_id:)
|
931
|
+
path = interpolate_path("/sites/{site_id}/unique_coupon_codes/{unique_coupon_code_id}/restore", site_id: site_id, unique_coupon_code_id: unique_coupon_code_id)
|
932
|
+
put(path)
|
933
|
+
end
|
934
|
+
end
|
935
|
+
end
|