patch_ruby 1.2.4 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -2
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +19 -3
  5. data/README.md +72 -8
  6. data/lib/patch_ruby.rb +1 -0
  7. data/lib/patch_ruby/api/estimates_api.rb +195 -0
  8. data/lib/patch_ruby/api/projects_api.rb +9 -0
  9. data/lib/patch_ruby/configuration.rb +2 -2
  10. data/lib/patch_ruby/models/allocation.rb +10 -0
  11. data/lib/patch_ruby/models/create_mass_estimate_request.rb +19 -1
  12. data/lib/patch_ruby/models/create_order_request.rb +7 -0
  13. data/lib/patch_ruby/models/create_preference_request.rb +7 -0
  14. data/lib/patch_ruby/models/error_response.rb +9 -0
  15. data/lib/patch_ruby/models/estimate.rb +24 -1
  16. data/lib/patch_ruby/models/estimate_list_response.rb +9 -0
  17. data/lib/patch_ruby/models/estimate_response.rb +9 -0
  18. data/lib/patch_ruby/models/meta_index_object.rb +11 -0
  19. data/lib/patch_ruby/models/order.rb +20 -0
  20. data/lib/patch_ruby/models/order_list_response.rb +9 -0
  21. data/lib/patch_ruby/models/order_response.rb +9 -0
  22. data/lib/patch_ruby/models/photo.rb +25 -4
  23. data/lib/patch_ruby/models/preference.rb +10 -0
  24. data/lib/patch_ruby/models/preference_list_response.rb +9 -0
  25. data/lib/patch_ruby/models/preference_response.rb +9 -0
  26. data/lib/patch_ruby/models/project.rb +40 -4
  27. data/lib/patch_ruby/models/project_list_response.rb +9 -0
  28. data/lib/patch_ruby/models/project_response.rb +9 -0
  29. data/lib/patch_ruby/models/sdg.rb +269 -0
  30. data/lib/patch_ruby/models/standard.rb +10 -0
  31. data/lib/patch_ruby/version.rb +1 -1
  32. data/patch_ruby.gemspec +1 -1
  33. data/spec/configuration_spec.rb +3 -3
  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 +52 -8
  53. data/spec/integration/orders_spec.rb +2 -2
  54. data/spec/integration/preferences_spec.rb +6 -2
  55. data/spec/integration/projects_spec.rb +20 -0
  56. data/spec/models/allocation_spec.rb +8 -1
  57. data/spec/models/create_mass_estimate_request_spec.rb +7 -1
  58. data/spec/models/create_order_request_spec.rb +7 -1
  59. data/spec/models/create_preference_request_spec.rb +8 -1
  60. data/spec/models/error_response_spec.rb +7 -1
  61. data/spec/models/estimate_list_response_spec.rb +7 -1
  62. data/spec/models/estimate_response_spec.rb +7 -1
  63. data/spec/models/estimate_spec.rb +8 -1
  64. data/spec/models/meta_index_object_spec.rb +7 -1
  65. data/spec/models/order_list_response_spec.rb +7 -1
  66. data/spec/models/order_response_spec.rb +7 -1
  67. data/spec/models/order_spec.rb +18 -1
  68. data/spec/models/preference_list_response_spec.rb +7 -1
  69. data/spec/models/preference_response_spec.rb +7 -1
  70. data/spec/models/preference_spec.rb +7 -1
  71. data/spec/models/project_list_response_spec.rb +7 -1
  72. data/spec/models/project_response_spec.rb +7 -1
  73. data/spec/models/project_spec.rb +21 -1
  74. data/spec/patch_ruby_spec.rb +18 -0
  75. data/spec/spec_helper.rb +10 -0
  76. data/spec/support/shared/generated_classes.rb +13 -0
  77. metadata +58 -17
@@ -90,6 +90,9 @@ module Patch
90
90
  # Retrieves a list of projects available for purchase on Patch's platform.
91
91
  # @param [Hash] opts the optional parameters
92
92
  # @option opts [Integer] :page
