Skip to content

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

@qvrb

Description

@qvrb

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


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions