Class: UspsApi::TrackingEvent
- Defined in:
- lib/usps_api/models/tracking_event.rb
Overview
To be done.
Instance Attribute Summary collapse
-
#action_code ⇒ String
Refer to Pub 199 page 256 for list of Action Codes.
-
#authorized_agent ⇒ TrueClass | FalseClass
Indicating whether the person signing is an Authorized Agent.
-
#event_city ⇒ String
The city where the event occurred.
-
#event_code ⇒ String
Refer to the lookup table for all the possible values.
-
#event_country ⇒ String
The country where the event occurred.
-
#event_state ⇒ String
The state where the event occurred.
-
#event_timestamp ⇒ DateTime
The date of the event.
-
#event_type ⇒ String
The type of event.
-
#event_zip ⇒ String
The ZIP Code™ of the event.
-
#firm ⇒ String
The company name if delivered to a company.
-
#gmt_offset ⇒ String
The offset of the local time of the event from Greenwich Mean Time (GMT).
-
#gmt_timestamp ⇒ DateTime
The date-time of the event in Greenwich Mean Time (GMT).
-
#name ⇒ String
The name of the persons signing for delivery (if available).
-
#reason_code ⇒ String
Refer to the lookup table for all the possible values.
-
#veri_point ⇒ TrueClass | FalseClass
Delivery scan location certified, if applicable.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(event_type: SKIP, event_timestamp: SKIP, gmt_timestamp: SKIP, gmt_offset: SKIP, event_country: SKIP, event_city: SKIP, event_state: SKIP, event_zip: SKIP, firm: SKIP, name: SKIP, authorized_agent: SKIP, event_code: SKIP, veri_point: SKIP, action_code: SKIP, reason_code: SKIP, additional_properties: nil) ⇒ TrackingEvent
constructor
A new instance of TrackingEvent.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_event_timestamp ⇒ Object
- #to_custom_gmt_timestamp ⇒ 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(event_type: SKIP, event_timestamp: SKIP, gmt_timestamp: SKIP, gmt_offset: SKIP, event_country: SKIP, event_city: SKIP, event_state: SKIP, event_zip: SKIP, firm: SKIP, name: SKIP, authorized_agent: SKIP, event_code: SKIP, veri_point: SKIP, action_code: SKIP, reason_code: SKIP, additional_properties: nil) ⇒ TrackingEvent
Returns a new instance of TrackingEvent.
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 |
# File 'lib/usps_api/models/tracking_event.rb', line 124 def initialize(event_type: SKIP, event_timestamp: SKIP, gmt_timestamp: SKIP, gmt_offset: SKIP, event_country: SKIP, event_city: SKIP, event_state: SKIP, event_zip: SKIP, firm: SKIP, name: SKIP, authorized_agent: SKIP, event_code: SKIP, veri_point: SKIP, action_code: SKIP, reason_code: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @event_type = event_type unless event_type == SKIP @event_timestamp = unless == SKIP @gmt_timestamp = unless == SKIP @gmt_offset = gmt_offset unless gmt_offset == SKIP @event_country = event_country unless event_country == SKIP @event_city = event_city unless event_city == SKIP @event_state = event_state unless event_state == SKIP @event_zip = event_zip unless event_zip == SKIP @firm = firm unless firm == SKIP @name = name unless name == SKIP @authorized_agent = unless == SKIP @event_code = event_code unless event_code == SKIP @veri_point = veri_point unless veri_point == SKIP @action_code = action_code unless action_code == SKIP @reason_code = reason_code unless reason_code == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#action_code ⇒ String
Refer to Pub 199 page 256 for list of Action Codes
69 70 71 |
# File 'lib/usps_api/models/tracking_event.rb', line 69 def action_code @action_code end |
#authorized_agent ⇒ TrueClass | FalseClass
Indicating whether the person signing is an Authorized Agent.
55 56 57 |
# File 'lib/usps_api/models/tracking_event.rb', line 55 def @authorized_agent end |
#event_city ⇒ String
The city where the event occurred.
35 36 37 |
# File 'lib/usps_api/models/tracking_event.rb', line 35 def event_city @event_city end |
#event_code ⇒ String
Refer to the lookup table for all the possible values. USPS® [Pub 199](postalpro.usps.com/pub199) Appendix G-4:USPS® Domestic Tracking Scan Events
61 62 63 |
# File 'lib/usps_api/models/tracking_event.rb', line 61 def event_code @event_code end |
#event_country ⇒ String
The country where the event occurred.
31 32 33 |
# File 'lib/usps_api/models/tracking_event.rb', line 31 def event_country @event_country end |
#event_state ⇒ String
The state where the event occurred.
39 40 41 |
# File 'lib/usps_api/models/tracking_event.rb', line 39 def event_state @event_state end |
#event_timestamp ⇒ DateTime
The date of the event.
19 20 21 |
# File 'lib/usps_api/models/tracking_event.rb', line 19 def @event_timestamp end |
#event_type ⇒ String
The type of event
15 16 17 |
# File 'lib/usps_api/models/tracking_event.rb', line 15 def event_type @event_type end |
#event_zip ⇒ String
The ZIP Code™ of the event.
43 44 45 |
# File 'lib/usps_api/models/tracking_event.rb', line 43 def event_zip @event_zip end |
#firm ⇒ String
The company name if delivered to a company.
47 48 49 |
# File 'lib/usps_api/models/tracking_event.rb', line 47 def firm @firm end |
#gmt_offset ⇒ String
The offset of the local time of the event from Greenwich Mean Time (GMT).
27 28 29 |
# File 'lib/usps_api/models/tracking_event.rb', line 27 def gmt_offset @gmt_offset end |
#gmt_timestamp ⇒ DateTime
The date-time of the event in Greenwich Mean Time (GMT).
23 24 25 |
# File 'lib/usps_api/models/tracking_event.rb', line 23 def @gmt_timestamp end |
#name ⇒ String
The name of the persons signing for delivery (if available).
51 52 53 |
# File 'lib/usps_api/models/tracking_event.rb', line 51 def name @name end |
#reason_code ⇒ String
Refer to the lookup table for all the possible values. USPS® [Pub 199](postalpro.usps.com/pub199) Appendix G-4: USPS® Domestic Tracking Scan Events
75 76 77 |
# File 'lib/usps_api/models/tracking_event.rb', line 75 def reason_code @reason_code end |
#veri_point ⇒ TrueClass | FalseClass
Delivery scan location certified, if applicable. Refer to GeoCertified
65 66 67 |
# File 'lib/usps_api/models/tracking_event.rb', line 65 def veri_point @veri_point end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/usps_api/models/tracking_event.rb', line 152 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. event_type = hash.key?('eventType') ? hash['eventType'] : SKIP = if hash.key?('eventTimestamp') (DateTimeHelper.from_rfc3339(hash['eventTimestamp']) if hash['eventTimestamp']) else SKIP end = if hash.key?('GMTTimestamp') (DateTimeHelper.from_rfc3339(hash['GMTTimestamp']) if hash['GMTTimestamp']) else SKIP end gmt_offset = hash.key?('GMTOffset') ? hash['GMTOffset'] : SKIP event_country = hash.key?('eventCountry') ? hash['eventCountry'] : SKIP event_city = hash.key?('eventCity') ? hash['eventCity'] : SKIP event_state = hash.key?('eventState') ? hash['eventState'] : SKIP event_zip = hash.key?('eventZIP') ? hash['eventZIP'] : SKIP firm = hash.key?('firm') ? hash['firm'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP = hash.key?('authorizedAgent') ? hash['authorizedAgent'] : SKIP event_code = hash.key?('eventCode') ? hash['eventCode'] : SKIP veri_point = hash.key?('veriPoint') ? hash['veriPoint'] : SKIP action_code = hash.key?('actionCode') ? hash['actionCode'] : SKIP reason_code = hash.key?('reasonCode') ? hash['reasonCode'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. TrackingEvent.new(event_type: event_type, event_timestamp: , gmt_timestamp: , gmt_offset: gmt_offset, event_country: event_country, event_city: event_city, event_state: event_state, event_zip: event_zip, firm: firm, name: name, authorized_agent: , event_code: event_code, veri_point: veri_point, action_code: action_code, reason_code: reason_code, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/usps_api/models/tracking_event.rb', line 78 def self.names @_hash = {} if @_hash.nil? @_hash['event_type'] = 'eventType' @_hash['event_timestamp'] = 'eventTimestamp' @_hash['gmt_timestamp'] = 'GMTTimestamp' @_hash['gmt_offset'] = 'GMTOffset' @_hash['event_country'] = 'eventCountry' @_hash['event_city'] = 'eventCity' @_hash['event_state'] = 'eventState' @_hash['event_zip'] = 'eventZIP' @_hash['firm'] = 'firm' @_hash['name'] = 'name' @_hash['authorized_agent'] = 'authorizedAgent' @_hash['event_code'] = 'eventCode' @_hash['veri_point'] = 'veriPoint' @_hash['action_code'] = 'actionCode' @_hash['reason_code'] = 'reasonCode' @_hash end |
.nullables ⇒ Object
An array for nullable fields
120 121 122 |
# File 'lib/usps_api/models/tracking_event.rb', line 120 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/usps_api/models/tracking_event.rb', line 99 def self.optionals %w[ event_type event_timestamp gmt_timestamp gmt_offset event_country event_city event_state event_zip firm name authorized_agent event_code veri_point action_code reason_code ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
217 218 219 220 221 222 223 |
# File 'lib/usps_api/models/tracking_event.rb', line 217 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/usps_api/models/tracking_event.rb', line 237 def inspect class_name = self.class.name.split('::').last "<#{class_name} event_type: #{@event_type.inspect}, event_timestamp:"\ " #{@event_timestamp.inspect}, gmt_timestamp: #{@gmt_timestamp.inspect}, gmt_offset:"\ " #{@gmt_offset.inspect}, event_country: #{@event_country.inspect}, event_city:"\ " #{@event_city.inspect}, event_state: #{@event_state.inspect}, event_zip:"\ " #{@event_zip.inspect}, firm: #{@firm.inspect}, name: #{@name.inspect}, authorized_agent:"\ " #{@authorized_agent.inspect}, event_code: #{@event_code.inspect}, veri_point:"\ " #{@veri_point.inspect}, action_code: #{@action_code.inspect}, reason_code:"\ " #{@reason_code.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_event_timestamp ⇒ Object
207 208 209 |
# File 'lib/usps_api/models/tracking_event.rb', line 207 def DateTimeHelper.to_rfc3339() end |
#to_custom_gmt_timestamp ⇒ Object
211 212 213 |
# File 'lib/usps_api/models/tracking_event.rb', line 211 def DateTimeHelper.to_rfc3339() end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
226 227 228 229 230 231 232 233 234 |
# File 'lib/usps_api/models/tracking_event.rb', line 226 def to_s class_name = self.class.name.split('::').last "<#{class_name} event_type: #{@event_type}, event_timestamp: #{@event_timestamp},"\ " gmt_timestamp: #{@gmt_timestamp}, gmt_offset: #{@gmt_offset}, event_country:"\ " #{@event_country}, event_city: #{@event_city}, event_state: #{@event_state}, event_zip:"\ " #{@event_zip}, firm: #{@firm}, name: #{@name}, authorized_agent: #{@authorized_agent},"\ " event_code: #{@event_code}, veri_point: #{@veri_point}, action_code: #{@action_code},"\ " reason_code: #{@reason_code}, additional_properties: #{@additional_properties}>" end |