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

channel_id being sent rather than ChannelID in start_conversation and conversation_webhook_create #84

Open
qvrb opened this issue Mar 7, 2023 · 0 comments

Comments

@qvrb
Copy link

qvrb commented Mar 7, 2023

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


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant