Class: UspsApi::ChangeOfAddressSubscriptionEvent
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::ChangeOfAddressSubscriptionEvent
- Defined in:
- lib/usps_api/models/change_of_address_subscription_event.rb
Overview
Change of Address Notification Event
Instance Attribute Summary collapse
-
#links ⇒ Array[HypermediaLink]
Hypermedia links to related resources.
-
#payload ⇒ String
Change of Address subscription details converted into a JSON formatted string.
-
#payload_details ⇒ ChangeOfAddressSubscriptionEventInformation
Change Of Address Subscription Event Information.
-
#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:, payload_details: SKIP, links: SKIP, additional_properties: nil) ⇒ ChangeOfAddressSubscriptionEvent
constructor
A new instance of ChangeOfAddressSubscriptionEvent.
-
#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:, payload_details: SKIP, links: SKIP, additional_properties: nil) ⇒ ChangeOfAddressSubscriptionEvent
Returns a new instance of ChangeOfAddressSubscriptionEvent.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 63 def initialize(subscription_id:, subscription_type:, timestamp:, payload:, payload_details: SKIP, 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 @payload_details = payload_details unless payload_details == SKIP @links = links unless links == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#links ⇒ Array[HypermediaLink]
Hypermedia links to related resources.
36 37 38 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 36 def links @links end |
#payload ⇒ String
Change of Address subscription details converted into a JSON formatted string.
28 29 30 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 28 def payload @payload end |
#payload_details ⇒ ChangeOfAddressSubscriptionEventInformation
Change Of Address Subscription Event Information
32 33 34 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 32 def payload_details @payload_details end |
#subscription_id ⇒ String
Unique identifier created for this Subscription.
15 16 17 |
# File 'lib/usps_api/models/change_of_address_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/change_of_address_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/change_of_address_subscription_event.rb', line 23 def @timestamp end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 79 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 if hash['payloadDetails'] payload_details = ChangeOfAddressSubscriptionEventInformation.from_hash(hash['payloadDetails']) end # Parameter is an array, so we need to iterate through it links = nil unless hash['links'].nil? links = [] hash['links'].each do |structure| links << (HypermediaLink.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. ChangeOfAddressSubscriptionEvent.new(subscription_id: subscription_id, subscription_type: subscription_type, timestamp: , payload: payload, payload_details: payload_details, links: links, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['subscription_id'] = 'subscriptionId' @_hash['subscription_type'] = 'subscriptionType' @_hash['timestamp'] = 'timestamp' @_hash['payload'] = 'payload' @_hash['payload_details'] = 'payloadDetails' @_hash['links'] = 'links' @_hash end |
.nullables ⇒ Object
An array for nullable fields
59 60 61 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 59 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 54 55 56 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 51 def self.optionals %w[ payload_details links ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
135 136 137 138 139 140 141 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 135 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}, payload_details: #{@payload_details.inspect}, links:"\ " #{@links.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_timestamp ⇒ Object
122 123 124 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 122 def DateTimeHelper.to_rfc3339() end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
127 128 129 130 131 132 |
# File 'lib/usps_api/models/change_of_address_subscription_event.rb', line 127 def to_s class_name = self.class.name.split('::').last "<#{class_name} subscription_id: #{@subscription_id}, subscription_type:"\ " #{@subscription_type}, timestamp: #{@timestamp}, payload: #{@payload}, payload_details:"\ " #{@payload_details}, links: #{@links}, additional_properties: #{@additional_properties}>" end |