freefeed-client
Ruby wrapper for Freefeed API.
Installation
Add following line to your Gemfile:
gem 'freefeed-client'
And then execute:
$ bundle
Or install it system-wide:
$ gem install freefeed-client
Usage
First things first, you need to obtain a token for your user. Then create your api client like this:
require 'freefeed'
client = Freefeed::Client.new('yourFreefeedAPIToken')
post = Freefeed::Types::PostCreate.new(
{
post: {
body: 'Hello World!'
},
meta: {
feeds: ['yourusername']
}
}
)
Freefeed::Post.create(client, post)
You can achive the same result without addressing Freefeed::Post
class directly:
require 'freefeed'
client = Freefeed::Client.new('yourFreefeedAPIToken')
post = Freefeed::Types::PostCreate.new(
{
post: {
body: 'Hello World!'
},
meta: {
feeds: ['yourusername']
}
}
)
client.posts_create(post)
You can even skip instantiating PostCreate
type, but you will lose some validation:
require 'freefeed'
client = Freefeed::Client.new('yourFreefeedAPIToken')
client.posts_create({post: {body: 'Hello World!'}, meta: {feeds: ['yourusername']}})
Logging
By default, freefeed-client
logs everything to STDOUT. You can change this behavior and provide your own logger class with some options. See example below:
client = Freefeed::Client.new(
'yourFreefeedAPIToken',
logger: Logger.new('log.txt'),
logger_options: {bodies: false, headers: false}
)