Method: CTM::NumberList#search
- Defined in:
- lib/ctm/number_list.rb
#search(country_code, options = {}) ⇒ Object
find a number within the given country/region and options like area_code or containing with contains
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ctm/number_list.rb', line 16 def search(country_code, ={}) = {:country_code => country_code}.merge() path_str = "/api/v1/#{@list_type_path}/search.json" res = self.class.get(path_str, :query => .merge(:auth_token => @token)) data = res.parsed_response if data["status"] == "success" list_data = {'available_numbers' => data['results'].map {|res| res.merge('account_id' => @account_id) }, 'page' => 1, 'per_page' => data['results'].size, 'total_entries' => data['results'].size} CTM::List.new('AvailableNumber', {:account_id => @account_id}, @token, list_data) else raise CTM::Error::List.new(data["error"]) end end |