recurly 3.0.0.beta.4 → 3.0.0.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +3 -1
  4. data/Gemfile +1 -1
  5. data/README.md +1 -1
  6. data/lib/recurly.rb +6 -2
  7. data/lib/recurly/client.rb +31 -26
  8. data/lib/recurly/client/adapter.rb +4 -2
  9. data/lib/recurly/client/operations.rb +118 -8
  10. data/lib/recurly/errors.rb +1 -1
  11. data/lib/recurly/pager.rb +3 -3
  12. data/lib/recurly/requests/account_acquisition_updatable.rb +1 -1
  13. data/lib/recurly/requests/account_create.rb +2 -2
  14. data/lib/recurly/requests/account_purchase.rb +86 -0
  15. data/lib/recurly/requests/account_update.rb +2 -2
  16. data/lib/recurly/requests/add_on_create.rb +3 -3
  17. data/lib/recurly/requests/add_on_update.rb +3 -3
  18. data/lib/recurly/requests/coupon_create.rb +6 -6
  19. data/lib/recurly/requests/external_refund.rb +1 -1
  20. data/lib/recurly/requests/invoice_create.rb +2 -2
  21. data/lib/recurly/requests/invoice_refund.rb +2 -2
  22. data/lib/recurly/requests/line_item_create.rb +3 -3
  23. data/lib/recurly/requests/plan_create.rb +3 -3
  24. data/lib/recurly/requests/plan_update.rb +4 -4
  25. data/lib/recurly/requests/purchase_create.rb +74 -0
  26. data/lib/recurly/requests/shipping_address_update.rb +2 -2
  27. data/lib/recurly/requests/subscription_change_create.rb +2 -2
  28. data/lib/recurly/requests/subscription_create.rb +1 -1
  29. data/lib/recurly/requests/subscription_purchase.rb +58 -0
  30. data/lib/recurly/requests/subscription_shipping_purchase.rb +22 -0
  31. data/lib/recurly/requests/subscription_update.rb +2 -2
  32. data/lib/recurly/resources/account.rb +18 -18
  33. data/lib/recurly/resources/account_acquisition.rb +9 -9
  34. data/lib/recurly/resources/account_balance.rb +2 -2
  35. data/lib/recurly/resources/account_mini.rb +4 -4
  36. data/lib/recurly/resources/account_note.rb +6 -6
  37. data/lib/recurly/resources/add_on.rb +15 -15
  38. data/lib/recurly/resources/add_on_mini.rb +4 -4
  39. data/lib/recurly/resources/billing_info.rb +16 -16
  40. data/lib/recurly/resources/billing_info_payment_method.rb +1 -1
  41. data/lib/recurly/resources/coupon.rb +16 -16
  42. data/lib/recurly/resources/coupon_discount.rb +1 -1
  43. data/lib/recurly/resources/coupon_discount_trial.rb +1 -1
  44. data/lib/recurly/resources/coupon_mini.rb +6 -6
  45. data/lib/recurly/resources/coupon_redemption.rb +12 -12
  46. data/lib/recurly/resources/coupon_redemption_mini.rb +7 -7
  47. data/lib/recurly/resources/credit_payment.rb +7 -7
  48. data/lib/recurly/resources/custom_field_definition.rb +12 -12
  49. data/lib/recurly/resources/error.rb +1 -1
  50. data/lib/recurly/resources/error_may_have_transaction.rb +1 -1
  51. data/lib/recurly/resources/fraud_info.rb +1 -1
  52. data/lib/recurly/resources/invoice.rb +12 -12
  53. data/lib/recurly/resources/invoice_mini.rb +2 -2
  54. data/lib/recurly/resources/line_item.rb +6 -6
  55. data/lib/recurly/resources/plan.rb +15 -15
  56. data/lib/recurly/resources/plan_mini.rb +4 -4
  57. data/lib/recurly/resources/settings.rb +6 -6
  58. data/lib/recurly/resources/shipping_address.rb +8 -8
  59. data/lib/recurly/resources/site.rb +16 -16
  60. data/lib/recurly/resources/subscription.rb +2 -2
  61. data/lib/recurly/resources/subscription_change.rb +8 -8
  62. data/lib/recurly/resources/transaction.rb +8 -8
  63. data/lib/recurly/resources/transaction_payment_method.rb +2 -2
  64. data/lib/recurly/resources/unique_coupon_code.rb +11 -11
  65. data/lib/recurly/resources/user.rb +8 -8
  66. data/lib/recurly/schema.rb +5 -6
  67. data/lib/recurly/schema/json_deserializer.rb +5 -4
  68. data/lib/recurly/schema/json_parser.rb +4 -4
  69. data/lib/recurly/schema/request_caster.rb +4 -4
  70. data/lib/recurly/schema/schema_factory.rb +1 -1
  71. data/lib/recurly/schema/schema_validator.rb +1 -2
  72. data/lib/recurly/version.rb +1 -1
  73. data/recurly.gemspec +12 -11
  74. data/scripts/format +6 -0
  75. data/scripts/test +12 -1
  76. metadata +22 -5
  77. data/scripts/check-deps +0 -28
  78. data/scripts/install-deps +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa84948d98ac3695fb2639905b05c1ae0ff8ee70
