recurly 3.0.0.beta.3 → 3.0.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -0
  3. data/.travis.yml +3 -1
  4. data/README.md +9 -2
  5. data/lib/recurly/client.rb +42 -13
  6. data/lib/recurly/client/adapter.rb +9 -18
  7. data/lib/recurly/client/operations.rb +1179 -78
  8. data/lib/recurly/errors/api_errors.rb +4 -0
  9. data/lib/recurly/errors/network_errors.rb +1 -1
  10. data/lib/recurly/pager.rb +5 -1
  11. data/lib/recurly/requests/account_acquisition_cost.rb +18 -0
  12. data/lib/recurly/requests/account_acquisition_updatable.rb +5 -1
  13. data/lib/recurly/requests/account_create.rb +23 -3
  14. data/lib/recurly/requests/account_update.rb +22 -2
  15. data/lib/recurly/requests/add_on_create.rb +7 -3
  16. data/lib/recurly/requests/add_on_pricing.rb +18 -0
  17. data/lib/recurly/requests/add_on_update.rb +7 -3
  18. data/lib/recurly/requests/address.rb +4 -0
  19. data/lib/recurly/requests/billing_info_create.rb +4 -0
  20. data/lib/recurly/requests/coupon_bulk_create.rb +4 -0
  21. data/lib/recurly/requests/coupon_create.rb +13 -9
  22. data/lib/recurly/requests/coupon_pricing.rb +18 -0
  23. data/lib/recurly/requests/coupon_redemption_create.rb +4 -0
  24. data/lib/recurly/requests/coupon_update.rb +4 -0
  25. data/lib/recurly/requests/external_refund.rb +22 -0
  26. data/lib/recurly/requests/invoice_address.rb +54 -0
  27. data/lib/recurly/requests/invoice_create.rb +6 -2
  28. data/lib/recurly/requests/invoice_refund.rb +7 -3
  29. data/lib/recurly/requests/invoice_updatable.rb +34 -0
  30. data/lib/recurly/requests/line_item_create.rb +6 -2
  31. data/lib/recurly/requests/line_item_refund.rb +4 -0
  32. data/lib/recurly/requests/plan_create.rb +11 -7
  33. data/lib/recurly/requests/plan_hosted_pages.rb +26 -0
  34. data/lib/recurly/requests/plan_pricing.rb +22 -0
  35. data/lib/recurly/requests/plan_update.rb +11 -7
  36. data/lib/recurly/requests/shipping_address_create.rb +4 -0
  37. data/lib/recurly/requests/shipping_address_update.rb +5 -1
  38. data/lib/recurly/requests/subscription_add_on_create.rb +8 -0
  39. data/lib/recurly/requests/subscription_change_create.rb +13 -5
  40. data/lib/recurly/requests/subscription_create.rb +11 -7
  41. data/lib/recurly/requests/subscription_pause.rb +4 -0
  42. data/lib/recurly/requests/subscription_update.rb +8 -4
  43. data/lib/recurly/resource.rb +6 -6
  44. data/lib/recurly/resources/account.rb +27 -11
  45. data/lib/recurly/resources/account_acquisition.rb +9 -5
  46. data/lib/recurly/resources/account_acquisition_cost.rb +18 -0
  47. data/lib/recurly/resources/account_balance.rb +7 -3
  48. data/lib/recurly/resources/account_balance_amount.rb +18 -0
  49. data/lib/recurly/resources/account_mini.rb +18 -2
  50. data/lib/recurly/resources/account_note.rb +7 -3
  51. data/lib/recurly/resources/add_on.rb +13 -9
  52. data/lib/recurly/resources/add_on_mini.rb +6 -2
  53. data/lib/recurly/resources/add_on_pricing.rb +18 -0
  54. data/lib/recurly/resources/address.rb +4 -0
  55. data/lib/recurly/resources/billing_info.rb +12 -8
  56. data/lib/recurly/resources/billing_info_payment_method.rb +34 -0
  57. data/lib/recurly/resources/billing_info_updated_by.rb +18 -0
  58. data/lib/recurly/resources/coupon.rb +21 -13
  59. data/lib/recurly/resources/coupon_discount.rb +7 -3
  60. data/lib/recurly/resources/coupon_discount_pricing.rb +18 -0
  61. data/lib/recurly/resources/coupon_discount_trial.rb +18 -0
  62. data/lib/recurly/resources/coupon_mini.rb +8 -4
  63. data/lib/recurly/resources/coupon_redemption.rb +9 -5
  64. data/lib/recurly/resources/coupon_redemption_mini.rb +8 -4
  65. data/lib/recurly/resources/credit_payment.rb +8 -4
  66. data/lib/recurly/resources/custom_field.rb +4 -0
  67. data/lib/recurly/resources/custom_field_definition.rb +11 -7
  68. data/lib/recurly/resources/error.rb +6 -2
  69. data/lib/recurly/resources/error_may_have_transaction.rb +6 -2
  70. data/lib/recurly/resources/fraud_info.rb +22 -0
  71. data/lib/recurly/resources/invoice.rb +17 -13
  72. data/lib/recurly/resources/invoice_address.rb +54 -0
  73. data/lib/recurly/resources/invoice_collection.rb +5 -1
  74. data/lib/recurly/resources/invoice_mini.rb +6 -2
  75. data/lib/recurly/resources/line_item.rb +13 -5
  76. data/lib/recurly/resources/line_item_list.rb +5 -1
  77. data/lib/recurly/resources/plan.rb +16 -12
  78. data/lib/recurly/resources/plan_hosted_pages.rb +26 -0
  79. data/lib/recurly/resources/plan_mini.rb +6 -2
  80. data/lib/recurly/resources/plan_pricing.rb +22 -0
  81. data/lib/recurly/resources/settings.rb +7 -3
  82. data/lib/recurly/resources/shipping_address.rb +8 -4
  83. data/lib/recurly/resources/site.rb +16 -8
  84. data/lib/recurly/resources/subscription.rb +9 -5
  85. data/lib/recurly/resources/subscription_add_on.rb +4 -0
  86. data/lib/recurly/resources/subscription_change.rb +9 -5
  87. data/lib/recurly/resources/tax_info.rb +4 -0
  88. data/lib/recurly/resources/transaction.rb +16 -8
  89. data/lib/recurly/resources/transaction_payment_gateway.rb +26 -0
  90. data/lib/recurly/resources/transaction_payment_method.rb +34 -0
  91. data/lib/recurly/resources/unique_coupon_code.rb +10 -6
  92. data/lib/recurly/resources/user.rb +8 -4
  93. data/lib/recurly/schema/json_deserializer.rb +18 -20
  94. data/lib/recurly/schema/request_caster.rb +1 -1
  95. data/lib/recurly/schema/schema_validator.rb +31 -8
  96. data/lib/recurly/version.rb +1 -1
  97. data/recurly.gemspec +1 -1
  98. data/scripts/check-deps +28 -0
  99. data/scripts/install-deps +44 -0
  100. metadata +37 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: c06a13da0a4a02efc0494087590ad6e050b7c21ee0e3539dc85184e7136f2444
4
- data.tar.gz: aad797e4c85cfa7e8388755d86fc443b27b187169d65f4db225d73c26a9da6c0
2
+ SHA1:
3
+ metadata.gz: fa84948d98ac3695fb2639905b05c1ae0ff8ee70
4
+ data.tar.gz: 36229c9d3cd0e548e1b8845d98453e07b4fc07a8
5
5
  SHA512:
6
- metadata.gz: ed00a71ff9a370d9ad98fdda0c224bd6c273b69bfd543d1e5f2b40c5aee9d69b79fc1c6a8fe965d4727615d4c06a61291767961659d88567f5ee8e8153c11beb
7
- data.tar.gz: 44a44276941e20c12c0998db7b73fb195eaea121be054a6b978a9f3a22cdbef04bf0e9bf5373b1db78cb75f128fec697112907ee0daff2187d7bc5db2b442ee9
6
+ metadata.gz: 6794cb420246f6407362fa23c1e0c5621df35703fa210f97b4090e0226e56b2e68f8040a654a943909f802c89c7b37246de363bc297bbd8b0af6266de7cf7fe3
7
+ data.tar.gz: cc7fb401cd2ef58e1444137bb0e881e71afac83135ca18c1012aa8aef0c3f2c2016760382873f3384f1e8f268b61aa3e73313280e7e5248e132b9157ed2936ab
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.4
data/.travis.yml CHANGED
@@ -5,4 +5,6 @@ rvm:
5
5
  - 2.4
6
6
  - 2.5
7
7
  - 2.6
8
- before_install: gem install bundler -v 1.14.6
8
+ before_install:
9
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
10
+ - gem install bundler -v '< 2'
data/README.md CHANGED
@@ -15,7 +15,7 @@ This contains everything in the README as well as code-level documentation. We s
15
15
  This gem is a pre-release. In your Gemfile, add `recurly` as a dependency.
16
16
 
17
17
  ```ruby
18
- gem 'recurly', '3.0.0.beta.3'
18
+ gem 'recurly', '3.0.0.beta.4'
19
19
  ```
20
20
 
21
21
  It's important that you lock on a specific version as there may be breaking changes between releases.
@@ -48,7 +48,7 @@ Recurly::Client.new(subdomain: 'mysite-prod', api_key: API_KEY) do |client|
48
48
  end
49
49
  ```
50
50
 
51
- If you only plan on using the client for more than one site, you should initialize a new client for each site.
51
+ If you plan on using the client for more than one site, you should initialize a new client for each site.
52
52
 
53
53
  ```ruby
54
54
  # Give a `site_id`
@@ -112,6 +112,7 @@ The names, types, and descriptions of these arguments are listed in the rubydocs
112
112
 
113
113
  ```ruby
114
114
  options = {
115
+ limit: 200, # number of items per page
115
116
  state: :active, # only active plans
116
117
  sort: :updated_at,
117
118
  order: :asc,
@@ -125,6 +126,12 @@ plans.each do |plan|
125
126
  end
126
127
  ```
127
128
 
129
+ **A note on `limit`**:
130
+
131
+ `limit` defaults to 20 items per page and can be set from 1 to 200. Choosing a lower limit means more network requests but smaller payloads.
132
+ We recommend keeping the default for most cases but increasing the limit if you are planning on iterating through many pages of items (e.g. all transactions in your site).
133
+
134
+
128
135
  ### Creating Resources
129
136
 
130
137
  Currently, resources are created by passing in a `body` keyword argument in the form of a `Hash`.
@@ -65,7 +65,7 @@ module Recurly
65
65
 
66
66
  def next_page(pager)
67
67
  run_request(:get, pager.next, nil, headers).tap do |response|
68
- raise_api_error!(response) if response.status != 200
68
+ raise_api_error!(response) unless (200...300).include?(response.status)
69
69
  end
70
70
  end
71
71
 
@@ -77,7 +77,7 @@ module Recurly
77
77
 
78
78
  def get(path, **options)
79
79
  response = run_request(:get, path, nil, headers)
80
- raise_api_error!(response) if response.status != 200
80
+ raise_api_error!(response) unless (200...300).include?(response.status)
81
81
  JSONParser.parse(self, response.body)
82
82
  rescue Faraday::ClientError => ex
83
83
  raise_network_error!(ex)
@@ -88,18 +88,22 @@ module Recurly
88
88
  request.validate!
89
89
  logger.info("POST BODY #{JSON.dump(request_data)}")
90
90
  response = run_request(:post, path, JSON.dump(request.attributes), headers)
91
- raise_api_error!(response) if response.status != 201
91
+ raise_api_error!(response) unless (200...300).include?(response.status)
92
92
  JSONParser.parse(self, response.body)
93
93
  rescue Faraday::ClientError => ex
94
94
  raise_network_error!(ex)
95
95
  end
96
96
 
97
- def put(path, request_data, request_class, **options)
98
- request = request_class.new(request_data)
99
- request.validate!
100
- logger.info("PUT BODY #{JSON.dump(request_data)}")
101
- response = run_request(:put, path, JSON.dump(request_data), headers)
102
- raise_api_error!(response) if ![200, 201].include?(response.status)
97
+ def put(path, request_data=nil, request_class=nil, **options)
98
+ response = if request_data
99
+ request = request_class.new(request_data)
100
+ request.validate!
101
+ logger.info("PUT BODY #{JSON.dump(request_data)}")
102
+ run_request(:put, path, JSON.dump(request_data), headers)
103
+ else
104
+ run_request(:put, path, nil, headers)
105
+ end
106
+ raise_api_error!(response) unless (200...300).include?(response.status)
103
107
  JSONParser.parse(self, response.body)
104
108
  rescue Faraday::ClientError => ex
105
109
  raise_network_error!(ex)
@@ -107,8 +111,10 @@ module Recurly
107
111
 
108
112
  def delete(path, **options)
109
113
  response = run_request(:delete, path, nil, headers)
110
- raise_api_error!(response) if ![200, 201].include?(response.status)
111
- JSONParser.parse(self, response.body)
114
+ raise_api_error!(response) unless (200...300).include?(response.status)
115
+ if response.body && !response.body.empty?
116
+ JSONParser.parse(self, response.body)
117
+ end
112
118
  rescue Faraday::ClientError => ex
