recurly 3.4.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.bumpversion.cfg +5 -1
  3. data/.github/workflows/docs.yml +28 -0
  4. data/.travis.yml +1 -0
  5. data/CHANGELOG.md +107 -13
  6. data/GETTING_STARTED.md +61 -1
  7. data/README.md +1 -1
  8. data/lib/recurly/client.rb +126 -52
  9. data/lib/recurly/client/operations.rb +314 -1
  10. data/lib/recurly/http.rb +3 -2
  11. data/lib/recurly/pager.rb +31 -12
  12. data/lib/recurly/requests/add_on_create.rb +15 -3
  13. data/lib/recurly/requests/add_on_update.rb +9 -1
  14. data/lib/recurly/requests/billing_info_create.rb +26 -2
  15. data/lib/recurly/requests/external_transaction.rb +26 -0
  16. data/lib/recurly/requests/plan_create.rb +8 -0
  17. data/lib/recurly/requests/plan_update.rb +8 -0
  18. data/lib/recurly/requests/shipping_method_create.rb +26 -0
  19. data/lib/recurly/requests/shipping_method_update.rb +26 -0
  20. data/lib/recurly/requests/subscription_add_on_create.rb +9 -1
  21. data/lib/recurly/requests/subscription_add_on_tier.rb +18 -0
  22. data/lib/recurly/requests/subscription_add_on_update.rb +6 -2
  23. data/lib/recurly/requests/subscription_change_create.rb +1 -1
  24. data/lib/recurly/requests/tier.rb +18 -0
  25. data/lib/recurly/resources/add_on.rb +8 -0
  26. data/lib/recurly/resources/line_item.rb +1 -1
  27. data/lib/recurly/resources/payment_method.rb +4 -0
  28. data/lib/recurly/resources/plan.rb +8 -0
  29. data/lib/recurly/resources/shipping_method.rb +4 -0
  30. data/lib/recurly/resources/subscription_add_on.rb +16 -0
  31. data/lib/recurly/resources/subscription_add_on_tier.rb +18 -0
  32. data/lib/recurly/resources/subscription_change_preview.rb +74 -0
  33. data/lib/recurly/resources/tier.rb +18 -0
  34. data/lib/recurly/resources/transaction.rb +4 -0
  35. data/lib/recurly/version.rb +1 -1
  36. data/openapi/api.yaml +5407 -2794
  37. data/recurly.gemspec +8 -0
  38. data/scripts/changelog +2 -0
  39. data/scripts/format +5 -1
  40. data/scripts/release +5 -3
  41. metadata +18 -4
@@ -30,6 +30,7 @@ module Recurly
30
30
  # order. In descending order updated records will move behind the cursor and could
31
31
  # prevent some records from being returned.
32
32
  #
33
+ # @param state [String] Filter by state.
33
34
  # @return [Pager<Resources::Site>] A list of sites.
34
35
  # @example
35
36
  # sites = @client.list_sites(limit: 200)
@@ -48,6 +49,16 @@ module Recurly
48
49
  #
49
50
  # @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+.
50
51
  # @return [Resources::Site] A site.
52
+ # @example
53
+ # begin
54
+ # site = @client.get_site(site_id: site_id)
55
+ # puts "Got Site #{site}"
56
+ # rescue Recurly::Errors::NotFoundError
57
+ # # If the resource was not found, you may want to alert the user or
58
+ # # just return nil
59
+ # puts "Resource Not Found"
60
+ # end
61
+ #
51
62
  def get_site(site_id:)
52
63
  path = interpolate_path("/sites/{site_id}", site_id: site_id)
53
64
  get(path)
@@ -251,6 +262,28 @@ module Recurly
251
262
  # @param body [Requests::AccountAcquisitionUpdatable] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountAcquisitionUpdatable}
252
263
  # @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+.
253
264
  # @return [Resources::AccountAcquisition] An account's updated acquisition data.
265
+ # @example
266
+ # begin
267
+ # acquisition_update = {
268
+ # campaign: "podcast-marketing",
269
+ # channel: "social_media",
270
+ # subchannel: "twitter",
271
+ # cost: {
272
+ # currency: "USD",
273
+ # amount: 0.50
274
+ # }
275
+ # }
276
+ # acquisition = @client.update_account_acquisition(
277
+ # account_id: account_id,
278
+ # body: acquisition_update
279
+ # )
280
+ # puts "Updated AccountAcqusition #{acquisition}"
281
+ # rescue Recurly::Errors::ValidationError => e
282
+ # # If the request was invalid, you may want to tell your user
283
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
284
+ # puts "ValidationError: #{e.recurly_error.params}"
285
+ # end
286
+ #
254
287
  def update_account_acquisition(account_id:, body:, **options)