4
- data.tar.gz: 36229c9d3cd0e548e1b8845d98453e07b4fc07a8
3
+ metadata.gz: 3a83d4657995fd0ff223c206cec0f070cd2444d6
4
+ data.tar.gz: 30cd8091362db149ca7c6b58eda4bc0e28909362
5
5
  SHA512:
6
- metadata.gz: 6794cb420246f6407362fa23c1e0c5621df35703fa210f97b4090e0226e56b2e68f8040a654a943909f802c89c7b37246de363bc297bbd8b0af6266de7cf7fe3
7
- data.tar.gz: cc7fb401cd2ef58e1444137bb0e881e71afac83135ca18c1012aa8aef0c3f2c2016760382873f3384f1e8f268b61aa3e73313280e7e5248e132b9157ed2936ab
6
+ metadata.gz: f4e1d7f40eddeec2548d7725b00a23753ce9c89101395a15bb33039ff8e4fc76366c6fab7d77739ba78a3d8ae5106bc42e0a86cd55b6f6b58d9ef8a0cbbcac3e
7
+ data.tar.gz: 7a009fc1f8447ae303d17cf4040fbb3b7e0ccbf391814479a9003342a06e059febbe4d8fe243c082a74a7c63da7afb57a5ad73b6d03cb067174b63dff2f2319e
@@ -1 +1 @@
1
- 2.4.4
1
+ 2.4.5
@@ -1,10 +1,12 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3
5
4
  - 2.4
6
5
  - 2.5
7
6
  - 2.6
7
+ bundler_args: --binstubs
8
8
  before_install:
9
9
  - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
10
10
  - gem install bundler -v '< 2'
