Skip to content

fetsh/freefeed-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

freefeed-client

Ruby wrapper for Freefeed API.

Gem Version

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}
)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published