patch_ruby 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +18 -2
  5. data/lib/patch_ruby/models/allocation.rb +10 -0
  6. data/lib/patch_ruby/models/create_mass_estimate_request.rb +7 -0
  7. data/lib/patch_ruby/models/create_order_request.rb +7 -0
  8. data/lib/patch_ruby/models/create_preference_request.rb +7 -0
  9. data/lib/patch_ruby/models/error_response.rb +9 -0
  10. data/lib/patch_ruby/models/estimate.rb +14 -1
  11. data/lib/patch_ruby/models/estimate_list_response.rb +9 -0
  12. data/lib/patch_ruby/models/estimate_response.rb +9 -0
  13. data/lib/patch_ruby/models/meta_index_object.rb +11 -0
  14. data/lib/patch_ruby/models/order.rb +20 -0
  15. data/lib/patch_ruby/models/order_list_response.rb +9 -0
  16. data/lib/patch_ruby/models/order_response.rb +9 -0
  17. data/lib/patch_ruby/models/photo.rb +21 -4
  18. data/lib/patch_ruby/models/preference.rb +10 -0
  19. data/lib/patch_ruby/models/preference_list_response.rb +9 -0
  20. data/lib/patch_ruby/models/preference_response.rb +9 -0
  21. data/lib/patch_ruby/models/project.rb +22 -0
  22. data/lib/patch_ruby/models/project_list_response.rb +9 -0
  23. data/lib/patch_ruby/models/project_response.rb +9 -0
  24. data/lib/patch_ruby/models/standard.rb +10 -0
  25. data/lib/patch_ruby/version.rb +1 -1
  26. data/spec/factories/allocations.rb +7 -0
  27. data/spec/factories/create_mass_estimate_requests.rb +6 -0
  28. data/spec/factories/create_order_requests.rb +8 -0
  29. data/spec/factories/create_preference_requests.rb +5 -0
  30. data/spec/factories/error_responses.rb +7 -0
  31. data/spec/factories/estimate_list_responses.rb +8 -0
  32. data/spec/factories/estimate_responses.rb +7 -0
  33. data/spec/factories/estimates.rb +8 -0
  34. data/spec/factories/meta_index_objects.rb +6 -0
  35. data/spec/factories/order_list_responses.rb +8 -0
  36. data/spec/factories/order_responses.rb +7 -0
  37. data/spec/factories/orders.rb +12 -0
  38. data/spec/factories/preference_list_responses.rb +8 -0
  39. data/spec/factories/preference_responses.rb +7 -0
  40. data/spec/factories/preferences.rb +7 -0
  41. data/spec/factories/project_list_responses.rb +8 -0
  42. data/spec/factories/project_responses.rb +7 -0
  43. data/spec/factories/projects.rb +15 -0
  44. data/spec/integration/estimates_spec.rb +0 -11
  45. data/spec/integration/orders_spec.rb +1 -1
  46. data/spec/models/allocation_spec.rb +8 -1
  47. data/spec/models/create_mass_estimate_request_spec.rb +7 -1
  48. data/spec/models/create_order_request_spec.rb +7 -1
  49. data/spec/models/create_preference_request_spec.rb +8 -1
  50. data/spec/models/error_response_spec.rb +7 -1
  51. data/spec/models/estimate_list_response_spec.rb +7 -1
  52. data/spec/models/estimate_response_spec.rb +7 -1
  53. data/spec/models/estimate_spec.rb +8 -1
  54. data/spec/models/meta_index_object_spec.rb +7 -1
  55. data/spec/models/order_list_response_spec.rb +7 -1
  56. data/spec/models/order_response_spec.rb +7 -1
  57. data/spec/models/order_spec.rb +18 -1
  58. data/spec/models/preference_list_response_spec.rb +7 -1
  59. data/spec/models/preference_response_spec.rb +7 -1
  60. data/spec/models/preference_spec.rb +7 -1
  61. data/spec/models/project_list_response_spec.rb +7 -1
  62. data/spec/models/project_response_spec.rb +7 -1
  63. data/spec/models/project_spec.rb +21 -1
  64. data/spec/spec_helper.rb +10 -0
  65. data/spec/support/shared/generated_classes.rb +13 -0
  66. metadata +57 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cc157169de2e66eca8ad5c41897f0345f9bd9286bf8ee62ab6c1040a327d3ff
