We are in the process of moving to Oklahoma, the moving truck comes tomorrow! We have lived in our current house for 16+ years, so we have accumulated a lot of stuff. We are having to figure out what to keep, what to give away/sell and what to throw away.
Earlier in the month I got an email about https://postman-hack.devpost.com/ and I signed up. Brian Dinh reached out to me on devpost chat and asking if I wanted to join his team. We chatted about some ideas for the Postman API Hack and agreed that it would be good to have a 3rd person on the team, so he reached out to Lydia Choi and she joined the team as well. We used Discord for most of our communication, although we also had a Zoom call (but for some reason the audio was worse). We decided on the name teamBoLD.
We iterated on a variety of project ideas, but ultimately decided on creating CoinStop. CoinStop "You’re on the subway after work and you want dessert. Do you have time to search for ice cream parlors at each stop? Our API minimizes your search by finding all nearest ones along your subway route." Here is a video teamBoLD made for CoinStop:
Our collection in Postman uses environment variables and collection variables to allow the user to specify a startAddress, endAddress, searchTerm, radius. There are also a bunch of API keys that need to be configured in the environment.
When you run the collection:
If the msisdn variable is set, we see if the variable named text is also set. If so we parse the contents in the text variable, splitting by semicolon (;) and updating our startAddress with the first item, endAddress with the second item (if set), searchTerm with the third item (if set), and radius with the fourth item (if set).
It uses the OpenCage API to get the Latitude & Longitude of the starting point and ending point; in the Tests script it validates that it got a successful response but it also parses the JSON response and saves the information in a collectionVariable (so it can be used in future scripts & even after the collection run is complete.)
It uses the Here API to get the subway route between the starting and ending location, and it also gets all of the intermediate stop (Lat/Long) information too. We store all of the route information into an array and set a flag to let us know if it is a start, stop, or intermediate stop.
Next we make a call to the Yelp API for businesses search using the first item in the array. We scope the search to the radius, search term, and set a limit of 5 results. We update the array with all of the businesses at that stop. If there are more items in the array we set the next request to be this step again and we increment a count environment variable so we know where we are in the array.
Next we create an array of all of the business ids. Then we pop the first id off the array and call Yelp API for business details. We calculate text to display the store hours for the previous day, current day and next day. Sometimes the previous day has something like "7AM to 2AM next day"; so if it's 1AM Saturday you need to know Friday hours to realize the store closes at 2AM. If there are more things still in the array we set the next request to be this step again.
We calculate a bunch of text for Jimbo (our Bot) to tell you about the businesses it found along your subway route. That text ends up as an environment variable which is used in the body of the POST request to the Dropbox API to create a file.
We then call the Dropbox API to share the document.
We then use the Discord API to post a message from Jimbo with a link to Dropbox
We have a step that renders an HTML table with results as well. This HTML pulled in a JS file that we hosted on our mock server. We also used our mock server for the request so that it shows you a message to switch to the Visualize tab. It turns out that during our testing we hit our quota of 1000 calls per month for mock server, so we learned how to use github.io and jamsionderek.github.io was created.
We have a step that renders a Google Map with the coins on the map representing how expensive the business is from 1 coin to 4 coins. We also use normal markers on the map for the start and end stops - clicking on it shows you information about which subway line to get on (it even is colored the same as the subway). Clicking on the coins shows you information about the business that we got from Yelp, like name, image, price, category, hours, etc.
Finally we check if the variable msisdn is set, and if so we send an SMS message via the Vonage API (Nexmo is now Vonage) to that phone number with the Dropbox link.
We configure Vonage with a webhook that uses CloudNewman (another hack I worked on this month, I'll make a separate post about it) to invoke our collection. Vonage posts to our collection and the body of the post has the "text" variable set to what the user typed, and the "msisdn" set the the phone number of the sender. Just what the first and last step of our collection needed. :)

Brian and I did a third hack, called SoManyAPIs. I'll create a post about that one as well.
I got the circuit board for my Christmas star back from OSHPark, so another post!
Okay, clearly lots of posts in my future but I need to get back to packing for now. I'll try to put some updates on my Facebook page for the moving process, if you are interested (I just sold my car there.)
Comentários