passaporteweb-client-ruby

A Ruby client for the PassaporteWeb REST API

Gem Version Build Status Coverage Status Code Climate Status

PassaporteWeb API docs: app.passaporteweb.com.br/static/docs/

passaporteweb-client-ruby RDoc documentation: rubydoc.info/github/myfreecomm/passaporteweb-client-ruby/frames/

The RDoc is the best place to learn how to use this client. A few example uses are listed below. See the mapping of API endpoints to this client code below as well to find what you need.

This client only uses the API of PassaporteWeb. To use the Single Sign-On (SSO) feature of PassaporteWeb via OAuth in Ruby, see the omni_auth_passaporte_web gem (code and example of use).

Installation

Add this line to your application's Gemfile:

gem 'passaporteweb-client', :require => 'passaporte_web'

And then execute:

$ bundle

Or install it yourself as:

$ gem install passaporteweb-client

Usage

Mapping of API endpoints to this client

Configuration

require 'passaporte_web'

PassaporteWeb.configure do |c|
  c.url = 'http://sandbox.app.passaporteweb.com.br' # defaults to 'https://app.passaporteweb.com.br' if omitted
  c.user_agent = 'My App v1.0' # optional, but you should pass a custom user-agent identifying your app
  c.application_token = 'some-app-token'
  c.application_secret = 'some-app-secret'
  c.user_token = 'some-user-token'
end

Examples

identity1 = PassaporteWeb::Identity.find("a5868d14-6529-477a-9c6b-a09dd42a7cd2")
identity1.email # "john@example.com"
identity1.first_name # "John"

identity2 = PassaporteWeb::Identity.find_by_email("john@example.com")
identity2.uuid # "a5868d14-6529-477a-9c6b-a09dd42a7cd2"

identity1 == profile2 # true

identity1.gender # nil
identity1.gender = 'M'
identity1.save # true
identity1.gender # 'M'

attributes = {
  "email" => "lula_luis7@example.com",
  "first_name" => "Luis Inácio",
  "last_name" => "da Silva",
  "password" => "rW5oHxYB",
  "password2" => "rW5oHxYB",
  "must_change_password" => true,
  "tos" => true,
  "inhibit_activation_message" => false,
  "cpf" => "353.423.680-73",
  "send_partner_news" => false,
  "send_myfreecomm_news" => false
}
identity = PassaporteWeb::Identity.new(attributes)
identity.save # true

attributes = {
  "email" => "lula_luis8@example.com",
  "first_name" => "Luis Inácio",
  "last_name" => "da Silva",
  "tos" => true
}
identity = PassaporteWeb::Identity.new(attributes)
identity.save # false
identity.errors # hash of errors

Contributing

  1. Fork it

  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 new Pull Request