4
- data.tar.gz: 5960f6ea41e96264a1293c6b40531817afcd810dd9e5a36988750d94a042c34b
3
+ metadata.gz: 034d244a5779a4ba17a6cdd074f0099905f190ac25fa274b8efc37757b5f6cfc
4
+ data.tar.gz: acc6a37eb68e11f88e5092ffe666f962d14798d317761e55bf9777707615fb41
5
5
  SHA512:
6
- metadata.gz: 7053e90b8e96ab75c3c3563146adb3cafa62c370e8c6bf429c7c0ff5e8d90f5020603d4ffb90b63847fd8821e47f5c47ccff1eace9f02734aa40e9053421597f
7
- data.tar.gz: 589fd1ec70c6ac629bc77d4249d82b0b17205d465909990f8c86992792a661ca972cfa32e666e0a1807c1dff94807d13b9e7c2c293e2becf15bf006a54a2f5af
6
+ metadata.gz: c371f8237161ec6fd8be9ddd5e269dc73168718016a5dbc3d3e8a2dca62df9c334171eec45ba8645451c4ee1933b1089844e42fc1002569f43671bac9b01f849
7
+ data.tar.gz: 8d8c39a9380511af517ad1057da04f1e69997f994cded647d41c4adfe016ec65ac5a5ce73ccac1b5323ae91cf56a88de94736dab8b44d19336cd80a94d276331
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.5] - 2020-01-08
11
+
12
+ ### Fixed
13
+
14
+ - Fixes [issues/5](https://github.com/patch-technology/patch-ruby/issues/5). Adds method `.openapi_nullable` which returns a set with all nullable properties. This method is referenced in `#to_hash` which returns a hash representation of the resource.
15
+ - Removes non-deterministic integration spec that is creating an Estimate with a specific project-id. Since we do not control the test data (yet) and make queries against our Test projects, we cannot be sure that we will have offsets available for a project ID. Instead we can rely on Patch core specs to cover this.
16
+ - Fixes a spec that was failing due to a Patch core change.
17
+ - Add spec factories and refactor generated method specs to shared examples.
18
+
10
19
  ## [1.2.4] - 2020-10-14
11
20
 
12
21
  ### Added
data/Gemfile CHANGED
@@ -6,4 +6,5 @@ group :development, :test do
6
6
  gem 'rake', '~> 13.0.1'
7
7
  gem 'pry-byebug'
8
8
  gem 'rubocop'
9
+ gem 'factory_bot'
9
10
  end
@@ -1,22 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- patch_ruby (1.2.4)
4
+ patch_ruby (1.2.5)
5
5
  json (~> 2.1, >= 2.1.0)
6
6
  typhoeus (~> 1.0, >= 1.0.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
+ activesupport (6.1.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ zeitwerk (~> 2.3)
11
17
  ast (2.4.1)
12
18
  byebug (11.1.3)
13
19
  coderay (1.1.3)
20
+ concurrent-ruby (1.1.7)
14
21
  diff-lcs (1.4.3)
15
22
  ethon (0.12.0)
16
23
  ffi (>= 1.3.0)
24
+ factory_bot (6.1.0)
25
+ activesupport (>= 5.0.0)
17
26
  ffi (1.13.1)
18
- json (2.3.1)
27
+ i18n (1.8.7)
28
+ concurrent-ruby (~> 1.0)
29
+ json (2.4.1)
19
30
  method_source (1.0.0)
31
+ minitest (5.14.3)
20
32
  parallel (1.19.2)
21
33
  parser (2.7.1.4)
22
34
  ast (~> 2.4.1)
@@ -57,12 +69,16 @@ GEM
57
69
  ruby-progressbar (1.10.1)
58
70
  typhoeus (1.4.0)
59
71
  ethon (>= 0.9.0)
72
+ tzinfo (2.0.4)
73
+ concurrent-ruby (~> 1.0)
60
74
  unicode-display_width (1.7.0)
75
+ zeitwerk (2.4.2)
61
76
 
62
77
  PLATFORMS
63
78
  ruby
64
79
 
65
80
  DEPENDENCIES
81
+ factory_bot
66
82
  patch_ruby!
67
83
  pry-byebug
68
84
  rake (~> 13.0.1)
@@ -14,10 +14,13 @@ require 'date'
14
14
 
15
15
  module Patch
16
16
  class Allocation
17
+ # A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in.
17
18
  attr_accessor :id
18
19
 
20
+ # A boolean indicating if this project is a production or test mode project.
19
21
  attr_accessor :production
20
22
 
23
+ # The amount (in grams) of allocated carbon offsets.
21
24
  attr_accessor :mass_g
22
25
 
23
26
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -38,6 +41,13 @@ module Patch
38
41
  }
39
42
  end
40
43
 
44
+ # Set with nullable attributes.
45
+ def self.openapi_nullable
46
+ nullable_properties = Set.new
47
+
48
+ nullable_properties
49
+ end
50
+
41
51
  # Allows models with corresponding API classes to delegate API operations to those API classes
42
52
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
43
53
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -34,6 +34,13 @@ module Patch
34
34
  }
35
35
  end
36
36
 
37
+ # Set with nullable attributes.
38
+ def self.openapi_nullable
39
+ nullable_properties = Set.new
40
+
41
+ nullable_properties
42
+ end
43
+
37
44
  # Allows models with corresponding API classes to delegate API operations to those API classes
38
45
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
39
46
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -42,6 +42,13 @@ module Patch
42
42
  }
