recurly 2.17.5 → 4.18.0

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