113
119
  raise_network_error!(ex)
114
120
  end
@@ -152,6 +158,9 @@ module Recurly
152
158
  @rate_limit = response.headers['x-ratelimit-limit'].to_i
153
159
  @rate_limit_remaining = response.headers['x-ratelimit-remaining'].to_i
154
160
  @rate_limit_reset = Time.at(response.headers['x-ratelimit-reset'].to_i).to_datetime
161
+ if !@_ignore_deprecation_warning && response.headers['Recurly-Deprecated']&.upcase == 'TRUE'
162
+ puts "[recurly-client-ruby] WARNING: Your current API version \"#{api_version}\" is deprecated and will be sunset on #{response.headers['Recurly-Sunset-Date']}"
163
+ end
155
164
  response
156
165
  end
157
166
 
@@ -164,6 +173,15 @@ module Recurly
164
173
  end
165
174
 
166
175
  def interpolate_path(path, **options)
176
+ options.each do |k, v|
177
+ unless [String, Symbol, Integer, Float].include?(v.class)
178
+ message = "We cannot build the url with the given argument #{k}=#{v.inspect}."
179
+ if k =~ /_id$/
180
+ message << " Since this appears to be an id, perhaps you meant to pass in a String?"
181
+ end
182
+ raise ArgumentError, message
183
+ end
184
+ end
167
185
  path = path.gsub("{", "%{")
168
186
  path % options
169
187
  end
@@ -179,8 +197,19 @@ module Recurly
179
197
  end
180
198
 
181
199
  def set_faraday_connection(api_key)
182
- @conn = Faraday.new(url: BASE_URL) do |faraday|
183
- if @log_level == Logger::INFO
200
+ options = {
201
+ url: BASE_URL,
202
+ request: { timeout: 60, open_timeout: 50 },
203
+ ssl: { verify: true }
204
+ }
205
+ # Let's not use the bundled cert in production yet
206
+ # but we will use these certs for any other staging or dev environment
207
+ unless BASE_URL.end_with?('.recurly.com')
208
+ options[:ssl][:ca_file] = File.join(File.dirname(__FILE__), '../data/ca-certificates.crt')
209
+ end
210
+
211
+ @conn = Faraday.new(options) do |faraday|
212
+ if [Logger::DEBUG, Logger::INFO].include?(@log_level)
184
213
  faraday.response :logger
185
214
  end
186
215
  faraday.basic_auth(api_key, '')
@@ -5,14 +5,14 @@ module Recurly
5
5
  module NetHttpPersistentAdapter
6
6
  protected
7
7
  def configure_net_adapter(faraday)
8
- faraday.adapter :net_http_persistent do |http| # yields Net::HTTP
9
- # Let's not use the bundled cert in production yet
10
- # but we will use these certs for any other staging or dev environment
11
- unless BASE_URL.end_with?('.recurly.com')
12
- http.ca_file = File.join(File.dirname(__FILE__), '../data/ca-certificates.crt')
8
+ faraday.adapter :net_http_persistent do |http|
9
+ # yields Net::HTTP::Persistent
10
+ # for net-http-persistent 2.X, alternative is for 3.X
11
+ if http.respond_to? :keep_alive_timeout
12
+ http.keep_alive_timeout = 60
13
+ else
14
+ http.keep_alive = 60
13
15
  end
14
- http.open_timeout = 50
15
- http.read_timeout = 60
16
16
  end
17
17
  end
18
18
  end
@@ -20,17 +20,8 @@ module Recurly
20
20
  module NetHttpAdapter
21
21
  protected
22
22
  def configure_net_adapter(faraday)
23
- faraday.adapter :net_http do |http| # yields Net::HTTP
24
- # Let's not use the bundled cert in production yet
25
- # but we will use these certs for any other staging or dev environment
26
- unless BASE_URL.end_with?('.recurly.com')
27
- http.ca_file = File.join(File.dirname(__FILE__), '../data/ca-certificates.crt')
28
- end
29
- http.use_ssl = true
30
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
31
- http.open_timeout = 50
32
- http.read_timeout = 60
33
- http.keep_alive_timeout = 60
23
+ faraday.adapter :net_http do |http|
24
+ # yields Net::HTTP
34
25
  end
35
26
  end
36
27
  end
@@ -1,13 +1,19 @@
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.
1
5
  module Recurly
2
6
  class Client
3
7
  def api_version
4
- "v2018-06-06"
8
+ "v2018-08-09"
5
9
  end
6
10
 
7
11
  # List sites
8
12
  #
9
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
10
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
13
+ # {https://partner-docs.recurly.com/v2018-08-09#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+.
11
17
  #
12
18
  # *Important notes:*
13
19
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -24,6 +30,12 @@ module Recurly
24
30
  # prevent some records from being returned.
25
31
  #
26
32
  # @return [Pager<Resources::Site>] A list of sites.
33
+ # @example
34
+ # sites = @client.list_sites(limit: 200)
35
+ # sites.each do |site|
36
+ # puts "Site: #{site.subdomain}"
37
+ # end
38
+ #
27
39
  def list_sites(**options)
28
40
  path = "/sites"
29
41
  pager(path, **options)
@@ -31,6 +43,8 @@ module Recurly
31
43
 
32
44
  # Fetch a site
33
45
  #
46
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_site get_site api documenation}
47
+ #
34
48
  # @return [Resources::Site] A site.
35
49
  def get_site()
36
50
  path = interpolate_path("/sites/{site_id}", site_id: site_id)
@@ -39,8 +53,10 @@ module Recurly
39
53
 
40
54
  # List a site's accounts
41
55
  #
42
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
43
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
56
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_accounts list_accounts api documenation}
57
+ #
58
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
59
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
44
60
  #
45
61
  # *Important notes:*
46
62
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -67,6 +83,12 @@ module Recurly
67
83
  #
68
84
  # @param past_due [String] Filter for accounts with an invoice in the +past_due+ state.
69
85
  # @return [Pager<Resources::Account>] A list of the site's accounts.
86
+ # @example
87
+ # accounts = @client.list_accounts(limit: 200)
88
+ # accounts.each do |account|
89
+ # puts "Account: #{account.code}"
90
+ # end
91
+ #
70
92
  def list_accounts(**options)
71
93
  path = interpolate_path("/sites/{site_id}/accounts", site_id: site_id)
72
94
  pager(path, **options)
@@ -74,8 +96,46 @@ module Recurly
74
96
 
75
97
  # Create an account
76
98
  #
99
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_account create_account api documenation}
100
+ #
77
101
  # @param body [Requests::AccountCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountCreate}
78
102
  # @return [Resources::Account] An account.
103
+ # @example
104
+ # begin
105
+ # account_create = {
106
+ # code: account_code,
107
+ # first_name: "Benjamin",
108
+ # last_name: "Du Monde",
109
+ # acquisition: {
110
+ # campaign: "podcast-marketing",
111
+ # channel: "social_media",
112
+ # subchannel: "twitter",
113
+ # cost: {
114
+ # currency: "USD",
115
+ # amount: 0.50
116
+ # }
117
+ # },
118
+ # shipping_addresses: [
119
+ # {
120
+ # nickname: "Home",
121
+ # street1: "1 Tchoupitoulas St",
122
+ # city: "New Orleans",
123
+ # region: "LA",
124
+ # country: "US",
125
+ # postal_code: "70115",
126
+ # first_name: "Benjamin",
127
+ # last_name: "Du Monde"
128
+ # }
129
+ # ]
130
+ # }
131
+ # account = @client.create_account(body: account_create)
132
+ # puts "Created Account #{account}"
133
+ # rescue Recurly::Errors::ValidationError => e
134
+ # # If the request was invalid, you may want to tell your user
135
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
136
+ # puts "ValidationError: #{e.recurly_error.params}"
137
+ # end
138
+ #
79
139
  def create_account(body:)
80
140
  path = interpolate_path("/sites/{site_id}/accounts", site_id: site_id)
81
141
  post(path, body, Requests::AccountCreate)
@@ -83,19 +143,18 @@ module Recurly
83
143
 
84
144
  # Fetch an account
85
145
  #
146
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_account get_account api documenation}
147
+ #
86
148
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
87
149
  # @return [Resources::Account] An account.
88
150
  # @example
89
151
  # begin
90
- # # You can use the `id` field from an Account object
91
- # account = @client.get_account(account_id: "hympfmab60ic")
92
- # # If you only have the account code, you can prefix with `code-`
93
- # account = @client.get_account(account_id: "code-benjamin.dumonde@example.com")
94
- # rescue Recurly::Errors::NotFoundError => e
95
- # puts e
96
- # # => Recurly::NotFoundError: Couldn't find Account with code = benjamin.dumonde@example.com
97
- # puts e.recurly_error
98
- # # => #<Recurly::Error:0x007f8b29918618 @attributes={:type=>"not_found", :message=>"Couldn't find Account with code = benjamin.dumonde@example.com", :params=>[{"param"=>"account_id"}]}>
152
+ # account = @client.get_account(account_id: account_id)
153
+ # puts "Got Account #{account}"
154
+ # rescue Recurly::Errors::NotFoundError
155
+ # # If the resource was not found, you may want to alert the user or
156
+ # # just return nil
157
+ # puts "Resource Not Found"
99
158
  # end
100
159
  #
101
160
  def get_account(account_id:)
@@ -105,9 +164,28 @@ module Recurly
105
164
 
106
165
  # Modify an account
107
166
  #
167
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/update_account update_account api documenation}
168
+ #
108
169
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
109
170
  # @param body [Requests::AccountUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountUpdate}
110
171
  # @return [Resources::Account] An account.
172
+ # @example
173
+ # begin
174
+ # account_update = {
175
+ # first_name: "Aaron",
176
+ # last_name: "Du Monde",
177
+ # }
178
+ # account = @client.update_account(
179
+ # account_id: account_id,
180
+ # body: account_update
181
+ # )
182
+ # puts "Updated Account #{account}"
183
+ # rescue Recurly::Errors::ValidationError => e
184
+ # # If the request was invalid, you may want to tell your user
185
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
186
+ # puts "ValidationError: #{e.recurly_error.params}"
187
+ # end
188
+ #
111
189
  def update_account(account_id:, body:)
112
190
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}", site_id: site_id, account_id: account_id)
113
191
  put(path, body, Requests::AccountUpdate)
@@ -115,8 +193,20 @@ module Recurly
115
193
 
116
194
  # Deactivate an account
117
195
  #
196
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/deactivate_account deactivate_account api documenation}
197
+ #
118
198
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
119
199
  # @return [Resources::Account] An account.
200
+ # @example
201
+ # begin
202
+ # account = @client.deactivate_account(account_id: account_id)
203
+ # puts "Deactivated Account #{account}"
204
+ # rescue Recurly::Errors::NotFoundError
205
+ # # If the resource was not found, you may want to alert the user or
206
+ # # just return nil
207
+ # puts "Resource Not Found"
208
+ # end
209
+ #
120
210
  def deactivate_account(account_id:)
121
211
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}", site_id: site_id, account_id: account_id)
122
212
  delete(path)
@@ -124,8 +214,20 @@ module Recurly
124
214
 
125
215
  # Fetch an account's acquisition data
126
216
  #
217
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_account_acquisition get_account_acquisition api documenation}
218
+ #
127
219
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
128
220
  # @return [Resources::AccountAcquisition] An account's acquisition data.
221
+ # @example
222
+ # begin
223
+ # @client.get_account_acquisition(account_id: account_id)
224
+ # puts "Got AccountAcquisition"
225
+ # rescue Recurly::Errors::NotFoundError
226
+ # # If the resource was not found, you may want to alert the user or
227
+ # # just return nil
228
+ # puts "Resource Not Found"
229
+ # end
230
+ #
129
231
  def get_account_acquisition(account_id:)
130
232
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/acquisition", site_id: site_id, account_id: account_id)
131
233
  get(path)
@@ -133,6 +235,8 @@ module Recurly
133
235
 
134
236
  # Update an account's acquisition data
135
237
  #
238
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/update_account_acquisition update_account_acquisition api documenation}
239
+ #
136
240
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
137
241
  # @param body [Requests::AccountAcquisitionUpdatable] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AccountAcquisitionUpdatable}
138
242
  # @return [Resources::AccountAcquisition] An account's updated acquisition data.
@@ -143,7 +247,19 @@ module Recurly
143
247
 
144
248
  # Remove an account's acquisition data
145
249
  #
250
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/remove_account_acquisition remove_account_acquisition api documenation}
251
+ #
146
252
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
253
+ # @example
254
+ # begin
255
+ # acquisition = @client.remove_account_acquisition(account_id: account_id)
256
+ # puts "Removed AccountAcqusition #{acquisition}"
257
+ # rescue Recurly::Errors::NotFoundError
258
+ # # If the resource was not found, you may want to alert the user or
259
+ # # just return nil
260
+ # puts "Resource Not Found"
261
+ # end
262
+ #
147
263
  def remove_account_acquisition(account_id:)