255
288
  path = interpolate_path("/accounts/{account_id}/acquisition", account_id: account_id)
256
289
  put(path, body, Requests::AccountAcquisitionUpdatable, **options)
@@ -845,6 +878,26 @@ module Recurly
845
878
  # @param body [Requests::ShippingAddressCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingAddressCreate}
846
879
  # @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+.
847
880
  # @return [Resources::ShippingAddress] Returns the new shipping address.
881
+ # @example
882
+ # begin
883
+ # shipping_address_create = {
884
+ # nickname: 'Work',
885
+ # street1: '900 Camp St',
886
+ # city: 'New Orleans',
887
+ # region: 'LA',
888
+ # country: 'US',
889
+ # postal_code: '70115',
890
+ # first_name: 'Joanna',
891
+ # last_name: 'Du Monde'
892
+ # }
893
+ # shipping_address = @client.create_shipping_address(account_id: account_id, body: shipping_address_create)
894
+ # puts "Created Shipping Address #{shipping_address}"
895
+ # rescue Recurly::Errors::NotFoundError
896
+ # # If the resource was not found, you may want to alert the user or
897
+ # # just return nil
898
+ # puts "Resource Not Found"
899
+ # end
900
+ #
848
901
  def create_shipping_address(account_id:, body:, **options)
849
902
  path = interpolate_path("/accounts/{account_id}/shipping_addresses", account_id: account_id)
850
903
  post(path, body, Requests::ShippingAddressCreate, **options)
@@ -1230,11 +1283,46 @@ module Recurly
1230
1283
  # @param body [Requests::CouponUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponUpdate}
1231
1284
  # @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+.
1232
1285
  # @return [Resources::Coupon] The updated coupon.
1286
+ # @example
1287
+ # begin
1288
+ # coupon_update = {
1289
+ # name: "New Coupon Name"
1290
+ # }
1291
+ # coupon = @client.update_coupon(coupon_id: coupon_id, body: coupon_update)
1292
+ # puts "Updated Coupon #{coupon}"
1293
+ # rescue Recurly::Errors::NotFoundError
1294
+ # # If the resource was not found, you may want to alert the user or
1295
+ # # just return nil
1296
+ # puts "Resource Not Found"
1297
+ # end
1298
+ #
1233
1299
  def update_coupon(coupon_id:, body:, **options)
1234
1300
  path = interpolate_path("/coupons/{coupon_id}", coupon_id: coupon_id)
1235
1301
  put(path, body, Requests::CouponUpdate, **options)
1236
1302
  end
1237
1303
 
1304
+ # Expire a coupon
1305
+ #
1306
+ # {https://developers.recurly.com/api/v2019-10-10#operation/deactivate_coupon deactivate_coupon api documenation}
1307
+ #
1308
+ # @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+.
1309
+ # @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+.
1310
+ # @return [Resources::Coupon] The expired Coupon
1311
+ # @example
1312
+ # begin
1313
+ # coupon = @client.deactivate_coupon(coupon_id: coupon_id)
1314
+ # puts "Deactivated Coupon #{coupon}"
1315
+ # rescue Recurly::Errors::NotFoundError
1316
+ # # If the resource was not found, you may want to alert the user or
1317
+ # # just return nil
1318
+ # puts "Resource Not Found"
1319
+ # end
1320
+ #
1321
+ def deactivate_coupon(coupon_id:, **options)
1322
+ path = interpolate_path("/coupons/{coupon_id}", coupon_id: coupon_id)
1323
+ delete(path, **options)
1324
+ end
1325
+
1238
1326
  # List unique coupon codes associated with a bulk coupon
1239
1327
  #
1240
1328
  # {https://developers.recurly.com/api/v2019-10-10#operation/list_unique_coupon_codes list_unique_coupon_codes api documenation}
@@ -1361,6 +1449,18 @@ module Recurly
1361
1449
  # @param custom_field_definition_id [String] Custom Field Definition ID
1362
1450
  # @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+.
1363
1451
  # @return [Resources::CustomFieldDefinition] An custom field definition.
