Class: NewStoreApi::Request
- Defined in:
- lib/new_store_api/models/request.rb
Overview
Request Model.
Instance Attribute Summary collapse
-
#easypost_marker ⇒ String
Set by carrier.
-
#reason ⇒ String
TODO: Write general description for this method.
-
#status ⇒ TrackingStatusEnum
TODO: Write general description for this method.
-
#tracking_code ⇒ String
TODO: Write general description for this method.
-
#updated_at ⇒ DateTime
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(reason = SKIP, status = SKIP, tracking_code = SKIP, updated_at = SKIP, easypost_marker = SKIP) ⇒ Request
constructor
A new instance of Request.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_updated_at ⇒ Object
-
#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(reason = SKIP, status = SKIP, tracking_code = SKIP, updated_at = SKIP, easypost_marker = SKIP) ⇒ Request
Returns a new instance of Request.
64 65 66 67 68 69 70 71 |
# File 'lib/new_store_api/models/request.rb', line 64 def initialize(reason = SKIP, status = SKIP, tracking_code = SKIP, updated_at = SKIP, easypost_marker = SKIP) @reason = reason unless reason == SKIP @status = status unless status == SKIP @tracking_code = tracking_code unless tracking_code == SKIP @updated_at = updated_at unless updated_at == SKIP @easypost_marker = easypost_marker unless easypost_marker == SKIP end |
Instance Attribute Details
#easypost_marker ⇒ String
Set by carrier. It is the time at which the event has been recorded/generated by the carrier.
33 34 35 |
# File 'lib/new_store_api/models/request.rb', line 33 def easypost_marker @easypost_marker end |
#reason ⇒ String
TODO: Write general description for this method
15 16 17 |
# File 'lib/new_store_api/models/request.rb', line 15 def reason @reason end |
#status ⇒ TrackingStatusEnum
TODO: Write general description for this method
19 20 21 |
# File 'lib/new_store_api/models/request.rb', line 19 def status @status end |
#tracking_code ⇒ String
TODO: Write general description for this method
23 24 25 |
# File 'lib/new_store_api/models/request.rb', line 23 def tracking_code @tracking_code end |
#updated_at ⇒ DateTime
Set by carrier. It is the time at which the event has been recorded/generated by the carrier.
28 29 30 |
# File 'lib/new_store_api/models/request.rb', line 28 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/new_store_api/models/request.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. reason = hash.key?('reason') ? hash['reason'] : SKIP status = hash.key?('status') ? hash['status'] : SKIP tracking_code = hash.key?('tracking_code') ? hash['tracking_code'] : SKIP updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) else SKIP end easypost_marker = hash.key?('easypost_marker') ? hash['easypost_marker'] : SKIP # Create object from extracted values. Request.new(reason, status, tracking_code, updated_at, easypost_marker) end |
.names ⇒ Object
A mapping from model property names to API property names.
36 37 38 39 40 41 42 43 44 |
# File 'lib/new_store_api/models/request.rb', line 36 def self.names @_hash = {} if @_hash.nil? @_hash['reason'] = 'reason' @_hash['status'] = 'status' @_hash['tracking_code'] = 'tracking_code' @_hash['updated_at'] = 'updated_at' @_hash['easypost_marker'] = 'easypost_marker' @_hash end |
.nullables ⇒ Object
An array for nullable fields
58 59 60 61 62 |
# File 'lib/new_store_api/models/request.rb', line 58 def self.nullables %w[ reason ] end |
.optionals ⇒ Object
An array for optional fields
47 48 49 50 51 52 53 54 55 |
# File 'lib/new_store_api/models/request.rb', line 47 def self.optionals %w[ reason status tracking_code updated_at easypost_marker ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
109 110 111 112 113 114 |
# File 'lib/new_store_api/models/request.rb', line 109 def inspect class_name = self.class.name.split('::').last "<#{class_name} reason: #{@reason.inspect}, status: #{@status.inspect}, tracking_code:"\ " #{@tracking_code.inspect}, updated_at: #{@updated_at.inspect}, easypost_marker:"\ " #{@easypost_marker.inspect}>" end |
#to_custom_updated_at ⇒ Object
97 98 99 |
# File 'lib/new_store_api/models/request.rb', line 97 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
102 103 104 105 106 |
# File 'lib/new_store_api/models/request.rb', line 102 def to_s class_name = self.class.name.split('::').last "<#{class_name} reason: #{@reason}, status: #{@status}, tracking_code: #{@tracking_code},"\ " updated_at: #{@updated_at}, easypost_marker: #{@easypost_marker}>" end |