148
264
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/acquisition", site_id: site_id, account_id: account_id)
149
265
  delete(path)
@@ -151,8 +267,20 @@ module Recurly
151
267
 
152
268
  # Reactivate an inactive account
153
269
  #
270
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/reactivate_account reactivate_account api documenation}
271
+ #
154
272
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
155
273
  # @return [Resources::Account] An account.
274
+ # @example
275
+ # begin
276
+ # account = @client.reactivate_account(account_id: account_id)
277
+ # puts "Reactivated account #{account}"
278
+ # rescue Recurly::Errors::NotFoundError
279
+ # # If the resource was not found, you may want to alert the user or
280
+ # # just return nil
281
+ # puts "Resource Not Found"
282
+ # end
283
+ #
156
284
  def reactivate_account(account_id:)
157
285
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/reactivate", site_id: site_id, account_id: account_id)
158
286
  put(path)
@@ -160,8 +288,20 @@ module Recurly
160
288
 
161
289
  # Fetch an account's balance and past due status
162
290
  #
291
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_account_balance get_account_balance api documenation}
292
+ #
163
293
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
164
294
  # @return [Resources::AccountBalance] An account's balance.
295
+ # @example
296
+ # begin
297
+ # balance = @client.get_account_balance(account_id: account_id)
298
+ # puts "Got AccountBalance #{balance}"
299
+ # rescue Recurly::Errors::NotFoundError
300
+ # # If the resource was not found, you may want to alert the user or
301
+ # # just return nil
302
+ # puts "Resource Not Found"
303
+ # end
304
+ #
165
305
  def get_account_balance(account_id:)
166
306
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/balance", site_id: site_id, account_id: account_id)
167
307
  get(path)
@@ -169,8 +309,20 @@ module Recurly
169
309
 
170
310
  # Fetch an account's billing information
171
311
  #
312
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_billing_info get_billing_info api documenation}
313
+ #
172
314
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
173
315
  # @return [Resources::BillingInfo] An account's billing information.
316
+ # @example
317
+ # begin
318
+ # billing = @client.get_billing_info(account_id: account_id)
319
+ # puts "Got BillingInfo #{billing}"
320
+ # rescue Recurly::Errors::NotFoundError
321
+ # # If the resource was not found, you may want to alert the user or
322
+ # # just return nil
323
+ # puts "Resource Not Found"
324
+ # end
325
+ #
174
326
  def get_billing_info(account_id:)
175
327
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/billing_info", site_id: site_id, account_id: account_id)
176
328
  get(path)
@@ -178,9 +330,28 @@ module Recurly
178
330
 
179
331
  # Set an account's billing information
180
332
  #
333
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/update_billing_info update_billing_info api documenation}
334
+ #
181
335
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
182
336
  # @param body [Requests::BillingInfoCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::BillingInfoCreate}
183
337
  # @return [Resources::BillingInfo] Updated billing information.
338
+ # @example
339
+ # begin
340
+ # billing_update = {
341
+ # first_name: "Aaron",
342
+ # last_name: "Du Monde",
343
+ # }
344
+ # billing = @client.update_billing_info(
345
+ # account_id: account_id,
346
+ # body: billing_update
347
+ # )
348
+ # puts "Updated BillingInfo #{billing}"
349
+ # rescue Recurly::Errors::ValidationError => e
350
+ # # If the request was invalid, you may want to tell your user
351
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
352
+ # puts "ValidationError: #{e.recurly_error.params}"
353
+ # end
354
+ #
184
355
  def update_billing_info(account_id:, body:)
185
356
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/billing_info", site_id: site_id, account_id: account_id)
186
357
  put(path, body, Requests::BillingInfoCreate)
@@ -188,7 +359,19 @@ module Recurly
188
359
 
189
360
  # Remove an account's billing information
190
361
  #
362
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/remove_billing_info remove_billing_info api documenation}
363
+ #
191
364
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
365
+ # @example
366
+ # begin
367
+ # @client.remove_billing_info(account_id: account_id)
368
+ # puts "Removed BillingInfo #{account_id}"
369
+ # rescue Recurly::Errors::NotFoundError
370
+ # # If the resource was not found, you may want to alert the user or
371
+ # # just return nil
372
+ # puts "Resource Not Found"
373
+ # end
374
+ #
192
375
  def remove_billing_info(account_id:)
193
376
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/billing_info", site_id: site_id, account_id: account_id)
194
377
  delete(path)
@@ -196,9 +379,11 @@ module Recurly
196
379
 
197
380
  # Show the coupon redemptions for an account
198
381
  #
382
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_account_coupon_redemptions list_account_coupon_redemptions api documenation}
383
+ #
199
384
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
200
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
201
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
385
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
386
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
202
387
  #
203
388
  # *Important notes:*
204
389
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -208,7 +393,26 @@ module Recurly
208
393
  # * Records are returned in an arbitrary order. Since results are all
209
394
  # returned at once you can sort the records yourself.
210
395
  #
396
+ # @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
397
+ # order. In descending order updated records will move behind the cursor and could
398
+ # prevent some records from being returned.
399
+ #
400
+ # @param begin_time [DateTime] Filter by begin_time when +sort=created_at+ or +sort=updated_at+.
401
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
402
+ #
403
+ # @param end_time [DateTime] Filter by end_time when +sort=created_at+ or +sort=updated_at+.
404
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
405
+ #
211
406
  # @return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions on an account.
407
+ # @example
408
+ # redemptions = @client.list_account_coupon_redemptions(
409
+ # account_id: account_id,
410
+ # limit: 200
411
+ # )
412
+ # redemptions.each do |redemption|
413
+ # puts "CouponRedemption: #{redemption.id}"
414
+ # end
415
+ #
212
416
  def list_account_coupon_redemptions(account_id:, **options)
213
417
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/coupon_redemptions", site_id: site_id, account_id: account_id)
214
418
  pager(path, **options)
@@ -216,8 +420,20 @@ module Recurly
216
420
 
217
421
  # Show the coupon redemption that is active on an account
218
422
  #
423
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_active_coupon_redemption get_active_coupon_redemption api documenation}
424
+ #
219
425
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
220
426
  # @return [Resources::CouponRedemption] An active coupon redemption on an account.
427
+ # @example
428
+ # begin
429
+ # redemption = @client.get_active_coupon_redemption(account_id: account_id)
430
+ # puts "Got CouponRedemption #{redemption}"
431
+ # rescue Recurly::Errors::NotFoundError
432
+ # # If the resource was not found, you may want to alert the user or
433
+ # # just return nil
434
+ # puts "Resource Not Found"
435
+ # end
436
+ #
221
437
  def get_active_coupon_redemption(account_id:)
222
438
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/coupon_redemptions/active", site_id: site_id, account_id: account_id)
223
439
  get(path)
@@ -225,9 +441,28 @@ module Recurly
225
441
 
226
442
  # Generate an active coupon redemption on an account
227
443
  #
444
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_coupon_redemption create_coupon_redemption api documenation}
445
+ #
228
446
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
229
447
  # @param body [Requests::CouponRedemptionCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponRedemptionCreate}
230
448
  # @return [Resources::CouponRedemption] Returns the new coupon redemption.
449
+ # @example
450
+ # begin
451
+ # redemption_create = {
452
+ # currency: 'USD',
453
+ # coupon_id: coupon_id
454
+ # }
455
+ # redemption = @client.create_coupon_redemption(
456
+ # account_id: account_id,
457
+ # body: redemption_create
458
+ # )
459
+ # puts "Created CouponRedemption #{redemption}"
460
+ # rescue Recurly::Errors::ValidationError => e
461
+ # # If the request was invalid, you may want to tell your user
462
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
463
+ # puts "ValidationError: #{e.recurly_error.params}"
464
+ # end
465
+ #
231
466
  def create_coupon_redemption(account_id:, body:)
232
467
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/coupon_redemptions/active", site_id: site_id, account_id: account_id)
233
468
  post(path, body, Requests::CouponRedemptionCreate)
@@ -235,8 +470,20 @@ module Recurly
235
470
 
236
471
  # Delete the active coupon redemption from an account
237
472
  #
473
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/remove_coupon_redemption remove_coupon_redemption api documenation}
474
+ #
238
475
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
239
476
  # @return [Resources::CouponRedemption] Coupon redemption deleted.
477
+ # @example
478
+ # begin
479
+ # @client.remove_coupon_redemption(account_id: account_id)
480
+ # puts "Removed CouponRedemption #{account_id}"
481
+ # rescue Recurly::Errors::NotFoundError
482
+ # # If the resource was not found, you may want to alert the user or
483
+ # # just return nil
484
+ # puts "Resource Not Found"
485
+ # end
486
+ #
240
487
  def remove_coupon_redemption(account_id:)
241
488
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/coupon_redemptions/active", site_id: site_id, account_id: account_id)
242
489
  delete(path)
@@ -244,6 +491,8 @@ module Recurly
244
491
 
245
492
  # List an account's credit payments
246
493
  #
494
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_account_credit_payments list_account_credit_payments api documenation}
495
+ #
247
496
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
248
497
  # @param limit [Integer] Limit number of records 1-200.
249
498
  # @param order [String] Sort order.
@@ -258,6 +507,15 @@ module Recurly
258
507
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
259
508
  #
260
509
  # @return [Pager<Resources::CreditPayment>] A list of the account's credit payments.
510
+ # @example
511
+ # payments = @client.list_account_credit_payments(
512
+ # account_id: account_id,
513
+ # limit: 200
514
+ # )
515
+ # payments.each do |payment|
516
+ # puts "CreditPayment: #{payment.id}"
517
+ # end
518
+ #
261
519
  def list_account_credit_payments(account_id:, **options)
262
520
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/credit_payments", site_id: site_id, account_id: account_id)
263
521
  pager(path, **options)
@@ -265,9 +523,11 @@ module Recurly
265
523
 
266
524
  # List an account's invoices
267
525
  #
526
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_account_invoices list_account_invoices api documenation}
527
+ #
268
528
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
269
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
270
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
529
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
530
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
271
531
  #
272
532
  # *Important notes:*
273
533
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -296,6 +556,15 @@ module Recurly
296
556
  # - +type=legacy+, only legacy invoices will be returned.
297
557
  #
298
558
  # @return [Pager<Resources::Invoice>] A list of the account's invoices.
559
+ # @example
560
+ # invoices = @client.list_account_invoices(
561
+ # account_id: account_id,
562
+ # limit: 200
563
+ # )
564
+ # invoices.each do |invoice|
565
+ # puts "Invoice: #{invoice.number}"
566
+ # end
567
+ #
299
568
  def list_account_invoices(account_id:, **options)
300
569
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/invoices", site_id: site_id, account_id: account_id)
301
570
  pager(path, **options)
@@ -303,9 +572,28 @@ module Recurly
303
572
 
304
573
  # Create an invoice for pending line items
305
574
  #
575
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_invoice create_invoice api documenation}
576
+ #
306
577
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
307
578
  # @param body [Requests::InvoiceCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceCreate}
308
579
  # @return [Resources::InvoiceCollection] Returns the new invoices.
580
+ # @example
581
+ # begin
582
+ # invoice_create = {
583
+ # currency: 'USD',
584
+ # collection_method: 'automatic'
585
+ # }
586
+ # collection = @client.create_invoice(
587
+ # account_id: account_id,
588
+ # body: invoice_create
589
+ # )
590
+ # puts "Created InvoiceCollection #{collection}"
591
+ # rescue Recurly::Errors::ValidationError => e
592
+ # # If the request was invalid, you may want to tell your user
593
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
594
+ # puts "ValidationError: #{e.recurly_error.params}"
595
+ # end
596
+ #
309
597
  def create_invoice(account_id:, body:)
310
598
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/invoices", site_id: site_id, account_id: account_id)
311
599
  post(path, body, Requests::InvoiceCreate)
@@ -313,9 +601,28 @@ module Recurly
313
601
 
314
602
  # Preview new invoice for pending line items
315
603
  #
604
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/preview_invoice preview_invoice api documenation}
605
+ #
316
606
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
317
607
  # @param body [Requests::InvoiceCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceCreate}
318
608
  # @return [Resources::InvoiceCollection] Returns the invoice previews.
609
+ # @example
610
+ # begin
611
+ # invoice_preview = {
612
+ # currency: "USD",
613
+ # collection_method: "automatic"
614
+ # }
615
+ # collection = @client.create_invoice(
616
+ # account_id: account_id,
617
+ # body: invoice_preview
618
+ # )
619
+ # puts "Created InvoiceCollection #{collection}"
620
+ # rescue Recurly::Errors::ValidationError => e
621
+ # # If the request was invalid, you may want to tell your user
622
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
623
+ # puts "ValidationError: #{e.recurly_error.params}"
624
+ # end
625
+ #
319
626
  def preview_invoice(account_id:, body:)
320
627
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/invoices/preview", site_id: site_id, account_id: account_id)
321
628
  post(path, body, Requests::InvoiceCreate)
