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



72
73
74
75
76
77
78
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
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 72

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?(:'zip')
    self.zip = attributes[:'zip']
  end 

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

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

  if attributes.key?(:'country_name')
    self.country_name = attributes[:'country_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 
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;



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

def checkpoint_time
  @checkpoint_time
end

#cityObject

City info provided by carrier city?: String;



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

def city
  @city
end

#coordinateObject

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



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

def coordinate
  @coordinate
end

#country_iso3Object

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



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

def country_iso3
  @country_iso3
end

#country_nameObject

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



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

def country_name
  @country_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;



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

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 </span>- The events’ value for the same checkpoint message is subject to change as we consistently strive to enhance the performance of this feature. events?: EventsCheckpoint[];



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

def events
  @events
end

#locationObject

Location info provided by carrier location?: String;



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

def location
  @location
end

#messageObject

Checkpoint message message?: String;



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

def message
  @message
end

#raw_tagObject

Checkpoint raw status provided by courier raw_tag?: String;



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

def raw_tag
  @raw_tag
end

#slugObject

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



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

def slug
  @slug
end

#stateObject

State info provided by carrier state?: String;



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

def state
  @state
end

#subtagObject

Current subtag of checkpoint. ( subtag?: String;



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

def subtag
  @subtag
end

#subtag_messageObject

Normalized checkpoint message. ( subtag_message?: String;



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

def subtag_message
  @subtag_message
end

#tagObject

Current status of tracking. ( tag?: TagV1;



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

def tag
  @tag
end

#zipObject

Postal code info provided by carrier zip?: String;



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

def zip
  @zip
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



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 217

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.



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 169

def self.attribute_map
  {
    :'created_at' => :'created_at',
    :'slug' => :'slug',
    :'checkpoint_time' => :'checkpoint_time',
    :'location' => :'location',
    :'city' => :'city',
    :'state' => :'state',
    :'zip' => :'zip',
    :'coordinate' => :'coordinate',
    :'country_iso3' => :'country_iso3',
    :'country_name' => :'country_name',
    :'message' => :'message',
    :'tag' => :'tag',
    :'subtag' => :'subtag',
    :'subtag_message' => :'subtag_message',
    :'raw_tag' => :'raw_tag',
    :'events' => :'events',
  }
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



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 193

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.



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 147

def self.openapi_types
  {
    :'created_at' => :'String',
    :'slug' => :'String',
    :'checkpoint_time' => :'String',
    :'location' => :'String',
    :'city' => :'String',
    :'state' => :'String',
    :'zip' => :'String',
    :'coordinate' => :'CoordinateCheckpoint',
    :'country_iso3' => :'String',
    :'country_name' => :'String',
    :'message' => :'String',
    :'tag' => :'TagV1',
    :'subtag' => :'String',
    :'subtag_message' => :'String',
    :'raw_tag' => :'String',
    :'events' => :'Array<EventsCheckpoint>',
  }
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



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

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



263
264
265
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 263

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



269
270
271
272
273
274
275
276
277
278
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 269

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



298
299
300
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 298

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



257
258
259
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 257

def to_s
  to_hash.to_s
end