Class: Bling::API::User

Inherits:
Request show all
Defined in:
lib/bling/api/user.rb

Overview

This class is used to make requests to all available actions related to users in Bling api. Is strongly recommended to use the Bling::API module wrapper

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bling::API::Request

Instance Method Details

#create(params) ⇒ Array

Insert a user in Bling

Examples:

user = Bling::API::User.new.create(
  {
  name: 'Jonh Doe',
  company_name: '',
  tax_type: 1,
  document: '35165478662',
  ir_rg: '306153420',
  address: 'My great street',
  number: '33',
  additional_address: 'apt 12',
  zipcode: '03454020',
  city: 'Sao Paulo',
  uf: 'SP',
  phone: '(11) 2233-3322',
  email: jonh@@doe.com'
  }
)

Parameters:

  • params (Hash)

    A hash with user options

Returns:

  • (Array)

    Call user#create and return an array with one record



57
58
59
# File 'lib/bling/api/user.rb', line 57

def create(params)
  post_request(t_url(:user), parsed_xml(params))
end

#get(user_id) ⇒ Array

Get a specific object based on user_id

Examples:

user = Bling::API::user.new.get

Parameters:

  • cpf (String)

    or cnpj from the user in Bling

Returns:

  • (Array)

    Call user#show and return an array with one record



28
29
30
# File 'lib/bling/api/user.rb', line 28

def get(user_id)
  get_request(t_url(:user, user_id))
end

#listArray

Get a list of available users

Examples:

users = Bling::API::User.new.list

Returns:

  • (Array)

    Call users index and return an array with records



15
16
17
# File 'lib/bling/api/user.rb', line 15

def list
  get_request(t_url(:users))
end