93
+ # @option opts [String] :country
94
+ # @option opts [String] :type
95
+ # @option opts [Integer] :minimum_available_mass
93
96
  # @return [ProjectListResponse]
94
97
  def retrieve_projects(opts = {})
95
98
  data, _status_code, _headers = retrieve_projects_with_http_info(opts)
@@ -100,6 +103,9 @@ module Patch
100
103
  # Retrieves a list of projects available for purchase on Patch's platform.
101
104
  # @param [Hash] opts the optional parameters
102
105
  # @option opts [Integer] :page
106
+ # @option opts [String] :country
107
+ # @option opts [String] :type
108
+ # @option opts [Integer] :minimum_available_mass
103
109
  # @return [Array<(ProjectListResponse, Integer, Hash)>] ProjectListResponse data, response status code and response headers
104
110
  def retrieve_projects_with_http_info(opts = {})
105
111
  if @api_client.config.debugging
@@ -111,6 +117,9 @@ module Patch
111
117
  # query parameters
112
118
  query_params = opts[:query_params] || {}
113
119
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
120
+ query_params[:'country'] = opts[:'country'] if !opts[:'country'].nil?
121
+ query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
122
+ query_params[:'minimum_available_mass'] = opts[:'minimum_available_mass'] if !opts[:'minimum_available_mass'].nil?
114
123
 
115
124
  # header parameters
116
125
  header_params = opts[:header_params] || {}
@@ -127,7 +127,7 @@ module Patch
127
127
 
128
128
  def initialize
129
129
  @scheme = 'https'
130
- @host = 'api.usepatch.com'
130
+ @host = 'api.patch.io'
131
131
  @base_path = ''
132
132
  @api_key = {}
133
133
  @api_key_prefix = {}
@@ -212,7 +212,7 @@ module Patch
212
212
  variables: {
213
213
  defaultHost: {
214
214
  description: "No description provided",
215
- default_value: "api.usepatch.com",
215
+ default_value: "api.patch.io",
216
216
  }
217
217
  }
218
218
  }
@@ -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
@@ -16,12 +16,15 @@ module Patch
16
16
  class CreateMassEstimateRequest
17
17
  attr_accessor :mass_g
18
18
 
19
+ attr_accessor :create_order
20
+
19
21
  attr_accessor :project_id
20
22
 
21
23
  # Attribute mapping from ruby-style variable name to JSON key.
22
24
  def self.attribute_map
23
25
  {
24
26
  :'mass_g' => :'mass_g',
27
+ :'create_order' => :'create_order',
25
28
  :'project_id' => :'project_id'
26
29
  }
27
30
  end
@@ -30,10 +33,20 @@ module Patch
30
33
  def self.openapi_types
31
34
  {
32
35
  :'mass_g' => :'Integer',
36
+ :'create_order' => :'Boolean',
33
37
  :'project_id' => :'String'
34
38
  }
35
39
  end
36
40
 
41
+ # Set with nullable attributes.
42
+ def self.openapi_nullable
43
+ nullable_properties = Set.new
44
+
45
+ nullable_properties.add("create_order")
46
+
47
+ nullable_properties
48
+ end
49
+
37
50
  # Allows models with corresponding API classes to delegate API operations to those API classes
38
51
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
39
52
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -64,6 +77,10 @@ module Patch
64
77
  self.mass_g = attributes[:'mass_g']
65
78
  end
66
79
 
80
+ if attributes.key?(:'create_order')
81
+ self.create_order = attributes[:'create_order']
82
+ end
83
+
67
84
  if attributes.key?(:'project_id')
68
85
  self.project_id = attributes[:'project_id']
69
86
  end
@@ -121,6 +138,7 @@ module Patch
121
138
  return true if self.equal?(o)
122
139
  self.class == o.class &&
123
140
  mass_g == o.mass_g &&
141
+ create_order == o.create_order &&
124
142
  project_id == o.project_id
125
143
  end
126
144
 
@@ -133,7 +151,7 @@ module Patch
133
151
  # Calculates hash code according to all attributes.
