Module: Twilio::Finder

Instance Method Summary collapse

Instance Method Details

#all(opts = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/twilio/finder.rb', line 27

def all(opts={})
  opts        = opts.with_indifferent_access
  # Support subaccounts by optionally passing in an account_sid or account object
   = opts.delete('account_sid') || opts.delete('account').try(:sid) || Twilio::ACCOUNT_SID
  connect     = opts.delete 'connect'

  params      = prepare_params opts if opts.any?
  handle_response get "#{resource_path()}.json#{params}", :account_sid => (connect && )
end

#count(opts = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/twilio/finder.rb', line 17

def count(opts={})
  opts        = opts.with_indifferent_access
  # Support subaccounts by optionally passing in an account_sid or account object
   = opts.delete('account_sid') || opts.delete('account').try(:sid) || Twilio::ACCOUNT_SID
  connect     = opts.delete 'connect'

  params      = prepare_params opts if opts.any?
  get("#{resource_path()}.json#{params}", :account_sid => (connect && )).parsed_response['total']
end

#find(id, opts = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/twilio/finder.rb', line 3

def find(id, opts={})
  opts        = opts.with_indifferent_access
  # Support subaccounts by optionally passing in an account_sid or account object
   = opts.delete('account_sid') || opts.delete('account').try(:sid) || Twilio::ACCOUNT_SID
  connect     = opts.delete 'connect'

  res  = get "#{resource_path()}/#{id}.json", :account_sid => (connect && )
  hash = res.parsed_response
  if (200..299).include? res.code
    hash['api_version'] = hash['api_version'].to_s # api_version parsed as a date by http_party
    new hash
  end
end