Module: Touggsl::RequestHelper
- Extended by:
- RequestHelper
- Included in:
- Auth, Client, RequestHelper
- Defined in:
- lib/touggsl/request_helpers.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
Instance Method Summary collapse
- #create_client(id, nome, nome_fantasia, email = nil, endereco = nil, numero = nil, bairro = nil, cidade = nil, estado = nil, cep = nil, dia_vencimento_sac = 0) ⇒ Object
-
#do_request(username, password) ⇒ Object
Authenticate user in superlogica.
- #get_clients_inadimplementes ⇒ Object
-
#hiring_plan_for_client(plan_id, client_id, id_contrato, notification = 0, quantidade_parcelas_adesao = 1, forma_pagamento) ⇒ Object
Hiring a plan.
-
#include_auth_to_requests(auth) ⇒ Object
include the authenticator in order to use in future requests.
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
7 8 9 |
# File 'lib/touggsl/request_helpers.rb', line 7 def auth @auth end |
Instance Method Details
#create_client(id, nome, nome_fantasia, email = nil, endereco = nil, numero = nil, bairro = nil, cidade = nil, estado = nil, cep = nil, dia_vencimento_sac = 0) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/touggsl/request_helpers.rb', line 35 def create_client(id, nome, nome_fantasia, email = nil, endereco = nil, numero = nil, bairro = nil, cidade = nil, estado = nil, cep = nil, dia_vencimento_sac =0) HTTParty.post("#{Touggsl.get_uri}sacados/put", :body => {'ST_SINCRO_SAC' => id, 'ST_NOME_SAC' => nome, 'ST_NOMEREF_SAC' => nome_fantasia, 'ST_EMAIL_SAC' => email, 'ST_DIAVENCIMENTO_SAC' => dia_vencimento_sac, 'ST_ENDERECO_SAC' => endereco, 'ST_ESTADO_SAC' => estado, 'ST_CIDADE_SAC' => cidade, 'ST_CEP_SAC' => cep, 'ST_NUMERO_SAC' => numero, 'ST_BAIRRO_SAC' => bairro}, :headers => {'Cookie' => auth.}) end |
#do_request(username, password) ⇒ Object
Authenticate user in superlogica.
Params
-
username- your e-mail used to log in into superlogica -
password- your password
Return
-
A valid json with response
Example
In order to authenticate you shoulid call this method with following params:
do_request("[email protected]", "password")
25 26 27 28 29 30 31 32 33 |
# File 'lib/touggsl/request_helpers.rb', line 25 def do_request(username, password) r = HTTParty.get("#{Touggsl.get_uri}auth/post") response = HTTParty.post("#{Touggsl.get_uri}auth/post", body: {username: "#{username}", password: "#{password}"}, :headers => {'Cookie' => r.headers['Set-Cookie']}) response end |
#get_clients_inadimplementes ⇒ Object
90 91 92 93 94 95 |
# File 'lib/touggsl/request_helpers.rb', line 90 def get_clients_inadimplementes today = Time.now.strftime('%m/%d/%Y') HTTParty.get("#{Touggsl.get_uri}inadimplencia/index", :body => {'posicaoEm' => today}, :headers => {'Cookie' => auth.}) end |
#hiring_plan_for_client(plan_id, client_id, id_contrato, notification = 0, quantidade_parcelas_adesao = 1, forma_pagamento) ⇒ Object
Hiring a plan.
This method expect that you create the plan in Superlogica plataform.
Params
-
plan_id- the id of the plan in Superlogica -
client_id- the id of client that wish hering plan -
id_contrato- a unique ID for contract -
notification- 0 to not send notification and 1 to send. Dont send by default -
quantidade_parcela_adesao- Number of plots for the plan. By default is 1 -
forma_pagamento- 0 = boleto.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/touggsl/request_helpers.rb', line 65 def hiring_plan_for_client(plan_id, client_id, id_contrato, notification=0, quantidade_parcelas_adesao=1, forma_pagamento) hiring_at = Time.now.strftime('%m/%d/%Y') HTTParty.post("#{Touggsl.get_uri}planosclientes/put", :body => {'PLANOS' => {1 => {'identificador' => client_id, 'ID_PLANO_PLA' => plan_id, 'DT_CONTRATO_PLC' => hiring_at, 'ST_IDENTIFICADOR_PLC' => id_contrato, 'FL_NOTIFICARCLIENTE' => notification, 'QUANT_PARCELAS_ADESAO' => quantidade_parcelas_adesao, 'ID_FORMAPAGAMENTO_RECB' => forma_pagamento}}}, :headers => {'Cookie' => auth. }) end |
#include_auth_to_requests(auth) ⇒ Object
include the authenticator in order to use in future requests
Params
-
auth- A Touggsl::Auth
86 87 88 |
# File 'lib/touggsl/request_helpers.rb', line 86 def include_auth_to_requests(auth) @auth = auth end |