GramV1Client

Installation

Add this line to your application's Gemfile:

gem 'gram_v1_client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install gram_v1_client

Setup

Before being used GramV1Client must be configured. In Rails app, put it in an Initializer.

GramV1Client.configure do |c|
   # Base URI used to access GrAM API
   c.site="http://my_site.org/api/v1/"
   # Username provided by Gadz.org
   c.user="my_user"
   # Password provided by Gadz.org
   c.password="my_password"
   # If your app use a proxy to access net, put it here
   #c.proxy="my_proxy"
 end

Usage

This client client is based on the active_ressource gem. Read its documentation for informations about interacting with ressources It provides access to the following resources on GrAM API :

  • Account
  • Profile
  • Email
  • Search

Account

Find

 = GramV1Client::Account.find("john.doe.ext")
puts .firstname
puts .lastname
#=> John
#=> Doe

Update

 = GramV1Client::Account.find("john.doe.ext")
.firstname = "Johny"
.save

Create

 = GramV1Client::Account.new(hruid: "john.doe.ext", firstname: "John", lastname: "Doe")
.save

Or

 = GramV1Client::Account.create(hruid: "john.doe.ext", firstname: "John", lastname: "Doe")

Profile

Find

profile = GramV1Client::Profile.find("john.doe.ext")
puts .firstname
puts .lastname
#=> John
#=> Doe

Email

Find

email = GramV1Client::Email.find("[email protected]")

This resource is used to search for accounts

You can use the generic search

 = GramV1Client::Search.where(:idSoce => "84185")

Or you can use helper methods :

 = GramV1Client::Search.search_by_hruid("john.doe.ext")
 = GramV1Client::Search.search_by_id_soce("84185")
 = GramV1Client::Search.search_by_email("[email protected]")
 = GramV1Client::Search.search_by_alias("john.doe")

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Zooip/gram_v1_client.

License

The gem is available as open source under the terms of the MIT License.