patch_ruby 1.0.0 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +78 -0
  3. data/Gemfile +2 -1
  4. data/Gemfile.lock +30 -11
  5. data/Makefile +10 -0
  6. data/README.md +61 -8
  7. data/lib/patch_ruby.rb +2 -0
  8. data/lib/patch_ruby/models/allocation.rb +25 -0
  9. data/lib/patch_ruby/models/create_mass_estimate_request.rb +48 -4
  10. data/lib/patch_ruby/models/create_order_request.rb +75 -7
  11. data/lib/patch_ruby/models/create_preference_request.rb +7 -0
  12. data/lib/patch_ruby/models/error_response.rb +9 -0
  13. data/lib/patch_ruby/models/estimate.rb +29 -1
  14. data/lib/patch_ruby/models/estimate_list_response.rb +9 -0
  15. data/lib/patch_ruby/models/estimate_response.rb +9 -0
  16. data/lib/patch_ruby/models/meta_index_object.rb +11 -0
  17. data/lib/patch_ruby/models/order.rb +105 -4
  18. data/lib/patch_ruby/models/order_list_response.rb +9 -0
  19. data/lib/patch_ruby/models/order_response.rb +9 -0
  20. data/lib/patch_ruby/models/photo.rb +233 -0
  21. data/lib/patch_ruby/models/preference.rb +25 -0
  22. data/lib/patch_ruby/models/preference_list_response.rb +9 -0
  23. data/lib/patch_ruby/models/preference_response.rb +9 -0
  24. data/lib/patch_ruby/models/project.rb +141 -25
  25. data/lib/patch_ruby/models/project_list_response.rb +9 -0
  26. data/lib/patch_ruby/models/project_response.rb +9 -0
  27. data/lib/patch_ruby/models/standard.rb +254 -0
  28. data/lib/patch_ruby/version.rb +1 -1
  29. data/spec/api/estimates_api_spec.rb +6 -7
  30. data/spec/api/orders_api_spec.rb +10 -11
  31. data/spec/api/preferences_api_spec.rb +8 -9
  32. data/spec/api/projects_api_spec.rb +4 -5
  33. data/spec/constants.rb +3 -0
  34. data/spec/factories/allocations.rb +7 -0
  35. data/spec/factories/create_mass_estimate_requests.rb +6 -0
  36. data/spec/factories/create_order_requests.rb +8 -0
  37. data/spec/factories/create_preference_requests.rb +5 -0
  38. data/spec/factories/error_responses.rb +7 -0
  39. data/spec/factories/estimate_list_responses.rb +8 -0
  40. data/spec/factories/estimate_responses.rb +7 -0
  41. data/spec/factories/estimates.rb +8 -0
  42. data/spec/factories/meta_index_objects.rb +6 -0
  43. data/spec/factories/order_list_responses.rb +8 -0
  44. data/spec/factories/order_responses.rb +7 -0
  45. data/spec/factories/orders.rb +12 -0
  46. data/spec/factories/preference_list_responses.rb +8 -0
  47. data/spec/factories/preference_responses.rb +7 -0
  48. data/spec/factories/preferences.rb +7 -0
  49. data/spec/factories/project_list_responses.rb +8 -0
  50. data/spec/factories/project_responses.rb +7 -0
  51. data/spec/factories/projects.rb +15 -0
  52. data/spec/integration/estimates_spec.rb +4 -3
  53. data/spec/integration/orders_spec.rb +60 -1
  54. data/spec/integration/preferences_spec.rb +1 -1
  55. data/spec/integration/projects_spec.rb +19 -1
  56. data/spec/models/allocation_spec.rb +8 -2
  57. data/spec/models/create_mass_estimate_request_spec.rb +7 -2
  58. data/spec/models/create_order_request_spec.rb +7 -2
  59. data/spec/models/create_preference_request_spec.rb +8 -2
  60. data/spec/models/error_response_spec.rb +7 -2
  61. data/spec/models/estimate_list_response_spec.rb +7 -2
  62. data/spec/models/estimate_response_spec.rb +7 -2
  63. data/spec/models/estimate_spec.rb +8 -2
  64. data/spec/models/meta_index_object_spec.rb +7 -2
  65. data/spec/models/order_list_response_spec.rb +7 -2
  66. data/spec/models/order_response_spec.rb +7 -2
  67. data/spec/models/order_spec.rb +18 -2
  68. data/spec/models/preference_list_response_spec.rb +7 -2
  69. data/spec/models/preference_response_spec.rb +7 -2
  70. data/spec/models/preference_spec.rb +7 -2
  71. data/spec/models/project_list_response_spec.rb +7 -2
  72. data/spec/models/project_response_spec.rb +7 -2
  73. data/spec/models/project_spec.rb +21 -2
  74. data/spec/spec_helper.rb +11 -0
  75. data/spec/support/shared/generated_classes.rb +13 -0
  76. metadata +61 -17
