GroSocial
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 = trueOnce 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.saveFuture-Proofing
TODO: Document how to access resources directly via GroSocial::Client.request
Contributing
- Fork it ( https://github.com/[my-github-username]/gro_social/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request