0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Client for The 86 conversation API server
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

The86::Client

Ruby client for "The 86" conversation API server.

Uses Faraday for HTTP transport, JSON encoding/decoding etc.

Uses Virtus for DataMapper-style object attribute declaration.

Uses MiniTest and WebMock for unit/integration testing (run rake).

Get Code, Run Tests

git clone REPO_PATH
cd the86-client
bundle install
bundle exec rake

Install the Gem

gem install the86-client

Add to a Project

echo 'gem "the86-client"' >> Gemfile
bundle

Usage

# The domain running The 86 discussion server.
The86::Client.domain = "the86.yourdomain.com"

# HTTP Basic Auth credentials allocated for your API client.
The86::Client.credentials = ["username", "password"]

# Create an end-user account:
user = The86::Client.users.create(name: "John Citizen")
oauth_token = user.access_tokens.first.token

# Create a new conversation:
conversation = The86::Client.group("example").conversations.create(
  content: "Hello world!",
  oauth_token: oauth_token
)

# Reply as another user:
user = The86::Client.users.create(name: "Jane Taxpayer")
conversation.posts.first.reply(
  content: "I concur!",
  oauth_token: user.access_tokens.first.token
)

# Follow up to a conversation:
user = The86::Client.users.create(name: "Joe Six-pack")
conversation.posts.create(
  content: "What are you guys talking about?",
  oauth_token: user.access_tokens.first.token
)

# List conversations:
conversations = The86::Client.group("example").conversations
second_page = conversations.more
third_page = second_page.more
third_page.each { |conversation| p conversation }

# Check for updates:
group = The86::Client.group("example")
conversations = group.conversations.with_parameters(
  posts_since: time.iso8601,
  without_user: 64,
)

# Like!
post = group.conversations.first.posts.first
post.likes.create(oauth_token: oauth_token)
likes = post.load.likes
puts "Liked by #{likes.count} people"
likes.each { |like| puts "* #{like.user.name}" }

Licence

(c) SitePoint, 2012, MIT license.