Class: NewStoreApi::PackageTracking
- Defined in:
- lib/new_store_api/models/package_tracking.rb
Overview
PackageTracking Model.
Instance Attribute Summary collapse
-
#reason ⇒ String
TODO: Write general description for this method.
-
#received_at ⇒ String
Set by Newstore.
-
#status ⇒ TrackingStatusEnum
Set by Newstore.
-
#tracking_code ⇒ String
Set by Newstore.
-
#updated_at ⇒ String
Set by carrier.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(received_at = nil, status = nil, tracking_code = nil, updated_at = nil, reason = SKIP) ⇒ PackageTracking
constructor
A new instance of PackageTracking.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(received_at = nil, status = nil, tracking_code = nil, updated_at = nil, reason = SKIP) ⇒ PackageTracking
Returns a new instance of PackageTracking.
61 62 63 64 65 66 67 68 |
# File 'lib/new_store_api/models/package_tracking.rb', line 61 def initialize(received_at = nil, status = nil, tracking_code = nil, updated_at = nil, reason = SKIP) @reason = reason unless reason == SKIP @received_at = received_at @status = status @tracking_code = tracking_code @updated_at = updated_at end |
Instance Attribute Details
#reason ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/new_store_api/models/package_tracking.rb', line 14 def reason @reason end |
#received_at ⇒ String
Set by Newstore. It is the time at which the event has been received on the endpoint.
19 20 21 |
# File 'lib/new_store_api/models/package_tracking.rb', line 19 def received_at @received_at end |
#status ⇒ TrackingStatusEnum
Set by Newstore. It is the time at which the event has been received on the endpoint.
24 25 26 |
# File 'lib/new_store_api/models/package_tracking.rb', line 24 def status @status end |
#tracking_code ⇒ String
Set by Newstore. It is the time at which the event has been received on the endpoint.
29 30 31 |
# File 'lib/new_store_api/models/package_tracking.rb', line 29 def tracking_code @tracking_code end |
#updated_at ⇒ String
Set by carrier. It is the time at which the event has been recorded/generated by the carrier.
34 35 36 |
# File 'lib/new_store_api/models/package_tracking.rb', line 34 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/new_store_api/models/package_tracking.rb', line 71 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. received_at = hash.key?('received_at') ? hash['received_at'] : nil status = hash.key?('status') ? hash['status'] : nil tracking_code = hash.key?('tracking_code') ? hash['tracking_code'] : nil updated_at = hash.key?('updated_at') ? hash['updated_at'] : nil reason = hash.key?('reason') ? hash['reason'] : SKIP # Create object from extracted values. PackageTracking.new(received_at, status, tracking_code, updated_at, reason) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 |
# File 'lib/new_store_api/models/package_tracking.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['reason'] = 'reason' @_hash['received_at'] = 'received_at' @_hash['status'] = 'status' @_hash['tracking_code'] = 'tracking_code' @_hash['updated_at'] = 'updated_at' @_hash end |
.nullables ⇒ Object
An array for nullable fields
55 56 57 58 59 |
# File 'lib/new_store_api/models/package_tracking.rb', line 55 def self.nullables %w[ reason ] end |
.optionals ⇒ Object
An array for optional fields
48 49 50 51 52 |
# File 'lib/new_store_api/models/package_tracking.rb', line 48 def self.optionals %w[ reason ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
97 98 99 100 101 102 |
# File 'lib/new_store_api/models/package_tracking.rb', line 97 def inspect class_name = self.class.name.split('::').last "<#{class_name} reason: #{@reason.inspect}, received_at: #{@received_at.inspect}, status:"\ " #{@status.inspect}, tracking_code: #{@tracking_code.inspect}, updated_at:"\ " #{@updated_at.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
90 91 92 93 94 |
# File 'lib/new_store_api/models/package_tracking.rb', line 90 def to_s class_name = self.class.name.split('::').last "<#{class_name} reason: #{@reason}, received_at: #{@received_at}, status: #{@status},"\ " tracking_code: #{@tracking_code}, updated_at: #{@updated_at}>" end |