class Twilio::REST::Messaging::V1::ServiceContext::UsAppToPersonList
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
Public Class Methods
Initialize the UsAppToPersonList
@param [Version] version Version
that contains the resource @param [String] messaging_service_sid The SID of the {Messaging
Service}[https://www.twilio.com/docs/messaging/services/api] that the resource is associated with.
@return [UsAppToPersonList] UsAppToPersonList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb 24 def initialize(version, messaging_service_sid: nil) 25 super(version) 26 27 # Path Solution 28 @solution = {messaging_service_sid: messaging_service_sid} 29 @uri = "/Services/#{@solution[:messaging_service_sid]}/Compliance/Usa2p" 30 end
Public Instance Methods
Create the UsAppToPersonInstance
@param [String] brand_registration_sid A2P Brand Registration SID @param [String] description A short description of what this SMS campaign does. @param [Array] message_samples Message samples, at least 2 and up to 5
sample messages, <=1024 chars each.
@param [String] us_app_to_person_usecase A2P Campaign Use Case. Examples: [ 2FA,
EMERGENCY, MARKETING..]
@param [Boolean] has_embedded_links Indicates that this SMS campaign will send
messages that contain links.
@param [Boolean] has_embedded_phone Indicates that this SMS campaign will send
messages that contain phone numbers.
@return [UsAppToPersonInstance] Created UsAppToPersonInstance
# File lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb 45 def create(brand_registration_sid: nil, description: nil, message_samples: nil, us_app_to_person_usecase: nil, has_embedded_links: nil, has_embedded_phone: nil) 46 data = Twilio::Values.of({ 47 'BrandRegistrationSid' => brand_registration_sid, 48 'Description' => description, 49 'MessageSamples' => Twilio.serialize_list(message_samples) { |e| e }, 50 'UsAppToPersonUsecase' => us_app_to_person_usecase, 51 'HasEmbeddedLinks' => has_embedded_links, 52 'HasEmbeddedPhone' => has_embedded_phone, 53 }) 54 55 payload = @version.create('POST', @uri, data: data) 56 57 UsAppToPersonInstance.new( 58 @version, 59 payload, 60 messaging_service_sid: @solution[:messaging_service_sid], 61 ) 62 end
When passed a block, yields UsAppToPersonInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb 102 def each 103 limits = @version.read_limits 104 105 page = self.page(page_size: limits[:page_size], ) 106 107 @version.stream(page, 108 limit: limits[:limit], 109 page_limit: limits[:page_limit]).each {|x| yield x} 110 end
Retrieve a single page of UsAppToPersonInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of UsAppToPersonInstance
# File lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb 136 def get_page(target_url) 137 response = @version.domain.request( 138 'GET', 139 target_url 140 ) 141 UsAppToPersonPage.new(@version, response, @solution) 142 end
Lists UsAppToPersonInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Array] Array of up to limit results
# File lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb 75 def list(limit: nil, page_size: nil) 76 self.stream(limit: limit, page_size: page_size).entries 77 end
Retrieve a single page of UsAppToPersonInstance
records from the API. Request
is executed immediately. @param [String] page_token PageToken provided by the API @param [Integer] page_number Page
Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page
of UsAppToPersonInstance
# File lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb 119 def page(page_token: :unset, page_number: :unset, page_size: :unset) 120 params = Twilio::Values.of({ 121 'PageToken' => page_token, 122 'Page' => page_number, 123 'PageSize' => page_size, 124 }) 125 126 response = @version.page('GET', @uri, params: params) 127 128 UsAppToPersonPage.new(@version, response, @solution) 129 end
Streams UsAppToPersonInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit.
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Enumerable] Enumerable that will yield up to limit results
# File lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb 90 def stream(limit: nil, page_size: nil) 91 limits = @version.read_limits(limit, page_size) 92 93 page = self.page(page_size: limits[:page_size], ) 94 95 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 96 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/messaging/v1/service/us_app_to_person.rb 146 def to_s 147 '#<Twilio.Messaging.V1.UsAppToPersonList>' 148 end