Welcome!
This is a basic ruby gem scaffold to create a client for call to an existing API endpoint.
The API's you will need to call is located at: https://blooming-savannah-20593.herokuapp.com/api/
You are tasked with creating a method that takes a user's name and returns their profile.
The api has two endpoints, responds with JSON, and is unauthenticated.
Returns a list of users.
Returns a specific user.
Zip up your code and send it along to the email instructed.
Have Fun!
=========================================================================================================
Here, the main task is to fetch the user's profile details based on user name. Additionally allowing fetching users and fetching user by id from blooming savannah API to verify sample output.
run -> bundle exec ruby api_client_fun.rb
CASE I: With correct user name
shaik.basha@NITRVSP019LX api_client_fun (master) $ bundle exec ruby api_client_fun.rb
**************** START ******************
Calling Blooming Savannah API to fetch users
{"company"=>"Planet Express", "id"=>1, "name"=>"Philip J Fry", "position"=>"Delivery Boy", "profile"=>{"age"=>25, "gender"=>"M", "planet"=>"Earth", "species"=>"Human", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>2, "name"=>"Turanga Leela", "position"=>"Captain", "profile"=>{"age"=>25, "gender"=>"F", "planet"=>"Earth", "species"=>"Mutant, Human", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>3, "name"=>"Bender Bending Rodríguez", "position"=>"Ship's Robot, Ship's Cook, Assistant Manager of Sales, Gunnery Chief", "profile"=>{"age"=>4, "gender"=>"M", "planet"=>"Earth", "species"=>"Robot", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>4, "name"=>"Planet Express Ship", "position"=>"Ship", "profile"=>{"age"=>"N/A", "gender"=>"N/A", "planet"=>"Earth", "species"=>"Robotic Spacecraft", "status"=>"N/A"}} {"company"=>"Planet Express", "id"=>5, "name"=>"Dr. John A. Zoidberg Ph.D", "position"=>"Staff Doctor", "profile"=>{"age"=>86, "gender"=>"M", "planet"=>"Decapod 10", "species"=>"Decapodian", "status"=>"Alive"}} {"company"=>"Democratic Order of Planets", "id"=>6, "name"=>"Zapp Brannigan", "position"=>"Captain", "profile"=>{"age"=>28, "gender"=>"M", "planet"=>"Earth", "species"=>"Human", "status"=>"Alive"}} {"company"=>"Democratic Order of Planets", "id"=>7, "name"=>"Kif Kroker", "position"=>"Lieutenant", "profile"=>{"age"=>24, "gender"=>"M", "planet"=>"Amphibios 9", "species"=>"Amphibiosans", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>8, "name"=>"Philip J Fry", "position"=>"Delivery Boy", "profile"=>{"age"=>25, "gender"=>"M", "planet"=>"Earth", "species"=>"Human", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>9, "name"=>"Turanga Leela", "position"=>"Captain", "profile"=>{"age"=>25, "gender"=>"F", "planet"=>"Earth", "species"=>"Mutant, Human", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>10, "name"=>"Bender Bending Rodríguez", "position"=>"Ship's Robot, Ship's Cook, Assistant Manager of Sales, Gunnery Chief", "profile"=>{"age"=>4, "gender"=>"M", "planet"=>"Earth", "species"=>"Robot", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>11, "name"=>"Planet Express Ship", "position"=>"Ship", "profile"=>{"age"=>"N/A", "gender"=>"N/A", "planet"=>"Earth", "species"=>"Robotic Spacecraft", "status"=>"N/A"}} {"company"=>"Planet Express", "id"=>12, "name"=>"Dr. John A. Zoidberg Ph.D", "position"=>"Staff Doctor", "profile"=>{"age"=>86, "gender"=>"M", "planet"=>"Decapod 10", "species"=>"Decapodian", "status"=>"Alive"}} {"company"=>"Democratic Order of Planets", "id"=>13, "name"=>"Zapp Brannigan", "position"=>"Captain", "profile"=>{"age"=>28, "gender"=>"M", "planet"=>"Earth", "species"=>"Human", "status"=>"Alive"}} {"company"=>"Democratic Order of Planets", "id"=>14, "name"=>"Kif Kroker", "position"=>"Lieutenant", "profile"=>{"age"=>24, "gender"=>"M", "planet"=>"Amphibios 9", "species"=>"Amphibiosans", "status"=>"Alive"}}
Calling Blooming Savannah API to fetch user by passing ID
Enter User ID: 7
User Details: {"company"=>"Democratic Order of Planets", "id"=>7, "name"=>"Kif Kroker", "position"=>"Lieutenant", "profile"=>{"age"=>24, "gender"=>"M", "planet"=>"Amphibios 9", "species"=>"Amphibiosans", "status"=>"Alive"}}
Calling Blooming Savannah API to fetch user's profile info using username
Enter User Name: Planet Express Ship
Profile Details of user Planet Express Ship {"age"=>"N/A", "gender"=>"N/A", "planet"=>"Earth", "species"=>"Robotic Spacecraft", "status"=>"N/A"}
**************** END ******************
CASE II: With incorrect user name
**************** START ******************
Calling Blooming Savannah API to fetch users
{"company"=>"Planet Express", "id"=>1, "name"=>"Philip J Fry", "position"=>"Delivery Boy", "profile"=>{"age"=>25, "gender"=>"M", "planet"=>"Earth", "species"=>"Human", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>2, "name"=>"Turanga Leela", "position"=>"Captain", "profile"=>{"age"=>25, "gender"=>"F", "planet"=>"Earth", "species"=>"Mutant, Human", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>3, "name"=>"Bender Bending Rodríguez", "position"=>"Ship's Robot, Ship's Cook, Assistant Manager of Sales, Gunnery Chief", "profile"=>{"age"=>4, "gender"=>"M", "planet"=>"Earth", "species"=>"Robot", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>4, "name"=>"Planet Express Ship", "position"=>"Ship", "profile"=>{"age"=>"N/A", "gender"=>"N/A", "planet"=>"Earth", "species"=>"Robotic Spacecraft", "status"=>"N/A"}} {"company"=>"Planet Express", "id"=>5, "name"=>"Dr. John A. Zoidberg Ph.D", "position"=>"Staff Doctor", "profile"=>{"age"=>86, "gender"=>"M", "planet"=>"Decapod 10", "species"=>"Decapodian", "status"=>"Alive"}} {"company"=>"Democratic Order of Planets", "id"=>6, "name"=>"Zapp Brannigan", "position"=>"Captain", "profile"=>{"age"=>28, "gender"=>"M", "planet"=>"Earth", "species"=>"Human", "status"=>"Alive"}} {"company"=>"Democratic Order of Planets", "id"=>7, "name"=>"Kif Kroker", "position"=>"Lieutenant", "profile"=>{"age"=>24, "gender"=>"M", "planet"=>"Amphibios 9", "species"=>"Amphibiosans", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>8, "name"=>"Philip J Fry", "position"=>"Delivery Boy", "profile"=>{"age"=>25, "gender"=>"M", "planet"=>"Earth", "species"=>"Human", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>9, "name"=>"Turanga Leela", "position"=>"Captain", "profile"=>{"age"=>25, "gender"=>"F", "planet"=>"Earth", "species"=>"Mutant, Human", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>10, "name"=>"Bender Bending Rodríguez", "position"=>"Ship's Robot, Ship's Cook, Assistant Manager of Sales, Gunnery Chief", "profile"=>{"age"=>4, "gender"=>"M", "planet"=>"Earth", "species"=>"Robot", "status"=>"Alive"}} {"company"=>"Planet Express", "id"=>11, "name"=>"Planet Express Ship", "position"=>"Ship", "profile"=>{"age"=>"N/A", "gender"=>"N/A", "planet"=>"Earth", "species"=>"Robotic Spacecraft", "status"=>"N/A"}} {"company"=>"Planet Express", "id"=>12, "name"=>"Dr. John A. Zoidberg Ph.D", "position"=>"Staff Doctor", "profile"=>{"age"=>86, "gender"=>"M", "planet"=>"Decapod 10", "species"=>"Decapodian", "status"=>"Alive"}} {"company"=>"Democratic Order of Planets", "id"=>13, "name"=>"Zapp Brannigan", "position"=>"Captain", "profile"=>{"age"=>28, "gender"=>"M", "planet"=>"Earth", "species"=>"Human", "status"=>"Alive"}} {"company"=>"Democratic Order of Planets", "id"=>14, "name"=>"Kif Kroker", "position"=>"Lieutenant", "profile"=>{"age"=>24, "gender"=>"M", "planet"=>"Amphibios 9", "species"=>"Amphibiosans", "status"=>"Alive"}}
Calling Blooming Savannah API to fetch user by passing ID Enter User ID: 100
User Details: No user found with ID: 100
Calling Blooming Savannah API to fetch user's profile info using username Enter User Name: Abcd Xyz
Profile Details of user Abcd Xyz: No Profile found for user Abcd Xyz
**************** END ******************