touggsl 0.7 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.DS_Store +0 -0
- data/{README.rdoc → README.md} +17 -14
- data/lib/touggsl/customer.rb +65 -16
- data/lib/touggsl/request_helpers.rb +34 -0
- data/lib/version.rb +1 -1
- data/test/touggsl/test_version.rb +3 -3
- data/touggsl.gemspec +5 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjcwZTRmMzgyNGM5MjIwZGZmZGRkNDM1MDljNjc3OWY0YjI0Zjg0MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzE5MGJhMzc4ZWY5YTY1OGE5YjFiNzNmNDhiM2Q3MWJmMDgwOGJhMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NzRmZjgxYTM4ZTJhYjU4ZjllZjRkZWY3NjFkMzVmYTQ2M2YxZjM4MzhjNTIz
|
10
|
+
MDQ4NTg0MjMxM2ZkOWM0MGEzYTJhMjg1NWY0ZTMwNmRjMGE4M2Y2ODhhZTM1
|
11
|
+
MzY3MjY1N2YxMzJlMzBlNjFiNGQwZWMwMjIxYTdhODZhY2RiZGU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTEyNTdmN2Y0YzRkNWU5MDcxNjdhNTI3MzBlMzgxN2ExYzMyZDBiZTljZDZl
|
14
|
+
ZjE2MjNkMjQwMmUxOTM2OGE0NzA5Y2VmNTFiMDk5YWJjNmI2ZDYzNmNjOGMy
|
15
|
+
ZWUwM2ZkYmNiZGVmZjJmYmNkOWFkOTg3NzBjZTZmZGUxN2ZjODY=
|
data/.DS_Store
CHANGED
Binary file
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# Touggsl - Access Superlogica API through Ruby Code
|
2
2
|
|
3
3
|
Até o momento essa gem fornece seis operações sobre a API da Superlogica
|
4
4
|
|
@@ -8,39 +8,42 @@ Até o momento essa gem fornece seis operações sobre a API da Superlogica
|
|
8
8
|
* Buscar clientes inadimplentes
|
9
9
|
* Verifica se cliente específico está inadimplente
|
10
10
|
* Retorna link de 2ª via para um cliente inadimplente
|
11
|
+
* Retorna todas as cobrancas do cliente, com status pendente por default
|
12
|
+
* Liquida uma cobrança, dado um ID da cobrança
|
13
|
+
* Gerar cobrança
|
11
14
|
|
12
|
-
|
15
|
+
## Autenticação
|
13
16
|
|
14
17
|
Touggsl.set_uri("http://sua_conta.superlogica.net/financeiro/atual/")
|
15
18
|
@auth = Touggsl::Auth
|
16
19
|
@auth.login("email", "password")
|
17
20
|
|
18
|
-
|
19
|
-
|
21
|
+
## Criando um cliente
|
22
|
+
|
20
23
|
client = Touggsl::Customer.new(@auth)
|
21
|
-
client.create_new_client("0303030", "Jack", "Tougg", "jack@tougg.com.br") # retorna "200" para sucesso
|
24
|
+
client.create_new_client("0303030", "Jack", "Tougg", "jack@tougg.com.br") # retorna "200" para sucesso
|
22
25
|
|
23
|
-
|
26
|
+
## Vinculando um plano a um cliente
|
24
27
|
|
25
28
|
client.hiring_plan(plan_id, client_id, contract_id) #retorna "200" para sucesso.
|
26
29
|
|
27
|
-
|
30
|
+
## Buscando inadimplentes
|
28
31
|
|
29
32
|
client.get_all_inadimplentes #retorna uma array de Client
|
30
33
|
|
31
|
-
|
34
|
+
## Verifica se cliente está inadimplente
|
32
35
|
|
33
36
|
client.is_inadimplente(client_id)
|
34
|
-
|
35
|
-
|
37
|
+
|
38
|
+
## 2ª Via Boleto
|
36
39
|
Retorna link de 2ª via, caso cliente estiver inadimplente.
|
37
40
|
|
38
41
|
client.link_2via(client_id)
|
39
42
|
|
40
43
|
Para maiores informações recomenda-se dar uma olhada nos testes e na documentação.
|
41
44
|
|
42
|
-
|
43
|
-
|
45
|
+
## Contributing to Touggsl
|
46
|
+
|
44
47
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
45
48
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
46
49
|
* Fork the project.
|
@@ -49,12 +52,12 @@ Para maiores informações recomenda-se dar uma olhada nos testes e na documenta
|
|
49
52
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
50
53
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
51
54
|
|
52
|
-
|
55
|
+
## Authors
|
53
56
|
|
54
57
|
* Édipo Luis Féderle - edipofederle@gmail.com
|
55
58
|
* Dyan Carlos Carra - dyancarra@gmail.com
|
56
59
|
|
57
|
-
|
60
|
+
## Copyright
|
58
61
|
|
59
62
|
Copyright (c) 2013 {Tougg}[http://tougg.com.br]. See LICENSE.txt for
|
60
63
|
further details.
|
data/lib/touggsl/customer.rb
CHANGED
@@ -4,12 +4,12 @@ require 'touggsl/request_helpers'
|
|
4
4
|
require 'touggsl/models/customer'
|
5
5
|
class Touggsl::Customer
|
6
6
|
include Touggsl::RequestHelper
|
7
|
-
|
7
|
+
|
8
8
|
attr_accessor :auth
|
9
|
-
|
9
|
+
|
10
10
|
##
|
11
11
|
# Recebe um Touggsl::Auth
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# Exemplo:
|
14
14
|
#
|
15
15
|
# auth = Touggsl::Auth
|
@@ -20,7 +20,7 @@ class Touggsl::Customer
|
|
20
20
|
@auth = auth
|
21
21
|
include_auth_to_requests(@auth)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
##
|
25
25
|
# Cadastra um novo cliente na Superlogica
|
26
26
|
#
|
@@ -37,7 +37,7 @@ class Touggsl::Customer
|
|
37
37
|
|
38
38
|
#create a class for response, at the time only return the
|
39
39
|
# status
|
40
|
-
json["status"]
|
40
|
+
json["status"]
|
41
41
|
end
|
42
42
|
|
43
43
|
##
|
@@ -60,7 +60,7 @@ class Touggsl::Customer
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
##
|
65
65
|
# Retorna todos os clientes que estão inadimplentes
|
66
66
|
#
|
@@ -77,31 +77,35 @@ class Touggsl::Customer
|
|
77
77
|
end
|
78
78
|
clients
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
##
|
82
|
-
# Retorna
|
82
|
+
# Retorna true se cliente esta inadimplente, false caso não for.
|
83
|
+
#
|
84
|
+
# ==== Params
|
85
|
+
# * <tt>client_id</tt> - ID do cliente
|
83
86
|
#
|
84
87
|
def is_inadimplente(client_id)
|
85
88
|
client = JSON.parse(checks_if_client_is_inadimplente(client_id))
|
86
|
-
|
87
|
-
return true
|
88
|
-
else
|
89
|
-
return false
|
90
|
-
end
|
89
|
+
client['data'].length > 0 ? true : false
|
91
90
|
end
|
92
|
-
|
91
|
+
|
93
92
|
##
|
94
93
|
# Retorna link de 2 via do boleto para cliente que nao está inadimplente
|
95
94
|
#
|
95
|
+
# # ==== Params
|
96
|
+
# * <tt>client_id</tt> - ID do cliente
|
97
|
+
#
|
96
98
|
def link_2via_normal_client(client_id)
|
97
99
|
link = JSON.parse(get_2via_link_normal_client(client_id))
|
98
100
|
link['data'].each do |d|
|
99
101
|
return d['link_2via']
|
100
102
|
end
|
101
103
|
end
|
102
|
-
|
104
|
+
|
103
105
|
##
|
104
106
|
# Retorna link de 2 via do boleto para cliente inadimplente
|
107
|
+
# ==== Params
|
108
|
+
# * <tt>client_id</tt> - ID do cliente
|
105
109
|
#
|
106
110
|
def link_2via(client_id)
|
107
111
|
link = JSON.parse(get_2via_link(client_id))
|
@@ -111,4 +115,49 @@ class Touggsl::Customer
|
|
111
115
|
end
|
112
116
|
end
|
113
117
|
end
|
114
|
-
|
118
|
+
|
119
|
+
##
|
120
|
+
# Retorna todas as cobrancas do cliente, com status pendente por default
|
121
|
+
# ==== Params
|
122
|
+
# * <tt>client_id</tt> - ID do cliente
|
123
|
+
# * <tt>status</tt> - status das cobranças
|
124
|
+
#
|
125
|
+
def billings(client_id, status = 'pendentes')
|
126
|
+
billings = JSON.parse(billings_request(client_id, status))
|
127
|
+
return billings['data']
|
128
|
+
end
|
129
|
+
|
130
|
+
##
|
131
|
+
# Liquida uma cobrança
|
132
|
+
#
|
133
|
+
# ==== Params
|
134
|
+
# * <tt>pay_id</tt> - ID do pagamento
|
135
|
+
# * <tt>value</tt> - valor da cobrança. Padrão é 24.90.
|
136
|
+
#
|
137
|
+
def pay(pay_id, value = 24.90)
|
138
|
+
pay = JSON.parse(pay_request(pay_id, value))
|
139
|
+
status = pay['status'].to_i
|
140
|
+
unless status == 200
|
141
|
+
return "Ocorreu algum erro."
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
##
|
146
|
+
# Gerar uma cobranca
|
147
|
+
# * <tt>client_id</tt> - ID do cliente
|
148
|
+
# * <tt>data_vencimento</tt> - data de vecimento da cobrança
|
149
|
+
# * <tt>product_id</tt> - ID do produto/serviço na superlógica
|
150
|
+
# * <tt>value</tt> - valor da cobrança
|
151
|
+
# * <tt>account_id</tt> - ID da conta na superlógica
|
152
|
+
#
|
153
|
+
def new_billing(client_id, data_vencimento, product_id, value, account_id = 1)
|
154
|
+
billing = JSON.parse(new_billing_request(client_id, data_vencimento, product_id, value, account_id))
|
155
|
+
if billing['status'].to_i == 200
|
156
|
+
billing["data"].each do |d|
|
157
|
+
return d["data"]["link_2via"]
|
158
|
+
end
|
159
|
+
else
|
160
|
+
billing['data'].each { |d| puts d['msg'] }
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -109,5 +109,39 @@ module Touggsl
|
|
109
109
|
def get_2via_link_normal_client(client_id)
|
110
110
|
HTTParty.post("#{Touggsl.get_uri}cobranca/index", :body => {'identificador' => client_id}, :headers => {'Cookie' => auth.get_cookie})
|
111
111
|
end
|
112
|
+
|
113
|
+
def billings_request(client_id, status)
|
114
|
+
HTTParty.post("#{Touggsl.get_uri}cobranca/index",
|
115
|
+
:body => {'identificador' => client_id, 'status' => status},
|
116
|
+
:headers => {'Cookie' => auth.get_cookie})
|
117
|
+
end
|
118
|
+
|
119
|
+
def pay_request(pay_id, value)
|
120
|
+
date = Time.now.strftime('%m/%d/%Y')
|
121
|
+
HTTParty.post("#{Touggsl.get_uri}cobranca/liquidar",
|
122
|
+
:body => {'ID_RECEBIMENTO_RECB' => pay_id,
|
123
|
+
'VL_EMITIDO_RECB' => value,
|
124
|
+
'VL_DEVIDO' => value,
|
125
|
+
'VL_TOTAL_RECB' => value,
|
126
|
+
'DT_LIQUIDACAO_RECB' => date,
|
127
|
+
'DT_RECEBIMENTO_RECB' => date,
|
128
|
+
'VL_MULTA' => 0,
|
129
|
+
'VL_JUROS' => 0,
|
130
|
+
'VL_DESCONTO' => 0,
|
131
|
+
'FL_DIFERENCA' => 0,
|
132
|
+
'DT_VENCIMENTO_PRE' => date,
|
133
|
+
'ID_FORMAPAGAMENTO_RECB' => 0,
|
134
|
+
'ID_CONTA_CB' => 1},
|
135
|
+
:headers => {'Cookie' => auth.get_cookie})
|
136
|
+
end
|
137
|
+
|
138
|
+
def new_billing_request(client_id, data_vencimento, product_id, value, account_id)
|
139
|
+
HTTParty.post("#{Touggsl.get_uri}cobranca/put",
|
140
|
+
: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}},
|
141
|
+
'identificador' => client_id,
|
142
|
+
'DT_VENCIMENTO_RECB' => data_vencimento,
|
143
|
+
'ID_CONTA_CB' => account_id},
|
144
|
+
:headers => {'Cookie' => auth.get_cookie})
|
145
|
+
end
|
112
146
|
end
|
113
147
|
end
|
data/lib/version.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require 'helper'
|
1
|
+
require 'helper'
|
2
2
|
require 'json'
|
3
3
|
require 'touggsl/auth'
|
4
4
|
require 'version'
|
5
5
|
module Touggsl
|
6
6
|
class TestAuth < Test::Unit::TestCase
|
7
|
-
|
7
|
+
|
8
8
|
|
9
9
|
def test_version
|
10
|
-
assert_equal "0.
|
10
|
+
assert_equal "0.8",Touggsl::VERSION
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/touggsl.gemspec
CHANGED
@@ -2,28 +2,28 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: touggsl 0.
|
5
|
+
# stub: touggsl 0.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "touggsl"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.8"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["Edipo Luis Federle", "Dyan Carlos Carra"]
|
13
|
-
s.date = "2013-12-
|
13
|
+
s.date = "2013-12-30"
|
14
14
|
s.description = "Ruby code to access superlogica API"
|
15
15
|
s.email = ["edipofederle@gmail.com", "dyancarra@gmail.com"]
|
16
16
|
s.executables = ["touggsl"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE.txt",
|
19
|
-
"README.
|
19
|
+
"README.md"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".DS_Store",
|
23
23
|
"Gemfile",
|
24
24
|
"Gemfile.lock",
|
25
25
|
"LICENSE.txt",
|
26
|
-
"README.
|
26
|
+
"README.md",
|
27
27
|
"Rakefile",
|
28
28
|
"bin/touggsl",
|
29
29
|
"lib/touggsl.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: touggsl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edipo Luis Federle
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
@@ -132,13 +132,13 @@ executables:
|
|
132
132
|
extensions: []
|
133
133
|
extra_rdoc_files:
|
134
134
|
- LICENSE.txt
|
135
|
-
- README.
|
135
|
+
- README.md
|
136
136
|
files:
|
137
137
|
- .DS_Store
|
138
138
|
- Gemfile
|
139
139
|
- Gemfile.lock
|
140
140
|
- LICENSE.txt
|
141
|
-
- README.
|
141
|
+
- README.md
|
142
142
|
- Rakefile
|
143
143
|
- bin/touggsl
|
144
144
|
- lib/touggsl.rb
|