Class: UspsApi::SubscriptionsTrackingSubscription
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- UspsApi::SubscriptionsTrackingSubscription
- Defined in:
- lib/usps_api/models/subscriptions_tracking_subscription.rb
Overview
Subscription for the tracking event data the consumer is receiving.
Instance Attribute Summary collapse
-
#access_control ⇒ AccessControl
Details on if the Tracking request was free or charged based on MID access through an IP Agreement.
-
#admin_notification ⇒ Array[SubscriptionsAdjustmentsEmailNotification]
Customer can supply an email address to receive important updates on the status and events related to the subscription.
-
#creation_timestamp ⇒ DateTime
When the subscription was originally created.
-
#expiration_timestamp ⇒ DateTime
When the subscription expires.
-
#filter_properties ⇒ Object
The filters that should be applied to the subscription.
-
#listener_url ⇒ String
Customer URL in which subscription data will be sent.
-
#secret ⇒ String
Customer supplied secret USPS will use to create a hash value.
-
#status ⇒ Status5
Current status of the subscription.
-
#status_change_timestamp ⇒ DateTime
Time when the status was last changed.
-
#status_reason ⇒ String
When status is suspended the Status Reason will return why it was suspended.
-
#subscription_id ⇒ String
Unique Identifier created for this Subscription.
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(listener_url:, secret:, admin_notification:, filter_properties:, subscription_id: SKIP, status: SKIP, status_reason: SKIP, creation_timestamp: SKIP, status_change_timestamp: SKIP, expiration_timestamp: SKIP, access_control: SKIP, additional_properties: nil) ⇒ SubscriptionsTrackingSubscription
constructor
A new instance of SubscriptionsTrackingSubscription.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_creation_timestamp ⇒ Object
- #to_custom_expiration_timestamp ⇒ Object
- #to_custom_status_change_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(listener_url:, secret:, admin_notification:, filter_properties:, subscription_id: SKIP, status: SKIP, status_reason: SKIP, creation_timestamp: SKIP, status_change_timestamp: SKIP, expiration_timestamp: SKIP, access_control: SKIP, additional_properties: nil) ⇒ SubscriptionsTrackingSubscription
Returns a new instance of SubscriptionsTrackingSubscription.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 109 def initialize(listener_url:, secret:, admin_notification:, filter_properties:, subscription_id: SKIP, status: SKIP, status_reason: SKIP, creation_timestamp: SKIP, status_change_timestamp: SKIP, expiration_timestamp: SKIP, access_control: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @subscription_id = subscription_id unless subscription_id == SKIP @listener_url = listener_url @secret = secret @status = status unless status == SKIP @status_reason = status_reason unless status_reason == SKIP @admin_notification = admin_notification @creation_timestamp = unless == SKIP @status_change_timestamp = unless == SKIP @expiration_timestamp = unless == SKIP @access_control = access_control unless access_control == SKIP @filter_properties = filter_properties @additional_properties = additional_properties end |
Instance Attribute Details
#access_control ⇒ AccessControl
Details on if the Tracking request was free or charged based on MID access through an IP Agreement.
-
‘FREE` - The Tracking request was free.
-
‘IP_AGREEMENT` - The tracking request was charged based on MID access
through an IP Agreement.
66 67 68 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 66 def access_control @access_control end |
#admin_notification ⇒ Array[SubscriptionsAdjustmentsEmailNotification]
Customer can supply an email address to receive important updates on the status and events related to the subscription.
46 47 48 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 46 def admin_notification @admin_notification end |
#creation_timestamp ⇒ DateTime
When the subscription was originally created.
50 51 52 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 50 def @creation_timestamp end |
#expiration_timestamp ⇒ DateTime
When the subscription expires.
58 59 60 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 58 def @expiration_timestamp end |
#filter_properties ⇒ Object
The filters that should be applied to the subscription. The structure of this property will change dependent on the type of subscription a client is signing up for.
72 73 74 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 72 def filter_properties @filter_properties end |
#listener_url ⇒ String
Customer URL in which subscription data will be sent. You can parse the data received on the server URL, and you can call back to the Tracking API for the full detailed set of events.
21 22 23 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 21 def listener_url @listener_url end |
#secret ⇒ String
Customer supplied secret USPS will use to create a hash value. The hash will be provided in the Notification payload. USPS will use the SHA-256 algorithm to create the hash value.
27 28 29 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 27 def secret @secret end |
#status ⇒ Status5
Current status of the subscription. USPS will post notifications to the supplied listenerURL. If the listenerURL cannot be reached or is invalid, USPS will change the status of the subscription to SUSPENDED. The customer has the option of changing the status to DISABLED. It is recommended the customer change the status to DISABLED if they know their endpoint will not be active, i.e operational maintenance.
36 37 38 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 36 def status @status end |
#status_change_timestamp ⇒ DateTime
Time when the status was last changed.
54 55 56 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 54 def @status_change_timestamp end |
#status_reason ⇒ String
When status is suspended the Status Reason will return why it was suspended.
41 42 43 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 41 def status_reason @status_reason end |
#subscription_id ⇒ String
Unique Identifier created for this Subscription.
15 16 17 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 15 def subscription_id @subscription_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 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 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 132 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. listener_url = hash.key?('listenerURL') ? hash['listenerURL'] : nil secret = hash.key?('secret') ? hash['secret'] : nil # Parameter is an array, so we need to iterate through it admin_notification = nil unless hash['adminNotification'].nil? admin_notification = [] hash['adminNotification'].each do |structure| admin_notification << (SubscriptionsAdjustmentsEmailNotification.from_hash(structure) if structure) end end admin_notification = nil unless hash.key?('adminNotification') filter_properties = hash.key?('filterProperties') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:SubscriptionsTrackingSubscriptionFilterProperties), hash['filterProperties'] ) : nil subscription_id = hash.key?('subscriptionId') ? hash['subscriptionId'] : SKIP status = hash.key?('status') ? hash['status'] : SKIP status_reason = hash.key?('statusReason') ? hash['statusReason'] : SKIP = if hash.key?('creationTimestamp') (DateTimeHelper.from_rfc3339(hash['creationTimestamp']) if hash['creationTimestamp']) else SKIP end = if hash.key?('statusChangeTimestamp') (DateTimeHelper.from_rfc3339(hash['statusChangeTimestamp']) if hash['statusChangeTimestamp']) else SKIP end = if hash.key?('expirationTimestamp') (DateTimeHelper.from_rfc3339(hash['expirationTimestamp']) if hash['expirationTimestamp']) else SKIP end access_control = hash.key?('accessControl') ? hash['accessControl'] : 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. SubscriptionsTrackingSubscription.new(listener_url: listener_url, secret: secret, admin_notification: admin_notification, filter_properties: filter_properties, subscription_id: subscription_id, status: status, status_reason: status_reason, creation_timestamp: , status_change_timestamp: , expiration_timestamp: , access_control: access_control, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 75 def self.names @_hash = {} if @_hash.nil? @_hash['subscription_id'] = 'subscriptionId' @_hash['listener_url'] = 'listenerURL' @_hash['secret'] = 'secret' @_hash['status'] = 'status' @_hash['status_reason'] = 'statusReason' @_hash['admin_notification'] = 'adminNotification' @_hash['creation_timestamp'] = 'creationTimestamp' @_hash['status_change_timestamp'] = 'statusChangeTimestamp' @_hash['expiration_timestamp'] = 'expirationTimestamp' @_hash['access_control'] = 'accessControl' @_hash['filter_properties'] = 'filterProperties' @_hash end |
.nullables ⇒ Object
An array for nullable fields
105 106 107 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 105 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 92 def self.optionals %w[ subscription_id status status_reason creation_timestamp status_change_timestamp expiration_timestamp access_control ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 208 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.listener_url, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.secret, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.admin_notification, ->(val) { SubscriptionsAdjustmentsEmailNotification.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and UnionTypeLookUp.get(:SubscriptionsTrackingSubscriptionFilterProperties) .validate(value.filter_properties) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['listenerURL'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['secret'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['adminNotification'], ->(val) { SubscriptionsAdjustmentsEmailNotification.validate(val) }, is_model_hash: true, is_inner_model_hash: true) and UnionTypeLookUp.get(:SubscriptionsTrackingSubscriptionFilterProperties) .validate(value['filterProperties']) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 252 def inspect class_name = self.class.name.split('::').last "<#{class_name} subscription_id: #{@subscription_id.inspect}, listener_url:"\ " #{@listener_url.inspect}, secret: #{@secret.inspect}, status: #{@status.inspect},"\ " status_reason: #{@status_reason.inspect}, admin_notification:"\ " #{@admin_notification.inspect}, creation_timestamp: #{@creation_timestamp.inspect},"\ " status_change_timestamp: #{@status_change_timestamp.inspect}, expiration_timestamp:"\ " #{@expiration_timestamp.inspect}, access_control: #{@access_control.inspect},"\ " filter_properties: #{@filter_properties.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_creation_timestamp ⇒ Object
194 195 196 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 194 def DateTimeHelper.to_rfc3339() end |
#to_custom_expiration_timestamp ⇒ Object
202 203 204 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 202 def DateTimeHelper.to_rfc3339() end |
#to_custom_status_change_timestamp ⇒ Object
198 199 200 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 198 def DateTimeHelper.to_rfc3339() end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
241 242 243 244 245 246 247 248 249 |
# File 'lib/usps_api/models/subscriptions_tracking_subscription.rb', line 241 def to_s class_name = self.class.name.split('::').last "<#{class_name} subscription_id: #{@subscription_id}, listener_url: #{@listener_url},"\ " secret: #{@secret}, status: #{@status}, status_reason: #{@status_reason},"\ " admin_notification: #{@admin_notification}, creation_timestamp: #{@creation_timestamp},"\ " status_change_timestamp: #{@status_change_timestamp}, expiration_timestamp:"\ " #{@expiration_timestamp}, access_control: #{@access_control}, filter_properties:"\ " #{@filter_properties}, additional_properties: #{@additional_properties}>" end |