1452
+ # @example
1453
+ # begin
1454
+ # custom_field_definition = @client.get_custom_field_definition(
1455
+ # custom_field_definition_id: custom_field_definition_id
1456
+ # )
1457
+ # puts "Got Custom Field Definition #{custom_field_definition}"
1458
+ # rescue Recurly::Errors::NotFoundError
1459
+ # # If the resource was not found, you may want to alert the user or
1460
+ # # just return nil
1461
+ # puts "Resource Not Found"
1462
+ # end
1463
+ #
1364
1464
  def get_custom_field_definition(custom_field_definition_id:, **options)
1365
1465
  path = interpolate_path("/custom_field_definitions/{custom_field_definition_id}", custom_field_definition_id: custom_field_definition_id)
1366
1466
  get(path, **options)
@@ -1615,6 +1715,20 @@ module Recurly
1615
1715
  # @param body [Requests::InvoiceUpdatable] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceUpdatable}
1616
1716
  # @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+.
1617
1717
  # @return [Resources::Invoice] An invoice.
1718
+ # @example
1719
+ # begin
1720
+ # invoice_update = {
1721
+ # customer_notes: "New Notes",
1722
+ # terms_and_conditions: "New Terms and Conditions"
1723
+ # }
1724
+ # invoice = @client.put_invoice(invoice_id: invoice_id, body: invoice_update)
1725
+ # puts "Updated invoice #{invoice}"
1726
+ # rescue Recurly::Errors::NotFoundError
1727
+ # # If the resource was not found, you may want to alert the user or
1728
+ # # just return nil
1729
+ # puts "Resource Not Found"
1730
+ # end
1731
+ #
1618
1732
  def put_invoice(invoice_id:, body:, **options)
1619
1733
  path = interpolate_path("/invoices/{invoice_id}", invoice_id: invoice_id)
1620
1734
  put(path, body, Requests::InvoiceUpdatable, **options)
@@ -1741,11 +1855,34 @@ module Recurly
1741
1855
  # @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+.
1742
1856
  # @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+.
1743
1857
  # @return [Resources::Invoice] The updated invoice.
1858
+ # @example
1859
+ # begin
1860
+ # invoice = @client.void_invoice(invoice_id: invoice_id)
1861
+ # puts "Voided invoice #{invoice}"
1862
+ # rescue Recurly::Errors::NotFoundError
1863
+ # # If the resource was not found, you may want to alert the user or
1864
+ # # just return nil
1865
+ # puts "Resource Not Found"
1866
+ # end
1867
+ #
1744
1868
  def void_invoice(invoice_id:, **options)
1745
1869
  path = interpolate_path("/invoices/{invoice_id}/void", invoice_id: invoice_id)
1746
1870
  put(path, **options)
1747
1871
  end
1748
1872
 
1873
+ # Record an external payment for a manual invoices.
1874
+ #
1875
+ # {https://developers.recurly.com/api/v2019-10-10#operation/record_external_transaction record_external_transaction api documenation}
1876
+ #
1877
+ # @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+.
1878
+ # @param body [Requests::ExternalTransaction] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ExternalTransaction}
1879
+ # @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+.
1880
+ # @return [Resources::Transaction] The recorded transaction.
1881
+ def record_external_transaction(invoice_id:, body:, **options)
1882
+ path = interpolate_path("/invoices/{invoice_id}/transactions", invoice_id: invoice_id)
1883
+ post(path, body, Requests::ExternalTransaction, **options)
1884
+ end
1885
+
1749
1886
  # List an invoice's line items
1750
1887
  #
1751
1888
  # {https://developers.recurly.com/api/v2019-10-10#operation/list_invoice_line_items list_invoice_line_items api documenation}
@@ -1780,6 +1917,15 @@ module Recurly
1780
1917
  # @param type [String] Filter by type field.
1781
1918
  # @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+.
1782
1919
  # @return [Pager<Resources::LineItem>] A list of the invoice's line items.
1920
+ # @example
1921
+ # line_items = @client.list_invoice_line_items(
1922
+ # invoice_id: invoice_id,
1923
+ # limit: 200
1924
+ # )
1925
+ # line_items.each do |line_item|
1926
+ # puts "Line Item: #{line_item.id}"
1927
+ # end
1928
+ #
1783
1929
  def list_invoice_line_items(invoice_id:, **options)
