A Buffer gem for anyone, making it easy to schedule posts to Twitter, Facebook, Google+, LinkedIn, and Pinterest
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
test
vendor/assets
.rspec
.travis.yml
Gemfile
Gemfile.lock
LICENSE.txt
Rakefile
buffer_app.gemspec
config.ru
readme.md

readme.md

Buffer Gem

Modelled after Octokit <3, this is a lightweight client for the Buffer API, which is intended to return (mostly) JSON as opposed to objects.

Code Climate Test Coverage Build Status

Table of Contents

Ruby Versions

This gem is built to work with Ruby 1.9.3+

See the Travis-CI build information above for build status on 1.9.3 and 2.1.2

Client API

What's Imlemented?

Installing

Put this sucker in your Gemfile and bundle install

gem "buffer-app", :git => "git://github.com/kaneda/buffer-ruby", :tag => "v1.2"

Then drop this into your config/application.rb (or wherever you want to use it)

require 'buffer_app'

Basic Usage

You can define the client up front or configure it later. The options array the BufferClient (and the API objects behind the scenes) uses takes in the following parameters:

  • :user_code
  • :auth_token
  • :logger
buffer_client = BufferClient.new({
  :user_code => "yourcode"
})

auth_tok = buffer_client.get_auth_token

buffer_client.configure({
  :auth_token => auth_tok
})

# Subsequent calls here (see below)

Available Calls

Client call Input Output Notes
get_auth_token Auth Token:String ENV variables "BUFFER_KEY" and "BUFFER_SECRET" must be defined here
get_user_id ID:String Convenience wrapper, calls get_user_json under the hood
get_user_json User:Hash
deauthorize Success:Boolean
get_user_profiles Profiles:Array
get_user_profile Profile ID:String Profile:Hash
get_schedule Profile ID:String Schedule:Hash
update_schedule Profile ID:String, Schedule:Hash Success:Boolean See below for schedule representation
get_update Social Media Post ID:String Update:Hash
get_pending_updates Profile ID:String, Options:Hash (optional) UpdateResult:Hash See Buffer API doc (link to the left) for optional parameters. "updates" key contains the Updates:Array
get_sent_updates Profile ID:String, Options:Hash (optional) UpdateResult:Hash See Buffer API doc (link to the left) for optional parameters. "updates" key contains the Updates:Array
get_interactions Social Media Post ID:String, Event:ENUM, Options:Hash (optional) Interactions:Hash See event types for possible event values and Buffer API doc (link to the left) for optional parameters. "interactions" key contains the Interactions:Array
reorder_updates Profile ID:String, Updates:Array, Options:Hash (optional) Updates:Array
shuffle_updates Profile ID:String, Options:Hash (optional) Updates:Array
create_update Profile IDs:Array, Options:Hash (optional) Update:Hash Note that for the "media" option, please specify each media option in the hash separately, e.g. { "media[link]" => "http%3A%2F%2Fgoogle.com", "media[description]" => "The%20google%20homepage" }. See all available options in the Buffer docs (link to the left)
update_status Social Media Post ID:String, Text:String, Options:Hash (optional) Update:Hash For the "media" option see the note on create_update above
share_update Social Media Post ID:String Success:Boolean
destroy_update Social Media Post ID:String Success:Boolean
move_to_top Social Media Post ID:String Success:Boolean
get_shares Unencodded URL:String Shares:Integer You can pass a normal URL here, the client will encode it. This is one of the only calls to not require an auth_token
get_configuration Configuration:Hash "services" key has internal keys for each service

Helper Methods

Method Description
configure Takes in a hash (as above) and reconfigures all API objects
has_error? Returns true if an error has been set in the client
get_error Returns the current error and wipes it out in the client
error Returns the current error, leaving it in tact

Defining a Schedule

To update a schedule the BufferClient is expecting a schedule of the form:

[
  {
    :days  => ['mon', 'tue', 'thu'],
    :times => ['12:45', '15:30', '17:43']
  },
  .
  .
  .
]

Note that you can make the keys symbols or strings, the client will accept either one.

Contributing

To contribute simply:

  1. Fork this project
  2. Make your changes in a new branch
  3. Create a PR
  4. Once approved squash your commits
  5. Party

Contact Me

Email: kanedasan@gmail.com

Twitter: @kanedasan

IRC: kaneda^ on FreeNode (##hackers)