@@ -323,9 +630,11 @@ module Recurly
323
630
 
324
631
  # List an account's line items
325
632
  #
633
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_account_line_items list_account_line_items api documenation}
634
+ #
326
635
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
327
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
328
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
636
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
637
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
329
638
  #
330
639
  # *Important notes:*
331
640
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -351,6 +660,15 @@ module Recurly
351
660
  # @param state [String] Filter by state field.
352
661
  # @param type [String] Filter by type field.
353
662
  # @return [Pager<Resources::LineItem>] A list of the account's line items.
663
+ # @example
664
+ # line_items = @client.list_account_line_items(
665
+ # account_id: account_id,
666
+ # limit: 200
667
+ # )
668
+ # line_items.each do |line_item|
669
+ # puts "LineItem: #{line_item.id}"
670
+ # end
671
+ #
354
672
  def list_account_line_items(account_id:, **options)
355
673
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/line_items", site_id: site_id, account_id: account_id)
356
674
  pager(path, **options)
@@ -358,9 +676,29 @@ module Recurly
358
676
 
359
677
  # Create a new line item for the account
360
678
  #
679
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_line_item create_line_item api documenation}
680
+ #
361
681
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
362
682
  # @param body [Requests::LineItemCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::LineItemCreate}
363
683
  # @return [Resources::LineItem] Returns the new line item.
684
+ # @example
685
+ # begin
686
+ # line_item_create = {
687
+ # currency: 'USD',
688
+ # unit_amount: 1_000,
689
+ # type: :charge
690
+ # }
691
+ # line_item = @client.create_line_item(
692
+ # account_id: account_id,
693
+ # body: line_item_create
694
+ # )
695
+ # puts "Created LineItem #{line_item}"
696
+ # rescue Recurly::Errors::ValidationError => e
697
+ # # If the request was invalid, you may want to tell your user
698
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
699
+ # puts "ValidationError: #{e.recurly_error.params}"
700
+ # end
701
+ #
364
702
  def create_line_item(account_id:, body:)
365
703
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/line_items", site_id: site_id, account_id: account_id)
366
704
  post(path, body, Requests::LineItemCreate)
@@ -368,9 +706,11 @@ module Recurly
368
706
 
369
707
  # Fetch a list of an account's notes
370
708
  #
709
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_account_notes list_account_notes api documenation}
710
+ #
371
711
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
372
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
373
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
712
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
713
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
374
714
  #
375
715
  # *Important notes:*
376
716
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -381,6 +721,12 @@ module Recurly
381
721
  # returned at once you can sort the records yourself.
382
722
  #
383
723
  # @return [Pager<Resources::AccountNote>] A list of an account's notes.
724
+ # @example
725
+ # account_notes = @client.list_account_notes(account_id: account_id, limit: 200)
726
+ # account_notes.each do |note|
727
+ # puts "AccountNote: #{note.message}"
728
+ # end
729
+ #
384
730
  def list_account_notes(account_id:, **options)
385
731
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/notes", site_id: site_id, account_id: account_id)
386
732
  pager(path, **options)
@@ -388,9 +734,24 @@ module Recurly
388
734
 
389
735
  # Fetch an account note
390
736
  #
737
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_account_note get_account_note api documenation}
738
+ #
391
739
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
392
740
  # @param account_note_id [String] Account Note ID.
393
741
  # @return [Resources::AccountNote] An account note.
742
+ # @example
743
+ # begin
744
+ # note = @client.get_account_note(
745
+ # account_id: account_id,
746
+ # account_note_id: note_id
747
+ # )
748
+ # puts "Got AccountNote #{note}"
749
+ # rescue Recurly::Errors::NotFoundError
750
+ # # If the resource was not found, you may want to alert the user or
751
+ # # just return nil
752
+ # puts "Resource Not Found"
753
+ # end
754
+ #
394
755
  def get_account_note(account_id:, account_note_id:)
395
756
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/notes/{account_note_id}", site_id: site_id, account_id: account_id, account_note_id: account_note_id)
396
757
  get(path)
@@ -398,9 +759,11 @@ module Recurly
398
759
 
399
760
  # Fetch a list of an account's shipping addresses
400
761
  #
762
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_shipping_addresses list_shipping_addresses api documenation}
763
+ #
401
764
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
402
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
403
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
765
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
766
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
404
767
  #
405
768
  # *Important notes:*
406
769
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -423,6 +786,15 @@ module Recurly
423
786
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
424
787
  #
425
788
  # @return [Pager<Resources::ShippingAddress>] A list of an account's shipping addresses.
789
+ # @example
790
+ # shipping_addresses = @client.list_shipping_addresses(
791
+ # account_id: account_id,
792
+ # limit: 200
793
+ # )
794
+ # shipping_addresses.each do |addr|
795
+ # puts "ShippingAddress: #{addr.nickname} - #{addr.street1}"
796
+ # end
797
+ #
426
798
  def list_shipping_addresses(account_id:, **options)
427
799
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/shipping_addresses", site_id: site_id, account_id: account_id)
428
800
  pager(path, **options)
@@ -430,6 +802,8 @@ module Recurly
430
802
 
431
803
  # Create a new shipping address for the account
432
804
  #
805
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_shipping_address create_shipping_address api documenation}
806
+ #
433
807
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
434
808
  # @param body [Requests::ShippingAddressCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingAddressCreate}
435
809
  # @return [Resources::ShippingAddress] Returns the new shipping address.
@@ -440,9 +814,24 @@ module Recurly
440
814
 
441
815
  # Fetch an account's shipping address
442
816
  #
817
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_shipping_address get_shipping_address api documenation}
818
+ #
443
819
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
444
820
  # @param shipping_address_id [String] Shipping Address ID.
445
821
  # @return [Resources::ShippingAddress] A shipping address.
822
+ # @example
823
+ # begin
824
+ # address = @client.get_shipping_address(
825
+ # account_id: account_id,
826
+ # shipping_address_id: shipping_address_id
827
+ # )
828
+ # puts "Got ShippingAddress #{address}"
829
+ # rescue Recurly::Errors::NotFoundError
830
+ # # If the resource was not found, you may want to alert the user or
831
+ # # just return nil
832
+ # puts "Resource Not Found"
833
+ # end
834
+ #
446
835
  def get_shipping_address(account_id:, shipping_address_id:)
447
836
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/shipping_addresses/{shipping_address_id}", site_id: site_id, account_id: account_id, shipping_address_id: shipping_address_id)
448
837
  get(path)
@@ -450,10 +839,31 @@ module Recurly
450
839
 
451
840
  # Update an account's shipping address
452
841
  #
842
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/update_shipping_address update_shipping_address api documenation}
843
+ #
453
844
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
454
845
  # @param shipping_address_id [String] Shipping Address ID.
455
846
  # @param body [Requests::ShippingAddressUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::ShippingAddressUpdate}
456
847
  # @return [Resources::ShippingAddress] The updated shipping address.
848
+ # @example
849
+ # begin
850
+ # address_update = {
851
+ # first_name: "Aaron",
852
+ # last_name: "Du Monde",
853
+ # postal_code: "70130"
854
+ # }
855
+ # address = @client.update_shipping_address(
856
+ # account_id: account_id,
857
+ # shipping_address_id: shipping_address_id,
858
+ # body: address_update
859
+ # )
860
+ # puts "Updated ShippingAddress #{address}"
861
+ # rescue Recurly::Errors::ValidationError => e
862
+ # # If the request was invalid, you may want to tell your user
863
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
864
+ # puts "ValidationError: #{e.recurly_error.params}"
865
+ # end
866
+ #
457
867
  def update_shipping_address(account_id:, shipping_address_id:, body:)
458
868
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/shipping_addresses/{shipping_address_id}", site_id: site_id, account_id: account_id, shipping_address_id: shipping_address_id)
459
869
  put(path, body, Requests::ShippingAddressUpdate)
@@ -461,8 +871,23 @@ module Recurly
461
871
 
462
872
  # Remove an account's shipping address
463
873
  #
874
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/remove_shipping_address remove_shipping_address api documenation}
875
+ #
464
876
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
465
877
  # @param shipping_address_id [String] Shipping Address ID.
878
+ # @example
879
+ # begin
880
+ # @client.remove_shipping_address(
881
+ # account_id: account_id,
882
+ # shipping_address_id: shipping_address_id
883
+ # )
884
+ # puts "Removed ShippingAddress #{shipping_address_id}"
885
+ # rescue Recurly::Errors::NotFoundError
886
+ # # If the resource was not found, you may want to alert the user or
887
+ # # just return nil
888
+ # puts "Resource Not Found"
889
+ # end
890
+ #
466
891
  def remove_shipping_address(account_id:, shipping_address_id:)
467
892
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/shipping_addresses/{shipping_address_id}", site_id: site_id, account_id: account_id, shipping_address_id: shipping_address_id)
468
893
  delete(path)
@@ -470,9 +895,11 @@ module Recurly
470
895
 
471
896
  # List an account's subscriptions
472
897
  #
898
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_account_subscriptions list_account_subscriptions api documenation}
899
+ #
473
900
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
474
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
475
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
901
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
902
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
476
903
  #
477
904
  # *Important notes:*
478
905
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -500,6 +927,15 @@ module Recurly
500
927
  # - When +state=live+, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.
501
928
  #
502
929
  # @return [Pager<Resources::Subscription>] A list of the account's subscriptions.
930
+ # @example
931
+ # subscriptions = @client.list_account_subscriptions(
932
+ # account_id: account_id,
933
+ # limit: 200
934
+ # )
935
+ # subscriptions.each do |subscription|
936
+ # puts "Subscription: #{subscription.uuid}"
937
+ # end
938
+ #
503
939
  def list_account_subscriptions(account_id:, **options)
504
940
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/subscriptions", site_id: site_id, account_id: account_id)
505
941
  pager(path, **options)
@@ -507,9 +943,11 @@ module Recurly
507
943
 
508
944
  # List an account's transactions
509
945
  #
946
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_account_transactions list_account_transactions api documenation}
947
+ #
510
948
  # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
511
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
512
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
949
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
950
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
513
951
  #
514
952
  # *Important notes:*
515
953
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -531,18 +969,76 @@ module Recurly
531
969
  # @param end_time [DateTime] Filter by end_time when +sort=created_at+ or +sort=updated_at+.
532
970
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
533
971
  #
534
- # @param type [String] Filter by type field.
972
+ # @param type [String] Filter by type field. The value +payment+ will return both +purchase+ and +capture+ transactions.
535
973
  # @param success [String] Filter by success field.
536
974
  # @return [Pager<Resources::Transaction>] A list of the account's transactions.
975
+ # @example
976
+ # transactions = @client.list_account_transactions(
977
+ # account_id: account_id,
978
+ # limit: 200
979
+ # )
980
+ # transactions.each do |transaction|
981
+ # puts "Transaction: #{transaction.uuid}"
982
+ # end
983
+ #
537
984
  def list_account_transactions(account_id:, **options)
538
985
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/transactions", site_id: site_id, account_id: account_id)
539
986
  pager(path, **options)
540
987
  end
541
988
 
989
+ # List an account's child accounts
990
+ #
991
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_child_accounts list_child_accounts api documenation}
992
+ #
993
+ # @param account_id [String] Account ID or code (use prefix: +code-+, e.g. +code-bob+).
994
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
995
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
996
+ #
997
+ # *Important notes:*
998
+ # * The +ids+ parameter cannot be used with any other ordering or filtering
999
+ # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1000
+ # * Invalid or unknown IDs will be ignored, so you should check that the
1001
+ # results correspond to your request.
1002
+ # * Records are returned in an arbitrary order. Since results are all
1003
+ # returned at once you can sort the records yourself.
1004
+ #
1005
+ # @param limit [Integer] Limit number of records 1-200.
1006
+ # @param order [String] Sort order.
1007
+ # @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
1008
+ # order. In descending order updated records will move behind the cursor and could
1009
+ # prevent some records from being returned.
1010
+ #
1011
+ # @param begin_time [DateTime] Filter by begin_time when +sort=created_at+ or +sort=updated_at+.
1012
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
1013
+ #
1014
+ # @param end_time [DateTime] Filter by end_time when +sort=created_at+ or +sort=updated_at+.
1015
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
1016
+ #
1017
+ # @param subscriber [String] Filter accounts accounts with or without a subscription in the +active+,
1018
+ # +canceled+, or +future+ state.
1019
+ #
1020
+ # @param past_due [String] Filter for accounts with an invoice in the +past_due+ state.
1021
+ # @return [Pager<Resources::Account>] A list of an account's child accounts.
1022
+ # @example
1023
+ # # child_accounts = @client.list_child_accounts(
1024
+ # # account_id: account_id,
1025
+ # # limit: 200
1026
+ # # )
1027
+ # # child_accounts.each do |child|
1028
+ # # puts "Account: #{child.code}"
1029
+ # # end
1030
+ #
1031
+ def list_child_accounts(account_id:, **options)
1032
+ path = interpolate_path("/sites/{site_id}/accounts/{account_id}/accounts", site_id: site_id, account_id: account_id)
1033
+ pager(path, **options)
1034
+ end
1035
+
542
1036
  # List a site's account acquisition data