11
+ script:
12
+ - ./scripts/test
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in recurly.gemspec
4
4
  gemspec
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.4'
18
+ gem 'recurly', '3.0.0.beta.5'
19
19
  ```
20
20
 
21
21
  It's important that you lock on a specific version as there may be breaking changes between releases.
@@ -4,13 +4,17 @@ require "recurly/request"
4
4
  require "recurly/resource"
5
5
  require "recurly/pager"
6
6
  # Include all request files
7
- resources = File.join(File.dirname(__FILE__), 'recurly', 'requests', '*.rb')
7
+ resources = File.join(File.dirname(__FILE__), "recurly", "requests", "*.rb")
8
8
  Dir.glob(resources, &method(:require))
9
9
  # Include all resource files
10
- resources = File.join(File.dirname(__FILE__), 'recurly', 'resources', '*.rb')
10
+ resources = File.join(File.dirname(__FILE__), "recurly", "resources", "*.rb")
11
11
  Dir.glob(resources, &method(:require))
12
12
  require "recurly/errors"
13
13
  require "recurly/client"
14
14
 
15
15
  module Recurly
16
+ STRICT_MODE = !ENV["RECURLY_STRICT_MODE"].nil?
17
+ if STRICT_MODE
18
+ puts "[Recurly] [WARNING] STRICT_MODE enabled. This should only be used for testing purposes."
19
+ end
16
20
  end
@@ -1,11 +1,12 @@
1
- require 'faraday'
2
- require 'logger'
3
- require_relative './schema/json_parser'
4
- require_relative './client/adapter'
1
+ require "faraday"
2
+ require "logger"
3
+ require "erb"
4
+ require_relative "./schema/json_parser"
5
+ require_relative "./client/adapter"
5
6
 
6
7
  module Recurly
7
8
  class Client
8
- require_relative './client/operations'
9
+ require_relative "./client/operations"
9
10
 
10
11
  BASE_URL = "https://partner-api.recurly.com/"
11
12
 
@@ -94,15 +95,15 @@ module Recurly
94
95
  raise_network_error!(ex)
95
96
  end
96
97
 
97
- def put(path, request_data=nil, request_class=nil, **options)
98
+ def put(path, request_data = nil, request_class = nil, **options)
98
99
  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
100
+ request = request_class.new(request_data)
101
+ request.validate!
102
+ logger.info("PUT BODY #{JSON.dump(request_data)}")
103
+ run_request(:put, path, JSON.dump(request_data), headers)
104
+ else
105
+ run_request(:put, path, nil, headers)
106
+ end
106
107
  raise_api_error!(response) unless (200...300).include?(response.status)
107
108
  JSONParser.parse(self, response.body)
108
109
  rescue Faraday::ClientError => ex
@@ -138,7 +139,7 @@ module Recurly
138
139
  when Faraday::TimeoutError
139
140
  Errors::TimeoutError
140
141
  when Faraday::ConnectionFailed
141
- Errors::ConnectionFailed
142
+ Errors::ConnectionFailedError
142
143
  when Faraday::SSLError
143
144
  Errors::SSLError
144
145
  else
@@ -155,25 +156,27 @@ module Recurly
155
156
  end
156
157
 
157
158
  def read_headers(response)
158
- @rate_limit = response.headers['x-ratelimit-limit'].to_i
159
- @rate_limit_remaining = response.headers['x-ratelimit-remaining'].to_i
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']}"
159
+ @rate_limit = response.headers["x-ratelimit-limit"].to_i
160
+ @rate_limit_remaining = response.headers["x-ratelimit-remaining"].to_i
161
+ @rate_limit_reset = Time.at(response.headers["x-ratelimit-reset"].to_i).to_datetime
162
+ if !@_ignore_deprecation_warning && response.headers["Recurly-Deprecated"]&.upcase == "TRUE"
163
+ puts "[recurly-client-ruby] WARNING: Your current API version \"#{api_version}\" is deprecated and will be sunset on #{response.headers["Recurly-Sunset-Date"]}"
163
164
  end
164
165
  response
165
166
  end
166
167
 
167
168
  def headers
168
169
  {
169
- 'Accept' => "application/vnd.recurly.#{api_version}", # got this method from operations.rb
170
- 'Content-Type' => 'application/json',
171
- 'User-Agent' => "Recurly/#{VERSION}; #{RUBY_DESCRIPTION}"
170
+ "Accept" => "application/vnd.recurly.#{api_version}", # got this method from operations.rb
171
+ "Content-Type" => "application/json",
172
+ "User-Agent" => "Recurly/#{VERSION}; #{RUBY_DESCRIPTION}",
172
173
  }.merge(@extra_headers)
173
174
  end
174
175
 
175
176
  def interpolate_path(path, **options)
176
177
  options.each do |k, v|
178
+ # Check to see that we are passing the correct data types
179
+ # This prevents a confusing error if the user passes in a non-primitive by mistake
177
180
  unless [String, Symbol, Integer, Float].include?(v.class)
178
181
  message = "We cannot build the url with the given argument #{k}=#{v.inspect}."
179
182
  if k =~ /_id$/
@@ -181,6 +184,8 @@ module Recurly
181
184
  end
182
185
  raise ArgumentError, message
183
186
  end
187
+ # We need to encode the values for the url
188
+ options[k] = ERB::Util.url_encode(v.to_s)
184
189
  end
185
190
  path = path.gsub("{", "%{")
186
191
  path % options
@@ -200,19 +205,19 @@ module Recurly
200
205
  options = {
201
206
  url: BASE_URL,
202
207
  request: { timeout: 60, open_timeout: 50 },
203
- ssl: { verify: true }
208
+ ssl: { verify: true },
204
209
  }
205
210
  # Let's not use the bundled cert in production yet
206
211
  # 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')
212
+ unless BASE_URL.end_with?(".recurly.com")
213
+ options[:ssl][:ca_file] = File.join(File.dirname(__FILE__), "../data/ca-certificates.crt")
209
214
  end
210
215
 
211
216
  @conn = Faraday.new(options) do |faraday|
212
217
  if [Logger::DEBUG, Logger::INFO].include?(@log_level)
213
218
  faraday.response :logger
214
219
  end
215
- faraday.basic_auth(api_key, '')
220
+ faraday.basic_auth(api_key, "")
216
221
  configure_net_adapter(faraday)
217
222
  end
218
223
  end
@@ -1,9 +1,10 @@
1
- require 'openssl'
1
+ require "openssl"
2
2
 
3
3
  module Recurly
4
4
  class Client
5
5
  module NetHttpPersistentAdapter
6
6
  protected
7
+
7
8
  def configure_net_adapter(faraday)
8
9
  faraday.adapter :net_http_persistent do |http|
9
10
  # yields Net::HTTP::Persistent
@@ -19,6 +20,7 @@ module Recurly
19
20
 
20
21
  module NetHttpAdapter
21
22
  protected
23
+
22
24
  def configure_net_adapter(faraday)
23
25
  faraday.adapter :net_http do |http|
24
26
  # yields Net::HTTP
@@ -29,7 +31,7 @@ module Recurly
29
31
  include NetHttpAdapter
30
32
 
31
33
  begin
32
- require 'net/http/persistent'
34
+ require "net/http/persistent"
33
35
  include NetHttpPersistentAdapter
34
36
  rescue LoadError
35
37
  end
@@ -16,6 +16,7 @@ module Recurly
16
16
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
17
17
  #
18
18
  # *Important notes:*
19
+ #
19
20
  # * The +ids+ parameter cannot be used with any other ordering or filtering
20
21
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
21
22
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -59,6 +60,7 @@ module Recurly
59
60
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
60
61
  #
61
62
  # *Important notes:*
63
+ #
62
64
  # * The +ids+ parameter cannot be used with any other ordering or filtering
63
65
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
64
66
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -386,6 +388,7 @@ module Recurly
386
388
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
387
389
  #
388
390
  # *Important notes:*
391
+ #
389
392
  # * The +ids+ parameter cannot be used with any other ordering or filtering
390
393
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
391
394
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -530,6 +533,7 @@ module Recurly
530
533
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
531
534
  #
532
535
  # *Important notes:*
536
+ #
533
537
  # * The +ids+ parameter cannot be used with any other ordering or filtering
534
538
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
535
539
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -637,6 +641,7 @@ module Recurly
637
641
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
638
642
  #
639
643
  # *Important notes:*
644
+ #
640
645
  # * The +ids+ parameter cannot be used with any other ordering or filtering
641
646
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
642
647
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -713,6 +718,7 @@ module Recurly
713
718
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
714
719
  #
715
720
  # *Important notes:*
721
+ #
716
722
  # * The +ids+ parameter cannot be used with any other ordering or filtering
717
723
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
718
724
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -766,6 +772,7 @@ module Recurly
766
772
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
767
773
  #
768
774
  # *Important notes:*
775
+ #
769
776
  # * The +ids+ parameter cannot be used with any other ordering or filtering
770
777
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
771
778
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -902,6 +909,7 @@ module Recurly
902
909
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
903
910
  #
904
911
  # *Important notes:*
912
+ #
905
913
  # * The +ids+ parameter cannot be used with any other ordering or filtering
906
914
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
907
915
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -922,6 +930,7 @@ module Recurly
922
930
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
923
931
  #
924
932
  # @param state [String] Filter by state.
933
+ #
925
934
  # - When +state=active+, +state=canceled+, +state=expired+, or +state=future+, subscriptions with states that match the query and only those subscriptions will be returned.
926
935
  # - When +state=in_trial+, only subscriptions that have a trial_started_at date earlier than now and a trial_ends_at date later than now will be returned.
927
936
  # - When +state=live+, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.
@@ -950,6 +959,7 @@ module Recurly
950
959
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
951
960
  #
952
961
  # *Important notes:*
962
+ #
953
963
  # * The +ids+ parameter cannot be used with any other ordering or filtering
954
964
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
955
965
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -995,6 +1005,7 @@ module Recurly
995
1005
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
996
1006
  #
997
1007
  # *Important notes:*
1008
+ #
998
1009
  # * The +ids+ parameter cannot be used with any other ordering or filtering
999
1010
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1000
1011
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1020,13 +1031,13 @@ module Recurly
1020
1031
  # @param past_due [String] Filter for accounts with an invoice in the +past_due+ state.
1021
1032
  # @return [Pager<Resources::Account>] A list of an account's child accounts.
1022
1033
  # @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
1034
+ # child_accounts = @client.list_child_accounts(
1035
+ # account_id: account_id,
1036
+ # limit: 200
1037
+ # )
1038
+ # child_accounts.each do |child|
1039
+ # puts "Account: #{child.code}"
1040
+ # end
1030
1041
  #
1031
1042
  def list_child_accounts(account_id:, **options)
1032
1043
  path = interpolate_path("/sites/{site_id}/accounts/{account_id}/accounts", site_id: site_id, account_id: account_id)
@@ -1041,6 +1052,7 @@ module Recurly
1041
1052
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1042
1053
  #
1043
1054
  # *Important notes:*
1055
+ #
1044
1056
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1045
1057
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1046
1058
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1080,6 +1092,7 @@ module Recurly
1080
1092
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1081
1093
  #
1082
1094
  # *Important notes:*
1095
+ #
1083
1096
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1084
1097
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1085
1098
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1187,6 +1200,7 @@ module Recurly
1187
1200
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1188
1201
  #
1189
1202
  # *Important notes:*
1203
+ #
1190
1204
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1191
1205
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1192
1206
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1259,6 +1273,7 @@ module Recurly
1259
1273
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1260
1274
  #
1261
1275
  # *Important notes:*
1276
+ #
1262
1277
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1263
1278
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1264
1279
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1279,6 +1294,12 @@ module Recurly
1279
1294
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
1280
1295
  #
1281
1296
  # @return [Pager<Resources::CustomFieldDefinition>] A list of the site's custom field definitions.
1297
+ # @example
1298
+ # custom_fields = @client.list_custom_field_definitions(limit: 200)
1299
+ # custom_fields.each do |field|
1300
+ # puts "CustomFieldDefinition: #{field.name}"
1301
+ # end
1302
+ #
1282
1303
  def list_custom_field_definitions(**options)
1283
1304
  path = interpolate_path("/sites/{site_id}/custom_field_definitions", site_id: site_id)
1284
1305
  pager(path, **options)
@@ -1303,6 +1324,7 @@ module Recurly
1303
1324
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1304
1325
  #
1305
1326
  # *Important notes:*
1327
+ #
1306
1328
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1307
1329
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1308
1330
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1457,7 +1479,7 @@ module Recurly
1457
1479
  put(path)
1458
1480
  end
1459
1481
 
1460
- # List a invoice's line items
1482
+ # List an invoice's line items
1461
1483
  #
1462
1484
  # {https://partner-docs.recurly.com/v2018-08-09#operation/list_invoice_line_items list_invoice_line_items api documenation}
1463
1485
  #
@@ -1466,6 +1488,7 @@ module Recurly
1466
1488
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1467
1489
  #
1468
1490
  # *Important notes:*
1491
+ #
1469
1492
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1470
1493
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1471
1494
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1503,6 +1526,7 @@ module Recurly
1503
1526
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1504
1527
  #
1505
1528
  # *Important notes:*
1529
+ #
1506
1530
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1507
1531
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1508
1532
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1583,6 +1607,7 @@ module Recurly
1583
1607
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1584
1608
  #
1585
1609
  # *Important notes:*
1610
+ #
1586
1611
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1587
1612
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1588
1613
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1662,6 +1687,7 @@ module Recurly
1662
1687
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1663
1688
  #
1664
1689
  # *Important notes:*
1690
+ #
1665
1691
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1666
1692
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1667
1693
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1785,6 +1811,7 @@ module Recurly
1785
1811
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1786
1812
  #
1787
1813
  # *Important notes:*
1814
+ #
1788
1815
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1789
1816
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1790
1817
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1889,6 +1916,7 @@ module Recurly
1889
1916
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1890
1917
  #
1891
1918
  # *Important notes:*
1919
+ #
1892
1920
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1893
1921
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1894
1922
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1934,6 +1962,7 @@ module Recurly
1934
1962
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
1935
1963
  #
1936
1964
  # *Important notes:*
1965
+ #
1937
1966
  # * The +ids+ parameter cannot be used with any other ordering or filtering
1938
1967
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
1939
1968
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -1954,6 +1983,7 @@ module Recurly
1954
1983
  # *Note:* this value is an ISO8601 timestamp. A partial timestamp that does not include a time zone will default to UTC.
1955
1984
  #
1956
1985
  # @param state [String] Filter by state.
1986
+ #
1957
1987
  # - When +state=active+, +state=canceled+, +state=expired+, or +state=future+, subscriptions with states that match the query and only those subscriptions will be returned.
1958
1988
  # - When +state=in_trial+, only subscriptions that have a trial_started_at date earlier than now and a trial_ends_at date later than now will be returned.
1959
1989
  # - When +state=live+, only subscriptions that are in an active, canceled, or future state or are in trial will be returned.
@@ -2267,6 +2297,7 @@ module Recurly
2267
2297
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
2268
2298
  #
2269
2299
  # *Important notes:*
2300
+ #
2270
2301
  # * The +ids+ parameter cannot be used with any other ordering or filtering
2271
2302
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
2272
2303
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -2316,6 +2347,7 @@ module Recurly
2316
2347
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
2317
2348
  #
2318
2349
  # *Important notes:*
2350
+ #
2319
2351
  # * The +ids+ parameter cannot be used with any other ordering or filtering
2320
2352
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
2321
2353
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -2362,6 +2394,7 @@ module Recurly
2362
2394
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
2363
2395
  #
2364
2396
  # *Important notes:*
2397
+ #
2365
2398
  # * The +ids+ parameter cannot be used with any other ordering or filtering
2366
2399
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
2367
2400
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -2402,6 +2435,7 @@ module Recurly
2402
2435
  # commas as separators, e.g. +ids=h1at4d57xlmy,gyqgg0d3v9n1,jrsm5b4yefg6+.
2403
2436
  #
2404
2437
  # *Important notes:*
2438
+ #
2405
2439
  # * The +ids+ parameter cannot be used with any other ordering or filtering
2406
2440
  # parameters (+limit+, +order+, +sort+, +begin_time+, +end_time+, etc)
2407
2441
  # * Invalid or unknown IDs will be ignored, so you should check that the
@@ -2488,5 +2522,81 @@ module Recurly
2488
2522
  path = interpolate_path("/sites/{site_id}/unique_coupon_codes/{unique_coupon_code_id}/restore", site_id: site_id, unique_coupon_code_id: unique_coupon_code_id)
2489
2523
  put(path)
2490
2524
  end
2525
+
2526
+ # Create a new purchase
2527
+ #
2528
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/create_purchase create_purchase api documenation}
2529
+ #
2530
+ # @param body [Requests::PurchaseCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PurchaseCreate}
2531
+ # @return [Resources::InvoiceCollection] Returns the new invoices
2532
+ # @example
2533
+ # begin
2534
+ # purchase = {
2535
+ # currency: "USD",
2536
+ # account: {
2537
+ # code: account_code,
2538
+ # first_name: "Benjamin",
2539
+ # last_name: "Du Monde",
2540
+ # billing_info: {
2541
+ # token_id: rjs_token_id
2542
+ # },
2543
+ # },
2544
+ # subscriptions: [
2545
+ # { plan_code: plan_code }
2546
+ # ]
2547
+ # }
2548
+ # invoice_collection = @client.create_purchase(
2549
+ # body: purchase
2550
+ # )
2551
+ # puts "Created Charge Invoice #{invoice_collection.charge_invoice}"
2552
+ # puts "Created Credit Invoices #{invoice_collection.credit_invoices}"
2553
+ # rescue Recurly::Errors::ValidationError => e
2554
+ # # If the request was invalid, you may want to tell your user
2555
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
2556
+ # puts "ValidationError: #{e.recurly_error.params}"
2557
+ # end
2558
+ #
2559
+ def create_purchase(body:)
2560
+ path = interpolate_path("/sites/{site_id}/purchases", site_id: site_id)
2561
+ post(path, body, Requests::PurchaseCreate)
2562
+ end
2563
+
2564
+ # Preview a new purchase
2565
+ #
2566
+ # {https://partner-docs.recurly.com/v2018-08-09#operation/preview_purchase preview_purchase api documenation}
2567
+ #
2568
+ # @param body [Requests::PurchaseCreate] The Hash representing the JSON request to send to the server. It should conform to the schema of {Requests::PurchaseCreate}
2569
+ # @return [Resources::InvoiceCollection] Returns preview of the new invoices
2570
+ # @example
2571
+ # begin
2572
+ # purchase = {
2573
+ # currency: "USD",
2574
+ # account: {
2575
+ # code: account_code,
2576
+ # first_name: "Benjamin",
2577
+ # last_name: "Du Monde",
2578
+ # billing_info: {
2579
+ # token_id: rjs_token_id
2580
+ # },
2581
+ # },
2582
+ # subscriptions: [
2583
+ # { plan_code: plan_code }
2584
+ # ]
2585
+ # }
2586
+ # invoice_collection = @client.preview_purchase(
2587
+ # body: purchase
2588
+ # )
2589
+ # puts "Preview Charge Invoice #{invoice_collection.charge_invoice}"
2590
+ # puts "Preview Credit Invoices #{invoice_collection.credit_invoices}"
2591
+ # rescue Recurly::Errors::ValidationError => e
2592
+ # # If the request was invalid, you may want to tell your user
2593
+ # # why. You can find the invalid params and reasons in e.recurly_error.params
2594
+ # puts "ValidationError: #{e.recurly_error.params}"
2595
+ # end
2596
+ #
2597
+ def preview_purchase(body:)
2598
+ path = interpolate_path("/sites/{site_id}/purchases/preview", site_id: site_id)
2599
+ post(path, body, Requests::PurchaseCreate)
2600
+ end
2491
2601
  end
2492
2602
  end