patch_ruby 1.22.0 → 1.24.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +1 -1
- data/README.md +32 -2
- data/lib/patch_ruby/api/estimates_api.rb +287 -7
- data/lib/patch_ruby/api/orders_api.rb +11 -4
- data/lib/patch_ruby/api/projects_api.rb +2 -2
- data/lib/patch_ruby/api_client.rb +1 -1
- data/lib/patch_ruby/models/allocation.rb +1 -1
- data/lib/patch_ruby/models/create_air_shipping_estimate_request.rb +374 -0
- data/lib/patch_ruby/models/create_order_request.rb +16 -7
- data/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb +404 -0
- data/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +507 -0
- data/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb +461 -0
- data/lib/patch_ruby/models/estimate.rb +1 -1
- data/lib/patch_ruby/models/order.rb +20 -7
- data/lib/patch_ruby/models/order_issued_to.rb +242 -0
- data/lib/patch_ruby/models/place_order_request.rb +228 -0
- data/lib/patch_ruby/models/project.rb +2 -2
- data/lib/patch_ruby/version.rb +1 -1
- data/lib/patch_ruby.rb +6 -0
- data/spec/integration/estimates_spec.rb +151 -0
- data/spec/integration/orders_spec.rb +34 -0
- data/spec/integration/projects_spec.rb +2 -2
- metadata +31 -25
@@ -0,0 +1,242 @@
|
|
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: engineering@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Patch
|
17
|
+
# An object containing the name & email of the party the inventory will be issued to.
|
18
|
+
class OrderIssuedTo
|
19
|
+
# The name of the issuee
|
20
|
+
attr_accessor :name
|
21
|
+
|
22
|
+
# The email address of the issuee
|
23
|
+
attr_accessor :email
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'name' => :'name',
|
29
|
+
:'email' => :'email'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns all the JSON keys this model knows about
|
34
|
+
def self.acceptable_attributes
|
35
|
+
attribute_map.values
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.openapi_types
|
40
|
+
{
|
41
|
+
:'name' => :'String',
|
42
|
+
:'email' => :'String'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# List of attributes with nullable: true
|
47
|
+
def self.openapi_nullable
|
48
|
+
Set.new([
|
49
|
+
:'name',
|
50
|
+
:'email'
|
51
|
+
])
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
56
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
57
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
58
|
+
def self.method_missing(message, *args, &block)
|
59
|
+
if Object.const_defined?('Patch::OrderIssuedTosApi::OPERATIONS') && Patch::OrderIssuedTosApi::OPERATIONS.include?(message)
|
60
|
+
Patch::OrderIssuedTosApi.new.send(message, *args)
|
61
|
+
else
|
62
|
+
super
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Initializes the object
|
67
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
68
|
+
def initialize(attributes = {})
|
69
|
+
if (!attributes.is_a?(Hash))
|
70
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::OrderIssuedTo` initialize method"
|
71
|
+
end
|
72
|
+
|
73
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
74
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
75
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
76
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::OrderIssuedTo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
77
|
+
end
|
78
|
+
h[k.to_sym] = v
|
79
|
+
}
|
80
|
+
|
81
|
+
if attributes.key?(:'name')
|
82
|
+
self.name = attributes[:'name']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:'email')
|
86
|
+
self.email = attributes[:'email']
|
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
|
+
invalid_properties
|
95
|
+
end
|
96
|
+
|
97
|
+
# Check to see if the all the properties in the model are valid
|
98
|
+
# @return true if the model is valid
|
99
|
+
def valid?
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
# Checks equality by comparing each attribute.
|
104
|
+
# @param [Object] Object to be compared
|
105
|
+
def ==(o)
|
106
|
+
return true if self.equal?(o)
|
107
|
+
self.class == o.class &&
|
108
|
+
name == o.name &&
|
109
|
+
email == o.email
|
110
|
+
end
|
111
|
+
|
112
|
+
# @see the `==` method
|
113
|
+
# @param [Object] Object to be compared
|
114
|
+
def eql?(o)
|
115
|
+
self == o
|
116
|
+
end
|
117
|
+
|
118
|
+
# Calculates hash code according to all attributes.
|
119
|
+
# @return [Integer] Hash code
|
120
|
+
def hash
|
121
|
+
[name, email].hash
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def self.build_from_hash(attributes)
|
128
|
+
new.build_from_hash(attributes)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Builds the object from hash
|
132
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
133
|
+
# @return [Object] Returns the model itself
|
134
|
+
def build_from_hash(attributes)
|
135
|
+
return nil unless attributes.is_a?(Hash)
|
136
|
+
self.class.openapi_types.each_pair do |key, type|
|
137
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
138
|
+
self.send("#{key}=", nil)
|
139
|
+
elsif type =~ /\AArray<(.*)>/i
|
140
|
+
# check to ensure the input is an array given that the attribute
|
141
|
+
# is documented as an array but the input is not
|
142
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
143
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
144
|
+
end
|
145
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
146
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
# Deserializes the data based on type
|
154
|
+
# @param string type Data type
|
155
|
+
# @param string value Value to be deserialized
|
156
|
+
# @return [Object] Deserialized data
|
157
|
+
def _deserialize(type, value)
|
158
|
+
case type.to_sym
|
159
|
+
when :Time
|
160
|
+
Time.parse(value)
|
161
|
+
when :Date
|
162
|
+
Date.parse(value)
|
163
|
+
when :String
|
164
|
+
value.to_s
|
165
|
+
when :Integer
|
166
|
+
value.to_i
|
167
|
+
when :Float
|
168
|
+
value.to_f
|
169
|
+
when :Boolean
|
170
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
171
|
+
true
|
172
|
+
else
|
173
|
+
false
|
174
|
+
end
|
175
|
+
when :Object
|
176
|
+
# generic object (usually a Hash), return directly
|
177
|
+
value
|
178
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
179
|
+
inner_type = Regexp.last_match[:inner_type]
|
180
|
+
value.map { |v| _deserialize(inner_type, v) }
|
181
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
182
|
+
k_type = Regexp.last_match[:k_type]
|
183
|
+
v_type = Regexp.last_match[:v_type]
|
184
|
+
{}.tap do |hash|
|
185
|
+
value.each do |k, v|
|
186
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
else # model
|
190
|
+
# models (e.g. Pet) or oneOf
|
191
|
+
klass = Patch.const_get(type)
|
192
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the string representation of the object
|
197
|
+
# @return [String] String presentation of the object
|
198
|
+
def to_s
|
199
|
+
to_hash.to_s
|
200
|
+
end
|
201
|
+
|
202
|
+
# to_body is an alias to to_hash (backward compatibility)
|
203
|
+
# @return [Hash] Returns the object in the form of hash
|
204
|
+
def to_body
|
205
|
+
to_hash
|
206
|
+
end
|
207
|
+
|
208
|
+
# Returns the object in the form of hash
|
209
|
+
# @return [Hash] Returns the object in the form of hash
|
210
|
+
def to_hash
|
211
|
+
hash = {}
|
212
|
+
self.class.attribute_map.each_pair do |attr, param|
|
213
|
+
value = self.send(attr)
|
214
|
+
if value.nil?
|
215
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
216
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
217
|
+
end
|
218
|
+
|
219
|
+
hash[param] = _to_hash(value)
|
220
|
+
end
|
221
|
+
hash
|
222
|
+
end
|
223
|
+
|
224
|
+
# Outputs non-array value in the form of hash
|
225
|
+
# For object, use to_hash. Otherwise, just return the value
|
226
|
+
# @param [Object] value Any valid value
|
227
|
+
# @return [Hash] Returns the value in the form of hash
|
228
|
+
def _to_hash(value)
|
229
|
+
if value.is_a?(Array)
|
230
|
+
value.compact.map { |v| _to_hash(v) }
|
231
|
+
elsif value.is_a?(Hash)
|
232
|
+
{}.tap do |hash|
|
233
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
234
|
+
end
|
235
|
+
elsif value.respond_to? :to_hash
|
236
|
+
value.to_hash
|
237
|
+
else
|
238
|
+
value
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
@@ -0,0 +1,228 @@
|
|
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: engineering@usepatch.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Patch
|
17
|
+
class PlaceOrderRequest
|
18
|
+
attr_accessor :issued_to
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'issued_to' => :'issued_to'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns all the JSON keys this model knows about
|
28
|
+
def self.acceptable_attributes
|
29
|
+
attribute_map.values
|
30
|
+
end
|
31
|
+
|
32
|
+
# Attribute type mapping.
|
33
|
+
def self.openapi_types
|
34
|
+
{
|
35
|
+
:'issued_to' => :'OrderIssuedTo'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# List of attributes with nullable: true
|
40
|
+
def self.openapi_nullable
|
41
|
+
Set.new([
|
42
|
+
])
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
# Allows models with corresponding API classes to delegate API operations to those API classes
|
47
|
+
# Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
|
48
|
+
# Eg. Order.create_order delegates to OrdersApi.new.create_order
|
49
|
+
def self.method_missing(message, *args, &block)
|
50
|
+
if Object.const_defined?('Patch::PlaceOrderRequestsApi::OPERATIONS') && Patch::PlaceOrderRequestsApi::OPERATIONS.include?(message)
|
51
|
+
Patch::PlaceOrderRequestsApi.new.send(message, *args)
|
52
|
+
else
|
53
|
+
super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Initializes the object
|
58
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
59
|
+
def initialize(attributes = {})
|
60
|
+
if (!attributes.is_a?(Hash))
|
61
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::PlaceOrderRequest` initialize method"
|
62
|
+
end
|
63
|
+
|
64
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
65
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
66
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
67
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::PlaceOrderRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
68
|
+
end
|
69
|
+
h[k.to_sym] = v
|
70
|
+
}
|
71
|
+
|
72
|
+
if attributes.key?(:'issued_to')
|
73
|
+
self.issued_to = attributes[:'issued_to']
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
78
|
+
# @return Array for valid properties with the reasons
|
79
|
+
def list_invalid_properties
|
80
|
+
invalid_properties = Array.new
|
81
|
+
invalid_properties
|
82
|
+
end
|
83
|
+
|
84
|
+
# Check to see if the all the properties in the model are valid
|
85
|
+
# @return true if the model is valid
|
86
|
+
def valid?
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
# Checks equality by comparing each attribute.
|
91
|
+
# @param [Object] Object to be compared
|
92
|
+
def ==(o)
|
93
|
+
return true if self.equal?(o)
|
94
|
+
self.class == o.class &&
|
95
|
+
issued_to == o.issued_to
|
96
|
+
end
|
97
|
+
|
98
|
+
# @see the `==` method
|
99
|
+
# @param [Object] Object to be compared
|
100
|
+
def eql?(o)
|
101
|
+
self == o
|
102
|
+
end
|
103
|
+
|
104
|
+
# Calculates hash code according to all attributes.
|
105
|
+
# @return [Integer] Hash code
|
106
|
+
def hash
|
107
|
+
[issued_to].hash
|
108
|
+
end
|
109
|
+
|
110
|
+
# Builds the object from hash
|
111
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
112
|
+
# @return [Object] Returns the model itself
|
113
|
+
def self.build_from_hash(attributes)
|
114
|
+
new.build_from_hash(attributes)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Builds the object from hash
|
118
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
119
|
+
# @return [Object] Returns the model itself
|
120
|
+
def build_from_hash(attributes)
|
121
|
+
return nil unless attributes.is_a?(Hash)
|
122
|
+
self.class.openapi_types.each_pair do |key, type|
|
123
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
124
|
+
self.send("#{key}=", nil)
|
125
|
+
elsif type =~ /\AArray<(.*)>/i
|
126
|
+
# check to ensure the input is an array given that the attribute
|
127
|
+
# is documented as an array but the input is not
|
128
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
129
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
130
|
+
end
|
131
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
132
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
self
|
137
|
+
end
|
138
|
+
|
139
|
+
# Deserializes the data based on type
|
140
|
+
# @param string type Data type
|
141
|
+
# @param string value Value to be deserialized
|
142
|
+
# @return [Object] Deserialized data
|
143
|
+
def _deserialize(type, value)
|
144
|
+
case type.to_sym
|
145
|
+
when :Time
|
146
|
+
Time.parse(value)
|
147
|
+
when :Date
|
148
|
+
Date.parse(value)
|
149
|
+
when :String
|
150
|
+
value.to_s
|
151
|
+
when :Integer
|
152
|
+
value.to_i
|
153
|
+
when :Float
|
154
|
+
value.to_f
|
155
|
+
when :Boolean
|
156
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
157
|
+
true
|
158
|
+
else
|
159
|
+
false
|
160
|
+
end
|
161
|
+
when :Object
|
162
|
+
# generic object (usually a Hash), return directly
|
163
|
+
value
|
164
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
165
|
+
inner_type = Regexp.last_match[:inner_type]
|
166
|
+
value.map { |v| _deserialize(inner_type, v) }
|
167
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
168
|
+
k_type = Regexp.last_match[:k_type]
|
169
|
+
v_type = Regexp.last_match[:v_type]
|
170
|
+
{}.tap do |hash|
|
171
|
+
value.each do |k, v|
|
172
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
else # model
|
176
|
+
# models (e.g. Pet) or oneOf
|
177
|
+
klass = Patch.const_get(type)
|
178
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Returns the string representation of the object
|
183
|
+
# @return [String] String presentation of the object
|
184
|
+
def to_s
|
185
|
+
to_hash.to_s
|
186
|
+
end
|
187
|
+
|
188
|
+
# to_body is an alias to to_hash (backward compatibility)
|
189
|
+
# @return [Hash] Returns the object in the form of hash
|
190
|
+
def to_body
|
191
|
+
to_hash
|
192
|
+
end
|
193
|
+
|
194
|
+
# Returns the object in the form of hash
|
195
|
+
# @return [Hash] Returns the object in the form of hash
|
196
|
+
def to_hash
|
197
|
+
hash = {}
|
198
|
+
self.class.attribute_map.each_pair do |attr, param|
|
199
|
+
value = self.send(attr)
|
200
|
+
if value.nil?
|
201
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
202
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
203
|
+
end
|
204
|
+
|
205
|
+
hash[param] = _to_hash(value)
|
206
|
+
end
|
207
|
+
hash
|
208
|
+
end
|
209
|
+
|
210
|
+
# Outputs non-array value in the form of hash
|
211
|
+
# For object, use to_hash. Otherwise, just return the value
|
212
|
+
# @param [Object] value Any valid value
|
213
|
+
# @return [Hash] Returns the value in the form of hash
|
214
|
+
def _to_hash(value)
|
215
|
+
if value.is_a?(Array)
|
216
|
+
value.compact.map { |v| _to_hash(v) }
|
217
|
+
elsif value.is_a?(Hash)
|
218
|
+
{}.tap do |hash|
|
219
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
220
|
+
end
|
221
|
+
elsif value.respond_to? :to_hash
|
222
|
+
value.to_hash
|
223
|
+
else
|
224
|
+
value
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
@@ -18,7 +18,7 @@ module Patch
|
|
18
18
|
# A unique uid for the record. UIDs will be prepended by pro_prod or pro_test depending on the mode it was created in.
|
19
19
|
attr_accessor :id
|
20
20
|
|
21
|
-
# A boolean indicating if this project is a production or
|
21
|
+
# A boolean indicating if this project is a production or demo mode project.
|
22
22
|
attr_accessor :production
|
23
23
|
|
24
24
|
# The name of the project.
|
@@ -30,7 +30,7 @@ module Patch
|
|
30
30
|
# DEPRECATED. Favor the technology_type field instead.
|
31
31
|
attr_accessor :type
|
32
32
|
|
33
|
-
# The mechanism of the project.
|
33
|
+
# The mechanism of the project. One of: removal, avoidance, avoidance_and_removal.
|
34
34
|
attr_accessor :mechanism
|
35
35
|
|
36
36
|
# The country of origin of the project.
|
data/lib/patch_ruby/version.rb
CHANGED
data/lib/patch_ruby.rb
CHANGED
@@ -18,12 +18,16 @@ require 'patch_ruby/configuration'
|
|
18
18
|
|
19
19
|
# Models
|
20
20
|
require 'patch_ruby/models/allocation'
|
21
|
+
require 'patch_ruby/models/create_air_shipping_estimate_request'
|
21
22
|
require 'patch_ruby/models/create_bitcoin_estimate_request'
|
22
23
|
require 'patch_ruby/models/create_ethereum_estimate_request'
|
23
24
|
require 'patch_ruby/models/create_flight_estimate_request'
|
24
25
|
require 'patch_ruby/models/create_hotel_estimate_request'
|
25
26
|
require 'patch_ruby/models/create_mass_estimate_request'
|
26
27
|
require 'patch_ruby/models/create_order_request'
|
28
|
+
require 'patch_ruby/models/create_rail_shipping_estimate_request'
|
29
|
+
require 'patch_ruby/models/create_road_shipping_estimate_request'
|
30
|
+
require 'patch_ruby/models/create_sea_shipping_estimate_request'
|
27
31
|
require 'patch_ruby/models/create_shipping_estimate_request'
|
28
32
|
require 'patch_ruby/models/create_success_response'
|
29
33
|
require 'patch_ruby/models/create_vehicle_estimate_request'
|
@@ -37,10 +41,12 @@ require 'patch_ruby/models/meta_index_object'
|
|
37
41
|
require 'patch_ruby/models/order'
|
38
42
|
require 'patch_ruby/models/order_inventory'
|
39
43
|
require 'patch_ruby/models/order_inventory_project'
|
44
|
+
require 'patch_ruby/models/order_issued_to'
|
40
45
|
require 'patch_ruby/models/order_list_response'
|
41
46
|
require 'patch_ruby/models/order_response'
|
42
47
|
require 'patch_ruby/models/parent_technology_type'
|
43
48
|
require 'patch_ruby/models/photo'
|
49
|
+
require 'patch_ruby/models/place_order_request'
|
44
50
|
require 'patch_ruby/models/project'
|
45
51
|
require 'patch_ruby/models/project_list_response'
|
46
52
|
require 'patch_ruby/models/project_response'
|
@@ -171,4 +171,155 @@ RSpec.describe 'Estimates Integration' do
|
|
171
171
|
expect(create_estimate_response.data.mass_g).to be >= 100_000
|
172
172
|
expect(create_estimate_response.data.id).not_to be_nil
|
173
173
|
end
|
174
|
+
|
175
|
+
context "when creating an air shipping estimate" do
|
176
|
+
it "supports creating an estimate using airports" do
|
177
|
+
air_shipping_estimate = Patch::Estimate.create_air_shipping_estimate(
|
178
|
+
aircraft_type: "cargo",
|
179
|
+
create_order: false,
|
180
|
+
destination_airport: "JFK",
|
181
|
+
freight_mass_g: 31_300,
|
182
|
+
origin_airport: "SFO"
|
183
|
+
)
|
184
|
+
expect(air_shipping_estimate.data.type).to eq('shipping_air')
|
185
|
+
expect(air_shipping_estimate.data.mass_g).to be >= 20_000
|
186
|
+
end
|
187
|
+
|
188
|
+
it "supports creating an estimate with an order" do
|
189
|
+
air_shipping_estimate = Patch::Estimate.create_air_shipping_estimate(
|
190
|
+
aircraft_type: "cargo",
|
191
|
+
create_order: true,
|
192
|
+
destination_airport: "JFK",
|
193
|
+
freight_mass_g: 19_140,
|
194
|
+
origin_airport: "SFO"
|
195
|
+
)
|
196
|
+
expect(air_shipping_estimate.data.type).to eq('shipping_air')
|
197
|
+
expect(air_shipping_estimate.data.mass_g).to be >= 20_000
|
198
|
+
expect(air_shipping_estimate.data.order.amount).to be >= 10_000
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
context "when creating a rail shipping estimate" do
|
203
|
+
it "supports creating an estimate using locodes" do
|
204
|
+
rail_shipping_estimate = Patch::Estimate.create_rail_shipping_estimate(
|
205
|
+
create_order: false,
|
206
|
+
destination_locode: "USSEA",
|
207
|
+
emissions_scope: "wtw",
|
208
|
+
freight_mass_g: 419_060,
|
209
|
+
fuel_type: "diesel",
|
210
|
+
origin_locode: "USSD2"
|
211
|
+
)
|
212
|
+
expect(rail_shipping_estimate.data.type).to eq('shipping_rail')
|
213
|
+
expect(rail_shipping_estimate.data.mass_g).to be >= 15_000
|
214
|
+
end
|
215
|
+
|
216
|
+
it "supports creating an estimate using postal codes" do
|
217
|
+
rail_shipping_estimate = Patch::Estimate.create_rail_shipping_estimate(
|
218
|
+
create_order: false,
|
219
|
+
destination_country_code: "US",
|
220
|
+
destination_postal_code: "97209",
|
221
|
+
emissions_scope: "wtw",
|
222
|
+
freight_mass_g: 226_000,
|
223
|
+
fuel_type: "diesel",
|
224
|
+
origin_country_code: "US",
|
225
|
+
origin_postal_code: "90210"
|
226
|
+
)
|
227
|
+
expect(rail_shipping_estimate.data.type).to eq('shipping_rail')
|
228
|
+
expect(rail_shipping_estimate.data.mass_g).to be >= 4_000
|
229
|
+
end
|
230
|
+
|
231
|
+
it "supports creating an estimate with an order" do
|
232
|
+
rail_shipping_estimate = Patch::Estimate.create_rail_shipping_estimate(
|
233
|
+
create_order: true,
|
234
|
+
destination_locode: "USSEA",
|
235
|
+
freight_mass_g: 359_000,
|
236
|
+
origin_locode: "USSD2"
|
237
|
+
)
|
238
|
+
expect(rail_shipping_estimate.data.type).to eq('shipping_rail')
|
239
|
+
expect(rail_shipping_estimate.data.mass_g).to be >= 15_000
|
240
|
+
expect(rail_shipping_estimate.data.order.amount).to be >= 10_000
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context "when creating a road shipping estimate" do
|
245
|
+
it "supports creating an estimate using locodes" do
|
246
|
+
road_shipping_estimate = Patch::Estimate.create_road_shipping_estimate(
|
247
|
+
create_order: false,
|
248
|
+
container_size_code: "20GP",
|
249
|
+
destination_locode: "USSEA",
|
250
|
+
emissions_scope: "wtw",
|
251
|
+
freight_mass_g: 124_870,
|
252
|
+
origin_locode: "USSD2"
|
253
|
+
)
|
254
|
+
expect(road_shipping_estimate.data.type).to eq('shipping_road')
|
255
|
+
expect(road_shipping_estimate.data.mass_g).to be >= 15_000
|
256
|
+
end
|
257
|
+
|
258
|
+
it "supports creating an estimate using postal codes" do
|
259
|
+
road_shipping_estimate = Patch::Estimate.create_road_shipping_estimate(
|
260
|
+
create_order: false,
|
261
|
+
destination_country_code: "US",
|
262
|
+
destination_postal_code: "97209",
|
263
|
+
emissions_scope: "wtw",
|
264
|
+
freight_mass_g: 226_000,
|
265
|
+
origin_country_code: "US",
|
266
|
+
origin_postal_code: "90210"
|
267
|
+
)
|
268
|
+
expect(road_shipping_estimate.data.type).to eq('shipping_road')
|
269
|
+
expect(road_shipping_estimate.data.mass_g).to be >= 4_000
|
270
|
+
end
|
271
|
+
|
272
|
+
it "supports creating an estimate with an order" do
|
273
|
+
road_shipping_estimate = Patch::Estimate.create_road_shipping_estimate(
|
274
|
+
create_order: true,
|
275
|
+
destination_locode: "USSEA",
|
276
|
+
freight_mass_g: 359_000,
|
277
|
+
origin_locode: "USSD2"
|
278
|
+
)
|
279
|
+
expect(road_shipping_estimate.data.type).to eq('shipping_road')
|
280
|
+
expect(road_shipping_estimate.data.mass_g).to be >= 15_000
|
281
|
+
expect(road_shipping_estimate.data.order.amount).to be >= 10_000
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
context "when creating a sea shipping estimate" do
|
286
|
+
it "supports creating an estimate using locodes" do
|
287
|
+
sea_shipping_estimate = Patch::Estimate.create_sea_shipping_estimate(
|
288
|
+
create_order: false,
|
289
|
+
container_size_code: "20GP",
|
290
|
+
destination_locode: "HKHKG",
|
291
|
+
emissions_scope: "wtw",
|
292
|
+
freight_mass_g: 124_870,
|
293
|
+
origin_locode: "FRMRS"
|
294
|
+
)
|
295
|
+
expect(sea_shipping_estimate.data.type).to eq('shipping_sea')
|
296
|
+
expect(sea_shipping_estimate.data.mass_g).to be >= 10_000
|
297
|
+
end
|
298
|
+
|
299
|
+
it "supports creating an estimate using postal codes" do
|
300
|
+
sea_shipping_estimate = Patch::Estimate.create_sea_shipping_estimate(
|
301
|
+
create_order: false,
|
302
|
+
destination_country_code: "US",
|
303
|
+
destination_postal_code: "97209",
|
304
|
+
emissions_scope: "wtw",
|
305
|
+
freight_mass_g: 226_000,
|
306
|
+
origin_country_code: "US",
|
307
|
+
origin_postal_code: "90210"
|
308
|
+
)
|
309
|
+
expect(sea_shipping_estimate.data.type).to eq('shipping_sea')
|
310
|
+
expect(sea_shipping_estimate.data.mass_g).to be >= 4_000
|
311
|
+
end
|
312
|
+
|
313
|
+
it "supports creating an estimate with an order" do
|
314
|
+
sea_shipping_estimate = Patch::Estimate.create_sea_shipping_estimate(
|
315
|
+
create_order: true,
|
316
|
+
destination_locode: "USSEA",
|
317
|
+
freight_mass_g: 359_000,
|
318
|
+
origin_locode: "USSD2"
|
319
|
+
)
|
320
|
+
expect(sea_shipping_estimate.data.type).to eq('shipping_sea')
|
321
|
+
expect(sea_shipping_estimate.data.mass_g).to be >= 15_000
|
322
|
+
expect(sea_shipping_estimate.data.order.amount).to be >= 10_000
|
323
|
+
end
|
324
|
+
end
|
174
325
|
end
|