43
43
  end
44
44
 
45
+ # Set with nullable attributes.
46
+ def self.openapi_nullable
47
+ nullable_properties = Set.new
48
+
49
+ nullable_properties
50
+ end
51
+
45
52
  # Allows models with corresponding API classes to delegate API operations to those API classes
46
53
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
47
54
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -30,6 +30,13 @@ module Patch
30
30
  }
31
31
  end
32
32
 
33
+ # Set with nullable attributes.
34
+ def self.openapi_nullable
35
+ nullable_properties = Set.new
36
+
37
+ nullable_properties
38
+ end
39
+
33
40
  # Allows models with corresponding API classes to delegate API operations to those API classes
34
41
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
35
42
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -38,6 +38,15 @@ module Patch
38
38
  }
39
39
  end
40
40
 
41
+ # Set with nullable attributes.
42
+ def self.openapi_nullable
43
+ nullable_properties = Set.new
44
+
45
+ nullable_properties.add("data")
46
+
47
+ nullable_properties
48
+ end
49
+
41
50
  # Allows models with corresponding API classes to delegate API operations to those API classes
42
51
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
43
52
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -14,12 +14,16 @@ require 'date'
14
14
 
15
15
  module Patch
16
16
  class Estimate
17
+ # A unique uid for the record. UIDs will be prepended by est_prod or est_test depending on the mode it was created in.
17
18
  attr_accessor :id
18
19
 
20
+ # A boolean indicating if this estimate is a production or test mode estimate.
19
21
  attr_accessor :production
20
22
 
23
+ # The type of estimate. Currently mass is the only supported value.
21
24
  attr_accessor :type
22
25
 
26
+ # An object returning the order associated with this estimate. See the [Order section](/?id=orders) for the full schema.
23
27
  attr_accessor :order
24
28
 
25
29
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -42,6 +46,15 @@ module Patch
42
46
  }
