Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 10 additions & 3 deletions lib/twilio-ruby/framework/rest/page_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module Twilio
module REST
# Page Base Class
class PageMetadata

META_KEYS = [
'end',
'first_page_uri',
Expand Down Expand Up @@ -74,8 +73,6 @@ def get_instance(payload)
end

def previous_page
return nil unless previous_page_url

@version.domain.request('GET', previous_page_url)
end

Expand All @@ -85,6 +82,16 @@ def next_page
@version.domain.request('GET', next_page_url)
end

def page_size
if @payload.body['meta'] && @payload.body['meta']['page_size']
return @payload.body['meta']['page_size']
elsif @payload.body['page_size']
return @payload.body['page_size']
end

0
end

def to_s
'#<PageMetadata>'
end
Expand Down
17 changes: 17 additions & 0 deletions lib/twilio-ruby/framework/rest/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ def initialize(version)
end

class InstanceResourceMetadata
def initialize(payload, headers, status_code)
@payload = payload
@headers = headers
@status_code = status_code
end

def headers
@headers
end

def status_code
@status_code
end
end

class InstanceListResource
def initialize(version, headers, status_code)
@version = version
@headers = headers
Expand All @@ -30,6 +46,7 @@ def initialize(version, headers, status_code)
def headers
@headers
end

def status_code
@status_code
end
Expand Down
22 changes: 18 additions & 4 deletions lib/twilio-ruby/framework/rest/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ def stream(page, limit: nil, page_limit: nil)
RecordStream.new(page, limit: limit, page_limit: page_limit)
end

def stream_with_metadata(page, limit: nil, page_limit: nil)
RecordStream.new(page, limit: limit, page_limit: page_limit)
end

def create(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
response = request(method, uri, params, data, headers, auth, timeout)

Expand Down Expand Up @@ -217,6 +213,24 @@ def update_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: n

response
end

def delete_with_metadata(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
response = request(
method,
uri,
params,
data,
headers,
auth,
timeout
)

if response.status_code < 200 || response.status_code >= 400
raise exception(response, 'Unable to delete record')
end

response
end
end
end
end
111 changes: 111 additions & 0 deletions lib/twilio-ruby/rest/accounts/v1/auth_token_promotion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ def update
)
end

##
# Update the AuthTokenPromotionInstanceMetadata
# @return [AuthTokenPromotionInstance] Updated AuthTokenPromotionInstance
def update_with_metadata

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





response = @version.update_with_metadata('POST', @uri, headers: headers)
authTokenPromotion_instance = AuthTokenPromotionInstance.new(
@version,
response.body,
)
AuthTokenPromotionInstanceMetadata.new(
@version,
authTokenPromotion_instance,
response.headers,
response.status_code
)
end


##
# Provide a user friendly representation
Expand All @@ -88,6 +112,45 @@ def inspect
end
end

class AuthTokenPromotionInstanceMetadata < InstanceResourceMetadata
##
# Initializes a new AuthTokenPromotionInstanceMetadata.
# @param [Version] version Version that contains the resource
# @param [}AuthTokenPromotionInstance] auth_token_promotion_instance The instance associated with the metadata.
# @param [Hash] headers Header object with response headers.
# @param [Integer] status_code The HTTP status code of the response.
# @return [AuthTokenPromotionInstanceMetadata] The initialized instance with metadata.
def initialize(version, auth_token_promotion_instance, headers, status_code)
super(version, headers, status_code)
@auth_token_promotion_instance = auth_token_promotion_instance
end

def auth_token_promotion
@auth_token_promotion_instance
end

def to_s
"<Twilio.Api.V2010.AuthTokenPromotionInstanceMetadata status=#{@status_code}>"
end
end

class AuthTokenPromotionListResponse < InstanceListResource
# @param [Array<AuthTokenPromotionInstance>] instance
# @param [Hash{String => Object}] headers
# @param [Integer] status_code
def initialize(version, payload, key)
@auth_token_promotion_instance = payload.body[key].map do |data|
AuthTokenPromotionInstance.new(version, data)
end
@headers = payload.headers
@status_code = payload.status_code
end

def auth_token_promotion_instance
@instance
end
end

class AuthTokenPromotionPage < Page
##
# Initialize the AuthTokenPromotionPage
Expand Down Expand Up @@ -116,6 +179,54 @@ def to_s
'<Twilio.Accounts.V1.AuthTokenPromotionPage>'
end
end

class AuthTokenPromotionPageMetadata < PageMetadata
attr_reader :auth_token_promotion_page

def initialize(version, response, solution, limit)
super(version, response)
@auth_token_promotion_page = []
@limit = limit
key = get_key(response.body)
number_of_records = response.body[key].size
while( limit != :unset && number_of_records <= limit )
@auth_token_promotion_page << AuthTokenPromotionListResponse.new(version, @payload, key)
@payload = self.next_page
break unless @payload
number_of_records += page_size
end
# Path Solution
@solution = solution
end

def each
@auth_token_promotion_page.each do |record|
yield record
end
end

def to_s
'<Twilio::REST::Accounts::V1PageMetadata>';
end
end
class AuthTokenPromotionListResponse < InstanceListResource

# @param [Array<AuthTokenPromotionInstance>] instance
# @param [Hash{String => Object}] headers
# @param [Integer] status_code
def initialize(version, payload, key)
@auth_token_promotion = payload.body[key].map do |data|
AuthTokenPromotionInstance.new(version, data)
end
@headers = payload.headers
@status_code = payload.status_code
end

def auth_token_promotion
@auth_token_promotion
end
end

class AuthTokenPromotionInstance < InstanceResource
##
# Initialize the AuthTokenPromotionInstance
Expand Down
79 changes: 79 additions & 0 deletions lib/twilio-ruby/rest/accounts/v1/bulk_consents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,37 @@ def create(
)
end

##
# Create the BulkConsentsInstanceMetadata
# @param [Array[Hash]] items This is a list of objects that describes a contact's opt-in status. Each object contains the following fields: `contact_id`, which must be a string representing phone number in [E.164 format](https://www.twilio.com/docs/glossary/what-e164); `correlation_id`, a unique 32-character UUID used to uniquely map the request item with the response item; `sender_id`, which can be either a valid messaging service SID or a from phone number; `status`, a string representing the consent status. Can be one of [`opt-in`, `opt-out`]; `source`, a string indicating the medium through which the consent was collected. Can be one of [`website`, `offline`, `opt-in-message`, `opt-out-message`, `others`]; `date_of_consent`, an optional datetime string field in ISO-8601 format that captures the exact date and time when the user gave or revoked consent. If not provided, it will be empty.
# @return [BulkConsentsInstance] Created BulkConsentsInstance
def create_with_metadata(
items: nil
)

data = Twilio::Values.of({
'Items' => Twilio.serialize_list(items) { |e| Twilio.serialize_object(e) },
})

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





response = @version.create_with_metadata('POST', @uri, data: data, headers: headers)
bulkConsents_instance = BulkConsentsInstance.new(
@version,
response.body,
)
BulkConsentsInstanceMetadata.new(
@version,
bulkConsents_instance,
response.headers,
response.status_code
)
end




Expand Down Expand Up @@ -92,6 +123,54 @@ def to_s
'<Twilio.Accounts.V1.BulkConsentsPage>'
end
end

class BulkConsentsPageMetadata < PageMetadata
attr_reader :bulk_consents_page

def initialize(version, response, solution, limit)
super(version, response)
@bulk_consents_page = []
@limit = limit
key = get_key(response.body)
number_of_records = response.body[key].size
while( limit != :unset && number_of_records <= limit )
@bulk_consents_page << BulkConsentsListResponse.new(version, @payload, key)
@payload = self.next_page
break unless @payload
number_of_records += page_size
end
# Path Solution
@solution = solution
end

def each
@bulk_consents_page.each do |record|
yield record
end
end

def to_s
'<Twilio::REST::Accounts::V1PageMetadata>';
end
end
class BulkConsentsListResponse < InstanceListResource

# @param [Array<BulkConsentsInstance>] instance
# @param [Hash{String => Object}] headers
# @param [Integer] status_code
def initialize(version, payload, key)
@bulk_consents = payload.body[key].map do |data|
BulkConsentsInstance.new(version, data)
end
@headers = payload.headers
@status_code = payload.status_code
end

def bulk_consents
@bulk_consents
end
end

class BulkConsentsInstance < InstanceResource
##
# Initialize the BulkConsentsInstance
Expand Down
Loading
Loading