1784
1930
  path = interpolate_path("/invoices/{invoice_id}/line_items", invoice_id: invoice_id)
1785
1931
  pager(path, **options)
@@ -1835,6 +1981,15 @@ module Recurly
1835
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+.
1836
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+.
1837
1983
  # @return [Pager<Resources::Invoice>] A list of the credit or charge invoices associated with the invoice.
1984
+ # @example
1985
+ # invoices = @client.list_related_invoices(
1986
+ # invoice_id: invoice_id,
1987
+ # limit: 200
1988
+ # )
1989
+ # invoices.each do |invoice|
1990
+ # puts "Invoice: #{invoice.number}"
1991
+ # end
1992
+ #
1838
1993
  def list_related_invoices(invoice_id:, **options)
1839
1994
  path = interpolate_path("/invoices/{invoice_id}/related_invoices", invoice_id: invoice_id)
1840
1995
  pager(path, **options)
@@ -1903,6 +2058,14 @@ module Recurly
1903
2058
  # @param type [String] Filter by type field.
1904
2059
  # @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+.
1905
2060
  # @return [Pager<Resources::LineItem>] A list of the site's line items.
2061
+ # @example
2062
+ # line_items = @client.list_line_items(
2063
+ # limit: 200
2064
+ # )
2065
+ # line_items.each do |line_item|
2066
+ # puts "LineItem: #{line_item.id}"
2067
+ # end
2068
+ #
1906
2069
  def list_line_items(**options)
1907
2070
  path = interpolate_path("/line_items")
1908
2071
  pager(path, **options)
@@ -2065,6 +2228,19 @@ module Recurly
2065
2228
  # @param body [Requests::PlanUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PlanUpdate}
2066
2229
  # @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+.
2067
2230
  # @return [Resources::Plan] A plan.
2231
+ # @example
2232
+ # begin
2233
+ # plan_update = {
2234
+ # name: "Monthly Kombucha Subscription"
2235
+ # }
2236
+ # plan = @client.update_plan(plan_id: plan_id, body: plan_update)
2237
+ # puts "Updated plan #{plan}"
2238
+ # rescue Recurly::Errors::NotFoundError
2239
+ # # If the resource was not found, you may want to alert the user or
2240
+ # # just return nil
2241
+ # puts "Resource Not Found"
2242
+ # end
2243
+ #
2068
2244
  def update_plan(plan_id:, body:, **options)
2069
2245
  path = interpolate_path("/plans/{plan_id}", plan_id: plan_id)
2070
2246
  put(path, body, Requests::PlanUpdate, **options)
@@ -2077,6 +2253,16 @@ module Recurly
2077
2253
  # @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+.
2078
2254
  # @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+.
2079
2255
  # @return [Resources::Plan] Plan deleted
2256
+ # @example
2257
+ # begin
2258
+ # plan = @client.remove_plan(plan_id: plan_id)
2259
+ # puts "Removed plan #{plan}"
2260
+ # rescue Recurly::Errors::NotFoundError
2261
+ # # If the resource was not found, you may want to alert the user or
2262
+ # # just return nil
2263
+ # puts "Resource Not Found"
2264
+ # end
2265
+ #
2080
2266
  def remove_plan(plan_id:, **options)
2081
2267
  path = interpolate_path("/plans/{plan_id}", plan_id: plan_id)
2082
2268
  delete(path, **options)
@@ -2136,6 +2322,27 @@ module Recurly
2136
2322
  # @param body [Requests::AddOnCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AddOnCreate}
2137
2323
  # @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
2324
  # @return [Resources::AddOn] An add-on.
2325
+ # @example
2326
+ # begin
2327
+ # new_add_on = {
2328
+ # code: 'coffee_grinder',
2329
+ # name: 'A quality grinder for your beans',
2330
+ # default_quantity: 1,
2331
+ # currencies: [
2332
+ # {
2333
+ # currency: 'USD',
2334
+ # unit_amount: 10_000
2335
+ # }
2336
+ # ]
2337
+ # }
2338
+ # add_on = @client.create_plan_add_on(plan_id: plan_id, body: new_add_on)
2339
+ # puts "Created plan add-on #{add_on}"
2340
+ # rescue Recurly::Errors::NotFoundError
2341
+ # # If the resource was not found, you may want to alert the user or
2342
+ # # just return nil
2343
+ # puts "Resource Not Found"
2344
+ # end
2345
+ #
2139
2346
  def create_plan_add_on(plan_id:, body:, **options)
