Skip to content
This repository has been archived by the owner on Feb 16, 2018. It is now read-only.
/ tent-client-ruby Public archive

Ruby Tent protocol client

License

Notifications You must be signed in to change notification settings

tent/tent-client-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tent Ruby Client Build Status

TentClient implements a Tent Protocol client library in Ruby.

For authenticating your app, see Omniauth-Tent.

You should be familiar with Faraday before continuing.

Install

Add the following to your Gemfile

gem "tent-client"

or

$ gem install tent-client

Usage

Setup

require "tent-client"
client = TentClient.new("https://entity.example.com")

# or, for more advanced use cases you may pass any of the following options:
options = {
  :server_meta => {}, #  deserialized JSON of the meta post (optional)
  :faraday_adapter => Faraday.default_adapter, # see https://github.com/lostisland/faraday for details (optional)
  :faraday_setup => proc { |f| }, # proc to be called for additional Faraday setup (optional)
  :ts_skew => 0 # see https://tent.io/docs/authentication#timestamp-skew for details (optional)
}
client = TentClient.new("https://entity.example.com", options)

API Endpoints

Object Description
client.post An instance of TentClient::Post.
client.post.head An instance of TentClient:Post where GETs are transformed into HEADs.
client.post.get(entity, post_id, params = {}, &block) GET post. Returns an instance of Faraday::Response.
client.post.get_attachment(entity, post_id, attachment_name, params = {}, &block) GET post_attachment (redirect followed).
client.post.mentions(entity, post_id, params = {}, &block) GET post with the ACCEPT header set accordingly.
client.post.versions(entity, post_id, params = {}, &block) GET post with the ACCEPT header set accordingly.
client.post.children(entity, post_id, params = {}, &block) GET post with the ACCEPT header set accordingly.
client.post.create(data, params = {}, options = {}, &block) POST post where data is the deserialized JSON of the post. Attachments may be passed via the options object using the :attachments key and an array of objects with :content_type, :category, :name, and :data (may be a string or an object with a read method).
client.post.delete(entity, post_id, params = {}, &block) DELETE post.
client.post.list(params = {}, &block) GET posts_feed.
client.attachment An instance of TentClient::Attachment.
client.attachment.get(entity, digest, params = {}, &block) GET attachment.
client.oauth_redirect_uri(params = {}) Returns an instance of URI.
client.oauth_token_exchange(data, &block) POST oauth_token.

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