Class: AftershipAPI::Model::Checkpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/aftership-tracking-sdk/models/checkpoint.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Checkpoint

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 79

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::Checkpoint` initialize method"
  end

  attributes = attributes.each_with_object({}) { |(k, v), h|
    h[k.to_sym] = v
  }

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'slug')
    self.slug = attributes[:'slug']
  end

  if attributes.key?(:'checkpoint_time')
    self.checkpoint_time = attributes[:'checkpoint_time']
  end

  if attributes.key?(:'location')
    self.location = attributes[:'location']
  end

  if attributes.key?(:'city')
    self.city = attributes[:'city']
  end

  if attributes.key?(:'state')
    self.state = attributes[:'state']
  end

  if attributes.key?(:'postal_code')
    self.postal_code = attributes[:'postal_code']
  end

  if attributes.key?(:'coordinate')
    self.coordinate = attributes[:'coordinate']
  end

  if attributes.key?(:'country_region')
    self.country_region = attributes[:'country_region']
  end

  if attributes.key?(:'country_region_name')
    self.country_region_name = attributes[:'country_region_name']
  end

  if attributes.key?(:'message')
    self.message = attributes[:'message']
  end

  if attributes.key?(:'tag')
    self.tag = attributes[:'tag']
  end

  if attributes.key?(:'subtag')
    self.subtag = attributes[:'subtag']
  end

  if attributes.key?(:'subtag_message')
    self.subtag_message = attributes[:'subtag_message']
  end

  if attributes.key?(:'raw_tag')
    self.raw_tag = attributes[:'raw_tag']
  end

  if attributes.key?(:'events')
    self.events = attributes[:'events']
  end

  if attributes.key?(:'source')
    self.source = attributes[:'source']
  end

  if attributes.key?(:'hash')
    self.hash = attributes[:'hash']
  end
end

Instance Attribute Details

#checkpoint_timeObject

The date and time of the checkpoint event, provided by the carrier. It uses the timezone of the checkpoint. The format may differ depending on how the carrier provides it:- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ checkpoint_time?: String;



15
16
17
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 15

def checkpoint_time
  @checkpoint_time
end

#cityObject

City info provided by carrier city?: String;



23
24
25
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 23

def city
  @city
end

#coordinateObject

The latitude and longitude coordinates indicate the precise location of the shipments that are currently in transit. coordinate?: CheckpointCoordinate;



35
36
37
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 35

def coordinate
  @coordinate
end

#country_regionObject

Country/Region ISO Alpha-3 (three letters) of the checkpoint country_region?: String;



39
40
41
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 39

def country_region
  @country_region
end

#country_region_nameObject

Country/Region name of the checkpoint, may also contain other location info. country_region_name?: String;



43
44
45
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 43

def country_region_name
  @country_region_name
end

#created_atObject

The date and time of the checkpoint event was added to AfterShip. It uses the format YYYY-MM-DDTHH:mm:ssZ for the timezone GMT +0. created_at?: String;



7
8
9
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 7

def created_at
  @created_at
end

#eventsObject

The array provides details about specific event(s) that occurred to a shipment, such as "returned_to_sender". You can find the full list of events and reasons - The events' value for the same checkpoint message is subject to change as we consistently strive to enhance the performance of this feature. events?: CheckpointEvents;



67
68
69
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 67

def events
  @events
end

#hashObject

Unique hash identifier for each checkpoint event, could be used for deduplication. hash?: String;



75
76
77
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 75

def hash
  @hash
end

#locationObject

Location info provided by carrier location?: String;



19
20
21
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 19

def location
  @location
end

#messageObject

Checkpoint message message?: String;



47
48
49
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 47

def message
  @message
end

#postal_codeObject

Postal code info provided by carrier postal_code?: String;



31
32
33
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 31

def postal_code
  @postal_code
end

#raw_tagObject

Checkpoint raw status provided by courier raw_tag?: String;



63
64
65
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 63

def raw_tag
  @raw_tag
end

#slugObject

The unique code of courier for this checkpoint. Get courier slug slug?: String;



11
12
13
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 11

def slug
  @slug
end

#sourceObject

The source of the checkpoint, which can either be from the carrier or when the user marks the tracking as completed. source?: CheckpointSource;



71
72
73
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 71

def source
  @source
end

#stateObject

State info provided by carrier state?: String;



27
28
29
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 27

def state
  @state
end

#subtagObject

Current subtag of checkpoint. ( subtag?: String;



55
56
57
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 55

def subtag
  @subtag
end

#subtag_messageObject

Normalized checkpoint message. ( subtag_message?: String;



59
60
61
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 59

def subtag_message
  @subtag_message
end

#tagObject

Current status of tracking. ( tag?: Tag;



51
52
53
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 51

def tag
  @tag
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • type (String)

    Data type

  • value (String)

    Value to be deserialized

Returns:

  • (Object)

    Deserialized data



236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 236

def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    klass = AftershipAPI::Model.const_get(type)
    klass.build_from_hash(value)
  end
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 186

def self.attribute_map
  {
    :'created_at' => :'created_at',
    :'slug' => :'slug',
    :'checkpoint_time' => :'checkpoint_time',
    :'location' => :'location',
    :'city' => :'city',
    :'state' => :'state',
    :'postal_code' => :'postal_code',
    :'coordinate' => :'coordinate',
    :'country_region' => :'country_region',
    :'country_region_name' => :'country_region_name',
    :'message' => :'message',
    :'tag' => :'tag',
    :'subtag' => :'subtag',
    :'subtag_message' => :'subtag_message',
    :'raw_tag' => :'raw_tag',
    :'events' => :'events',
    :'source' => :'source',
    :'hash' => :'hash',
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 212

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(key) && attributes[key].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[key].is_a?(Array)
        transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[key].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[key])
    end
  end
  new(transformed_hash)
end

.openapi_typesObject

Attribute type mapping.



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 162

def self.openapi_types
  {
    :'created_at' => :'String',
    :'slug' => :'String',
    :'checkpoint_time' => :'String',
    :'location' => :'String',
    :'city' => :'String',
    :'state' => :'String',
    :'postal_code' => :'String',
    :'coordinate' => :'CheckpointCoordinate',
    :'country_region' => :'String',
    :'country_region_name' => :'String',
    :'message' => :'String',
    :'tag' => :'Tag',
    :'subtag' => :'String',
    :'subtag_message' => :'String',
    :'raw_tag' => :'String',
    :'events' => :'Array<CheckpointEvents>',
    :'source' => :'CheckpointSource',
    :'hash' => :'String',
  }
end

Instance Method Details

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 303

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



282
283
284
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 282

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



288
289
290
291
292
293
294
295
296
297
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 288

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?

    hash[param] = _to_hash(value)
  end
  hash
end

#to_json(*a) ⇒ Object



317
318
319
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 317

def to_json(*a)
  to_hash.to_json(*a)
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



276
277
278
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 276

def to_s
  to_hash.to_s
end