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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -6,13 +6,13 @@ module Recurly
6
6
  module Resources
7
7
  class User < Resource
8
8
 
9
- # @!attribute [r] created_at
9
+ # @!attribute created_at
10
10
  # @return [DateTime]
11
- define_attribute :created_at, DateTime, { :read_only => true }
11
+ define_attribute :created_at, DateTime
12
12
 
13
- # @!attribute [r] deleted_at
13
+ # @!attribute deleted_at
14
14
  # @return [DateTime]
15
- define_attribute :deleted_at, DateTime, { :read_only => true }
15
+ define_attribute :deleted_at, DateTime
16
16
 
17
17
  # @!attribute email
18
18
  # @return [String]
@@ -22,17 +22,17 @@ module Recurly
22
22
  # @return [String]
23
23
  define_attribute :first_name, String
24
24
 
25
- # @!attribute [r] id
25
+ # @!attribute id
26
26
  # @return [String]
27
- define_attribute :id, String, { :read_only => true }
27
+ define_attribute :id, String
28
28
 
29
29
  # @!attribute last_name
30
30
  # @return [String]
31
31
  define_attribute :last_name, String
32
32
 
33
- # @!attribute [r] object
33
+ # @!attribute object
34
34
  # @return [String] Object type
35
- define_attribute :object, String, { :read_only => true }
35
+ define_attribute :object, String
36
36
 
37
37
  # @!attribute time_zone
38
38
  # @return [String]
@@ -88,7 +88,7 @@ module Recurly
88
88
  # @return [String]
89
89
  attr_accessor :description
90
90
 
91
- def initialize(name, type, options={}, description=nil)
91
+ def initialize(name, type, options = {}, description = nil)
92
92
  @name = name
93
93
  @type = type
94
94
  @options = options
@@ -113,9 +113,8 @@ module Recurly
113
113
  private_constant :Attribute
114
114
  end
115
115
 
116
-
117
- require_relative './schema/schema_factory'
118
- require_relative './schema/schema_validator'
119
- require_relative './schema/json_deserializer'
120
- require_relative './schema/request_caster'
116
+ require_relative "./schema/schema_factory"
117
+ require_relative "./schema/schema_validator"
118
+ require_relative "./schema/json_deserializer"
119
+ require_relative "./schema/request_caster"
121
120
  end
@@ -1,4 +1,4 @@
1
- require 'date'
1
+ require "date"
2
2
 
3
3
  module Recurly
4
4
  class Schema
@@ -18,7 +18,7 @@ module Recurly
18
18
  def from_json(attributes = {})
19
19
  resource = new()
20
20
  attributes.each do |attr_name, val|
21
- next if attr_name == 'object'
21
+ next if attr_name == "object"
22
22
 
23
23
  schema_attr = self.schema.get_attribute(attr_name)
24
24
 
@@ -44,8 +44,9 @@ module Recurly
44
44
 
45
45
  resource.send(writer, val)
46
46
  else
47
- # TODO ignoring these missing fields for now
48
- puts "Missing #{attr_name}"
47
+ if Recurly::STRICT_MODE
48
+ raise ArgumentError, "#{resource.class.name} encountered json attribute #{attr_name.inspect}: #{val.inspect} but it's unknown to it's schema"
49
+ end
49
50
  end
50
51
  end
51
52
  resource
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require "json"
2
2
 
3
3
  module Recurly
4
4
  # This is a wrapper class to help parse responses into Recurly objects.
@@ -23,7 +23,7 @@ module Recurly
23
23
  type = if data.has_key?("error")
24
24
  "error"
25
25
  else
26
- data.delete('object')
26
+ data.delete("object")
27
27
  end
28
28
  klazz = self.recurly_class(type)
29
29
 
@@ -52,10 +52,10 @@ module Recurly
52
52
  case type
53
53
  when nil
54
54
  nil
55
- when 'list'
55
+ when "list"
56
56
  Pager
57
57
  else
58
- type_camelized = type.split('_').map(&:capitalize).join
58
+ type_camelized = type.split("_").map(&:capitalize).join
59
59
  if Resources.const_defined?(type_camelized)
60
60
  klazz = Resources.const_get(type_camelized)
61
61
  if klazz.ancestors.include?(Resource)
@@ -1,4 +1,4 @@
1
- require 'date'
1
+ require "date"
2
2
 
3
3
  module Recurly
4
4
  class Schema
@@ -25,13 +25,13 @@ module Recurly
25
25
  # @param data [Hash,Resource,Request] The data to transform into a JSON Hash.
26
26
  # @param schema [Schema] The schema to use to transform the data into a JSON Hash.
