Kele API Gem Case Study
Kele is an API Gem that exist to access a student’s dashboard of Bloc’s REST API. Kele allows the developer to retrieve mentor’s availability, send/receive messages and submit checkpoints for work completed.
The Kele project was assigned to me as a review for backend programming fundamentals. I receive a list user stories and was asked to build an API Gem from scratch to satisfy each user story.
Bloc’s API supplies an external facing JSON Web Token authorized gateway to the Bloc application which can be accessed via cURL.
The Kele API Gem needed satisfy each of the following user needs:
- Users can retrieve roadmaps and checkpoints
- Users can retrieve a list of their messages, respond to an existing message, and create a new message thread
- Users can initialize and authorize Kele with a Bloc username and password
- Users can retrieve the current user as a JSON splotch
- Users can retrieve a list of their mentor’s availability
- Users can submit checkpoint assignments
Starting from scratch, I created the API Gem so that I could initialize a method to create a new Kele to be authorized with a username and password.
After creating an authorized user, the user could access their authentication token from the Bloc API.
I created a get_me method to retrieve the information about the user. I added the JSON Gem to utilize the json.parse method to convert the user data returned into a Ruby hash .
The user can get the mentor availability by using the get_mentor_availability(mentor_id) method. get_mentor_availability requires a mentor_id which can be found in the user data returned by get_me.
I used a similar process to create the methods for get_roadmap(roadmap_id) and get_checkpoint(checkpoint_id). The user can access the roadmap_id and checkpoint_id by using the get_me method.
I created a method called create_message(sender, recipient_id, subject, stripped_text, token = nil) to allow users to send and reply to message threads. In this method, token alludes to an existing message thread’s token in which is required to reply to an existing message. Without one presence, the value with default to nil and create a new message.
The create_submission method allows a student to submit a lesson checkpoint to their mentor. A student can submit a checkpoint accurately by using their enrollment_id, which is accessible through the get_me method.
This was my first time creating a Ruby Gem. On this project, I used the HTTParty and JSON gem to provide easy access to the student’s information on Bloc’s API and eliminates the need to use cURL.
This project gave me an opportunity to understand the difference between creating a Rails application and a Ruby gem. After completing this project, I feel like I have a basic understanding of creating a Ruby gem and making HTTP requests.
I really enjoyed this project because it helped me understand what JSON data does. I took it a step farther and used it to parse data for my portfolio website.