Skip to content

prefixes

Md. Mazharul islam Mithu edited this page May 4, 2017 · 1 revision

This API allow you to get a list of all available countries and the associated calling prefixes.

client = CheckMobi::Resources::Prefixes.new
response = client.perform

If everything works fine you should get response like this

#<CheckMobi::Response:0x00000002457700
 @http_client=
  #<CheckMobi::Client:0x0000000239e890
   @endpoint=#<URI::HTTPS https://api.checkmobi.com/v1/prefixes>,
   @headers={"Content-Type"=>"application/json", "Accept"=>"application/json", "Authorization"=>nil},
   @request=#<Net::HTTP::Get GET>,
   @response=#<Net::HTTPOK 200 OK readbody=true>>>

Then you can get prefixes like this

prefixes = response.response_body

The response comes in json, you might want to convert it parse that

require 'json'
prefixes = JSON.parse(response.response_body)

Clone this wiki locally