Wilson
Wilson

Reputation: 181

How do I print out a response from an API call Ruby

I'm looking to print out the response from an API call with Kickbox's api.

This is what I have

require "kickbox"

client   = Kickbox::Client.new('XXXXXXXXXXXXXXXXXXXXXXXXXXXX')
kickbox  = client.kickbox()
response = kickbox.verify("[email protected]")

puts response

I'm not getting any response when trying to run the file in my terminal.

Upvotes: 1

Views: 1741

Answers (1)

schaitanya
schaitanya

Reputation: 481

try response.body

{
  "result"  =>"unknown",
  "reason"  =>"no_connect",
  "role"  =>true,
  "free"  =>false,
  "disposable"  =>false,
  "accept_all"  =>false,
  "did_you_mean"  =>nil,
  "sendex"  =>0.35,
  "email"  =>"[email protected]",
  "user"  =>"test",
  "domain"  =>"example.com",
  "success"  =>true,
  "message"  =>nil
}

You can also get the response time and balance from headers from response.headers

{
  "content-type"  =>"application/json",
  "x-kickbox-balance"  =>"99",
  "x-kickbox-response-time"=>"17"
}

Upvotes: 1

Related Questions