touggsl 0.4 → 0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.DS_Store +0 -0
- data/README.rdoc +19 -9
- data/bin/touggsl +0 -0
- data/lib/touggsl.rb +1 -1
- data/lib/touggsl/{client.rb → customer.rb} +29 -6
- data/lib/touggsl/models/{client.rb → customer.rb} +1 -1
- data/lib/touggsl/request_helpers.rb +12 -0
- data/lib/version.rb +1 -1
- data/test/touggsl/{test_client.rb → test_customer.rb} +2 -2
- data/touggsl.gemspec +6 -5
- metadata +7 -6
data/.DS_Store
ADDED
Binary file
|
data/README.rdoc
CHANGED
@@ -1,31 +1,41 @@
|
|
1
1
|
= Touggsl - Access Superlogica API through Ruby Code
|
2
2
|
|
3
|
-
Até o momento essa gem fornece
|
3
|
+
Até o momento essa gem fornece seis operações sobre a API da Superlogica
|
4
4
|
|
5
5
|
* Autenticação
|
6
6
|
* Cadastro de cliente
|
7
7
|
* Assinar um plano para um cliente
|
8
8
|
* Buscar clientes inadimplentes
|
9
|
+
* Verifica se cliente específico está inadimplente
|
10
|
+
* Retorna link de 2ª via para um cliente inadimplente
|
9
11
|
|
10
12
|
== Autenticação
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
Touggsl.set_uri("http://sua_conta.superlogica.net/financeiro/atual/")
|
15
|
+
@auth = Touggsl::Auth
|
16
|
+
@auth.login("email", "password")
|
15
17
|
|
16
18
|
== Criando um cliente
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
+
client = Touggsl::Customer.new(@auth)
|
21
|
+
client.create_new_client("0303030", "Jack", "Tougg", "jack@tougg.com.br") # retorna "200" para sucesso
|
20
22
|
|
21
|
-
== Vinculando um
|
23
|
+
== Vinculando um plano a um cliente
|
22
24
|
|
23
|
-
|
25
|
+
client.hiring_plan(plan_id, client_id, contract_id) #retorna "200" para sucesso.
|
24
26
|
|
25
27
|
== Buscando inadimplentes
|
26
28
|
|
27
|
-
|
29
|
+
client.get_all_inadimplentes #retorna uma array de Client
|
28
30
|
|
31
|
+
== Verifica se cliente está inadimplente
|
32
|
+
|
33
|
+
client.is_inadimplente(client_id)
|
34
|
+
|
35
|
+
== 2ª Via Boleto
|
36
|
+
Retorna link de 2ª via, caso cliente estiver inadimplente.
|
37
|
+
|
38
|
+
client.link_2via(client_id)
|
29
39
|
|
30
40
|
Para maiores informações recomenda-se dar uma olhada nos testes e na documentação.
|
31
41
|
|
data/bin/touggsl
CHANGED
File without changes
|
data/lib/touggsl.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'touggsl'
|
2
2
|
require 'json'
|
3
3
|
require 'touggsl/request_helpers'
|
4
|
-
require 'touggsl/models/
|
5
|
-
class Touggsl::
|
4
|
+
require 'touggsl/models/customer'
|
5
|
+
class Touggsl::Customer
|
6
6
|
include Touggsl::RequestHelper
|
7
7
|
|
8
8
|
attr_accessor :auth
|
@@ -64,7 +64,7 @@ class Touggsl::Client
|
|
64
64
|
##
|
65
65
|
# Retorna todos os clientes que estão inadimplentes
|
66
66
|
#
|
67
|
-
def
|
67
|
+
def get_all_inadimplentes
|
68
68
|
clients = []
|
69
69
|
clients_json = JSON.parse(get_clients_inadimplementes)
|
70
70
|
clients_json["data"].each do |j|
|
@@ -73,9 +73,32 @@ class Touggsl::Client
|
|
73
73
|
dias_atraso = recebimento[0]["encargos"][0]["diasatraso"]
|
74
74
|
id_client = j["id_sacado_sac"]
|
75
75
|
segunda_via = recebimento[0]["link_2via"]
|
76
|
-
clients <<
|
76
|
+
clients << Customer.new(id_client, name, dias_atraso, segunda_via)
|
77
77
|
end
|
78
78
|
clients
|
79
79
|
end
|
80
|
-
|
81
|
-
|
80
|
+
|
81
|
+
##
|
82
|
+
# Retorna boolean se cliente esta inadimplente
|
83
|
+
#
|
84
|
+
def is_inadimplente(client_id)
|
85
|
+
client = JSON.parse(checks_if_client_is_inadimplente(client_id))
|
86
|
+
if client['data'].length > 0
|
87
|
+
return true
|
88
|
+
else
|
89
|
+
return false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# Retorna link de 2 via do boleto para cliente inadimplente
|
95
|
+
#
|
96
|
+
def link_2via(client_id)
|
97
|
+
link = JSON.parse(get_2via_link(client_id))
|
98
|
+
link['data'].each do |d|
|
99
|
+
d['recebimento'].each do |v|
|
100
|
+
return v['link_2via']
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -93,5 +93,17 @@ module Touggsl
|
|
93
93
|
:body => {'posicaoEm' => today}, :headers => {'Cookie' => auth.get_cookie})
|
94
94
|
|
95
95
|
end
|
96
|
+
|
97
|
+
def checks_if_client_is_inadimplente(client_id)
|
98
|
+
today = Time.now.strftime("%m/%d/%Y")
|
99
|
+
HTTParty.post("#{Touggsl.get_uri}inadimplencia/index",
|
100
|
+
:body => {'identificador' => client_id, 'posicaoEm' => today}, :headers => {'Cookie' => auth.get_cookie})
|
101
|
+
end
|
102
|
+
|
103
|
+
def get_2via_link(client_id)
|
104
|
+
today = Time.now.strftime("%m/%d/%Y")
|
105
|
+
HTTParty.post("#{Touggsl.get_uri}inadimplencia/index",
|
106
|
+
:body => {'identificador' => client_id, 'posicaoEm' => today}, :headers => {'Cookie' => auth.get_cookie})
|
107
|
+
end
|
96
108
|
end
|
97
109
|
end
|
data/lib/version.rb
CHANGED
@@ -2,7 +2,7 @@ require 'helper'
|
|
2
2
|
require 'json'
|
3
3
|
require 'touggsl'
|
4
4
|
require 'touggsl_helper'
|
5
|
-
require './lib/touggsl/
|
5
|
+
require './lib/touggsl/customer'
|
6
6
|
class TestClient < Test::Unit::TestCase
|
7
7
|
|
8
8
|
|
@@ -19,7 +19,7 @@ Time.stubs(:now).returns(Time.mktime(2013,11,03))
|
|
19
19
|
|
20
20
|
auth = Touggsl::Auth
|
21
21
|
auth.login("jack", "secret")
|
22
|
-
@client = Touggsl::
|
22
|
+
@client = Touggsl::Customer.new(auth)
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_client_should_have_a_auth
|
data/touggsl.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "touggsl"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Edipo Luis Federle", "Dyan Carlos Carra"]
|
12
|
-
s.date = "2013-11-
|
12
|
+
s.date = "2013-11-23"
|
13
13
|
s.description = "Ruby code to access superlogica API"
|
14
14
|
s.email = ["edipofederle@gmail.com", "dyancarra@gmail.com"]
|
15
15
|
s.executables = ["touggsl"]
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
"README.rdoc"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
|
+
".DS_Store",
|
21
22
|
"Gemfile",
|
22
23
|
"Gemfile.lock",
|
23
24
|
"LICENSE.txt",
|
@@ -26,15 +27,15 @@ Gem::Specification.new do |s|
|
|
26
27
|
"bin/touggsl",
|
27
28
|
"lib/touggsl.rb",
|
28
29
|
"lib/touggsl/auth.rb",
|
29
|
-
"lib/touggsl/
|
30
|
-
"lib/touggsl/models/
|
30
|
+
"lib/touggsl/customer.rb",
|
31
|
+
"lib/touggsl/models/customer.rb",
|
31
32
|
"lib/touggsl/request_helpers.rb",
|
32
33
|
"lib/version.rb",
|
33
34
|
"test/contratarplano.json",
|
34
35
|
"test/helper.rb",
|
35
36
|
"test/inadimplentes.json",
|
36
37
|
"test/touggsl/test_auth.rb",
|
37
|
-
"test/touggsl/
|
38
|
+
"test/touggsl/test_customer.rb",
|
38
39
|
"test/touggsl/test_touggsl.rb",
|
39
40
|
"test/touggsl/test_version.rb",
|
40
41
|
"test/touggsl_helper.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.6'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-11-
|
13
|
+
date: 2013-11-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: shoulda
|
@@ -151,6 +151,7 @@ extra_rdoc_files:
|
|
151
151
|
- LICENSE.txt
|
152
152
|
- README.rdoc
|
153
153
|
files:
|
154
|
+
- .DS_Store
|
154
155
|
- Gemfile
|
155
156
|
- Gemfile.lock
|
156
157
|
- LICENSE.txt
|
@@ -159,15 +160,15 @@ files:
|
|
159
160
|
- bin/touggsl
|
160
161
|
- lib/touggsl.rb
|
161
162
|
- lib/touggsl/auth.rb
|
162
|
-
- lib/touggsl/
|
163
|
-
- lib/touggsl/models/
|
163
|
+
- lib/touggsl/customer.rb
|
164
|
+
- lib/touggsl/models/customer.rb
|
164
165
|
- lib/touggsl/request_helpers.rb
|
165
166
|
- lib/version.rb
|
166
167
|
- test/contratarplano.json
|
167
168
|
- test/helper.rb
|
168
169
|
- test/inadimplentes.json
|
169
170
|
- test/touggsl/test_auth.rb
|
170
|
-
- test/touggsl/
|
171
|
+
- test/touggsl/test_customer.rb
|
171
172
|
- test/touggsl/test_touggsl.rb
|
172
173
|
- test/touggsl/test_version.rb
|
173
174
|
- test/touggsl_helper.rb
|
@@ -187,7 +188,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
188
|
version: '0'
|
188
189
|
segments:
|
189
190
|
- 0
|
190
|
-
hash:
|
191
|
+
hash: 506723146345324378
|
191
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
193
|
none: false
|
193
194
|
requirements:
|