Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom header support #516

Merged
merged 2 commits into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions lib/twilio-ruby/framework/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def exception(response, header)
Twilio::REST::RestError.new(header, response)
end

def fetch(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil)
def fetch(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
response = request(
method,
uri,
Expand Down Expand Up @@ -93,7 +93,7 @@ def update(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: n
response.body
end

def delete(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil)
def delete(method, uri, params: {}, data: {}, headers: {}, auth: nil, timeout: nil)
response = request(
method,
uri,
Expand Down Expand Up @@ -127,7 +127,7 @@ def read_limits(limit = nil, page_size = nil)
}
end

def page(method, uri, params = {}, data = {}, headers = {}, auth = nil, timeout = nil)
def page(method, uri, params = {}, data = {}, headers: {}, auth: nil, timeout: nil)
eshanholtz marked this conversation as resolved.
Show resolved Hide resolved
request(
method,
uri,
Expand Down
33 changes: 24 additions & 9 deletions lib/twilio-ruby/rest/chat/v2/service/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ def initialize(version, service_sid: nil)
# backup/separate source and where a Message was previously updated.
# @param [String] created_by The `identity` of the User that created the channel.
# Default is: `system`.
# @param [channel.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [ChannelInstance] Created ChannelInstance
def create(friendly_name: :unset, unique_name: :unset, attributes: :unset, type: :unset, date_created: :unset, date_updated: :unset, created_by: :unset)
def create(friendly_name: :unset, unique_name: :unset, attributes: :unset, type: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset)
data = Twilio::Values.of({
'FriendlyName' => friendly_name,
'UniqueName' => unique_name,
Expand All @@ -62,8 +64,9 @@ def create(friendly_name: :unset, unique_name: :unset, attributes: :unset, type:
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
'CreatedBy' => created_by,
})
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

payload = @version.create('POST', @uri, data: data)
payload = @version.create('POST', @uri, data: data, headers: headers)

ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], )
end
Expand Down Expand Up @@ -226,9 +229,13 @@ def fetch

##
# Delete the ChannelInstance
# @param [channel.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [Boolean] true if delete succeeds, false otherwise
def delete
@version.delete('DELETE', @uri)
def delete(x_twilio_webhook_enabled: :unset)
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

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

##
Expand All @@ -251,8 +258,10 @@ def delete
# as the date it was last updated.
# @param [String] created_by The `identity` of the User that created the channel.
# Default is: `system`.
# @param [channel.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [ChannelInstance] Updated ChannelInstance
def update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset)
def update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset)
data = Twilio::Values.of({
'FriendlyName' => friendly_name,
'UniqueName' => unique_name,
Expand All @@ -261,8 +270,9 @@ def update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
'CreatedBy' => created_by,
})
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

payload = @version.update('POST', @uri, data: data)
payload = @version.update('POST', @uri, data: data, headers: headers)

ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
end
Expand Down Expand Up @@ -511,9 +521,11 @@ def fetch

##
# Delete the ChannelInstance
# @param [channel.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [Boolean] true if delete succeeds, false otherwise
def delete
context.delete
def delete(x_twilio_webhook_enabled: :unset)
context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
end

##
Expand All @@ -536,15 +548,18 @@ def delete
# as the date it was last updated.
# @param [String] created_by The `identity` of the User that created the channel.
# Default is: `system`.
# @param [channel.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [ChannelInstance] Updated ChannelInstance
def update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset)
def update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset)
context.update(
friendly_name: friendly_name,
unique_name: unique_name,
attributes: attributes,
date_created: date_created,
date_updated: date_updated,
created_by: created_by,
x_twilio_webhook_enabled: x_twilio_webhook_enabled,
)
end