27
27
  # @return [Hash] The pure Hash ready to be serialized into JSON.
28
- def cast(data, schema=self.schema)
28
+ def cast(data, schema = self.schema)
29
29
  casted = {}
30
30
  if data.is_a?(Resource) || data.is_a?(Request)
31
31
  data = as_json(data, schema)
32
32
  end
33
33
 
34
- data.each do |k,v|
34
+ data.each do |k, v|
35
35
  schema_attr = schema.get_attribute(k)
36
36
  norm_val = if v.respond_to?(:attributes)
37
37
  cast(v, schema_attr.recurly_class.schema)
@@ -59,7 +59,7 @@ module Recurly
59
59
 
60
60
  def as_json(resource, schema)
61
61
  writeable_attributes = schema.attributes.reject(&:read_only?).map(&:name)
62
- resource.attributes.select { |k,_| writeable_attributes.include?(k) }
62
+ resource.attributes.select { |k, _| writeable_attributes.include?(k) }
63
63
  end
64
64
  end
65
65
  end
@@ -28,7 +28,7 @@ module Recurly
28
28
  # acount.code = "newcode" # this method protected since read_only = true
29
29
  # account.code
30
30
  # #=> "mycode"
31
- def define_attribute(name, type, options={})
31
+ def define_attribute(name, type, options = {})
32
32
  attribute = schema.add_attribute(name, type, options)
33
33
 
34
34
  # Define the reader
@@ -118,7 +118,7 @@ module Recurly
118
118
  while j < m
119
119
  cost = (char1 == str2_codepoints[j]) ? 0 : 1
120
120
  x = min3(
121
- d[j+1] + 1, # insertion
121
+ d[j + 1] + 1, # insertion
122
122
  i + 1, # deletion
123
123
  d[j] + cost # substitution
124
124
  )
@@ -145,4 +145,3 @@ module Recurly
145
145
  end
146
146
  end
147
147
  end
148
-
@@ -1,3 +1,3 @@
1
1
  module Recurly
2
- VERSION = "3.0.0.beta.4"
2
+ VERSION = "3.0.0.beta.5"
3
3
  end
@@ -1,20 +1,20 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'recurly/version'
4
+ require "recurly/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "recurly"
8
- spec.version = Recurly::VERSION
9
- spec.authors = ["Recurly"]
10
- spec.email = ["support@recurly.com"]
7
+ spec.name = "recurly"
8
+ spec.version = Recurly::VERSION
9
+ spec.authors = ["Recurly"]
10
+ spec.email = ["support@recurly.com"]
11
11
 
12
- spec.summary = "The ruby client for Recurly's Partner API"
13
- spec.description = "The ruby client for Recurly's Partner API"
14
- spec.homepage = "https://partner-docs.recurly.com"
15
- spec.license = "MIT"
12
+ spec.summary = "The ruby client for Recurly's Partner API"
13
+ spec.description = "The ruby client for Recurly's Partner API"
14
+ spec.homepage = "https://partner-docs.recurly.com"
15
+ spec.license = "MIT"
16
16
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
18
  f.match(%r{^(test|spec|features)/})
19
19
  end
20
20
  # spec.bindir = "exe"
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "yard", "~> 0.9"
31
31
  spec.add_development_dependency "pry", "~> 0.10"
32
32
  spec.add_development_dependency "simplecov", "~> 0.16"
33
+ spec.add_development_dependency "rufo", "~> 0.7"
33
34
  end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ if [ "$1" == "--check" ]; then
3
+ ./bin/rufo . --check
4
+ else
5
+ ./bin/rufo . -x
6
+ fi
@@ -1,3 +1,14 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- ./bin/rspec
3
+ # First check formatting
4
+ echo "Checking style..."
5
+ ./scripts/format --check
6
+ if [ $? -ne 0 ]; then
7
+ echo "Code does not conform to style guide. To autoformat, run './scripts/format'."
8
+ exit 1
9
+ else
10
+ echo "Style check passed"
11
+ fi
12
+
13
+ # Run tests
14
+ rake spec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recurly
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta.4
4
+ version: 3.0.0.beta.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Recurly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-04 00:00:00.000000000 Z
11
+ date: 2019-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -128,6 +128,20 @@ dependencies:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0.16'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rufo
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '0.7'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '0.7'
131
145
  description: The ruby client for Recurly's Partner API
132
146
  email:
133
147
  - support@recurly.com
@@ -156,6 +170,7 @@ files:
156
170
  - lib/recurly/requests/account_acquisition_cost.rb
157
171
  - lib/recurly/requests/account_acquisition_updatable.rb