43
47
  end
44
48
 
49
+ # Set with nullable attributes.
50
+ def self.openapi_nullable
51
+ nullable_properties = Set.new
52
+
53
+ nullable_properties.add("order")
54
+
55
+ nullable_properties
56
+ end
57
+
45
58
  # Allows models with corresponding API classes to delegate API operations to those API classes
46
59
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
47
60
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -226,7 +239,7 @@ module Patch
226
239
  is_nullable = self.class.openapi_nullable.include?(attr)
227
240
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
241
  end
229
-
242
+
230
243
  hash[param] = _to_hash(value)
231
244
  end
232
245
  hash
@@ -42,6 +42,15 @@ module Patch
42
42
  }
43
43
  end
44
44
 
45
+ # Set with nullable attributes.
46
+ def self.openapi_nullable
47
+ nullable_properties = Set.new
48
+
49
+ nullable_properties.add("error")
50
+
51
+ nullable_properties
52
+ end
53
+
45
54
  # Allows models with corresponding API classes to delegate API operations to those API classes
46
55
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
47
56
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -38,6 +38,15 @@ module Patch
38
38
  }
39
39
  end
40
40
 
41
+ # Set with nullable attributes.
42
+ def self.openapi_nullable
43
+ nullable_properties = Set.new
44
+
45
+ nullable_properties.add("error")
46
+
47
+ nullable_properties
48
+ end
49
+
41
50
  # Allows models with corresponding API classes to delegate API operations to those API classes
42
51
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
43
52
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -34,6 +34,17 @@ module Patch
34
34
  }
35
35
  end
36
36
 
37
+ # Set with nullable attributes.
38
+ def self.openapi_nullable
39
+ nullable_properties = Set.new
40
+
41
+ nullable_properties.add("prev_page")
42
+
43
+ nullable_properties.add("next_page")
44
+
45
+ nullable_properties
46
+ end
47
+
37
48
  # Allows models with corresponding API classes to delegate API operations to those API classes
38
49
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
39
50
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -14,22 +14,31 @@ require 'date'
14
14
 
15
15
  module Patch
16
16
  class Order
17
+ # A unique uid for the record. UIDs will be prepended by ord_prod or ord_test depending on the mode it was created in.
17
18
  attr_accessor :id
18
19
 
20
+ # The amount of carbon offsets in grams purchased through this order.
19
21
  attr_accessor :mass_g
20
22
 
23
+ # A boolean indicating if this order is a production or test mode order.
21
24
  attr_accessor :production
22
25
 
26
+ # The current state of the order.
23
27
  attr_accessor :state
24
28
 
29
+ # The current state of the allocated carbon offsets of the order.
25
30
  attr_accessor :allocation_state
26
31
 
32
+ # The total price in cents USD of the carbon offsets purchased through this order.
27
33
  attr_accessor :price_cents_usd
28
34
 
35
+ # The Patch Fee in cents USD for this order.
29
36
  attr_accessor :patch_fee_cents_usd
30
37
 
38
+ # An array containing the inventory allocations for this order.
31
39
  attr_accessor :allocations
32
40
 
41
+ # An optional JSON object containing metadata for this order.
33
42
  attr_accessor :metadata
34
43
 
35
44
  class EnumAttributeValidator
@@ -84,6 +93,17 @@ module Patch
84
93
  }
85
94
  end
86
95
 
96
+ # Set with nullable attributes.
97
+ def self.openapi_nullable
98
+ nullable_properties = Set.new
99
+
100
+ nullable_properties.add("price_cents_usd")
101
+
102
+ nullable_properties.add("patch_fee_cents_usd")
103
+
104
+ nullable_properties
105
+ end
106
+
87
107
  # Allows models with corresponding API classes to delegate API operations to those API classes
88
108
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
89
109
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -42,6 +42,15 @@ module Patch
42
42
  }
43
43
  end
44
44
 
