Class: Verizon::UsageTriggerAddRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/usage_trigger_add_request.rb

Overview

UsageTriggerAddRequest Model.

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(account_name:, service_name: ServiceName::LOCATION, threshold_value:, trigger_name: SKIP, allow_excess: SKIP, send_sms_notification: SKIP, sms_phone_numbers: SKIP, send_email_notification: SKIP, email_addresses: SKIP, additional_properties: nil) ⇒ UsageTriggerAddRequest

Returns a new instance of UsageTriggerAddRequest.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 83

def initialize(account_name:, service_name: ServiceName::LOCATION,
               threshold_value:, trigger_name: SKIP, allow_excess: SKIP,
               send_sms_notification: SKIP, sms_phone_numbers: SKIP,
               send_email_notification: SKIP, email_addresses: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @trigger_name = trigger_name unless trigger_name == SKIP
  @account_name = 
  @service_name = service_name
  @threshold_value = threshold_value
  @allow_excess = allow_excess unless allow_excess == SKIP
  @send_sms_notification = send_sms_notification unless send_sms_notification == SKIP
  @sms_phone_numbers = sms_phone_numbers unless sms_phone_numbers == SKIP
  @send_email_notification = send_email_notification unless send_email_notification == SKIP
  @email_addresses = email_addresses unless email_addresses == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_nameString

Account name

Returns:

  • (String)


18
19
20
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 18

def 
  @account_name
end

#allow_excessTrueClass | FalseClass

Allow additional requests after thresholdValue is reached. (currently not functional)

Returns:

  • (TrueClass | FalseClass)


32
33
34
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 32

def allow_excess
  @allow_excess
end

#email_addressesString

Comma-separated list of email addresses to send alerts to.

Returns:

  • (String)


49
50
51
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 49

def email_addresses
  @email_addresses
end

#send_email_notificationTrueClass | FalseClass

Send email alerts when the thresholdValue is reached.

Returns:

  • (TrueClass | FalseClass)


45
46
47
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 45

def send_email_notification
  @send_email_notification
end

#send_sms_notificationTrueClass | FalseClass

Send SMS (text) alerts when the thresholdValue is reached.

Returns:

  • (TrueClass | FalseClass)


36
37
38
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 36

def send_sms_notification
  @send_sms_notification
end

#service_nameServiceName

Service name

Returns:



22
23
24
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 22

def service_name
  @service_name
end

#sms_phone_numbersString

Comma-separated list of phone numbers to send SMS alerts to. Digits only; no dashes or parentheses, etc.

Returns:

  • (String)


41
42
43
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 41

def sms_phone_numbers
  @sms_phone_numbers
end

#threshold_valueString

The percent of subscribed usage required to activate the trigger, such as 90 or 100.

Returns:

  • (String)


27
28
29
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 27

def threshold_value
  @threshold_value
end

#trigger_nameString

Usage trigger name

Returns:

  • (String)


14
15
16
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 14

def trigger_name
  @trigger_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 104

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('accountName') ? hash['accountName'] : nil
  service_name = hash['serviceName'] ||= ServiceName::LOCATION
  threshold_value =
    hash.key?('thresholdValue') ? hash['thresholdValue'] : nil
  trigger_name = hash.key?('triggerName') ? hash['triggerName'] : SKIP
  allow_excess = hash.key?('allowExcess') ? hash['allowExcess'] : SKIP
  send_sms_notification =
    hash.key?('sendSmsNotification') ? hash['sendSmsNotification'] : SKIP
  sms_phone_numbers =
    hash.key?('smsPhoneNumbers') ? hash['smsPhoneNumbers'] : SKIP
  send_email_notification =
    hash.key?('sendEmailNotification') ? hash['sendEmailNotification'] : SKIP
  email_addresses =
    hash.key?('emailAddresses') ? hash['emailAddresses'] : 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.
  UsageTriggerAddRequest.new(account_name: ,
                             service_name: service_name,
                             threshold_value: threshold_value,
                             trigger_name: trigger_name,
                             allow_excess: allow_excess,
                             send_sms_notification: send_sms_notification,
                             sms_phone_numbers: sms_phone_numbers,
                             send_email_notification: send_email_notification,
                             email_addresses: email_addresses,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 52

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['trigger_name'] = 'triggerName'
  @_hash['account_name'] = 'accountName'
  @_hash['service_name'] = 'serviceName'
  @_hash['threshold_value'] = 'thresholdValue'
  @_hash['allow_excess'] = 'allowExcess'
  @_hash['send_sms_notification'] = 'sendSmsNotification'
  @_hash['sms_phone_numbers'] = 'smsPhoneNumbers'
  @_hash['send_email_notification'] = 'sendEmailNotification'
  @_hash['email_addresses'] = 'emailAddresses'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 79

def self.nullables
  []
end

.optionalsObject

An array for optional fields



67
68
69
70
71
72
73
74
75
76
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 67

def self.optionals
  %w[
    trigger_name
    allow_excess
    send_sms_notification
    sms_phone_numbers
    send_email_notification
    email_addresses
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



154
155
156
157
158
159
160
161
162
163
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 154

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} trigger_name: #{@trigger_name.inspect}, account_name:"\
  " #{@account_name.inspect}, service_name: #{@service_name.inspect}, threshold_value:"\
  " #{@threshold_value.inspect}, allow_excess: #{@allow_excess.inspect},"\
  " send_sms_notification: #{@send_sms_notification.inspect}, sms_phone_numbers:"\
  " #{@sms_phone_numbers.inspect}, send_email_notification:"\
  " #{@send_email_notification.inspect}, email_addresses: #{@email_addresses.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



144
145
146
147
148
149
150
151
# File 'lib/verizon/models/usage_trigger_add_request.rb', line 144

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} trigger_name: #{@trigger_name}, account_name: #{@account_name},"\
  " service_name: #{@service_name}, threshold_value: #{@threshold_value}, allow_excess:"\
  " #{@allow_excess}, send_sms_notification: #{@send_sms_notification}, sms_phone_numbers:"\
  " #{@sms_phone_numbers}, send_email_notification: #{@send_email_notification},"\
  " email_addresses: #{@email_addresses}, additional_properties: #{@additional_properties}>"
end