543
1037
  #
544
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
545
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1038
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_account_acquisition list_account_acquisition api documenation}
1039
+ #
1040
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1041
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
546
1042
  #
547
1043
  # *Important notes:*
548
1044
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -564,16 +1060,24 @@ module Recurly
564
1060
  # @param end_time [DateTime] Filter by end_time when +sort=created_at+ or +sort=updated_at+.
565
1061
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
566
1062
  #
567
- # @return [Resources::AccountAcquisition] A list of the site's account acquisition data.
1063
+ # @return [Pager<Resources::AccountAcquisition>] A list of the site's account acquisition data.
1064
+ # @example
1065
+ # acquisitions = @client.list_account_acquisition(limit: 200)
1066
+ # acquisitions.each do |acquisition|
1067
+ # puts "AccountAcquisition: #{acquisition.cost}"
1068
+ # end
1069
+ #
568
1070
  def list_account_acquisition(**options)
569
1071
  path = interpolate_path("/sites/{site_id}/acquisitions", site_id: site_id)
570
- get(path, **options)
1072
+ pager(path, **options)
571
1073
  end
572
1074
 
573
1075
  # List a site's coupons
574
1076
  #
575
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
576
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1077
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_coupons list_coupons api documenation}
1078
+ #
1079
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1080
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
577
1081
  #
578
1082
  # *Important notes:*
579
1083
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -596,6 +1100,12 @@ module Recurly
596
1100
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
597
1101
  #
598
1102
  # @return [Pager<Resources::Coupon>] A list of the site's coupons.
1103
+ # @example
1104
+ # coupons = @client.list_coupons(limit: 200)
1105
+ # coupons.each do |coupon|
1106
+ # puts "coupon: #{coupon.code}"
1107
+ # end
1108
+ #
599
1109
  def list_coupons(**options)
600
1110
  path = interpolate_path("/sites/{site_id}/coupons", site_id: site_id)
601
1111
  pager(path, **options)
@@ -603,8 +1113,33 @@ module Recurly
603
1113
 
604
1114
  # Create a new coupon
605
1115
  #
1116
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_coupon create_coupon api documenation}
1117
+ #
606
1118
  # @param body [Requests::CouponCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponCreate}
607
1119
  # @return [Resources::Coupon] A new coupon.
1120
+ # @example
1121
+ # begin
1122
+ # coupon_create = {
1123
+ # name: "Promotional Coupon",
1124
+ # code: coupon_code,
1125
+ # discount_type: 'fixed',
1126
+ # currencies: [
1127
+ # {
1128
+ # currency: 'USD',
1129
+ # discount: 10_000
1130
+ # }
1131
+ # ]
1132
+ # }
1133
+ # coupon = @client.create_coupon(
1134
+ # body: coupon_create
1135
+ # )
1136
+ # puts "Created Coupon #{coupon}"
1137
+ # rescue Recurly::Errors::ValidationError => e
1138
+ # # If the request was invalid, you may want to tell your user
1139
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
1140
+ # puts "ValidationError: #{e.recurly_error.params}"
1141
+ # end
1142
+ #
608
1143
  def create_coupon(body:)
609
1144
  path = interpolate_path("/sites/{site_id}/coupons", site_id: site_id)
610
1145
  post(path, body, Requests::CouponCreate)
@@ -612,8 +1147,20 @@ module Recurly
612
1147
 
613
1148
  # Fetch a coupon
614
1149
  #
1150
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_coupon get_coupon api documenation}
1151
+ #
615
1152
  # @param coupon_id [String] Coupon ID or code (use prefix: +code-+, e.g. +code-10off+).
616
1153
  # @return [Resources::Coupon] A coupon.
1154
+ # @example
1155
+ # begin
1156
+ # coupon = @client.get_coupon(coupon_id: coupon_id)
1157
+ # puts "Got Coupon #{coupon}"
1158
+ # rescue Recurly::Errors::NotFoundError
1159
+ # # If the resource was not found, you may want to alert the user or
1160
+ # # just return nil
1161
+ # puts "Resource Not Found"
1162
+ # end
1163
+ #
617
1164
  def get_coupon(coupon_id:)
618
1165
  path = interpolate_path("/sites/{site_id}/coupons/{coupon_id}", site_id: site_id, coupon_id: coupon_id)
619
1166
  get(path)
@@ -621,6 +1168,8 @@ module Recurly
621
1168
 
622
1169
  # Update an active coupon
623
1170
  #
1171
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/update_coupon update_coupon api documenation}
1172
+ #
624
1173
  # @param coupon_id [String] Coupon ID or code (use prefix: +code-+, e.g. +code-10off+).
625
1174
  # @param body [Requests::CouponUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::CouponUpdate}
626
1175
  # @return [Resources::Coupon] The updated coupon.
@@ -631,9 +1180,11 @@ module Recurly
631
1180
 
632
1181
  # List unique coupon codes associated with a bulk coupon
633
1182
  #
1183
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_unique_coupon_codes list_unique_coupon_codes api documenation}
1184
+ #
634
1185
  # @param coupon_id [String] Coupon ID or code (use prefix: +code-+, e.g. +code-10off+).
635
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
636
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1186
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1187
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
637
1188
  #
638
1189
  # *Important notes:*
639
1190
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -663,6 +1214,8 @@ module Recurly
663
1214
 
664
1215
  # List a site's credit payments
665
1216
  #
1217
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_credit_payments list_credit_payments api documenation}
1218
+ #
666
1219
  # @param limit [Integer] Limit number of records 1-200.
667
1220
  # @param order [String] Sort order.
668
1221
  # @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
@@ -676,6 +1229,12 @@ module Recurly
676
1229
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
677
1230
  #
678
1231
  # @return [Pager<Resources::CreditPayment>] A list of the site's credit payments.
1232
+ # @example
1233
+ # payments = @client.list_credit_payments(limit: 200)
1234
+ # payments.each do |payment|
1235
+ # puts "CreditPayment: #{payment.id}"
1236
+ # end
1237
+ #
679
1238
  def list_credit_payments(**options)
680
1239
  path = interpolate_path("/sites/{site_id}/credit_payments", site_id: site_id)
681
1240
  pager(path, **options)
@@ -683,6 +1242,8 @@ module Recurly
683
1242
 
684
1243
  # Fetch a credit payment
685
1244
  #
1245
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_credit_payment get_credit_payment api documenation}
1246
+ #
686
1247
  # @param credit_payment_id [String] Credit Payment ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
687
1248
  # @return [Resources::CreditPayment] A credit payment.
688
1249
  def get_credit_payment(credit_payment_id:)
@@ -692,8 +1253,10 @@ module Recurly
692
1253
 
693
1254
  # List a site's custom field definitions
694
1255
  #
695
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
696
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1256
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_custom_field_definitions list_custom_field_definitions api documenation}
1257
+ #
1258
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1259
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
697
1260
  #
698
1261
  # *Important notes:*
699
1262
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -723,6 +1286,8 @@ module Recurly
723
1286
 
724
1287
  # Fetch an custom field definition
725
1288
  #
1289
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_custom_field_definition get_custom_field_definition api documenation}
1290
+ #
726
1291
  # @param custom_field_definition_id [String] Custom Field Definition ID
727
1292
  # @return [Resources::CustomFieldDefinition] An custom field definition.
728
1293
  def get_custom_field_definition(custom_field_definition_id:)
@@ -732,8 +1297,10 @@ module Recurly
732
1297
 
733
1298
  # List a site's invoices
734
1299
  #
735
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
736
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1300
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_invoices list_invoices api documenation}
1301
+ #
1302
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1303
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
737
1304
  #
738
1305
  # *Important notes:*
739
1306
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -762,6 +1329,12 @@ module Recurly
762
1329
  # - +type=legacy+, only legacy invoices will be returned.
763
1330
  #
764
1331
  # @return [Pager<Resources::Invoice>] A list of the site's invoices.
1332
+ # @example
1333
+ # invoices = @client.list_invoices(limit: 200)
1334
+ # invoices.each do |invoice|
1335
+ # puts "Invoice: #{invoice.number}"
1336
+ # end
1337
+ #
765
1338
  def list_invoices(**options)
766
1339
  path = interpolate_path("/sites/{site_id}/invoices", site_id: site_id)
767
1340
  pager(path, **options)
@@ -769,17 +1342,53 @@ module Recurly
769
1342
 
770
1343
  # Fetch an invoice
771
1344
  #
1345
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_invoice get_invoice api documenation}
1346
+ #
772
1347
  # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
773
1348
  # @return [Resources::Invoice] An invoice.
1349
+ # @example
1350
+ # begin
1351
+ # invoice = @client.get_invoice(invoice_id: invoice_id)
1352
+ # puts "Got invoice #{invoice}"
1353
+ # rescue Recurly::Errors::NotFoundError
1354
+ # # If the resource was not found, you may want to alert the user or
1355
+ # # just return nil
1356
+ # puts "Resource Not Found"
1357
+ # end
1358
+ #
774
1359
  def get_invoice(invoice_id:)
775
1360
  path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}", site_id: site_id, invoice_id: invoice_id)
776
1361
  get(path)
777
1362
  end
778
1363
 
1364
+ # Update an invoice
1365
+ #
1366
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/put_invoice put_invoice api documenation}
1367
+ #
1368
+ # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
1369
+ # @param body [Requests::InvoiceUpdatable] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceUpdatable}
1370
+ # @return [Resources::Invoice] An invoice.
1371
+ def put_invoice(invoice_id:, body:)
1372
+ path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}", site_id: site_id, invoice_id: invoice_id)
1373
+ put(path, body, Requests::InvoiceUpdatable)
1374
+ end
1375
+
779
1376
  # Collect a pending or past due, automatic invoice
780
1377
  #
1378
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/collect_invoice collect_invoice api documenation}
1379
+ #
781
1380
  # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
782
1381
  # @return [Resources::Invoice] The updated invoice.
1382
+ # @example
1383
+ # begin
1384
+ # invoice = @client.collect_invoice(invoice_id: invoice_id)
1385
+ # puts "Collected invoice #{invoice}"
1386
+ # rescue Recurly::Errors::NotFoundError
1387
+ # # If the resource was not found, you may want to alert the user or
1388
+ # # just return nil
1389
+ # puts "Resource Not Found"
1390
+ # end
1391
+ #
783
1392
  def collect_invoice(invoice_id:)
784
1393
  path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/collect", site_id: site_id, invoice_id: invoice_id)
785
1394
  put(path)
@@ -787,8 +1396,20 @@ module Recurly
787
1396
 
788
1397
  # Mark an open invoice as failed
789
1398
  #
1399
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/fail_invoice fail_invoice api documenation}
1400
+ #
790
1401
  # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
791
1402
  # @return [Resources::Invoice] The updated invoice.
1403
+ # @example
1404
+ # begin
1405
+ # invoice = @client.fail_invoice(invoice_id: invoice_id)
1406
+ # puts "Failed invoice #{invoice}"
1407
+ # rescue Recurly::Errors::NotFoundError
1408
+ # # If the resource was not found, you may want to alert the user or
1409
+ # # just return nil
1410
+ # puts "Resource Not Found"
1411
+ # end
1412
+ #
792
1413
  def fail_invoice(invoice_id:)
793
1414
  path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/mark_failed", site_id: site_id, invoice_id: invoice_id)
794
1415
  put(path)
@@ -796,8 +1417,20 @@ module Recurly
796
1417
 
797
1418
  # Mark an open invoice as successful
798
1419
  #
1420
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/mark_invoice_successful mark_invoice_successful api documenation}
1421
+ #
799
1422
  # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
800
1423
  # @return [Resources::Invoice] The updated invoice.
1424
+ # @example
1425
+ # begin
1426
+ # invoice = @client.mark_invoice_successful(invoice_id: invoice_id)
1427
+ # puts "Marked invoice sucessful #{invoice}"
1428
+ # rescue Recurly::Errors::NotFoundError
1429
+ # # If the resource was not found, you may want to alert the user or
1430
+ # # just return nil
1431
+ # puts "Resource Not Found"
1432
+ # end
1433
+ #
801
1434
  def mark_invoice_successful(invoice_id:)
802
1435
  path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/mark_successful", site_id: site_id, invoice_id: invoice_id)
803
1436
  put(path)
@@ -805,8 +1438,20 @@ module Recurly
805
1438
 
806
1439
  # Reopen a closed, manual invoice
807
1440
  #
1441
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/reopen_invoice reopen_invoice api documenation}
1442
+ #
808
1443
  # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
809
1444
  # @return [Resources::Invoice] The updated invoice.
1445
+ # @example
1446
+ # begin
1447
+ # invoice = @client.reopen_invoice(invoice_id: invoice_id)
1448
+ # puts "Reopened invoice #{invoice}"
1449
+ # rescue Recurly::Errors::NotFoundError
1450
+ # # If the resource was not found, you may want to alert the user or
1451
+ # # just return nil
1452
+ # puts "Resource Not Found"
1453
+ # end
1454
+ #
810
1455
  def reopen_invoice(invoice_id:)