@@ -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
@@ -0,0 +1,254 @@
1
+ =begin
2
+ #Patch API V1
3
+
4
+ #The core API used to integrate with Patch's service
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: developers@usepatch.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Patch
16
+ class Standard
17
+ # The standard type.
18
+ attr_accessor :type
19
+
20
+ # The acronym for the standard.
21
+ attr_accessor :acronym
22
+
23
+ # The description of the standard.
24
+ attr_accessor :description
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'type' => :'type',
30
+ :'acronym' => :'acronym',
31
+ :'description' => :'description'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'type' => :'String',
39
+ :'acronym' => :'String',
40
+ :'description' => :'String'
41
+ }
42
+ end
43
+
44
+ # Set with nullable attributes.
45
+ def self.openapi_nullable
46
+ nullable_properties = Set.new
47
+
48
+ nullable_properties
49
+ end
50
+
51
+ # Allows models with corresponding API classes to delegate API operations to those API classes
52
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
53
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
54
+ def self.method_missing(message, *args, &block)
55
+ if Object.const_defined?('Patch::StandardsApi::OPERATIONS') && Patch::StandardsApi::OPERATIONS.include?(message)
56
+ Patch::StandardsApi.new.send(message, *args)
57
+ else
58
+ super
59
+ end
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::Standard` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Standard`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'type')
78
+ self.type = attributes[:'type']
79
+ end
80
+
81
+ if attributes.key?(:'acronym')
82
+ self.acronym = attributes[:'acronym']
83
+ end
84
+
85
+ if attributes.key?(:'description')
86
+ self.description = attributes[:'description']
87
+ end
88
+ end
89
+
90
+ # Show invalid properties with the reasons. Usually used together with valid?
91
+ # @return Array for valid properties with the reasons
92
+ def list_invalid_properties
93
+ invalid_properties = Array.new
94
+ if @type.nil?
95
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
96
+ end
97
+
98
+ if @acronym.nil?
99
+ invalid_properties.push('invalid value for "acronym", acronym cannot be nil.')
100
+ end
101
+
102
+ if @description.nil?
103
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
104
+ end
105
+
106
+ invalid_properties
107
+ end
108
+
109
+ # Check to see if the all the properties in the model are valid
110
+ # @return true if the model is valid
111
+ def valid?
112
+ return false if @type.nil?
113
+ return false if @acronym.nil?
114
+ return false if @description.nil?
115
+ true
116
+ end
117
+
118
+ # Checks equality by comparing each attribute.
119
+ # @param [Object] Object to be compared
120
+ def ==(o)
121
+ return true if self.equal?(o)
122
+ self.class == o.class &&
123
+ type == o.type &&
124
+ acronym == o.acronym &&
125
+ description == o.description
126
+ end
127
+
128
+ # @see the `==` method
129
+ # @param [Object] Object to be compared
130
+ def eql?(o)
131
+ self == o
132
+ end
133
+
134
+ # Calculates hash code according to all attributes.
135
+ # @return [Integer] Hash code
136
+ def hash
137
+ [type, acronym, description].hash
138
+ end
139
+
140
+ # Builds the object from hash
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ # @return [Object] Returns the model itself
143
+ def self.build_from_hash(attributes)
144
+ new.build_from_hash(attributes)
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def build_from_hash(attributes)
151
+ return nil unless attributes.is_a?(Hash)
152
+ self.class.openapi_types.each_pair do |key, type|
153
+ if type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
157
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
158
+ end
159
+ elsif !attributes[self.class.attribute_map[key]].nil?
160
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
161
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
162
+ end
163
+
164
+ self
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def _deserialize(type, value)
172
+ case type.to_sym
173
+ when :DateTime
174
+ DateTime.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :Boolean
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ Patch.const_get(type).build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ if value.nil?
227
+ is_nullable = self.class.openapi_nullable.include?(attr)
228
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
229
+ end
230
+
231
+ hash[param] = _to_hash(value)
232
+ end
233
+ hash
234
+ end
235
+
236
+ # Outputs non-array value in the form of hash
237
+ # For object, use to_hash. Otherwise, just return the value
238
+ # @param [Object] value Any valid value
239
+ # @return [Hash] Returns the value in the form of hash
240
+ def _to_hash(value)
241
+ if value.is_a?(Array)
242
+ value.compact.map { |v| _to_hash(v) }
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.each { |k, v| hash[k] = _to_hash(v) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash
249
+ else
250
+ value
251
+ end
252
+ end
253
+ end
254
+ end
@@ -11,5 +11,5 @@ OpenAPI Generator version: 4.3.1
11
11
  =end
12
12
 
13
13
  module Patch
14
- VERSION = '1.0.0'
14
+ VERSION = '1.2.5'
15
15
  end
@@ -34,8 +34,8 @@ describe 'EstimatesApi' do
34
34
 
35
35
  # unit tests for create_mass_estimate
36
36
  # Create an estimate based on mass of CO2
37
- # Creates an estimate for the mass of CO2 to be compensated. An order in the &#x60;draft&#x60; state will also be created, linked to the estimate.
38
- # @param create_mass_estimate_request
37
+ # Creates an estimate for the mass of CO2 to be compensated. An order in the &#x60;draft&#x60; state will also be created, linked to the estimate.
38
+ # @param create_mass_estimate_request
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [EstimateResponse]
41
41
  describe 'create_mass_estimate test' do
@@ -46,8 +46,8 @@ describe 'EstimatesApi' do
46
46
 
47
47
  # unit tests for retrieve_estimate
48
48
  # Retrieves an estimate
49
- # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for.
50
- # @param id
49
+ # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for.
50
+ # @param id
51
51
  # @param [Hash] opts the optional parameters
52
52
  # @return [EstimateResponse]
53
53
  describe 'retrieve_estimate test' do
@@ -58,14 +58,13 @@ describe 'EstimatesApi' do
58
58
 
59
59
  # unit tests for retrieve_estimates
60
60
  # Retrieves a list of estimates
61
- # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for.
61
+ # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for.
62
62
  # @param [Hash] opts the optional parameters
63
- # @option opts [Integer] :page
63
+ # @option opts [Integer] :page
64
64
  # @return [EstimateListResponse]
65
65
  describe 'retrieve_estimates test' do
66
66
  it 'should work' do
67
67
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
68
68
  end
69
69
  end
70
-
71
70
  end
@@ -34,8 +34,8 @@ describe 'OrdersApi' do
34
34
 
35
35
  # unit tests for cancel_order
36
36
  # Cancel an order
37
- # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the &#x60;draft&#x60; state can be cancelled.
38
- # @param id
37
+ # Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the &#x60;draft&#x60; state can be cancelled.
38
+ # @param id
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [OrderResponse]
41
41
  describe 'cancel_order test' do
@@ -46,8 +46,8 @@ describe 'OrdersApi' do
46
46
 
47
47
  # unit tests for create_order
48
48
  # Creates an order
49
- # Creates an order in the &#x60;placed&#x60; state. To create a &#x60;draft&#x60; order, create an estimate first.
50
- # @param create_order_request
49
+ # Creates an order in the &#x60;placed&#x60; state. To create a &#x60;draft&#x60; order, create an estimate first.
50
+ # @param create_order_request
51
51
  # @param [Hash] opts the optional parameters
52
52
  # @return [OrderResponse]
53
53
  describe 'create_order test' do
@@ -58,8 +58,8 @@ describe 'OrdersApi' do
58
58
 
59
59
  # unit tests for place_order
60
60
  # Place an order
61
- # Placing an order confirms an order&#39;s allocation of offsets. Only orders that are in the &#x60;draft&#x60; state can be placed
62
- # @param id
61
+ # Placing an order confirms an order&#39;s allocation of offsets. Only orders that are in the &#x60;draft&#x60; state can be placed
62
+ # @param id
63
63
  # @param [Hash] opts the optional parameters
64
64
  # @return [OrderResponse]
65
65
  describe 'place_order test' do
@@ -70,8 +70,8 @@ describe 'OrdersApi' do
70
70
 
71
71
  # unit tests for retrieve_order
72
72
  # Retrieves an order
73
- # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
74
- # @param id
73
+ # Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
74
+ # @param id
75
75
  # @param [Hash] opts the optional parameters
76
76
  # @return [OrderResponse]
77
77
  describe 'retrieve_order test' do
@@ -82,14 +82,13 @@ describe 'OrdersApi' do
82
82
 
83
83
  # unit tests for retrieve_orders
84
84
  # Retrieves a list of orders
85
- # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
85
+ # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
86
86
  # @param [Hash] opts the optional parameters
87
- # @option opts [Integer] :page
87
+ # @option opts [Integer] :page
88
88
  # @return [OrderListResponse]
89
89
  describe 'retrieve_orders test' do
90
90
  it 'should work' do
91
91
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
92
92
  end
93
93
  end
94
-
95
94
  end
@@ -34,8 +34,8 @@ describe 'PreferencesApi' do
34
34
 
35
35
  # unit tests for create_preference
36
36
  # creates a project preference
37
- # Creates a project preference for the given organization. If you have a &#x60;preference&#x60; in place, all of your orders will be directed to the project the preference points to.
38
- # @param create_preference_request
37
+ # Creates a project preference for the given organization. If you have a &#x60;preference&#x60; in place, all of your orders will be directed to the project the preference points to.
38
+ # @param create_preference_request
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [PreferenceResponse]
41
41
  describe 'create_preference test' do
@@ -46,8 +46,8 @@ describe 'PreferencesApi' do
46
46
 
47
47
  # unit tests for delete_preference
48
48
  # Deletes an organization&#39;s preference for a project
49
- # Deletes the given &#x60;preference&#x60;. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one.
50
- # @param id
49
+ # Deletes the given &#x60;preference&#x60;. Once a preference is deleted, it cannot be undone. If you want to restore your previous preference, create a new one.
50
+ # @param id
51
51
  # @param [Hash] opts the optional parameters
52
52
  # @return [PreferenceResponse]
53
53
  describe 'delete_preference test' do
@@ -58,8 +58,8 @@ describe 'PreferencesApi' do
58
58
 
59
59
  # unit tests for retrieve_preference
60
60
  # Retrieve the preference
61
- # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.
62
- # @param id
61
+ # Retrieve the preference and project of an organization. You can only retrieve preferences associated with your organization.
62
+ # @param id
63
63
  # @param [Hash] opts the optional parameters
64
64
  # @return [PreferenceResponse]
65
65
  describe 'retrieve_preference test' do
@@ -70,14 +70,13 @@ describe 'PreferencesApi' do
70
70
 
71
71
  # unit tests for retrieve_preferences
72
72
  # Retrieves a list of preferences
73
- # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.
73
+ # Retrieves a list of preferences and associated projects of an organization. You can only retrieve preferences associated with your organization.
74
74
  # @param [Hash] opts the optional parameters
75
- # @option opts [Integer] :page
75
+ # @option opts [Integer] :page
76
76
  # @return [PreferenceListResponse]
77
77
  describe 'retrieve_preferences test' do
78
78
  it 'should work' do
79
79
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
80
80
  end
81
81
  end
82
-
83
82
  end
@@ -34,8 +34,8 @@ describe 'ProjectsApi' do
34
34
 
35
35
  # unit tests for retrieve_project
36
36
  # Retrieves a project
37
- # Retrieves a project available on Patch&#39;s platform.
38
- # @param id
37
+ # Retrieves a project available on Patch&#39;s platform.
38
+ # @param id
39
39
  # @param [Hash] opts the optional parameters
40
40
  # @return [ProjectResponse]
41
41
  describe 'retrieve_project test' do
@@ -46,14 +46,13 @@ describe 'ProjectsApi' do
46
46
 
47
47
  # unit tests for retrieve_projects
48
48
  # Retrieves a list of projects
49
- # Retrieves a list of projects available for purchase on Patch&#39;s platform.
49
+ # Retrieves a list of projects available for purchase on Patch&#39;s platform.
50
50
  # @param [Hash] opts the optional parameters
51
- # @option opts [Integer] :page
51
+ # @option opts [Integer] :page
52
52
  # @return [ProjectListResponse]
53
53
  describe 'retrieve_projects test' do
54
54
  it 'should work' do
55
55
  # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
56
56
  end
57
57
  end
58
-
59
58
  end