/mirror-api

Simple Mirror API Ruby client for Google Glass

Primary LanguageRubyMIT LicenseMIT

Travis-ci

Code Climate

Mirror::Api

Simple Mirror Api client library.

Benefits

  • Robust error handling. You can choose whether to bubble errors or not.
  • Snake case(ruby friendly) notation for requests and responses

Installation

Add this line to your application's Gemfile:

gem 'mirror-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mirror-api

Usage

##Getting Started ###Require the mirror-api gem.

require "mirror-api"

Authenticating your client

token = Mirror::Api::OAuth.new(client_id, client_secret, refresh_token)

api = Mirror::Api::Client.new(token)

##Timeline

items = api.timeline.list
item_1 = api.timeline.insert({text: "What up WORLD?!?!"})
item_2 = api.timeline.insert({text: "Do you like tacos?", menu_items:[{action: "REPLY"}]})
txt = "Seriously, do you like tacos? This is the second time I had to ask you."
item_2 = api.timeline.update(item_2.id, {text: txt, menu_items:[{action: "REPLY"}]})
item_2 = api.timeline.patch(item_2.id, {text: "You realize you are a bad friend right?", menu_items:[{action: "REPLY"}]})
api.timeline.get(item_2.id)
api.timeline.delete(item_2.id)

##Timeline Attachments

attachments = api.timeline.list(item_1.id, {attachments:{}})
#for the sake of getting an id...
attachment = attachments.items.first
api.timeline.get(item_2.id, {attachments:{id: attachment.id}})
api.timeline.delete(item_2.id, {attachments:{id: attachment.id}})

##Subscriptions

subscriptions = api.subscriptions.list
subscription = api.subscriptions.insert({collection: "timeline", userToken:"user_1", operation: ["UPDATE"], callbackUrl: "https://yourawesomewebsite.com/callback"})
item_2 = api.subscriptions.update(subscription.id, {collection: "timeline", operation: ["UPDATE", "INSERT", "DELETE"], callbackUrl: "https://yourawesomewebsite.com/callback"})
api.subscriptions.delete(item_2.id)

##Locations

locations = api.locations.list
#for the sake of getting an id...
location = locations.items.first
api.locations.get(location.id)

##Contacts

items = api.contacts.list
contact = api.contacts.insert({id: '1234', displayName: 'Troll', imageUrls: ["http://pixelr3ap3r.com/wp-content/uploads/2012/08/357c6328ee4b11e1bfbf22000a1c91a7_7.jpg"]})
contact = api.contacts.update(contact.id, {displayName: 'Unicorn'})
contact = api.contacts.patch(contact.id, {displayName: 'Grumpy Cat', imageUrls: ["http://blog.catmoji.com/wp-content/uploads/2012/09/grumpy-cat.jpeg"]})
api.contacts.get(contact.id)
api.contacts.delete(contact.id)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request