811
1456
  path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/reopen", site_id: site_id, invoice_id: invoice_id)
812
1457
  put(path)
@@ -814,9 +1459,11 @@ module Recurly
814
1459
 
815
1460
  # List a invoice's line items
816
1461
  #
1462
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_invoice_line_items list_invoice_line_items api documenation}
1463
+ #
817
1464
  # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
818
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
819
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1465
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1466
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
820
1467
  #
821
1468
  # *Important notes:*
822
1469
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -849,9 +1496,11 @@ module Recurly
849
1496
 
850
1497
  # Show the coupon redemptions applied to an invoice
851
1498
  #
1499
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_invoice_coupon_redemptions list_invoice_coupon_redemptions api documenation}
1500
+ #
852
1501
  # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
853
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
854
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1502
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1503
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
855
1504
  #
856
1505
  # *Important notes:*
857
1506
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -861,7 +1510,26 @@ module Recurly
861
1510
  # * Records are returned in an arbitrary order. Since results are all
862
1511
  # returned at once you can sort the records yourself.
863
1512
  #
1513
+ # @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
1514
+ # order. In descending order updated records will move behind the cursor and could
1515
+ # prevent some records from being returned.
1516
+ #
1517
+ # @param begin_time [DateTime] Filter by begin_time when +sort=created_at+ or +sort=updated_at+.
1518
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
1519
+ #
1520
+ # @param end_time [DateTime] Filter by end_time when +sort=created_at+ or +sort=updated_at+.
1521
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
1522
+ #
864
1523
  # @return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions associated with the invoice.
1524
+ # @example
1525
+ # coupon_redemptions = @client.list_invoice_coupon_redemptions(
1526
+ # invoice_id: invoice_id,
1527
+ # limit: 200
1528
+ # )
1529
+ # coupon_redemptions.each do |redemption|
1530
+ # puts "CouponRedemption: #{redemption.id}"
1531
+ # end
1532
+ #
865
1533
  def list_invoice_coupon_redemptions(invoice_id:, **options)
866
1534
  path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/coupon_redemptions", site_id: site_id, invoice_id: invoice_id)
867
1535
  pager(path, **options)
@@ -869,6 +1537,8 @@ module Recurly
869
1537
 
870
1538
  # List an invoice's related credit or charge invoices
871
1539
  #
1540
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_related_invoices list_related_invoices api documenation}
1541
+ #
872
1542
  # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
873
1543
  # @return [Pager<Resources::Invoice>] A list of the credit or charge invoices associated with the invoice.
874
1544
  def list_related_invoices(invoice_id:)
@@ -878,9 +1548,28 @@ module Recurly
878
1548
 
879
1549
  # Refund an invoice
880
1550
  #
1551
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/refund_invoice refund_invoice api documenation}
1552
+ #
881
1553
  # @param invoice_id [String] Invoice ID or number (use prefix: +number-+, e.g. +number-1000+).
882
1554
  # @param body [Requests::InvoiceRefund] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::InvoiceRefund}
883
1555
  # @return [Resources::Invoice] Returns the new credit invoice.
1556
+ # @example
1557
+ # begin
1558
+ # invoice_refund = {
1559
+ # type: "amount",
1560
+ # amount: 100,
1561
+ # }
1562
+ # invoice = @client.refund_invoice(
1563
+ # invoice_id: invoice_id,
1564
+ # body: invoice_refund
1565
+ # )
1566
+ # puts "Refunded invoice #{invoice}"
1567
+ # rescue Recurly::Errors::ValidationError => e
1568
+ # # If the request was invalid, you may want to tell your user
1569
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
1570
+ # puts "ValidationError: #{e.recurly_error.params}"
1571
+ # end
1572
+ #
884
1573
  def refund_invoice(invoice_id:, body:)
885
1574
  path = interpolate_path("/sites/{site_id}/invoices/{invoice_id}/refund", site_id: site_id, invoice_id: invoice_id)
886
1575
  post(path, body, Requests::InvoiceRefund)
@@ -888,8 +1577,10 @@ module Recurly
888
1577
 
889
1578
  # List a site's line items
890
1579
  #
891
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
892
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1580
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_line_items list_line_items api documenation}
1581
+ #
1582
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1583
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
893
1584
  #
894
1585
  # *Important notes:*
895
1586
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -922,8 +1613,20 @@ module Recurly
922
1613
 
923
1614
  # Fetch a line item
924
1615
  #
1616
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_line_item get_line_item api documenation}
1617
+ #
925
1618
  # @param line_item_id [String] Line Item ID.
926
1619
  # @return [Resources::LineItem] A line item.
1620
+ # @example
1621
+ # begin
1622
+ # line_item = @client.get_line_item(line_item_id: line_item_id)
1623
+ # puts "Got LineItem #{line_item}"
1624
+ # rescue Recurly::Errors::NotFoundError
1625
+ # # If the resource was not found, you may want to alert the user or
1626
+ # # just return nil
1627
+ # puts "Resource Not Found"
1628
+ # end
1629
+ #
927
1630
  def get_line_item(line_item_id:)
928
1631
  path = interpolate_path("/sites/{site_id}/line_items/{line_item_id}", site_id: site_id, line_item_id: line_item_id)
929
1632
  get(path)
@@ -931,7 +1634,21 @@ module Recurly
931
1634
 
932
1635
  # Delete an uninvoiced line item
933
1636
  #
1637
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/remove_line_item remove_line_item api documenation}
1638
+ #
934
1639
  # @param line_item_id [String] Line Item ID.
1640
+ # @example
1641
+ # begin
1642
+ # @client.remove_line_item(
1643
+ # line_item_id: line_item_id
1644
+ # )
1645
+ # puts "Removed LineItem #{line_item_id}"
1646
+ # rescue Recurly::Errors::NotFoundError
1647
+ # # If the resource was not found, you may want to alert the user or
1648
+ # # just return nil
1649
+ # puts "Resource Not Found"
1650
+ # end
1651
+ #
935
1652
  def remove_line_item(line_item_id:)
936
1653
  path = interpolate_path("/sites/{site_id}/line_items/{line_item_id}", site_id: site_id, line_item_id: line_item_id)
937
1654
  delete(path)
@@ -939,8 +1656,10 @@ module Recurly
939
1656
 
940
1657
  # List a site's plans
941
1658
  #
942
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
943
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1659
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_plans list_plans api documenation}
1660
+ #
1661
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1662
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
944
1663
  #
945
1664
  # *Important notes:*
946
1665
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -964,6 +1683,12 @@ module Recurly
964
1683
  #
965
1684
  # @param state [String] Filter by state.
966
1685
  # @return [Pager<Resources::Plan>] A list of plans.
1686
+ # @example
1687
+ # plans = @client.list_plans(limit: 200)
1688
+ # plans.each do |plan|
1689
+ # puts "Plan: #{plan.code}"
1690
+ # end
1691
+ #
967
1692
  def list_plans(**options)
968
1693
  path = interpolate_path("/sites/{site_id}/plans", site_id: site_id)
969
1694
  pager(path, **options)
@@ -971,8 +1696,37 @@ module Recurly
971
1696
 
972
1697
  # Create a plan
973
1698
  #
1699
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_plan create_plan api documenation}
1700
+ #
974
1701
  # @param body [Requests::PlanCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PlanCreate}
975
1702
  # @return [Resources::Plan] A plan.
1703
+ # @example
1704
+ # begin
1705
+ # plan_create = {
1706
+ # code: plan_code,
1707
+ # name: plan_name,
1708
+ # currencies: [
1709
+ # currency: "USD",
1710
+ # setup_fee: 1_000
1711
+ # ],
1712
+ # add_ons: [
1713
+ # {
1714
+ # name: 'Extra User',
1715
+ # code: 'extra_user',
1716
+ # currencies: [
1717
+ # { currency: 'USD', unit_amount: 10_000 }
1718
+ # ]
1719
+ # }
1720
+ # ]
1721
+ # }
1722
+ # plan = @client.create_plan(body: plan_create)
1723
+ # puts "Created Plan #{plan}"
1724
+ # rescue Recurly::Errors::ValidationError => e
1725
+ # # If the request was invalid, you may want to tell your user
1726
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
1727
+ # puts "ValidationError: #{e.recurly_error.params}"
1728
+ # end
1729
+ #
976
1730
  def create_plan(body:)
977
1731
  path = interpolate_path("/sites/{site_id}/plans", site_id: site_id)
978
1732
  post(path, body, Requests::PlanCreate)
@@ -980,8 +1734,20 @@ module Recurly
980
1734
 
981
1735
  # Fetch a plan
982
1736
  #
1737
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_plan get_plan api documenation}
1738
+ #
983
1739
  # @param plan_id [String] Plan ID or code (use prefix: +code-+, e.g. +code-gold+).
984
1740
  # @return [Resources::Plan] A plan.
1741
+ # @example
1742
+ # begin
1743
+ # plan = @client.get_plan(plan_id: plan_id)
1744
+ # puts "Got plan #{plan}"
1745
+ # rescue Recurly::Errors::NotFoundError
1746
+ # # If the resource was not found, you may want to alert the user or
1747
+ # # just return nil
1748
+ # puts "Resource Not Found"
1749
+ # end
1750
+ #
985
1751
  def get_plan(plan_id:)
986
1752
  path = interpolate_path("/sites/{site_id}/plans/{plan_id}", site_id: site_id, plan_id: plan_id)
987
1753
  get(path)
@@ -989,6 +1755,8 @@ module Recurly
989
1755
 
990
1756
  # Update a plan
991
1757
  #
1758
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/update_plan update_plan api documenation}
1759
+ #
992
1760
  # @param plan_id [String] Plan ID or code (use prefix: +code-+, e.g. +code-gold+).
993
1761
  # @param body [Requests::PlanUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PlanUpdate}
994
1762
  # @return [Resources::Plan] A plan.
@@ -999,6 +1767,8 @@ module Recurly
999
1767
 
1000
1768
  # Remove a plan
1001
1769
  #
1770
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/remove_plan remove_plan api documenation}
1771
+ #
1002
1772
  # @param plan_id [String] Plan ID or code (use prefix: +code-+, e.g. +code-gold+).
1003
1773
  # @return [Resources::Plan] Plan deleted
1004
1774
  def remove_plan(plan_id:)
@@ -1008,9 +1778,11 @@ module Recurly
1008
1778
 
1009
1779
  # List a plan's add-ons
1010
1780
  #
1781
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_plan_add_ons list_plan_add_ons api documenation}
1782
+ #
1011
1783
  # @param plan_id [String] Plan ID or code (use prefix: +code-+, e.g. +code-gold+).
1012
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
1013
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1784
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1785
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1014
1786
  #
1015
1787
  # *Important notes:*
1016
1788
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -1034,6 +1806,15 @@ module Recurly
1034
1806
  #
1035
1807
  # @param state [String] Filter by state.
1036
1808
  # @return [Pager<Resources::AddOn>] A list of add-ons.
1809
+ # @example
1810
+ # add_ons = @client.list_plan_add_ons(
1811
+ # plan_id: plan_id,
1812
+ # limit: 200
1813
+ # )
1814
+ # add_ons.each do |add_on|
1815
+ # puts "AddOn: #{add_on.code}"
1816
+ # end
1817
+ #
1037
1818
  def list_plan_add_ons(plan_id:, **options)
1038
1819
  path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons", site_id: site_id, plan_id: plan_id)
1039
1820
  pager(path, **options)
@@ -1041,6 +1822,8 @@ module Recurly
1041
1822
 
1042
1823
  # Create an add-on
1043
1824
  #
1825
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_plan_add_on create_plan_add_on api documenation}
1826
+ #
1044
1827
  # @param plan_id [String] Plan ID or code (use prefix: +code-+, e.g. +code-gold+).
1045
1828
  # @param body [Requests::AddOnCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AddOnCreate}
1046
1829
  # @return [Resources::AddOn] An add-on.
@@ -1051,39 +1834,59 @@ module Recurly
1051
1834
 
1052
1835
  # Fetch a plan's add-on
1053
1836
  #
1054
- # @param add_on_id [String] Add-on ID or code (use prefix: +code-+, e.g. +code-gold+).
1837
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_plan_add_on get_plan_add_on api documenation}
1838
+ #
1055
1839
  # @param plan_id [String] Plan ID or code (use prefix: +code-+, e.g. +code-gold+).
1840
+ # @param add_on_id [String] Add-on ID or code (use prefix: +code-+, e.g. +code-gold+).
1056
1841
  # @return [Resources::AddOn] An add-on.