45
+ # Set with nullable attributes.
46
+ def self.openapi_nullable
47
+ nullable_properties = Set.new
48
+
49
+ nullable_properties.add("error")
50
+
51
+ nullable_properties
52
+ end
53
+
45
54
  # Allows models with corresponding API classes to delegate API operations to those API classes
46
55
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
47
56
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -38,6 +38,15 @@ module Patch
38
38
  }
39
39
  end
40
40
 
41
+ # Set with nullable attributes.
42
+ def self.openapi_nullable
43
+ nullable_properties = Set.new
44
+
45
+ nullable_properties.add("error")
46
+
47
+ nullable_properties
48
+ end
49
+
41
50
  # Allows models with corresponding API classes to delegate API operations to those API classes
42
51
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
43
52
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -16,20 +16,31 @@ module Patch
16
16
  class Photo
17
17
  attr_accessor :url
18
18
 
19
+ attr_accessor :id
20
+
19
21
  # Attribute mapping from ruby-style variable name to JSON key.
20
22
  def self.attribute_map
21
23
  {
22
- :'url' => :'url'
24
+ :'url' => :'url',
25
+ :'id' => :'id'
23
26
  }
24
27
  end
25
28
 
26
29
  # Attribute type mapping.
27
30
  def self.openapi_types
28
31
  {
29
- :'url' => :'String'
32
+ :'url' => :'String',
33
+ :'id' => :'String'
30
34
  }
31
35
  end
32
36
 
37
+ # Set with nullable attributes.
38
+ def self.openapi_nullable
39
+ nullable_properties = Set.new
40
+
41
+ nullable_properties
42
+ end
43
+
33
44
  # Allows models with corresponding API classes to delegate API operations to those API classes
34
45
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
35
46
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -69,6 +80,10 @@ module Patch
69
80
  invalid_properties.push('invalid value for "url", url cannot be nil.')
70
81
  end
71
82
 
83
+ if @id.nil?
84
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
85
+ end
86
+
72
87
  invalid_properties
73
88
  end
74
89
 
@@ -76,6 +91,7 @@ module Patch
76
91
  # @return true if the model is valid
77
92
  def valid?
78
93
  return false if @url.nil?
94
+ return false if @id.nil?
79
95
  true
80
96
  end
81
97
 
@@ -84,7 +100,8 @@ module Patch
84
100
  def ==(o)
85
101
  return true if self.equal?(o)
86
102
  self.class == o.class &&
87
- url == o.url
103
+ url == o.url &&
104
+ id == o.id
88
105
  end
89
106
 
90
107
  # @see the `==` method
@@ -96,7 +113,7 @@ module Patch
96
113
  # Calculates hash code according to all attributes.
97
114
  # @return [Integer] Hash code
98
115
  def hash
99
- [url].hash
116
+ [url, id].hash
100
117
  end
101
118
 
102
119
  # Builds the object from hash
@@ -14,10 +14,13 @@ require 'date'
14
14
 
15
15
  module Patch
16
16
  class Preference
17
+ # A unique uid for the record. UIDs will be prepended by pre_prod or pre_test depending on the mode it was created in.
17
18
  attr_accessor :id
18
19
 
20
+ # Percentage of total purchased offsets that should go to a project. Default is 100%.
19
21
  attr_accessor :allocation_percentage
20
22
 
23
+ # An object returning the Project record this Preference is associated with. See the [Project section](/?id=projects) for the full schema.
21
24
  attr_accessor :project
22
25
 
23
26
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -38,6 +41,13 @@ module Patch
38
41
  }
39
42
  end
40
43
 
44
+ # Set with nullable attributes.
45
+ def self.openapi_nullable
46
+ nullable_properties = Set.new
47
+
48
+ nullable_properties
49
+ end
50
+
41
51
  # Allows models with corresponding API classes to delegate API operations to those API classes
42
52
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
43
53
  # Eg. Order.create_order delegates to OrdersApi.new.create_order