Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For this to work, the module containing the keys must be registered as io.picolabs.twiliolesson_keys because that's the name of the module we load. The ruleset using the keys must be registered as io.piolabs.use_twilio_v2 since that's the name of the ruleset the keys are provided to in the provide keys pragma. You can store the ruleset containing the keys on AWS S3 behind a private URL, on a Web server with Basic Auth, or using some other scheme that will protect it from viewing by people who would steal the keys. The ruleset using the keys can be stored at a public URL.

...

We now have a Twilio module that wraps the Twilio API in functions and actions that are more convenient for KRL rulesets to use. We've also taken steps to protect sensitive keys while making their use convenient.

As always, it is a good idea to test your code during development.

Exercises

  1. Sign up for a developer account at Edmunds
  2. Generate a key.
  3. Create a key module with the Edmunds key 
  4. Create an Edmunds module that uses the key module created above and contains a function that wraps the Edmunds VIN Decoding API:
    1. The function should take a VIN as it's argument
    2. The function should return a JSON object containing the vehicle make, model, years, and city and highway mileage. (use http:get() with parseJSON = true)
  5. Write a ruleset to use and test your Edmunds module by calling the function and returning the results as a directive from a rule. You can test it with real VINs from cars you have access to, or use RandomVIN.

Note: The Edmunds API has a limit of 25 calls per day. You can request an upgrade, but that can take a few days, so plan accordingly.