recurly 2.17.0 → 3.14.0

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