Skip to content
Fetches AirNow API data for a lat/lng and POSTs the current conditions to a callback URL.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
fetch_conditions
fixtures/vcr_cassettes/air_now
script
tests/unit
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.md
packaged.yaml
template.yaml

README.md

air-now-service

Fetches AirNow API data for a lat/lng and POSTs the current conditions to a callback URL.

Based on http://blog.blackninjadojo.com/aws/serverless/2019/02/18/build-package-and-deploy-an-aws-lambda-using-the-ruby-runtime.html.

Requirements

Setup process

rvm use 2.5.0

gem install bundler -v '1.17.3'
bundle

Packaging and deployment

script/ship

Testing

ruby tests/unit/test_handler.rb

Usage

Aws::Lambda::Client.new.invoke({
  function_name: ENV["AIR_NOW_SERVICE_ARN"],
  invocation_type: "Event",
  log_type: "None",
  payload: {
    config: {
      location_id: id,
      latitude: latitude,
      longitude: longitude,
      air_now_api_key: ENV["AIR_NOW_API_KEY"],
      callback_secret: ENV["AIR_NOW_SERVICE_SECRET_KEY"],
      callback_url: ENV["AIR_NOW_SERVICE_CALLBACK_URL"] || air_now_callback_url,
    },
  }.to_json,
})
You can’t perform that action at this time.