Using Twilio Ruby SDK

If you are using the Twilio Ruby SDK, you can override the initialize method of the base class using the following code snippet:

require "twilio-ruby"

class Twilio::REST::ApiBase 
  def initialize(twilio)
    super(twilio)
    @base_url =  "https://us-west-1.twilio.to.nest.messagebird.com"
    @host = "us-west-1.twilio.to.nest.messagebird.com"
    @port = 443
    @v2010 = nil
  end
end

This would allow you to make a request to the MessageBird Twilio Adapter. You can try it out with the following sample code:

require "twilio-ruby"

class Twilio::REST::ApiBase 
  def initialize(twilio)
    super(twilio)
    @base_url =  "https://eu-west-1.twilio.to.nest.messagebird.com"
    @host = "eu-west-1.twilio.to.nest.messagebird.com"
    @port = 443
    @v2010 = nil
  end
end

# Your Account SID and Auth Token
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

@client = Twilio::REST::Client.new account_sid, auth_token
message = @client.messages.create(
  body: "Hello from Ruby",
  to: "+12345678901",  # Text this number
  from: "+15005550006", # From a valid MessageBird number
)

puts message.sid

Last updated