Class: Twilio::REST::Messaging::V1::ServiceContext::UsAppToPersonContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, messaging_service_sid, sid) ⇒ UsAppToPersonContext

Initialize the UsAppToPersonContext

Parameters:

  • version (Version)

    Version that contains the resource

  • messaging_service_sid (String)

    The SID of the [Messaging Service](www.twilio.com/docs/messaging/services/api) to update the resource from.

  • sid (String)

    The SID of the US A2P Compliance resource to update ‘QE2c6890da8086d771620e9b13fadeba0b`.



202
203
204
205
206
207
208
209
210
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 202

def initialize(version, messaging_service_sid, sid)
    super(version)

    # Path Solution
    @solution = { messaging_service_sid: messaging_service_sid, sid: sid,  }
    @uri = "/Services/#{@solution[:messaging_service_sid]}/Compliance/Usa2p/#{@solution[:sid]}"

    
end

Instance Method Details

#deleteBoolean

Delete the UsAppToPersonInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



214
215
216
217
218
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 214

def delete

    
    @version.delete('DELETE', @uri)
end

#fetchUsAppToPersonInstance

Fetch the UsAppToPersonInstance

Returns:



223
224
225
226
227
228
229
230
231
232
233
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 223

def fetch

    
    payload = @version.fetch('GET', @uri)
    UsAppToPersonInstance.new(
        @version,
        payload,
        messaging_service_sid: @solution[:messaging_service_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



285
286
287
288
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 285

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Messaging.V1.UsAppToPersonContext #{context}>"
end

#to_sObject

Provide a user friendly representation



278
279
280
281
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 278

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Messaging.V1.UsAppToPersonContext #{context}>"
end

#update(has_embedded_links: nil, has_embedded_phone: nil, message_samples: nil, message_flow: nil, description: nil, age_gated: nil, direct_lending: nil) ⇒ UsAppToPersonInstance

Update the UsAppToPersonInstance

Parameters:

  • has_embedded_links (Boolean) (defaults to: nil)

    Indicates that this SMS campaign will send messages that contain links.

  • has_embedded_phone (Boolean) (defaults to: nil)

    Indicates that this SMS campaign will send messages that contain phone numbers.

  • message_samples (Array[String]) (defaults to: nil)

    An array of sample message strings, min two and max five. Min length for each sample: 20 chars. Max length for each sample: 1024 chars.

  • message_flow (String) (defaults to: nil)

    Required for all Campaigns. Details around how a consumer opts-in to their campaign, therefore giving consent to receive their messages. If multiple opt-in methods can be used for the same campaign, they must all be listed. 40 character minimum. 2048 character maximum.

  • description (String) (defaults to: nil)

    A short description of what this SMS campaign does. Min length: 40 characters. Max length: 4096 characters.

  • age_gated (Boolean) (defaults to: nil)

    A boolean that specifies whether campaign requires age gate for federally legal content.

  • direct_lending (Boolean) (defaults to: nil)

    A boolean that specifies whether campaign allows direct lending or not.

Returns:



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 245

def update(
    has_embedded_links: nil, 
    has_embedded_phone: nil, 
    message_samples: nil, 
    message_flow: nil, 
    description: nil, 
    age_gated: nil, 
    direct_lending: nil
)

    data = Twilio::Values.of({
        'HasEmbeddedLinks' => has_embedded_links,
        'HasEmbeddedPhone' => has_embedded_phone,
        'MessageSamples' => Twilio.serialize_list(message_samples) { |e| e },
        'MessageFlow' => message_flow,
        'Description' => description,
        'AgeGated' => age_gated,
        'DirectLending' => direct_lending,
    })

    
    payload = @version.update('POST', @uri, data: data)
    UsAppToPersonInstance.new(
        @version,
        payload,
        messaging_service_sid: @solution[:messaging_service_sid],
        sid: @solution[:sid],
    )
end