Sweater Weather is a BE application that is designed to return desired weather conditions for a specific area. The current weather, a five day forecast, and a 48 hour forecast are all available. Directions from one location to another are also available. By combining the two, Sweater Weather is able to geocode a destination location based on its name, find the route to that destination, and also return what the current weather conditions will be upon arrival of the desired destination. Sweater weather consumes data from an active weather API, an active mapquest API, and the Unsplash photo API. By creating endpoints in a new API, Whether Sweater is able to serialize, and send data to the FE team, ssatisfying their needs for their application.
- Create a functioning BE API with new endpoints through the consumption and exposure of other API endpoints
- Follow SOA convention
- Create new endpoints
- Use serializers to package, and send JSON responses
- Implement sessions after user sign in
- Test API exposure
- Test JSON response of newsly created endpoints
- Combine the consumption of multiple APIs for a single JSON response
- Ruby 2.7.2
- Rails 7.0.3
#Global Scope
gem 'bcrypt', '~> 3.1.7'
gem 'faraday'
gem 'jsonapi-serializer'
gem 'figaro'
#group :development, :test
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rspec-rails'
gem 'pry'
gem 'faker'
gem 'simplecov'
gem 'factory_bot_rails'
#group :test
gem 'capybara'
gem 'launchy'
gem 'shoulda-matchers'
gem 'simplecov'
gem 'vcr'
gem 'webmock'- VCR Docs
- WebMock Docs
- Figaro Docs
- Faraday Docs
- JSONAPI_Serialzier Docs
- SimpleCov Docs
- Capybara Docs
- ShouldMatchers Docs
- Factory Bot Rails Docs
- Faker Docs
- Bcrypt Docs
- Fork & Clone the repo
$ git clone git@github.com:michaeljhicks/whether_sweater.git- Navigate to the directory
$ cd whether_sweater- Install gem packages:
$ bundle install- Update gem packages:
$ bundle update- Run the migrations:
$ rails db:{drop,create,migrate,seed}To properly run the test suite, you will need to follow the below instructions and run the following commands in terminal:
- Navigate to the above mentioned API websites (three in total) and request a developer API key for each of the respective APIs. This allows you to access the data properly.
- Upon having been granted all required API keys and navigate to the
whether_sweather/config/application.ymlfile. - If you are unable to locate the
/config/application.ymlfile in your IDE, run the commandshell bundle exec figaro installIn the terminal. The/config/application.ymlshould appear. If you are still having problems, please references the Figaro documentation as shown below. - Add your API keys in this format at the bottom of the
ruby/config/application.ymlfile:
mapquest_api_key: 'api_key'weather_api_key: 'api_key'unsplash_api_key: 'api_key'
- Once you have the API keys in place, you can run the entire test suite! To do this simply run the command
bundle exec rspec - Upon executing the initial test suite, you will notice it's running at a concerningly glacial pace. This is because of of the suite actually hitting the real API endpoints. However thanks to VCR, this initial run is the only slower execution whereby VCR records the API response on first execution, and then stores the responses in a file known as a 'cassette' to reduce API rate limits, thus optimizing the test suite performance.
GET /api/v1/forecast?location=denver,coGET /api/v1backgrounds?location=denver,coPOST /api/v1/usersJSON Params Passed for User create
- key: email value: your_email@here
- key: password value: password
- key: password_confirmation value: password
POST /api/v1/sessionsJSON Params Passed for User login/Session Creation
- key: email value: your_email@here
- key: password value: 'Password123"
- key: password_confirmation value: 'Password123'
POST /api/v1/road_trip- *JSON Params Passed for Road Trip Creation
- key: origin value:Denver,CO
- key: destination value: Pueblo,CO
- key: api_key value: "your api key here"
All string interpolated values are dynamic values being passed in the code as query params. The param "imperial" on the weather API is the preferred form of measurement. API is metric by defualt. End Points are as they appear in the API services in the code.
GET http://www.mapquestapi.com/geocoding/v1/address?location=#{location}GET http://www.mapquestapi.com/directions/v2/route?from=#{trip_params[:from]}&to=#{trip_params[:to]}GET https://api.openweathermap.org/data/2.5/onecall?lat=#{lat}&lon=#{lng}&units=imperialGET https://api.unsplash.com/search/photos?page=1&query=#{city}")
