Completing Phase 1…CLI App

Tammarra McPhaul
3 min readMar 6, 2021

I made it!

I’m two months into the Flatiron School Software Engineering online program and I have finished my first project! Three weeks ago, when I realized we were approaching project mode, I freaked out! This first phase has flown by so fast! All of the late nights studying Ruby got me to this point. I had no idea what to expect for this project but I knew I had to tackle this head first.

Our first project consisted of creating a CLI application. My first thought…HOW DO I START THIS?!?

Photo by Daniel Mingook Kim on Unsplash

The CLI application has to access data from a webpage. Once the data is obtained, we have to generate a list containing this data. The user gets to make a selection from that list and the application should generate additional information regarding the user’s selection. Sounds simple right? Conceptually…yes. From a new coder’s POV…maybe not so simple.

First, I had to decide on a concept. What did I want my application to be about? My cohort provided a few links with free APIs to use. I searched for an API on https://github.com/public-apis/public-apis. After scrolling down the list, I decided to use https://balldontlie.io/ for NBA stats. I wanted to create a list of players (wasn’t sure which ones yet) and the user will get to select a player to see their stats.

I used the HTTParty gem to send a HTTP request. Pry became my best friend during project mode! I used pry to see what my response variable returned to make sure I was doing this the right way. My method worked but there was one issue…the stats were two seasons behind the current season. Back to the drawing board…

Photo by Karla Hernandez on Unsplash

After coming up with a different idea and finding another API, I decided to create a “storefront” for an artist’s music catalog. With the iTunes search API, I am able to generate data pertaining to a specific artist. I chose Beyonce (my fav!). The list will include her catalog available for purchase on iTunes. The user’s selection leads to additional details regarding that selection. The user will choose to purchase that selection. If the user selects yes, an iTunes link is generated.

I think using an API was the hardest part of the project. I’ve never used an API or even know what one was. Using HTTParty.get method on the API URL returned the data I needed but as a JSON object. From there, I had to figure out how to clean up this data so I could iterate over it and instantiate album objects. Using JSON.parse(resp.body) did the trick.

Before parsing…
After parsing…

To retrieve the value, I needed to iterate over response[“results”]. Response is the returned hash of data and “results” is the key. As I iterate, I am instantiating new album objects.

Hash iteration

After this, it literally felt like those cartoons when the lightbulb appears on top of the character’s head. I got into a groove and over the last two weeks, I finished my application. It generates a list of the artist’s albums, allows the user to select from the list, additional information of that selection is generated, and continues to loop the application if the user wants to continue selecting items from that list. Simple concept but it’s functional!

On to Phase 2…

--

--