Giter VIP home page Giter VIP logo

tenkit's Introduction

Tenkit 天気ト

Gem GitHub Workflow Status

A wrapper for Apple's WeatherKit API in Ruby

A portmanteau of "tenki" the Japanese word for weather, and "kit", the end of WeatherKit.

This project is in beta, some of its API may be unstable, or possibly non-functional (like WeatherKit itself). We recommend pinning the version in your Gemfile until we get to a stable release, at which point we will be using Semantic Versioning.

Installation

Add to Gemfile

gem 'tenkit'

See Apple's instructions on how to Get Started with Weatherkit. Your WeatherKit API dashboard should be at this URL https://developer.apple.com/account/resources/services/weatherkit.

Usage

See Credentials for information on how to obtain the configuration values below.

Tenkit.configure do |c|
  c.team_id = ENV["APPLE_DEVELOPER_TEAM_ID"]
  c.service_id = ENV["APPLE_DEVELOPER_SERVICE_ID"]
  c.key_id = ENV["APPLE_DEVELOPER_KEY_ID"]
  c.key =  ENV["APPLE_DEVELOPER_PRIVATE_KEY"]
end

client = Tenkit::Client.new

lat = '37.323'
lon = '122.032'

client.weather(lat, lon)

Credentials

Once obtained, these values should be kept secret.

For Ruby you might use ENV variables, or a .env file not committed to git.

Rails projects will likely store these values encrypted in custom credentials, which can be commited to git.

APPLE_DEVELOPER_TEAM_ID

This is your Apple Team ID, taken from the top-right of your developer account certificates page:

screenshot example of where to find your team ID

APPLE_DEVELOPER_SERVICE_ID

This is a Service ID that you’ll need to create: https://developer.apple.com/account/resources/identifiers/list/serviceId It will be in the same style as an App ID, as a reverse domain name, e.g. “com.example.fancypantsweather”

APPLE_DEVELOPER_KEY_ID

Generate a new key: https://developer.apple.com/account/resources/authkeys/add Give it a name (not important but descriptive to you) and make sure to check “WeatherKit”

screenshot example of registering a new key

Make sure you download the key and keep it safe for the next credential. Use the generated Key ID as the value for APPLE DEVELOPER KEY ID.

APPLE_DEVELOPER_PRIVATE_KEY

This is the freshly downloaded private key, a .p8 file. P8 is a format that presents the private key in plain text (.p12 is a binary format). You may have seen these before, they look something like this:

-----BEGIN PRIVATE KEY-----
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAA
-----END PRIVATE KEY-----

About

Maintained by: Super Basic

tenkit's People

Contributors

jameswpierce avatar seereadcode avatar cowlibob avatar drvn-mr avatar dependabot[bot] avatar

Stargazers

 avatar The Best Ruby on Rails Guides avatar Jonathan Davies avatar Igor Zubkov avatar Dmytro Piliugin avatar Tim Riley avatar Marco Roth avatar Joel Hawksley avatar E.T.Cook avatar Santiago Pravisani avatar Eugeniu Vozoca avatar Adam Perfect avatar Andy Huynh avatar James Mead avatar Kevin Fagan avatar  avatar Dasutin avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tenkit's Issues

Improving error handling

Hi, thanks for the work on this gem.

I noticed the current code doesn't handle errors at all, so a bad response would result in trying to parse invalid JSON.

I'm mostly making this issue to work out how errors should be handled.

An easy solution could be simply returning nil for WeatherResponse.weather when !response.success?
But it's possible we could want to provide more info in the regular response, without the user having to look at the raw response.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.