Project

gro_social

0.0
No commit activity in last 3 years
No release in over 3 years
A simple Ruby client for GroSocial's REST API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 1.8.0
~> 0.7.0
 Project Readme

GroSocial

Code Climate Test Coverage Build Status

The gro_social gem provides a Ruby interface to the GroSocial REST API. The gem is intended to be lightweight with simple wrappers around the exposed resources.

Installation

Add this line to your application's Gemfile:

gem 'gro_social'

And then execute:

$ bundle

Or install it yourself as:

$ gem install gro_social

Usage

First you need to set your API credentials with the GroSocial::Client.

GroSocial::Client.api_key = 'YOUR_KEY'
GroSocial::Client.api_password = 'SECRET'

You can enable test mode for the client in a similar fashion.

GroSocial::Client.test_mode = true

Once these configuration options are set appropriately you are ready to simply interact with the supported resources.

Users

There are two classes that you will work with in regards to users: GroSocial::Users and GroSocial::User. GroSocial::Users represents the class you will use to locate specific users or iterate over them. GroSocial::Users can be treated like a Hash when it comes to accessing and working with the GroSocial::User records.

Retrieval

Retrieval is keyed to the ID for the user you want to access.

user = GroSocial::Users[1234]   # GroSocial::User

user.id         # '1234'
user.firstname  # 'John'
user.lastname   # 'Doe'

Creation

The << operation is used to both create and update records and its behavior is based on whether the GroSocial::User being pushed in already has an ID value set.

user = GroSocial::User.new(
    firstname:  'John',
    lastname:   'Doe',
    email:      'johndoe@example.com',
    password:   'secret123'
)
user.id         # nil

GroSocial::Users << user

user.id         # '12345'

Subscriptions

Updating

user = GroSocial::Users[1234]
subscription = user.subscription # => an instance of GroSocial::Subscription

subscription.canceled = false
subscription.nextpaymentdate = 1.year.from_now
subscription.save

Future-Proofing

TODO: Document how to access resources directly via GroSocial::Client.request

Contributing

  1. Fork it ( https://github.com/[my-github-username]/gro_social/fork )
  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 a new Pull Request