Class: Pigeon::TwilioController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/pigeon/twilio_controller.rb

Instance Method Summary collapse

Instance Method Details

#get_incoming_phone_numbersObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/pigeon/twilio_controller.rb', line 5

def get_incoming_phone_numbers
   = params[:account_sid].strip
  auth_token = params[:auth_token].strip

  client = Twilio::REST::Client.new , auth_token
  incoming_phones = client..incoming_phone_numbers.list
  json = incoming_phones.map do |phone|
    {
      sid: phone.sid,
      phone_number: phone.phone_number,
      friendly_name: phone.friendly_name,
    }
  end
  render json: json
rescue Twilio::REST::RequestError => ex
  head :unauthorized
end