1057
- def get_plan_add_on(add_on_id:, plan_id:)
1058
- path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}", site_id: site_id, add_on_id: add_on_id, plan_id: plan_id)
1842
+ # @example
1843
+ # begin
1844
+ # add_on = @client.get_plan_add_on(
1845
+ # plan_id: plan_id, add_on_id: add_on_id
1846
+ # )
1847
+ # puts "Got plan add-on #{add_on}"
1848
+ # rescue Recurly::Errors::NotFoundError
1849
+ # # If the resource was not found, you may want to alert the user or
1850
+ # # just return nil
1851
+ # puts "Resource Not Found"
1852
+ # end
1853
+ #
1854
+ def get_plan_add_on(plan_id:, add_on_id:)
1855
+ path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}", site_id: site_id, plan_id: plan_id, add_on_id: add_on_id)
1059
1856
  get(path)
1060
1857
  end
1061
1858
 
1062
1859
  # Update an add-on
1063
1860
  #
1064
- # @param add_on_id [String] Add-on ID or code (use prefix: +code-+, e.g. +code-gold+).
1861
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/update_plan_add_on update_plan_add_on api documenation}
1862
+ #
1065
1863
  # @param plan_id [String] Plan ID or code (use prefix: +code-+, e.g. +code-gold+).
1864
+ # @param add_on_id [String] Add-on ID or code (use prefix: +code-+, e.g. +code-gold+).
1066
1865
  # @param body [Requests::AddOnUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::AddOnUpdate}
1067
1866
  # @return [Resources::AddOn] An add-on.
1068
- def update_plan_add_on(add_on_id:, plan_id:, body:)
1069
- path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}", site_id: site_id, add_on_id: add_on_id, plan_id: plan_id)
1867
+ def update_plan_add_on(plan_id:, add_on_id:, body:)
1868
+ path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}", site_id: site_id, plan_id: plan_id, add_on_id: add_on_id)
1070
1869
  put(path, body, Requests::AddOnUpdate)
1071
1870
  end
1072
1871
 
1073
1872
  # Remove an add-on
1074
1873
  #
1075
- # @param add_on_id [String] Add-on ID or code (use prefix: +code-+, e.g. +code-gold+).
1874
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/remove_plan_add_on remove_plan_add_on api documenation}
1875
+ #
1076
1876
  # @param plan_id [String] Plan ID or code (use prefix: +code-+, e.g. +code-gold+).
1877
+ # @param add_on_id [String] Add-on ID or code (use prefix: +code-+, e.g. +code-gold+).
1077
1878
  # @return [Resources::AddOn] Add-on deleted
1078
- def remove_plan_add_on(add_on_id:, plan_id:)
1079
- path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}", site_id: site_id, add_on_id: add_on_id, plan_id: plan_id)
1879
+ def remove_plan_add_on(plan_id:, add_on_id:)
1880
+ path = interpolate_path("/sites/{site_id}/plans/{plan_id}/add_ons/{add_on_id}", site_id: site_id, plan_id: plan_id, add_on_id: add_on_id)
1080
1881
  delete(path)
1081
1882
  end
1082
1883
 
1083
1884
  # List a site's add-ons
1084
1885
  #
1085
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
1086
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1886
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_add_ons list_add_ons api documenation}
1887
+ #
1888
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1889
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1087
1890
  #
1088
1891
  # *Important notes:*
1089
1892
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -1114,6 +1917,8 @@ module Recurly
1114
1917
 
1115
1918
  # Fetch an add-on
1116
1919
  #
1920
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_add_on get_add_on api documenation}
1921
+ #
1117
1922
  # @param add_on_id [String] Add-on ID or code (use prefix: +code-+, e.g. +code-gold+).
1118
1923
  # @return [Resources::AddOn] An add-on.
1119
1924
  def get_add_on(add_on_id:)
@@ -1123,8 +1928,10 @@ module Recurly
1123
1928
 
1124
1929
  # List a site's subscriptions
1125
1930
  #
1126
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
1127
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
1931
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_subscriptions list_subscriptions api documenation}
1932
+ #
1933
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
1934
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1128
1935
  #
1129
1936
  # *Important notes:*
1130
1937
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -1152,6 +1959,12 @@ module Recurly
1152
1959
  # - When +state=live+, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.
1153
1960
  #
1154
1961
  # @return [Pager<Resources::Subscription>] A list of the site's subscriptions.
1962
+ # @example
1963
+ # subscriptions = @client.list_subscriptions(limit: 200)
1964
+ # subscriptions.each do |subscription|
1965
+ # puts "Subscription: #{subscription.uuid}"
1966
+ # end
1967
+ #
1155
1968
  def list_subscriptions(**options)
1156
1969
  path = interpolate_path("/sites/{site_id}/subscriptions", site_id: site_id)
1157
1970
  pager(path, **options)
@@ -1159,8 +1972,31 @@ module Recurly
1159
1972
 
1160
1973
  # Create a new subscription
1161
1974
  #
1975
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_subscription create_subscription api documenation}
1976
+ #
1162
1977
  # @param body [Requests::SubscriptionCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionCreate}
1163
1978
  # @return [Resources::Subscription] A subscription.
1979
+ # @example
1980
+ # begin
1981
+ # subscription_create = {
1982
+ # plan_code: plan_code,
1983
+ # currency: "USD",
1984
+ # # This can be an existing account or
1985
+ # # a new acocunt
1986
+ # account: {
1987
+ # code: account_code,
1988
+ # }
1989
+ # }
1990
+ # subscription = @client.create_subscription(
1991
+ # body: subscription_create
1992
+ # )
1993
+ # puts "Created Subscription #{subscription}"
1994
+ # rescue Recurly::Errors::ValidationError => e
1995
+ # # If the request was invalid, you may want to tell your user
1996
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
1997
+ # puts "ValidationError: #{e.recurly_error.params}"
1998
+ # end
1999
+ #
1164
2000
  def create_subscription(body:)
1165
2001
  path = interpolate_path("/sites/{site_id}/subscriptions", site_id: site_id)
1166
2002
  post(path, body, Requests::SubscriptionCreate)
@@ -1168,19 +2004,20 @@ module Recurly
1168
2004
 
1169
2005
  # Fetch a subscription
1170
2006
  #
2007
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_subscription get_subscription api documenation}
2008
+ #
1171
2009
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1172
2010
  # @return [Resources::Subscription] A subscription.
1173
2011
  # @example
1174
2012
  # begin
1175
- # # You can use the `id` field from a Subscription object
1176
- # subscription = @client.get_subscription(subscription_id: "hympfmu77b4d")
1177
- # # If you have the uuid, you can prefix with `uuid-`
1178
- # subscription = @client.get_subscription(subscription_id: "uuid-419cd2effd49236e502ccc42db928280")
1179
- # rescue Recurly::Errors::NotFoundError => e
1180
- # puts e
1181
- # # => Recurly::NotFoundError: Couldn't Subscription with uuid = 419cd2effd49236e502ccc42db928280
1182
- # puts e.recurly_error
1183
- # # => #<Recurly::Error:0x007f8b29918618 @attributes={:type=>"not_found", :message=>"Couldn't find Subscription with uuid = 419cd2effd49236e502ccc42db928280", :params=>[{"param"=>"subscription_id"}]}>
2013
+ # subscription = @client.get_subscription(
2014
+ # subscription_id: subscription_id
2015
+ # )
2016
+ # puts "Got Subscription #{subscription}"
2017
+ # rescue Recurly::Errors::NotFoundError
2018
+ # # If the resource was not found, you may want to alert the user or
2019
+ # # just return nil
2020
+ # puts "Resource Not Found"
1184
2021
  # end
1185
2022
  #
1186
2023
  def get_subscription(subscription_id:)
@@ -1190,9 +2027,28 @@ module Recurly
1190
2027
 
1191
2028
  # Modify a subscription
1192
2029
  #
2030
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/modify_subscription modify_subscription api documenation}
2031
+ #
1193
2032
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1194
2033
  # @param body [Requests::SubscriptionUpdate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionUpdate}
1195
2034
  # @return [Resources::Subscription] A subscription.
2035
+ # @example
2036
+ # begin
2037
+ # subscription_update = {
2038
+ # customer_notes: "New Notes",
2039
+ # terms_and_conditions: "New ToC"
2040
+ # }
2041
+ # subscription = @client.modify_subscription(
2042
+ # subscription_id: subscription_id,
2043
+ # body: subscription_update
2044
+ # )
2045
+ # puts "Modified Subscription #{subscription}"
2046
+ # rescue Recurly::Errors::ValidationError => e
2047
+ # # If the request was invalid, you may want to tell your user
2048
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
2049
+ # puts "ValidationError: #{e.recurly_error.params}"
2050
+ # end
2051
+ #
1196
2052
  def modify_subscription(subscription_id:, body:)
1197
2053
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}", site_id: site_id, subscription_id: subscription_id)
1198
2054
  put(path, body, Requests::SubscriptionUpdate)
@@ -1200,6 +2056,8 @@ module Recurly
1200
2056
 
1201
2057
  # Terminate a subscription
1202
2058
  #
2059
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/terminate_subscription terminate_subscription api documenation}
2060
+ #
1203
2061
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1204
2062
  # @param refund [String] The type of refund to perform:
1205
2063
  #
@@ -1212,6 +2070,18 @@ module Recurly
1212
2070
  # You may also terminate a subscription with no refund and then manually refund specific invoices.
1213
2071
  #
1214
2072
  # @return [Resources::Subscription] An expired subscription.
2073
+ # @example
2074
+ # begin
2075
+ # subscription = @client.terminate_subscription(
2076
+ # subscription_id: subscription_id,
2077
+ # )
2078
+ # puts "Terminated Subscription #{subscription}"
2079
+ # rescue Recurly::Errors::NotFoundError
2080
+ # # If the resource was not found, you may want to alert the user or
2081
+ # # just return nil
2082
+ # puts "Resource Not Found"
2083
+ # end
2084
+ #
1215
2085
  def terminate_subscription(subscription_id:, **options)
1216
2086
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}", site_id: site_id, subscription_id: subscription_id)
1217
2087
  delete(path, **options)
@@ -1219,8 +2089,22 @@ module Recurly
1219
2089
 
1220
2090
  # Cancel a subscription
1221
2091
  #
2092
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/cancel_subscription cancel_subscription api documenation}
2093
+ #
1222
2094
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1223
2095
  # @return [Resources::Subscription] A canceled or failed subscription.
2096
+ # @example
2097
+ # begin
2098
+ # subscription = @client.cancel_subscription(
2099
+ # subscription_id: subscription_id
2100
+ # )
2101
+ # puts "Canceled Subscription #{subscription}"
2102
+ # rescue Recurly::Errors::NotFoundError
2103
+ # # If the resource was not found, you may want to alert the user or
2104
+ # # just return nil
2105
+ # puts "Resource Not Found"
2106
+ # end
2107
+ #
1224
2108
  def cancel_subscription(subscription_id:)
1225
2109
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/cancel", site_id: site_id, subscription_id: subscription_id)
1226
2110
  put(path)
@@ -1228,8 +2112,22 @@ module Recurly
1228
2112
 
1229
2113
  # Reactivate a canceled subscription
1230
2114
  #
2115
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/reactivate_subscription reactivate_subscription api documenation}
2116
+ #
1231
2117
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1232
2118
  # @return [Resources::Subscription] An active subscription.
2119
+ # @example
2120
+ # begin
2121
+ # subscription = @client.reactivate_subscription(
2122
+ # subscription_id: subscription_id
2123
+ # )
2124
+ # puts "Reactivated Canceled Subscription #{subscription}"
2125
+ # rescue Recurly::Errors::NotFoundError
2126
+ # # If the resource was not found, you may want to alert the user or
2127
+ # # just return nil
2128
+ # puts "Resource Not Found"
2129
+ # end
2130
+ #
1233
2131
  def reactivate_subscription(subscription_id:)
1234
2132
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/reactivate", site_id: site_id, subscription_id: subscription_id)
1235
2133
  put(path)
@@ -1237,9 +2135,27 @@ module Recurly
1237
2135
 
1238
2136
  # Pause subscription
1239
2137
  #
2138
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/pause_subscription pause_subscription api documenation}
2139
+ #
1240
2140
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1241
2141
  # @param body [Requests::SubscriptionPause] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionPause}
1242
2142
  # @return [Resources::Subscription] A subscription.
2143
+ # @example
2144
+ # begin
2145
+ # subscription_pause = {
2146
+ # remaining_pause_cycles: 10
2147
+ # }
2148
+ # subscription = @client.pause_subscription(
2149
+ # subscription_id: subscription_id,
2150
+ # body: subscription_pause
2151
+ # )
2152
+ # puts "Paused Subscription #{subscription}"
2153
+ # rescue Recurly::Errors::NotFoundError
2154
+ # # If the resource was not found, you may want to alert the user or
2155
+ # # just return nil
2156
+ # puts "Resource Not Found"
2157
+ # end
2158
+ #
1243
2159
  def pause_subscription(subscription_id:, body:)
1244
2160
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/pause", site_id: site_id, subscription_id: subscription_id)
1245
2161
  put(path, body, Requests::SubscriptionPause)
@@ -1247,8 +2163,22 @@ module Recurly
1247
2163
 
1248
2164
  # Resume subscription
1249
2165
  #