134
152
  # @return [Integer] Hash code
135
153
  def hash
136
- [mass_g, project_id].hash
154
+ [mass_g, create_order, project_id].hash
137
155
  end
138
156
 
139
157
  # Builds the object from hash
@@ -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,19 @@ 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. Available types are mass, flight, shipping, and vehicle.
21
24
  attr_accessor :type
22
25
 
26
+ # The estimated mass in grams for this estimate.
27
+ attr_accessor :mass_g
28
+
29
+ # An object returning the order associated with this estimate. See the [Order section](/?id=orders) for the full schema.
23
30
  attr_accessor :order
24
31
 
25
32
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -28,6 +35,7 @@ module Patch
28
35
  :'id' => :'id',
29
36
  :'production' => :'production',
30
37
  :'type' => :'type',
38
+ :'mass_g' => :'mass_g',
31
39
  :'order' => :'order'
32
40
  }
33
41
  end
@@ -38,10 +46,20 @@ module Patch
38
46
  :'id' => :'String',
39
47
  :'production' => :'Boolean',
40
48
  :'type' => :'String',
49
+ :'mass_g' => :'Integer',
41
50
  :'order' => :'Order'
42
51
  }
43
52
  end
44
53
 
54
+ # Set with nullable attributes.
55
+ def self.openapi_nullable
56
+ nullable_properties = Set.new
57
+
58
+ nullable_properties.add("order")
59
+
60
+ nullable_properties
61
+ end
62
+
45
63
  # Allows models with corresponding API classes to delegate API operations to those API classes
46
64
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
47
65
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -80,6 +98,10 @@ module Patch
80
98
  self.type = attributes[:'type']
81
99
  end
82
100
 
101
+ if attributes.key?(:'mass_g')
102
+ self.mass_g = attributes[:'mass_g']
103
+ end
104
+
83
105
  if attributes.key?(:'order')
84
106
  self.order = attributes[:'order']
85
107
  end
@@ -121,6 +143,7 @@ module Patch
121
143
  id == o.id &&
122
144
  production == o.production &&
123
145
  type == o.type &&
146
+ mass_g == o.mass_g &&
124
147
  order == o.order
125
148
  end
126
149
 
@@ -133,7 +156,7 @@ module Patch
133
156
  # Calculates hash code according to all attributes.
134
157
  # @return [Integer] Hash code
135
158
  def hash
136
- [id, production, type, order].hash
159
+ [id, production, type, mass_g, order].hash
137
160
  end
138
161
 
139
162
  # Builds the object from 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
@@ -59,6 +70,10 @@ module Patch
59
70
  if attributes.key?(:'url')
60
71
  self.url = attributes[:'url']
61
72
  end
73
+
74
+ if attributes.key?(:'id')
75
+ self.id = attributes[:'id']
76
+ end
62
77
  end
63
78
 
64
79
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -69,6 +84,10 @@ module Patch
69
84
  invalid_properties.push('invalid value for "url", url cannot be nil.')
70
85
  end
71
86
 
87
+ if @id.nil?
88
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
89
+ end
90
+
72
91
  invalid_properties
73
92
  end
74
93
 
@@ -76,6 +95,7 @@ module Patch
76
95
  # @return true if the model is valid
77
96
  def valid?
78
97
  return false if @url.nil?
98
+ return false if @id.nil?
79
99
  true
80
100
  end
81
101
 
@@ -84,7 +104,8 @@ module Patch
84
104
  def ==(o)
85
105
  return true if self.equal?(o)
86
106
  self.class == o.class &&
87
- url == o.url
107
+ url == o.url &&
108
+ id == o.id
88
109
  end
89
110
 
90
111
  # @see the `==` method
@@ -96,7 +117,7 @@ module Patch
96
117
  # Calculates hash code according to all attributes.
97
118
  # @return [Integer] Hash code
98
119
  def hash
99
- [url].hash
120
+ [url, id].hash
100
121
  end
101
122
 
102
123
  # Builds the object from hash