Class: UspsApi::EnabledNotificationRequests

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/enabled_notification_requests.rb

Overview

USPS® Text Tracking is a mechanism by which customers can be notified of the status of their package.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(sms: SKIP, e_mail: SKIP) ⇒ EnabledNotificationRequests

Returns a new instance of EnabledNotificationRequests.



42
43
44
45
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 42

def initialize(sms: SKIP, e_mail: SKIP)
  @sms = sms unless sms == SKIP
  @e_mail = e_mail unless e_mail == SKIP
end

Instance Attribute Details

#e_mailEMail

E-mail notification.

Returns:



19
20
21
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 19

def e_mail
  @e_mail
end

#smsAvailableNotificationOptions

Noticication options that are available for the tracking number



15
16
17
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 15

def sms
  @sms
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 48

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  sms = AvailableNotificationOptions.from_hash(hash['SMS']) if hash['SMS']
  e_mail = EMail.from_hash(hash['EMail']) if hash['EMail']

  # Create object from extracted values.
  EnabledNotificationRequests.new(sms: sms,
                                  e_mail: e_mail)
end

.namesObject

A mapping from model property names to API property names.



22
23
24
25
26
27
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 22

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['sms'] = 'SMS'
  @_hash['e_mail'] = 'EMail'
  @_hash
end

.nullablesObject

An array for nullable fields



38
39
40
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 38

def self.nullables
  []
end

.optionalsObject

An array for optional fields



30
31
32
33
34
35
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 30

def self.optionals
  %w[
    sms
    e_mail
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



62
63
64
65
66
67
68
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 62

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



77
78
79
80
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 77

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} sms: #{@sms.inspect}, e_mail: #{@e_mail.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



71
72
73
74
# File 'lib/usps_api/models/enabled_notification_requests.rb', line 71

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} sms: #{@sms}, e_mail: #{@e_mail}>"
end