2166
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/resume_subscription resume_subscription api documenation}
2167
+ #
1250
2168
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1251
2169
  # @return [Resources::Subscription] A subscription.
2170
+ # @example
2171
+ # begin
2172
+ # subscription = @client.resume_subscription(
2173
+ # subscription_id: subscription_id
2174
+ # )
2175
+ # puts "Resumed Subscription #{subscription}"
2176
+ # rescue Recurly::Errors::NotFoundError
2177
+ # # If the resource was not found, you may want to alert the user or
2178
+ # # just return nil
2179
+ # puts "Resource Not Found"
2180
+ # end
2181
+ #
1252
2182
  def resume_subscription(subscription_id:)
1253
2183
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/resume", site_id: site_id, subscription_id: subscription_id)
1254
2184
  put(path)
@@ -1256,8 +2186,22 @@ module Recurly
1256
2186
 
1257
2187
  # Fetch a subscription's pending change
1258
2188
  #
2189
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_subscription_change get_subscription_change api documenation}
2190
+ #
1259
2191
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1260
2192
  # @return [Resources::SubscriptionChange] A subscription's pending change.
2193
+ # @example
2194
+ # begin
2195
+ # change = @client.get_subscription_change(
2196
+ # subscription_id: subscription_id
2197
+ # )
2198
+ # puts "Got SubscriptionChange #{change}"
2199
+ # rescue Recurly::Errors::NotFoundError
2200
+ # # If the resource was not found, you may want to alert the user or
2201
+ # # just return nil
2202
+ # puts "Resource Not Found"
2203
+ # end
2204
+ #
1261
2205
  def get_subscription_change(subscription_id:)
1262
2206
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/change", site_id: site_id, subscription_id: subscription_id)
1263
2207
  get(path)
@@ -1265,9 +2209,28 @@ module Recurly
1265
2209
 
1266
2210
  # Create a new subscription change
1267
2211
  #
2212
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_subscription_change create_subscription_change api documenation}
2213
+ #
1268
2214
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1269
2215
  # @param body [Requests::SubscriptionChangeCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::SubscriptionChangeCreate}
1270
2216
  # @return [Resources::SubscriptionChange] A subscription change.
2217
+ # @example
2218
+ # begin
2219
+ # change_create = {
2220
+ # timeframe: "now",
2221
+ # plan_code: new_plan_code
2222
+ # }
2223
+ # change = @client.create_subscription_change(
2224
+ # subscription_id: subscription_id,
2225
+ # body: change_create
2226
+ # )
2227
+ # puts "Created SubscriptionChange #{change}"
2228
+ # rescue Recurly::Errors::ValidationError => e
2229
+ # # If the request was invalid, you may want to tell your user
2230
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
2231
+ # puts "ValidationError: #{e.recurly_error.params}"
2232
+ # end
2233
+ #
1271
2234
  def create_subscription_change(subscription_id:, body:)
1272
2235
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/change", site_id: site_id, subscription_id: subscription_id)
1273
2236
  post(path, body, Requests::SubscriptionChangeCreate)
@@ -1275,7 +2238,21 @@ module Recurly
1275
2238
 
1276
2239
  # Delete the pending subscription change
1277
2240
  #
2241
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/remove_subscription_change remove_subscription_change api documenation}
2242
+ #
1278
2243
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
2244
+ # @example
2245
+ # begin
2246
+ # @client.remove_subscription_change(
2247
+ # subscription_id: subscription_id
2248
+ # )
2249
+ # puts "Removed SubscriptionChange #{subscription_id}"
2250
+ # rescue Recurly::Errors::NotFoundError
2251
+ # # If the resource was not found, you may want to alert the user or
2252
+ # # just return nil
2253
+ # puts "Resource Not Found"
2254
+ # end
2255
+ #
1279
2256
  def remove_subscription_change(subscription_id:)
1280
2257
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/change", site_id: site_id, subscription_id: subscription_id)
1281
2258
  delete(path)
@@ -1283,9 +2260,11 @@ module Recurly
1283
2260
 
1284
2261
  # List a subscription's invoices
1285
2262
  #
2263
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_subscription_invoices list_subscription_invoices api documenation}
2264
+ #
1286
2265
  # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1287
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
1288
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
2266
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
2267
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1289
2268
  #
1290
2269
  # *Important notes:*
1291
2270
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -1314,15 +2293,27 @@ module Recurly
1314
2293
  # - +type=legacy+, only legacy invoices will be returned.
1315
2294
  #
1316
2295
  # @return [Pager<Resources::Invoice>] A list of the subscription's invoices.
2296
+ # @example
2297
+ # invoices = @client.list_subscription_invoices(
2298
+ # subscription_id: subscription_id,
2299
+ # limit: 200
2300
+ # )
2301
+ # invoices.each do |invoice|
2302
+ # puts "Invoice: #{invoice.number}"
2303
+ # end
2304
+ #
1317
2305
  def list_subscription_invoices(subscription_id:, **options)
1318
2306
  path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/invoices", site_id: site_id, subscription_id: subscription_id)
1319
2307
  pager(path, **options)
1320
2308
  end
1321
2309
 
1322
- # List a site's transactions
2310
+ # List a subscription's line items
1323
2311
  #
1324
- # @param ids [String] Filter results by their IDs. Up to 200 IDs can be passed at once using
1325
- # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1+.
2312
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_subscription_line_items list_subscription_line_items api documenation}
2313
+ #
2314
+ # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
2315
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
2316
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1326
2317
  #
1327
2318
  # *Important notes:*
1328
2319
  # * The +ids+ parameter cannot be used with any other ordering or filtering
@@ -1344,9 +2335,101 @@ module Recurly
1344
2335
  # @param end_time [DateTime] Filter by end_time when +sort=created_at+ or +sort=updated_at+.
1345
2336
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
1346
2337
  #
2338
+ # @param original [String] Filter by original field.
2339
+ # @param state [String] Filter by state field.
1347
2340
  # @param type [String] Filter by type field.
2341
+ # @return [Pager<Resources::LineItem>] A list of the subscription's line items.
2342
+ # @example
2343
+ # line_items = @client.list_subscription_line_items(
2344
+ # subscription_id: subscription_id,
2345
+ # limit: 200
2346
+ # )
2347
+ # line_items.each do |line_item|
2348
+ # puts "LineItem: #{line_item.id}"
2349
+ # end
2350
+ #
2351
+ def list_subscription_line_items(subscription_id:, **options)
2352
+ path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/line_items", site_id: site_id, subscription_id: subscription_id)
2353
+ pager(path, **options)
2354
+ end
2355
+
2356
+ # Show the coupon redemptions for a subscription
2357
+ #
2358
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_subscription_coupon_redemptions list_subscription_coupon_redemptions api documenation}
2359
+ #
2360
+ # @param subscription_id [String] Subscription ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
2361
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
2362
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
2363
+ #
2364
+ # *Important notes:*
2365
+ # * The +ids+ parameter cannot be used with any other ordering or filtering
2366
+ # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
2367
+ # * Invalid or unknown IDs will be ignored, so you should check that the
2368
+ # results correspond to your request.
2369
+ # * Records are returned in an arbitrary order. Since results are all
2370
+ # returned at once you can sort the records yourself.
2371
+ #
2372
+ # @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
2373
+ # order. In descending order updated records will move behind the cursor and could
2374
+ # prevent some records from being returned.
2375
+ #
2376
+ # @param begin_time [DateTime] Filter by begin_time when +sort=created_at+ or +sort=updated_at+.
2377
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
2378
+ #
2379
+ # @param end_time [DateTime] Filter by end_time when +sort=created_at+ or +sort=updated_at+.
2380
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
2381
+ #
2382
+ # @return [Pager<Resources::CouponRedemption>] A list of the the coupon redemptions on a subscription.
2383
+ # @example
2384
+ # coupon_redemptions = @client.list_subscription_coupon_redemptions(
2385
+ # subscription_id: subscription_id,
2386
+ # limit: 200
2387
+ # )
2388
+ # coupon_redemptions.each do |redemption|
2389
+ # puts "CouponRedemption: #{redemption.id}"
2390
+ # end
2391
+ #
2392
+ def list_subscription_coupon_redemptions(subscription_id:, **options)
2393
+ path = interpolate_path("/sites/{site_id}/subscriptions/{subscription_id}/coupon_redemptions", site_id: site_id, subscription_id: subscription_id)
2394
+ pager(path, **options)
2395
+ end
2396
+
2397
+ # List a site's transactions
2398
+ #
2399
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/list_transactions list_transactions api documenation}
2400
+ #
2401
+ # @param ids [string] Filter results by their IDs. Up to 200 IDs can be passed at once using
2402
+ # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
2403
+ #
2404
+ # *Important notes:*
2405
+ # * The +ids+ parameter cannot be used with any other ordering or filtering
2406
+ # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
2407
+ # * Invalid or unknown IDs will be ignored, so you should check that the
2408
+ # results correspond to your request.
2409
+ # * Records are returned in an arbitrary order. Since results are all
2410
+ # returned at once you can sort the records yourself.
2411
+ #
2412
+ # @param limit [Integer] Limit number of records 1-200.
2413
+ # @param order [String] Sort order.
2414
+ # @param sort [String] Sort field. You *really* only want to sort by +updated_at+ in ascending
2415
+ # order. In descending order updated records will move behind the cursor and could
2416
+ # prevent some records from being returned.
2417
+ #
2418
+ # @param begin_time [DateTime] Filter by begin_time when +sort=created_at+ or +sort=updated_at+.
2419
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
2420
+ #
2421
+ # @param end_time [DateTime] Filter by end_time when +sort=created_at+ or +sort=updated_at+.
2422
+ # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
2423
+ #
2424
+ # @param type [String] Filter by type field. The value +payment+ will return both +purchase+ and +capture+ transactions.
1348
2425
  # @param success [String] Filter by success field.
1349
2426
  # @return [Pager<Resources::Transaction>] A list of the site's transactions.
2427
+ # @example
2428
+ # transactions = @client.list_transactions(limit: 200)
2429
+ # transactions.each do |transaction|
2430
+ # puts "Transaction: #{transaction.uuid}"
2431
+ # end
2432
+ #
1350
2433
  def list_transactions(**options)
1351
2434
  path = interpolate_path("/sites/{site_id}/transactions", site_id: site_id)
1352
2435
  pager(path, **options)
@@ -1354,8 +2437,20 @@ module Recurly
1354
2437
 
1355
2438
  # Fetch a transaction
1356
2439
  #
2440
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_transaction get_transaction api documenation}
2441
+ #
1357
2442
  # @param transaction_id [String] Transaction ID or UUID (use prefix: +uuid-+, e.g. +uuid-123457890+).
1358
2443
  # @return [Resources::Transaction] A transaction.
2444
+ # @example
2445
+ # begin
2446
+ # transaction = @client.get_transaction(transaction_id: transaction_id)
2447
+ # puts "Got Transaction #{transaction}"
2448
+ # rescue Recurly::Errors::NotFoundError
2449
+ # # If the resource was not found, you may want to alert the user or
2450
+ # # just return nil
2451
+ # puts "Resource Not Found"
2452
+ # end
2453
+ #
1359
2454
  def get_transaction(transaction_id:)
1360
2455
  path = interpolate_path("/sites/{site_id}/transactions/{transaction_id}", site_id: site_id, transaction_id: transaction_id)
1361
2456
  get(path)
@@ -1363,6 +2458,8 @@ module Recurly
1363
2458
 
1364
2459
  # Fetch a unique coupon code
1365
2460
  #
2461
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/get_unique_coupon_code get_unique_coupon_code api documenation}
2462
+ #
1366
2463
  # @param unique_coupon_code_id [String] Unique Coupon Code ID or code (use prefix: +code-+, e.g. +code-abc-8dh2-def+).
1367
2464
  # @return [Resources::UniqueCouponCode] A unique coupon code.
1368
2465
  def get_unique_coupon_code(unique_coupon_code_id:)
@@ -1372,6 +2469,8 @@ module Recurly
1372
2469
 
1373
2470
  # Deactivate a unique coupon code
1374
2471
  #
2472
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/deactivate_unique_coupon_code deactivate_unique_coupon_code api documenation}
2473
+ #
1375
2474
  # @param unique_coupon_code_id [String] Unique Coupon Code ID or code (use prefix: +code-+, e.g. +code-abc-8dh2-def+).
1376
2475
  # @return [Resources::UniqueCouponCode] A unique coupon code.
1377
2476
  def deactivate_unique_coupon_code(unique_coupon_code_id:)
@@ -1381,6 +2480,8 @@ module Recurly
1381
2480
 
1382
2481
  # Restore a unique coupon code
1383
2482
  #
2483
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/reactivate_unique_coupon_code reactivate_unique_coupon_code api documenation}
2484
+ #
1384
2485
  # @param unique_coupon_code_id [String] Unique Coupon Code ID or code (use prefix: +code-+, e.g. +code-abc-8dh2-def+).
1385
2486
  # @return [Resources::UniqueCouponCode] A unique coupon code.
1386
2487
  def reactivate_unique_coupon_code(unique_coupon_code_id:)