Class: Emites::Resources::Taker

Inherits:
Base
  • Object
show all
Defined in:
lib/emites/resources/taker.rb

Overview

A wrapper to Emites takers API

API

Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/taker.html

Examples:

Listing all takers:

client = Emites.client("MY_SECRET_TOKEN")
client.takers.list

Creating an taker:

client = Emites.client("MY_SECRET_TOKEN")
client.takers.create({cnpj: "01001001000113"})

See Also:

Instance Attribute Summary

Attributes inherited from Base

#http

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Hooks

#notify

Constructor Details

This class inherits a constructor from Emites::Resources::Base

Instance Method Details

#create(params) ⇒ Emites::Entities::Taker

Creates a Taker related to the Account

API

Method: POST /api/v1/takers

Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/taker.html#criacao

Parameters:

  • params (Hash)

    a hash with Taker attributes

Returns:



29
30
31
32
33
# File 'lib/emites/resources/taker.rb', line 29

def create(params)
  http.post("/takers", { body: params }) do |response|
    respond_with_entity(response)
  end
end

#destroy(id) ⇒ Boolean

Deletes a Taker by it’s id. Returns true</true> if deletion performed well, otherwise, returns <tt>false.

API

Method: DELETE /api/v1/takers/:id

Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/taker.html#remocao

Parameters:

  • id (Integer)

    the Taker id

Returns:

  • (Boolean)

    whether deletion was performed or not



89
90
91
92
93
# File 'lib/emites/resources/taker.rb', line 89

def destroy(id)
  http.delete("/takers/#{id}") do |response|
    response.code == 204
  end
end

#info(id) ⇒ Emites::Entities::Taker

Retrieves a Taker by it’s id

API

Method: GET /api/v1/takers/:id

Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/taker.html#detalhes

Parameters:

  • id (Integer)

    the Taker id

Returns:



44
45
46
47
48
# File 'lib/emites/resources/taker.rb', line 44

def info(id)
  http.get("/takers/#{id}") do |response|
    respond_with_entity(response)
  end
end

#listArray

Lists all takers related to the account

API

Method: GET /api/v1/takers

Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/taker.html#listagem

Returns:

  • (Array)

    an array of Taker



58
59
60
61
62
# File 'lib/emites/resources/taker.rb', line 58

def list
  http.get("/takers") do |response|
    respond_with_collection(response)
  end
end

#search(params) ⇒ Array

Lists all takers related to the account matching search results

API

Method: GET /api/v1/takers?cnpj=:cnpj

Documentation: myfreecomm.github.io/emites/sandbox/v1/modules/taker.html#filtros

Parameters:

  • params (Hash)

    a hash with Taker attributes

Returns:

  • (Array)

    an array of Taker



73
74
75
76
77
# File 'lib/emites/resources/taker.rb', line 73

def search(params)
  http.get("/takers", { params: params }) do |response|
    respond_with_collection(response)
  end
end