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`.



342
343
344
345
346
347
348
349
350
351
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 342

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



355
356
357
358
359
360
361
362
363
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 355

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

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

#delete_with_metadataBoolean

Delete the UsAppToPersonInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 368

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      usAppToPerson_instance = UsAppToPersonInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      UsAppToPersonInstanceMetadata.new(@version, usAppToPerson_instance, response.headers, response.status_code)
end

#fetch(x_twilio_api_version: :unset) ⇒ UsAppToPersonInstance

Fetch the UsAppToPersonInstance

Parameters:

  • x_twilio_api_version (String) (defaults to: :unset)

    The version of the Messaging API to use for this request

Returns:



388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 388

def fetch(
  x_twilio_api_version: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Api-Version' => x_twilio_api_version, })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    UsAppToPersonInstance.new(
        @version,
        payload,
        messaging_service_sid: @solution[:messaging_service_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadata(x_twilio_api_version: :unset) ⇒ UsAppToPersonInstance

Fetch the UsAppToPersonInstanceMetadata

Parameters:

  • x_twilio_api_version (String) (defaults to: :unset)

    The version of the Messaging API to use for this request

Returns:



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 411

def (
  x_twilio_api_version: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Api-Version' => x_twilio_api_version, })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    us_app_to_person_instance = UsAppToPersonInstance.new(
        @version,
        response.body,
        messaging_service_sid: @solution[:messaging_service_sid],
        sid: @solution[:sid],
    )
    UsAppToPersonInstanceMetadata.new(
        @version,
        us_app_to_person_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



558
559
560
561
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 558

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

#to_sObject

Provide a user friendly representation



551
552
553
554
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 551

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, privacy_policy_url: :unset, terms_and_conditions_url: :unset, x_twilio_api_version: :unset) ⇒ 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.

  • privacy_policy_url (String) (defaults to: :unset)

    The URL of the privacy policy for the campaign.

  • terms_and_conditions_url (String) (defaults to: :unset)

    The URL of the terms and conditions for the campaign.

  • x_twilio_api_version (String) (defaults to: :unset)

    The version of the Messaging API to use for this request

Returns:



449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 449

def update(
  has_embedded_links: nil, 
  has_embedded_phone: nil, 
  message_samples: nil, 
  message_flow: nil, 
  description: nil, 
  age_gated: nil, 
  direct_lending: nil, 
  privacy_policy_url: :unset, 
  terms_and_conditions_url: :unset, 
  x_twilio_api_version: :unset
)

    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,
        'PrivacyPolicyUrl' => privacy_policy_url,
        'TermsAndConditionsUrl' => terms_and_conditions_url,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Api-Version' => x_twilio_api_version, })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    UsAppToPersonInstance.new(
        @version,
        payload,
        messaging_service_sid: @solution[:messaging_service_sid],
        sid: @solution[:sid],
    )
end

#update_with_metadata(has_embedded_links: nil, has_embedded_phone: nil, message_samples: nil, message_flow: nil, description: nil, age_gated: nil, direct_lending: nil, privacy_policy_url: :unset, terms_and_conditions_url: :unset, x_twilio_api_version: :unset) ⇒ UsAppToPersonInstance

Update the UsAppToPersonInstanceMetadata

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.

  • privacy_policy_url (String) (defaults to: :unset)

    The URL of the privacy policy for the campaign.

  • terms_and_conditions_url (String) (defaults to: :unset)

    The URL of the terms and conditions for the campaign.

  • x_twilio_api_version (String) (defaults to: :unset)

    The version of the Messaging API to use for this request

Returns:



502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb', line 502

def (
  has_embedded_links: nil, 
  has_embedded_phone: nil, 
  message_samples: nil, 
  message_flow: nil, 
  description: nil, 
  age_gated: nil, 
  direct_lending: nil, 
  privacy_policy_url: :unset, 
  terms_and_conditions_url: :unset, 
  x_twilio_api_version: :unset
)

    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,
        'PrivacyPolicyUrl' => privacy_policy_url,
        'TermsAndConditionsUrl' => terms_and_conditions_url,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Api-Version' => x_twilio_api_version, })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    us_app_to_person_instance = UsAppToPersonInstance.new(
        @version,
        response.body,
        messaging_service_sid: @solution[:messaging_service_sid],
        sid: @solution[:sid],
    )
    UsAppToPersonInstanceMetadata.new(
        @version,
        us_app_to_person_instance,
        response.headers,
        response.status_code
    )
end