2140
2347
  path = interpolate_path("/plans/{plan_id}/add_ons", plan_id: plan_id)
2141
2348
  post(path, body, Requests::AddOnCreate, **options)
@@ -2175,6 +2382,23 @@ module Recurly
2175
2382
  # @param body [Requests::AddOnUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AddOnUpdate}
2176
2383
  # @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+.
2177
2384
  # @return [Resources::AddOn] An add-on.
2385
+ # @example
2386
+ # begin
2387
+ # add_on_update = {
2388
+ # name: "A quality grinder for your finest beans"
2389
+ # }
2390
+ # add_on = @client.update_plan_add_on(
2391
+ # plan_id: plan_id,
2392
+ # add_on_id: add_on_id,
2393
+ # body: add_on_update
2394
+ # )
2395
+ # puts "Updated add-on #{add_on}"
2396
+ # rescue Recurly::Errors::NotFoundError
2397
+ # # If the resource was not found, you may want to alert the user or
2398
+ # # just return nil
2399
+ # puts "Resource Not Found"
2400
+ # end
2401
+ #
2178
2402
  def update_plan_add_on(plan_id:, add_on_id:, body:, **options)
2179
2403
  path = interpolate_path("/plans/{plan_id}/add_ons/{add_on_id}", plan_id: plan_id, add_on_id: add_on_id)
2180
2404
  put(path, body, Requests::AddOnUpdate, **options)
@@ -2188,6 +2412,19 @@ module Recurly
2188
2412
  # @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+.
2189
2413
  # @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+.
2190
2414
  # @return [Resources::AddOn] Add-on deleted
2415
+ # @example
2416
+ # begin
2417
+ # add_on = @client.remove_plan_add_on(
2418
+ # plan_id: plan_id,
2419
+ # add_on_id: add_on_id
2420
+ # )
2421
+ # puts "Removed add-on #{add_on}"
2422
+ # rescue Recurly::Errors::NotFoundError
2423
+ # # If the resource was not found, you may want to alert the user or
2424
+ # # just return nil
2425
+ # puts "Resource Not Found"
2426
+ # end
2427
+ #
2191
2428
  def remove_plan_add_on(plan_id:, add_on_id:, **options)
2192
2429
  path = interpolate_path("/plans/{plan_id}/add_ons/{add_on_id}", plan_id: plan_id, add_on_id: add_on_id)
2193
2430
  delete(path, **options)
@@ -2224,6 +2461,14 @@ module Recurly
2224
2461
  # @param state [String] Filter by state.
2225
2462
  # @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+.
2226
2463
  # @return [Pager<Resources::AddOn>] A list of add-ons.
2464
+ # @example
2465
+ # add_ons = @client.list_add_ons(
2466
+ # limit: 200
2467
+ # )
2468
+ # add_ons.each do |add_on|
2469
+ # puts "AddOn: #{add_on.code}"
2470
+ # end
2471
+ #
2227
2472
  def list_add_ons(**options)
2228
2473
  path = interpolate_path("/add_ons")
2229
2474
  pager(path, **options)
@@ -2236,6 +2481,16 @@ module Recurly
2236
2481
  # @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+.
2237
2482
  # @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+.
2238
2483
  # @return [Resources::AddOn] An add-on.
2484
+ # @example
2485
+ # begin
2486
+ # add_on = @client.get_add_on(add_on_id: add_on_id)
2487
+ # puts "Got add-on #{add_on}"
2488
+ # rescue Recurly::Errors::NotFoundError
2489
+ # # If the resource was not found, you may want to alert the user or
2490
+ # # just return nil
2491
+ # puts "Resource Not Found"
2492
+ # end
2493
+ #
2239
2494
  def get_add_on(add_on_id:, **options)
2240
2495
  path = interpolate_path("/add_ons/{add_on_id}", add_on_id: add_on_id)
2241
2496
  get(path, **options)
@@ -2271,23 +2526,68 @@ module Recurly
2271
2526
  #
2272
2527
  # @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+.
2273
2528
  # @return [Pager<Resources::ShippingMethod>] A list of the site's shipping methods.
2529
+ # @example
2530
+ # shipping_methods = @client.list_shipping_methods(
2531
+ # limit: 200
2532
+ # )
2533
+ # shipping_methods.each do |shipping_method|
2534
+ # puts "Shipping Method: #{shipping_method.code}"
2535
+ # end
2536
+ #
2274
2537
  def list_shipping_methods(**options)
