Class: Verizon::SmsSendRequest

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

Overview

Request to send SMS.

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:, sms_message:, custom_fields: SKIP, data_encoding: SKIP, device_ids: SKIP, group_name: SKIP, service_plan: SKIP, time_to_live: SKIP, additional_properties: nil) ⇒ SmsSendRequest

Returns a new instance of SmsSendRequest.



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

def initialize(account_name:, sms_message:, custom_fields: SKIP,
               data_encoding: SKIP, device_ids: SKIP, group_name: SKIP,
               service_plan: SKIP, time_to_live: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_name = 
  @sms_message = sms_message
  @custom_fields = custom_fields unless custom_fields == SKIP
  @data_encoding = data_encoding unless data_encoding == SKIP
  @device_ids = device_ids unless device_ids == SKIP
  @group_name = group_name unless group_name == SKIP
  @service_plan = service_plan unless service_plan == SKIP
  @time_to_live = time_to_live unless time_to_live == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_nameString

The name of a billing account.

Returns:

  • (String)


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

def 
  @account_name
end

#custom_fieldsArray[CustomFields]

The names and values of custom fields, if you want to only include devices that have matching custom fields.

Returns:



24
25
26
# File 'lib/verizon/models/sms_send_request.rb', line 24

def custom_fields
  @custom_fields
end

#data_encodingString

The SMS message encoding, which can be 7-bit (default), 8-bit-ASCII, 8-bit-UTF-8, 8-bit-DATA.

Returns:

  • (String)


29
30
31
# File 'lib/verizon/models/sms_send_request.rb', line 29

def data_encoding
  @data_encoding
end

#device_idsArray[DeviceId]

The devices that you want to send the message to, specified by device identifier.

Returns:



34
35
36
# File 'lib/verizon/models/sms_send_request.rb', line 34

def device_ids
  @device_ids
end

#group_nameString

The name of a device group, if you want to send the SMS message to all devices in the device group.

Returns:

  • (String)


39
40
41
# File 'lib/verizon/models/sms_send_request.rb', line 39

def group_name
  @group_name
end

#service_planString

The name of a service plan, if you want to only include devices that have that service plan.

Returns:

  • (String)


44
45
46
# File 'lib/verizon/models/sms_send_request.rb', line 44

def service_plan
  @service_plan
end

#sms_messageString

The contents of the SMS message. The SMS message is limited to 160 characters in 7-bit format, or 140 characters in 8-bit format.

Returns:

  • (String)


19
20
21
# File 'lib/verizon/models/sms_send_request.rb', line 19

def sms_message
  @sms_message
end

#time_to_liveString

A period of time the message remains valid or an end date for the message. This value would be less than the 5 day default.

Returns:

  • (String)


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

def time_to_live
  @time_to_live
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



101
102
103
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
142
143
144
145
146
147
148
149
# File 'lib/verizon/models/sms_send_request.rb', line 101

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('accountName') ? hash['accountName'] : nil
  sms_message = hash.key?('smsMessage') ? hash['smsMessage'] : nil
  # Parameter is an array, so we need to iterate through it
  custom_fields = nil
  unless hash['customFields'].nil?
    custom_fields = []
    hash['customFields'].each do |structure|
      custom_fields << (CustomFields.from_hash(structure) if structure)
    end
  end

  custom_fields = SKIP unless hash.key?('customFields')
  data_encoding = hash.key?('dataEncoding') ? hash['dataEncoding'] : SKIP
  # Parameter is an array, so we need to iterate through it
  device_ids = nil
  unless hash['deviceIds'].nil?
    device_ids = []
    hash['deviceIds'].each do |structure|
      device_ids << (DeviceId.from_hash(structure) if structure)
    end
  end

  device_ids = SKIP unless hash.key?('deviceIds')
  group_name = hash.key?('groupName') ? hash['groupName'] : SKIP
  service_plan = hash.key?('servicePlan') ? hash['servicePlan'] : SKIP
  time_to_live = hash.key?('timeToLive') ? hash['timeToLive'] : 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.
  SmsSendRequest.new(account_name: ,
                     sms_message: sms_message,
                     custom_fields: custom_fields,
                     data_encoding: data_encoding,
                     device_ids: device_ids,
                     group_name: group_name,
                     service_plan: service_plan,
                     time_to_live: time_to_live,
                     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
# File 'lib/verizon/models/sms_send_request.rb', line 52

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_name'] = 'accountName'
  @_hash['sms_message'] = 'smsMessage'
  @_hash['custom_fields'] = 'customFields'
  @_hash['data_encoding'] = 'dataEncoding'
  @_hash['device_ids'] = 'deviceIds'
  @_hash['group_name'] = 'groupName'
  @_hash['service_plan'] = 'servicePlan'
  @_hash['time_to_live'] = 'timeToLive'
  @_hash
end

.nullablesObject

An array for nullable fields



78
79
80
# File 'lib/verizon/models/sms_send_request.rb', line 78

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    custom_fields
    data_encoding
    device_ids
    group_name
    service_plan
    time_to_live
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



161
162
163
164
165
166
167
168
# File 'lib/verizon/models/sms_send_request.rb', line 161

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_name: #{@account_name.inspect}, sms_message:"\
  " #{@sms_message.inspect}, custom_fields: #{@custom_fields.inspect}, data_encoding:"\
  " #{@data_encoding.inspect}, device_ids: #{@device_ids.inspect}, group_name:"\
  " #{@group_name.inspect}, service_plan: #{@service_plan.inspect}, time_to_live:"\
  " #{@time_to_live.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



152
153
154
155
156
157
158
# File 'lib/verizon/models/sms_send_request.rb', line 152

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_name: #{@account_name}, sms_message: #{@sms_message},"\
  " custom_fields: #{@custom_fields}, data_encoding: #{@data_encoding}, device_ids:"\
  " #{@device_ids}, group_name: #{@group_name}, service_plan: #{@service_plan}, time_to_live:"\
  " #{@time_to_live}, additional_properties: #{@additional_properties}>"
end