Class: UspsApi::SubscriptionsTrackingSubscriptionEvent
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::SubscriptionsTrackingSubscriptionEvent
- Defined in:
- lib/usps_api/models/subscriptions_tracking_subscription_event.rb
Overview
Subscription Event
Instance Attribute Summary collapse
-
#links ⇒ Array[AdjustmentsHypermediaLink]
Hypermedia links to related resources.
-
#payload ⇒ String
Tracking details converted into a JSON formatted string.
-
#subscription_id ⇒ String
Unique identifier created for this Subscription.
-
#subscription_type ⇒ String
The name of the topic related to this event.
-
#timestamp ⇒ DateTime
Timestamp message was generated, in ISO-8601 format.
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(subscription_id:, subscription_type:, timestamp:, payload:, links: SKIP, additional_properties: nil) ⇒ SubscriptionsTrackingSubscriptionEvent
constructor
A new instance of SubscriptionsTrackingSubscriptionEvent.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_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(subscription_id:, subscription_type:, timestamp:, payload:, links: SKIP, additional_properties: nil) ⇒ SubscriptionsTrackingSubscriptionEvent
Returns a new instance of SubscriptionsTrackingSubscriptionEvent.
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 56 def initialize(subscription_id:, subscription_type:, timestamp:, payload:, links: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @subscription_id = subscription_id @subscription_type = subscription_type @timestamp = @payload = payload @links = links unless links == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#links ⇒ Array[AdjustmentsHypermediaLink]
Hypermedia links to related resources.
31 32 33 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 31 def links @links end |
#payload ⇒ String
Tracking details converted into a JSON formatted string.
27 28 29 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 27 def payload @payload end |
#subscription_id ⇒ String
Unique identifier created for this Subscription.
15 16 17 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 15 def subscription_id @subscription_id end |
#subscription_type ⇒ String
The name of the topic related to this event.
19 20 21 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 19 def subscription_type @subscription_type end |
#timestamp ⇒ DateTime
Timestamp message was generated, in ISO-8601 format.
23 24 25 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 23 def @timestamp end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
70 71 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 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 70 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. subscription_id = hash.key?('subscriptionId') ? hash['subscriptionId'] : nil subscription_type = hash.key?('subscriptionType') ? hash['subscriptionType'] : nil = if hash.key?('timestamp') (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp']) end payload = hash.key?('payload') ? hash['payload'] : nil # Parameter is an array, so we need to iterate through it links = nil unless hash['links'].nil? links = [] hash['links'].each do |structure| links << (AdjustmentsHypermediaLink.from_hash(structure) if structure) end end links = SKIP unless hash.key?('links') # 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. SubscriptionsTrackingSubscriptionEvent.new(subscription_id: subscription_id, subscription_type: subscription_type, timestamp: , payload: payload, links: links, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 42 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['subscription_id'] = 'subscriptionId' @_hash['subscription_type'] = 'subscriptionType' @_hash['timestamp'] = 'timestamp' @_hash['payload'] = 'payload' @_hash['links'] = 'links' @_hash end |
.nullables ⇒ Object
An array for nullable fields
52 53 54 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 52 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
45 46 47 48 49 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 45 def self.optionals %w[ links ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
122 123 124 125 126 127 128 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 122 def inspect class_name = self.class.name.split('::').last "<#{class_name} subscription_id: #{@subscription_id.inspect}, subscription_type:"\ " #{@subscription_type.inspect}, timestamp: #{@timestamp.inspect}, payload:"\ " #{@payload.inspect}, links: #{@links.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_timestamp ⇒ Object
109 110 111 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 109 def DateTimeHelper.to_rfc3339() end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
114 115 116 117 118 119 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription_event.rb', line 114 def to_s class_name = self.class.name.split('::').last "<#{class_name} subscription_id: #{@subscription_id}, subscription_type:"\ " #{@subscription_type}, timestamp: #{@timestamp}, payload: #{@payload}, links: #{@links},"\ " additional_properties: #{@additional_properties}>" end |