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



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
145
146
147
148
149
150
151
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 75

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_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
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 </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?: CheckpointEvents[];



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

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

#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

#zipObject

Postal code info provided by carrier zip?: String;



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

def zip
  @zip
end

Class Method Details

._deserialize(type, value) ⇒ Object

Deserializes the data based on type



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
254
255
256
257
258
259
260
261
262
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 226

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.



177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 177

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_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',
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 202

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.



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 154

def self.openapi_types
  {
    :'created_at' => :'String',
    :'slug' => :'String',
    :'checkpoint_time' => :'String',
    :'location' => :'String',
    :'city' => :'String',
    :'state' => :'String',
    :'zip' => :'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',
  }
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



293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 293

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)



272
273
274
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 272

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



278
279
280
281
282
283
284
285
286
287
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 278

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



307
308
309
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 307

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

#to_sString

Returns the string representation of the object



266
267
268
# File 'lib/aftership-tracking-sdk/models/checkpoint.rb', line 266

def to_s
  to_hash.to_s
end