Expand Down
33 changes: 24 additions & 9 deletions lib/twilio-ruby/rest/chat/v2/service/channel/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def initialize(version, service_sid: nil, channel_sid: nil)
# backup/separate source and where a Member was previously updated.
# @param [String] attributes A valid JSON string that contains
# application-specific data.
# @param [member.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [MemberInstance] Created MemberInstance
def create(identity: nil, role_sid: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset, date_created: :unset, date_updated: :unset, attributes: :unset)
def create(identity: nil, role_sid: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset)
data = Twilio::Values.of({
'Identity' => identity,
'RoleSid' => role_sid,
Expand All @@ -73,8 +75,9 @@ def create(identity: nil, role_sid: :unset, last_consumed_message_index: :unset,
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
'Attributes' => attributes,
})
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

payload = @version.create('POST', @uri, data: data)
payload = @version.create('POST', @uri, data: data, headers: headers)

MemberInstance.new(
@version,
Expand Down Expand Up @@ -257,9 +260,13 @@ def fetch

##
# Delete the MemberInstance
# @param [member.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [Boolean] true if delete succeeds, false otherwise
def delete
@version.delete('DELETE', @uri)
def delete(x_twilio_webhook_enabled: :unset)
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

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

##
Expand All @@ -285,8 +292,10 @@ def delete
# as the date it was last updated.
# @param [String] attributes A valid JSON string that contains
# application-specific data.
# @param [member.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [MemberInstance] Updated MemberInstance
def update(role_sid: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset, date_created: :unset, date_updated: :unset, attributes: :unset)
def update(role_sid: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset)
data = Twilio::Values.of({
'RoleSid' => role_sid,
'LastConsumedMessageIndex' => last_consumed_message_index,
Expand All @@ -295,8 +304,9 @@ def update(role_sid: :unset, last_consumed_message_index: :unset, last_consumpti
'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
'Attributes' => attributes,
})
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

payload = @version.update('POST', @uri, data: data)
payload = @version.update('POST', @uri, data: data, headers: headers)

MemberInstance.new(
@version,
Expand Down Expand Up @@ -461,9 +471,11 @@ def fetch

##
# Delete the MemberInstance
# @param [member.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [Boolean] true if delete succeeds, false otherwise
def delete
context.delete
def delete(x_twilio_webhook_enabled: :unset)
context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
end

##
Expand All @@ -489,15 +501,18 @@ def delete
# as the date it was last updated.
# @param [String] attributes A valid JSON string that contains
# application-specific data.
# @param [member.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [MemberInstance] Updated MemberInstance
def update(role_sid: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset, date_created: :unset, date_updated: :unset, attributes: :unset)
def update(role_sid: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset)
context.update(
role_sid: role_sid,
last_consumed_message_index: last_consumed_message_index,
last_consumption_timestamp: last_consumption_timestamp,
date_created: date_created,
date_updated: date_updated,
attributes: attributes,
x_twilio_webhook_enabled: x_twilio_webhook_enabled,
)
end

Expand Down
33 changes: 24 additions & 9 deletions lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ def initialize(version, service_sid: nil, channel_sid: nil)
# @param [String] media_sid The SID of the
# [Media](https://www.twilio.com/docs/chat/rest/media) to attach to the new
# Message.
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [MessageInstance] Created MessageInstance
def create(from: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, body: :unset, media_sid: :unset)
def create(from: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, body: :unset, media_sid: :unset, x_twilio_webhook_enabled: :unset)
data = Twilio::Values.of({
'From' => from,
'Attributes' => attributes,
Expand All @@ -65,8 +67,9 @@ def create(from: :unset, attributes: :unset, date_created: :unset, date_updated:
'Body' => body,
'MediaSid' => media_sid,
})
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

payload = @version.create('POST', @uri, data: data)
payload = @version.create('POST', @uri, data: data, headers: headers)

MessageInstance.new(
@version,
Expand Down Expand Up @@ -242,9 +245,13 @@ def fetch

##
# Delete the MessageInstance
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [Boolean] true if delete succeeds, false otherwise
def delete
@version.delete('DELETE', @uri)
def delete(x_twilio_webhook_enabled: :unset)
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

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

##
Expand All @@ -267,8 +274,10 @@ def delete
# updated the Message, if applicable.
# @param [String] from The [Identity](https://www.twilio.com/docs/chat/identity)
# of the message's author.
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [MessageInstance] Updated MessageInstance
def update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, from: :unset)
def update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, from: :unset, x_twilio_webhook_enabled: :unset)
data = Twilio::Values.of({
'Body' => body,
'Attributes' => attributes,
Expand All @@ -277,8 +286,9 @@ def update(body: :unset, attributes: :unset, date_created: :unset, date_updated:
'LastUpdatedBy' => last_updated_by,
'From' => from,
})
headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })

payload = @version.update('POST', @uri, data: data)
payload = @version.update('POST', @uri, data: data, headers: headers)

MessageInstance.new(
@version,
Expand Down Expand Up @@ -470,9 +480,11 @@ def fetch

##
# Delete the MessageInstance
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [Boolean] true if delete succeeds, false otherwise
def delete
context.delete
def delete(x_twilio_webhook_enabled: :unset)
context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
end

##
Expand All @@ -495,15 +507,18 @@ def delete
# updated the Message, if applicable.
# @param [String] from The [Identity](https://www.twilio.com/docs/chat/identity)
# of the message's author.
# @param [message.WebhookEnabledType] x_twilio_webhook_enabled The
# X-Twilio-Webhook-Enabled HTTP request header
# @return [MessageInstance] Updated MessageInstance
def update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, from: :unset)
def update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, from: :unset, x_twilio_webhook_enabled: :unset)
context.update(
body: body,
attributes: attributes,
date_created: date_created,
date_updated: date_updated,
last_updated_by: last_updated_by,
from: from,
x_twilio_webhook_enabled: x_twilio_webhook_enabled,
)
end

Expand Down
Loading