2275
2538
  path = interpolate_path("/shipping_methods")
2276
2539
  pager(path, **options)
2277
2540
  end
2278
2541
 
2542
+ # Create a new shipping method
2543
+ #
2544
+ # {https://developers.recurly.com/api/v2019-10-10#operation/create_shipping_method create_shipping_method api documenation}
2545
+ #
2546
+ # @param body [Requests::ShippingMethodCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingMethodCreate}
2547
+ # @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+.
2548
+ # @return [Resources::ShippingMethod] A new shipping method.
2549
+ def create_shipping_method(body:, **options)
2550
+ path = interpolate_path("/shipping_methods")
2551
+ post(path, body, Requests::ShippingMethodCreate, **options)
2552
+ end
2553
+
2279
2554
  # Fetch a shipping method
2280
2555
  #
2281
2556
  # {https://developers.recurly.com/api/v2019-10-10#operation/get_shipping_method get_shipping_method api documenation}
2282
2557
  #
2283
2558
  # @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+.
2284
2559
  # @param site_id [String] Site ID or subdomain. For ID no prefix is used e.g. +e28zov4fw0v2+. For subdomain use prefix +subdomain-+, e.g. +subdomain-recurly+.
2285
- # @return [Resources::ShippingMethod] A shipping_method.
2560
+ # @return [Resources::ShippingMethod] A shipping method.
2286
2561
  def get_shipping_method(id:, **options)
2287
2562
  path = interpolate_path("/shipping_methods/{id}", id: id)
2288
2563
  get(path, **options)
2289
2564
  end
2290
2565
 
2566
+ # Update an active Shipping Method
2567
+ #
2568
+ # {https://developers.recurly.com/api/v2019-10-10#operation/update_shipping_method update_shipping_method api documenation}
2569
+ #
2570
+ # @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+.
2571
+ # @param body [Requests::ShippingMethodUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingMethodUpdate}
2572
+ # @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+.
2573
+ # @return [Resources::ShippingMethod] The updated shipping method.
2574
+ def update_shipping_method(shipping_method_id:, body:, **options)
2575
+ path = interpolate_path("/shipping_methods/{shipping_method_id}", shipping_method_id: shipping_method_id)
2576
+ put(path, body, Requests::ShippingMethodUpdate, **options)
2577
+ end
2578
+
2579
+ # Deactivate a shipping method
2580
+ #
2581
+ # {https://developers.recurly.com/api/v2019-10-10#operation/deactivate_shipping_method deactivate_shipping_method api documenation}
2582
+ #
2583
+ # @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+.
2584
+ # @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+.
2585
+ # @return [Resources::ShippingMethod] A shipping method.
2586
+ def deactivate_shipping_method(shipping_method_id:, **options)
2587
+ path = interpolate_path("/shipping_methods/{shipping_method_id}", shipping_method_id: shipping_method_id)
2588
+ delete(path, **options)
2589
+ end
2590
+
2291
2591
  # List a site's subscriptions
2292
2592
  #
2293
2593
  # {https://developers.recurly.com/api/v2019-10-10#operation/list_subscriptions list_subscriptions api documenation}
@@ -2648,6 +2948,19 @@ module Recurly
2648
2948
  delete(path, **options)
2649
2949
  end
2650
2950
 
2951
+ # Preview a new subscription change
2952
+ #
2953
+ # {https://developers.recurly.com/api/v2019-10-10#operation/preview_subscription_change preview_subscription_change api documenation}
2954
+ #
2955
+ # @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+.
2956
+ # @param body [Requests::SubscriptionChangeCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionChangeCreate}
2957
+ # @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+.
2958
+ # @return [Resources::SubscriptionChangePreview] A subscription change.
2959
+ def preview_subscription_change(subscription_id:, body:, **options)
2960
+ path = interpolate_path("/subscriptions/{subscription_id}/change/preview", subscription_id: subscription_id)
2961
+ post(path, body, Requests::SubscriptionChangeCreate, **options)
2962
+ end
2963
+
2651
2964
  # List a subscription's invoices
2652
2965
  #
2653
2966
  # {https://developers.recurly.com/api/v2019-10-10#operation/list_subscription_invoices list_subscription_invoices api documenation}