Skip to content

cotelha/passaporteweb-client-ruby

 
 

Repository files navigation

passaporteweb-client-ruby

A Ruby client for the PassaporteWeb REST API

<img src=“https://badge.fury.io/rb/passaporteweb-client.png” alt=“Gem Version” /> <img src=“https://travis-ci.org/myfreecomm/passaporteweb-client-ruby.png?branch=master” alt=“Build Status” /> <img src=“https://coveralls.io/repos/myfreecomm/passaporteweb-client-ruby/badge.png?branch=master” alt=“Coverage Status” /> <img src=“https://codeclimate.com/github/myfreecomm/passaporteweb-client-ruby.png” alt=“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 # "[email protected]"
identity1.first_name # "John"

identity2 = PassaporteWeb::Identity.find_by_email("[email protected]")
identity2.uuid # "a5868d14-6529-477a-9c6b-a09dd42a7cd2"

identity1 == profile2 # true

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

attributes = {
  "email" => "[email protected]",
  "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" => "[email protected]",
  "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

About

A Ruby client for the PassaporteWeb REST API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%