module Touggsl::RequestHelper
Attributes
auth[R]
Public Instance Methods
billings_request(client_id, status)
click to toggle source
# File lib/touggsl/request_helpers.rb, line 113 def billings_request(client_id, status) HTTParty.post("#{Touggsl.get_uri}cobranca/index", :body => {'identificador' => client_id, 'status' => status}, :headers => {'Cookie' => auth.get_cookie}) end
checks_if_client_is_inadimplente(client_id)
click to toggle source
# File lib/touggsl/request_helpers.rb, line 97 def checks_if_client_is_inadimplente(client_id) today = Time.now.strftime("%m/%d/%Y") HTTParty.post("#{Touggsl.get_uri}inadimplencia/index", :body => {'identificador' => client_id, 'posicaoEm' => today}, :headers => {'Cookie' => auth.get_cookie}) end
create_client(id, nome, nome_fantasia, email = nil, endereco = nil, numero = nil, bairro = nil, cidade = nil, estado = nil, cep = nil, dia_vencimento_sac =0)
click to toggle source
# File lib/touggsl/request_helpers.rb, line 34 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.get_cookie}) end
do_request(username, password)
click to toggle source
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 should call this method with following params:
do_request("email@email.com", "password")
# 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_2via_link(client_id)
click to toggle source
# File lib/touggsl/request_helpers.rb, line 103 def get_2via_link(client_id) today = Time.now.strftime("%m/%d/%Y") HTTParty.post("#{Touggsl.get_uri}inadimplencia/index", :body => {'identificador' => client_id, 'posicaoEm' => today}, :headers => {'Cookie' => auth.get_cookie}) end
get_2via_link_normal_client(client_id)
click to toggle source
# File lib/touggsl/request_helpers.rb, line 109 def get_2via_link_normal_client(client_id) HTTParty.post("#{Touggsl.get_uri}cobranca/index", :body => {'identificador' => client_id}, :headers => {'Cookie' => auth.get_cookie}) end
get_clients_inadimplementes()
click to toggle source
# 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.get_cookie}) end
hiring_plan_for_client(plan_id, client_id, id_contrato, notification=0, quantidade_parcelas_adesao=1, forma_pagamento)
click to toggle source
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.
# File lib/touggsl/request_helpers.rb, line 64 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.get_cookie }) end
include_auth_to_requests(auth)
click to toggle source
include the authenticator in order to use in future requests
Params¶ ↑
-
auth
- ATouggsl::Auth
# File lib/touggsl/request_helpers.rb, line 86 def include_auth_to_requests(auth) @auth = auth end
new_billing_request(client_id, data_vencimento, product_id, value, account_id)
click to toggle source
# File lib/touggsl/request_helpers.rb, line 138 def new_billing_request(client_id, data_vencimento, product_id, value, account_id) HTTParty.post("#{Touggsl.get_uri}cobranca/put", :body => {'COMPO_RECEBIMENTO' => {0 => {'ID_PRODUTO_PRD' => product_id, 'ST_DESCRICAO_PRD' => product_id, 'NM_QUANTIDADE_PRD' => '1', 'VL_UNITARIO_PRD' => value, 'ST_VALOR_COMP' => value}}, 'identificador' => client_id, 'DT_VENCIMENTO_RECB' => data_vencimento, 'ID_CONTA_CB' => account_id}, :headers => {'Cookie' => auth.get_cookie}) end
pay_request(pay_id, value)
click to toggle source
# File lib/touggsl/request_helpers.rb, line 119 def pay_request(pay_id, value) date = Time.now.strftime('%m/%d/%Y') HTTParty.post("#{Touggsl.get_uri}cobranca/liquidar", :body => {'ID_RECEBIMENTO_RECB' => pay_id, 'VL_EMITIDO_RECB' => value, 'VL_DEVIDO' => value, 'VL_TOTAL_RECB' => value, 'DT_LIQUIDACAO_RECB' => date, 'DT_RECEBIMENTO_RECB' => date, 'VL_MULTA' => 0, 'VL_JUROS' => 0, 'VL_DESCONTO' => 0, 'FL_DIFERENCA' => 0, 'DT_VENCIMENTO_PRE' => date, 'ID_FORMAPAGAMENTO_RECB' => 0, 'ID_CONTA_CB' => 1}, :headers => {'Cookie' => auth.get_cookie}) end