ruby-rest-api
ruby-rest-api copied to clipboard
channel_id being sent rather than ChannelID in start_conversation and conversation_webhook_create
in messagebird gem ver 4.0.0 in client.rb
def start_conversation(to, channel_id, params = {})
Conversation.new(conversation_request(
:post,
'conversations/start',
params.merge(to: to,
channel_id: channel_id)
))
end
but the parameter should be ChannelId so the code should be modified to:
def start_conversation(to, channel_id, params = {})
Conversation.new(conversation_request(
:post,
'conversations/start',
params.merge(to: to,
ChannelId: channel_id)
))
end
also in
def conversation_webhook_create(channel_id, url, events = [])
ConversationWebhook.new(conversation_request(
:post,
'webhooks',
channel_id: channel_id,
url: url,
events: events
))
end
should be:-
def conversation_webhook_create(channel_id, url, events = [])
ConversationWebhook.new(conversation_request(
:post,
'webhooks',
ChannelId: channel_id,
url: url,
events: events
))
end
You can override them by creating a file override_messagebird_methods.b in config/initializers
require 'messagebird'
require 'messagebird/client'
require 'messagebird/conversation'
require 'messagebird/conversation_webhook'
MessageBird::Client.module_eval do
# Redefine the parse_body method on the MessageBird::Client class
def start_conversation(to, channel_id, params = {})
MessageBird::Conversation.new(conversation_request( :post, 'conversations/start', params.merge(to: to, channelId: channel_id)))
end
def conversation_webhook_create(channel_id, url, events = [])
MessageBird::ConversationWebhook.new(conversation_request( :post, 'webhooks', channelId: channel_id, url: url, events: events))
end
end