158
172
  - lib/recurly/requests/account_create.rb
173
+ - lib/recurly/requests/account_purchase.rb
159
174
  - lib/recurly/requests/account_update.rb
160
175
  - lib/recurly/requests/add_on_create.rb
161
176
  - lib/recurly/requests/add_on_pricing.rb
@@ -178,12 +193,15 @@ files:
178
193
  - lib/recurly/requests/plan_hosted_pages.rb
179
194
  - lib/recurly/requests/plan_pricing.rb
180
195
  - lib/recurly/requests/plan_update.rb
196
+ - lib/recurly/requests/purchase_create.rb
181
197
  - lib/recurly/requests/shipping_address_create.rb
182
198
  - lib/recurly/requests/shipping_address_update.rb
183
199
  - lib/recurly/requests/subscription_add_on_create.rb
184
200
  - lib/recurly/requests/subscription_change_create.rb
185
201
  - lib/recurly/requests/subscription_create.rb
186
202
  - lib/recurly/requests/subscription_pause.rb
203
+ - lib/recurly/requests/subscription_purchase.rb
204
+ - lib/recurly/requests/subscription_shipping_purchase.rb
187
205
  - lib/recurly/requests/subscription_update.rb
188
206
  - lib/recurly/resource.rb
189
207
  - lib/recurly/resources/account.rb
@@ -244,9 +262,8 @@ files:
244
262
  - lib/recurly/version.rb
245
263
  - recurly.gemspec
246
264
  - scripts/build
247
- - scripts/check-deps
248
265
  - scripts/clean
249
- - scripts/install-deps
266
+ - scripts/format
250
267
  - scripts/test
251
268
  homepage: https://partner-docs.recurly.com
252
269
  licenses:
@@ -268,7 +285,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
285
  version: 1.3.1
269
286
  requirements: []
270
287
  rubyforge_project:
271
- rubygems_version: 2.6.14.1
288
+ rubygems_version: 2.6.14.3
272
289
  signing_key:
273
290
  specification_version: 4
274
291
  summary: The ruby client for Recurly's Partner API
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
-
4
- function check_for_command {
5
- if ! hash eval "$1" 2>/dev/null; then
6
- echo "✖ Could not find '$1'"
7
- exit 1
8
- fi
9
- echo "✓ Found $1"
10
- }
11
-
12
- check_for_command "ruby"
13
- check_for_command "bundle"
14
-
15
- RUBY_VERSION=$(ruby --version)
16
- RUBY_MAJOR=$(ruby --version | cut -d' ' -f2 | cut -d'.' -f1)
17
- RUBY_MINOR=$(ruby --version | cut -d' ' -f2 | cut -d'.' -f2)
18
-
19
- function unsupported_ruby_version {
20
- echo "✖ Unsupported ruby version is ${RUBY_VERSION}"
21
- exit 1
22
- }
23
-
24
- if [ "$RUBY_MAJOR" -lt "2" ] || [ "$RUBY_MINOR" -lt "3" ]; then
25
- unsupported_ruby_version
26
- else
27
- echo "✓ Version ${RUBY_VERSION} is compatible"
28
- fi
@@ -1,44 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
-
4
- if ! hash brew 2>/dev/null; then
5
- echo "✖ Homebrew not found. Please install: https://brew.sh/"
6
- exit 1
7
- else
8
- echo "✓ Found homebrew"
9
- fi
10
-
11
- if ! hash rbenv 2>/dev/null; then
12
- read -p "✖ 'rbenv' not found. Would you like to install it? [Y/n] " -n 1 -r
13
- echo
14
- if [[ $REPLY =~ ^[Yy\n]$ ]]
15
- then
16
- brew install rbenv ruby-build && true
17
- echo
18
- echo "Please follow the rbenv instructions below before continuing:"
19
- eval "$(rbenv init -)"
20
- echo $(rbenv init)
21
- read -p "Press enter to continue"
22
- # Installs latest stable version
23
- VERSION=$(rbenv install -l | grep -v - | tail -1)
24
- rbenv install $VERSION
25
- rbenv global $VERSION
26
- else
27
- exit 1
28
- fi
29
- else
30
- echo "✓ Found rbenv"
31
- fi
32
-
33
- if ! hash bundle 2>/dev/null; then
34
- read -p "✖ 'bundle' not found. Would you like to install it? [Y/n] " -n 1 -r
35
- echo
36
- if [[ $REPLY =~ ^[Yy]$ ]]
37
- then
38
- gem install bundler
39
- else
40
- exit 1
41
- fi
42
- else
43
- echo "✓ Found bundle"
44
- fi