I'm using ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
rails: Rails 5.1.3
I have action in which I check a phone number if it is valid or not and action where I send message. the message action working perfectly but I get an error when I try to check a number. this is the action
def check_phone_number
account_sid = Rails.application.secrets.twilio_sid
auth_token = Rails.application.secrets.twilio_token
@lookup_client = Twilio::REST::LookupsClient.new(account_sid,
auth_token)
response = @lookup_client.phone_numbers.get("#
{params[:phone_number]}")
begin
response.phone_number
render json: {'response' => 'ok'}
rescue Exception => e
if e.code == 20404
render json: { 'error' => 'Invalid Number' }
else
render json: { 'error' => 'Invalid Number' }
end
end
end
the error is uninitialised Twilio::REST::LookupsClient
how can I solve it?