deliveree_sdk 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,271 @@
1
+ =begin
2
+ #Deliveree SDK
3
+ #With Deliveree API, developers can integrate our on-demand local delivery platform into their applications. The API is designed for developers to check prices, book an immediate or scheduled delivery and follow updates until delivery completion.
4
+ Contact: duke@deliveree.com
5
+ =end
6
+
7
+ require 'date'
8
+
9
+ module Deliveree
10
+ class Location
11
+ attr_accessor :address
12
+
13
+ attr_accessor :latitude
14
+
15
+ attr_accessor :longitude
16
+
17
+ attr_accessor :recipient_name
18
+
19
+ attr_accessor :recipient_phone
20
+
21
+ attr_accessor :note
22
+
23
+ attr_accessor :need_cod
24
+
25
+ attr_accessor :cod_note
26
+
27
+ attr_accessor :cod_invoice_fees
28
+
29
+ attr_accessor :need_pod
30
+
31
+ attr_accessor :pod_note
32
+
33
+ attr_accessor :position_trackings
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'address' => :'address',
39
+ :'latitude' => :'latitude',
40
+ :'longitude' => :'longitude',
41
+ :'recipient_name' => :'recipient_name',
42
+ :'recipient_phone' => :'recipient_phone',
43
+ :'note' => :'note',
44
+ :'need_cod' => :'need_cod',
45
+ :'cod_note' => :'cod_note',
46
+ :'cod_invoice_fees' => :'cod_invoice_fees',
47
+ :'need_pod' => :'need_pod',
48
+ :'pod_note' => :'pod_note',
49
+ :'position_trackings' => :'position_trackings'
50
+ }
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.attribute_types
55
+ {
56
+ :'address' => :'String',
57
+ :'latitude' => :'Float',
58
+ :'longitude' => :'Float',
59
+ :'recipient_name' => :'String',
60
+ :'recipient_phone' => :'String',
61
+ :'note' => :'String',
62
+ :'need_cod' => :'BOOLEAN',
63
+ :'cod_note' => :'String',
64
+ :'cod_invoice_fees' => :'Float',
65
+ :'need_pod' => :'BOOLEAN',
66
+ :'pod_note' => :'String',
67
+ :'position_trackings' => :'Array<PositionTracking>'
68
+ }
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ return unless attributes.is_a?(Hash)
75
+
76
+ # convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
78
+
79
+ # To make sure attribute mandatory
80
+ self.address = attributes[:'address']
81
+ self.latitude = attributes[:'latitude']
82
+ self.longitude = attributes[:'longitude']
83
+
84
+ if attributes.has_key?(:'recipient_name')
85
+ self.recipient_name = attributes[:'recipient_name']
86
+ end
87
+
88
+ if attributes.has_key?(:'recipient_phone')
89
+ self.recipient_phone = attributes[:'recipient_phone']
90
+ end
91
+
92
+ if attributes.has_key?(:'note')
93
+ self.note = attributes[:'note']
94
+ end
95
+
96
+ if attributes.has_key?(:'need_cod')
97
+ self.need_cod = attributes[:'need_cod']
98
+ end
99
+
100
+ if attributes.has_key?(:'cod_note')
101
+ self.cod_note = attributes[:'cod_note']
102
+ end
103
+
104
+ if attributes.has_key?(:'cod_invoice_fees')
105
+ self.cod_invoice_fees = attributes[:'cod_invoice_fees']
106
+ end
107
+
108
+ if attributes.has_key?(:'need_pod')
109
+ self.need_pod = attributes[:'need_pod']
110
+ end
111
+
112
+ if attributes.has_key?(:'pod_note')
113
+ self.pod_note = attributes[:'pod_note']
114
+ end
115
+
116
+ if attributes.has_key?(:'position_trackings')
117
+ if (value = attributes[:'position_trackings']).is_a?(Array)
118
+ self.position_trackings = value
119
+ end
120
+ end
121
+ end
122
+
123
+ # Show invalid properties with the reasons. Usually used together with valid?
124
+ # @return Array for valid properties with the reasons
125
+ def list_invalid_properties
126
+ invalid_properties = Array.new
127
+ invalid_properties
128
+ end
129
+
130
+ # Check to see if the all the properties in the model are valid
131
+ # @return true if the model is valid
132
+ def valid?
133
+ true
134
+ end
135
+
136
+ # Checks equality by comparing each attribute.
137
+ # @param [Object] Object to be compared
138
+ def ==(o)
139
+ return true if self.equal?(o)
140
+ self.class == o.class &&
141
+ address == o.address &&
142
+ latitude == o.latitude &&
143
+ longitude == o.longitude &&
144
+ recipient_name == o.recipient_name &&
145
+ recipient_phone == o.recipient_phone &&
146
+ note == o.note &&
147
+ need_cod == o.need_cod &&
148
+ cod_note == o.cod_note &&
149
+ cod_invoice_fees == o.cod_invoice_fees &&
150
+ need_pod == o.need_pod &&
151
+ pod_note == o.pod_note &&
152
+ position_trackings == o.position_trackings
153
+ end
154
+
155
+ # @see the `==` method
156
+ # @param [Object] Object to be compared
157
+ def eql?(o)
158
+ self == o
159
+ end
160
+
161
+ # Calculates hash code according to all attributes.
162
+ # @return [Fixnum] Hash code
163
+ def hash
164
+ [address, latitude, longitude, recipient_name, recipient_phone, note, need_cod, cod_note, cod_invoice_fees, need_pod, pod_note, position_trackings].hash
165
+ end
166
+
167
+ # Builds the object from hash
168
+ # @param [Hash] attributes Model attributes in the form of hash
169
+ # @return [Object] Returns the model itself
170
+ def build_from_hash(attributes)
171
+ return nil unless attributes.is_a?(Hash)
172
+ self.class.attribute_types.each_pair do |key, type|
173
+ if type =~ /\AArray<(.*)>/i
174
+ # check to ensure the input is an array given that the the attribute
175
+ # is documented as an array but the input is not
176
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
177
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
178
+ end
179
+ elsif !attributes[self.class.attribute_map[key]].nil?
180
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
181
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
182
+ end
183
+
184
+ self
185
+ end
186
+
187
+ # Deserializes the data based on type
188
+ # @param string type Data type
189
+ # @param string value Value to be deserialized
190
+ # @return [Object] Deserialized data
191
+ def _deserialize(type, value)
192
+ case type.to_sym
193
+ when :DateTime
194
+ DateTime.parse(value)
195
+ when :Date
196
+ Date.parse(value)
197
+ when :String
198
+ value.to_s
199
+ when :Integer
200
+ value.to_i
201
+ when :Float
202
+ value.to_f
203
+ when :BOOLEAN
204
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
205
+ true
206
+ else
207
+ false
208
+ end
209
+ when :Object
210
+ # generic object (usually a Hash), return directly
211
+ value
212
+ when /\AArray<(?<inner_type>.+)>\z/
213
+ inner_type = Regexp.last_match[:inner_type]
214
+ value.map { |v| _deserialize(inner_type, v) }
215
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
216
+ k_type = Regexp.last_match[:k_type]
217
+ v_type = Regexp.last_match[:v_type]
218
+ {}.tap do |hash|
219
+ value.each do |k, v|
220
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
221
+ end
222
+ end
223
+ else # model
224
+ temp_model = Deliveree.const_get(type).new
225
+ temp_model.build_from_hash(value)
226
+ end
227
+ end
228
+
229
+ # Returns the string representation of the object
230
+ # @return [String] String presentation of the object
231
+ def to_s
232
+ to_hash.to_s
233
+ end
234
+
235
+ # to_body is an alias to to_hash (backward compatibility)
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_body
238
+ to_hash
239
+ end
240
+
241
+ # Returns the object in the form of hash
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_hash
244
+ hash = {}
245
+ self.class.attribute_map.each_pair do |attr, param|
246
+ value = self.send(attr)
247
+ next if value.nil?
248
+ hash[param] = _to_hash(value)
249
+ end
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+ end
271
+ end
@@ -0,0 +1,213 @@
1
+ =begin
2
+ #Deliveree SDK
3
+ #With Deliveree API, developers can integrate our on-demand local delivery platform into their applications. The API is designed for developers to check prices, book an immediate or scheduled delivery and follow updates until delivery completion.
4
+ Contact: duke@deliveree.com
5
+ =end
6
+
7
+ require 'date'
8
+
9
+ module Deliveree
10
+ class PositionTracking
11
+ attr_accessor :id
12
+
13
+ attr_accessor :latitude
14
+
15
+ attr_accessor :longitude
16
+
17
+ attr_accessor :tracked_at
18
+
19
+ attr_accessor :tracking_type
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'id' => :'id',
25
+ :'latitude' => :'latitude',
26
+ :'longitude' => :'longitude',
27
+ :'tracked_at' => :'tracked_at',
28
+ :'tracking_type' => :'tracking_type'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.attribute_types
34
+ {
35
+ :'id' => :'Integer',
36
+ :'latitude' => :'Float',
37
+ :'longitude' => :'Float',
38
+ :'tracked_at' => :'DateTime',
39
+ :'tracking_type' => :'String'
40
+ }
41
+ end
42
+
43
+ # Initializes the object
44
+ # @param [Hash] attributes Model attributes in the form of hash
45
+ def initialize(attributes = {})
46
+ return unless attributes.is_a?(Hash)
47
+
48
+ # convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
50
+
51
+ if attributes.has_key?(:'id')
52
+ self.id = attributes[:'id']
53
+ end
54
+
55
+ if attributes.has_key?(:'latitude')
56
+ self.latitude = attributes[:'latitude']
57
+ end
58
+
59
+ if attributes.has_key?(:'longitude')
60
+ self.longitude = attributes[:'longitude']
61
+ end
62
+
63
+ if attributes.has_key?(:'tracked_at')
64
+ self.tracked_at = attributes[:'tracked_at']
65
+ end
66
+
67
+ if attributes.has_key?(:'tracking_type')
68
+ self.tracking_type = attributes[:'tracking_type']
69
+ end
70
+ end
71
+
72
+ # Show invalid properties with the reasons. Usually used together with valid?
73
+ # @return Array for valid properties with the reasons
74
+ def list_invalid_properties
75
+ invalid_properties = Array.new
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ true
83
+ end
84
+
85
+ # Checks equality by comparing each attribute.
86
+ # @param [Object] Object to be compared
87
+ def ==(o)
88
+ return true if self.equal?(o)
89
+ self.class == o.class &&
90
+ id == o.id &&
91
+ latitude == o.latitude &&
92
+ longitude == o.longitude &&
93
+ tracked_at == o.tracked_at &&
94
+ tracking_type == o.tracking_type
95
+ end
96
+
97
+ # @see the `==` method
98
+ # @param [Object] Object to be compared
99
+ def eql?(o)
100
+ self == o
101
+ end
102
+
103
+ # Calculates hash code according to all attributes.
104
+ # @return [Fixnum] Hash code
105
+ def hash
106
+ [id, latitude, longitude, tracked_at, tracking_type].hash
107
+ end
108
+
109
+ # Builds the object from hash
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ # @return [Object] Returns the model itself
112
+ def build_from_hash(attributes)
113
+ return nil unless attributes.is_a?(Hash)
114
+ self.class.attribute_types.each_pair do |key, type|
115
+ if type =~ /\AArray<(.*)>/i
116
+ # check to ensure the input is an array given that the the attribute
117
+ # is documented as an array but the input is not
118
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
119
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
120
+ end
121
+ elsif !attributes[self.class.attribute_map[key]].nil?
122
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
124
+ end
125
+
126
+ self
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def _deserialize(type, value)
134
+ case type.to_sym
135
+ when :DateTime
136
+ DateTime.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :BOOLEAN
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ temp_model = Deliveree.const_get(type).new
167
+ temp_model.build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ next if value.nil?
190
+ hash[param] = _to_hash(value)
191
+ end
192
+ hash
193
+ end
194
+
195
+ # Outputs non-array value in the form of hash
196
+ # For object, use to_hash. Otherwise, just return the value
197
+ # @param [Object] value Any valid value
198
+ # @return [Hash] Returns the value in the form of hash
199
+ def _to_hash(value)
200
+ if value.is_a?(Array)
201
+ value.compact.map { |v| _to_hash(v) }
202
+ elsif value.is_a?(Hash)
203
+ {}.tap do |hash|
204
+ value.each { |k, v| hash[k] = _to_hash(v) }
205
+ end
206
+ elsif value.respond_to? :to_hash
207
+ value.to_hash
208
+ else
209
+ value
210
+ end
211
+ end
212
+ end
213
+ end