vpsa 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/vpsa/api/client_classes.rb +20 -0
- data/lib/vpsa/client.rb +5 -1
- data/lib/vpsa/searcher/operational/client_class_searcher.rb +10 -0
- data/lib/vpsa/version.rb +1 -1
- data/spec/vpsa/api/client_classes_spec.rb +41 -0
- data/spec/vpsa/client_spec.rb +4 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03cd78da745990c1ac149242b249855294e82df3
|
4
|
+
data.tar.gz: 5a47b16ae4a96519ac5afe237fe1ff61ec1cc00e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f236572b709fca6b8264dae274ac582f78b11f15b2bdcbf06405f6ef9a8e4dcfc020fb41b560be9e87855e8253c5b54743561c32ba2eb8c3096143d44242707
|
7
|
+
data.tar.gz: c843f2b6da979799acb8cea52861fa009beec8227e5abf7626c9b2a72fa6627e15725aa4f4a286463fba6436e352a5477ab68ea106fcde9cdef9cc2086306124
|
data/README.md
CHANGED
@@ -35,6 +35,7 @@ With the client instance, you can access the following resources:
|
|
35
35
|
* Lançamentos Padrões (client.default_entries) **Listing and finding**
|
36
36
|
* Provisões (client.provisions) **Only Creation**
|
37
37
|
* Dados Login (client.user_data)
|
38
|
+
* Classes de Clientes (client.client_classes) **Listing and finding**
|
38
39
|
|
39
40
|
## Using the resources
|
40
41
|
### Listing
|
@@ -47,6 +48,7 @@ Currently the following entities are implemented:
|
|
47
48
|
* [Terceiros](lib/vpsa/searcher/administrative/third_party_searcher.rb)
|
48
49
|
* [Entidades](lib/vpsa/searcher/administrative/entity_searcher.rb)
|
49
50
|
* [Lançamentos Padrões](lib/vpsa/searcher/financial/default_entry_searcher.rb)
|
51
|
+
* [Classes de Clientes](lib/vpsa/searcher/operational/client_class_searcher.rb)
|
50
52
|
|
51
53
|
### Finding
|
52
54
|
All resources implement a **find** method.
|
@@ -74,7 +76,7 @@ You can get the token owner information by calling the following method:
|
|
74
76
|
```
|
75
77
|
|
76
78
|
### Reading the response
|
77
|
-
All methods return
|
79
|
+
All methods return a Vpsa::Client::Response object. This objects contains the following attributes:
|
78
80
|
|
79
81
|
```ruby
|
80
82
|
response = Vpsa.new(YOUR_ACCESS_TOKEN).third_parties.list
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Vpsa
|
2
|
+
module Api
|
3
|
+
class ClientClasses < Client
|
4
|
+
require_all 'vpsa/searcher/operational', 'client_class_searcher'
|
5
|
+
|
6
|
+
base_uri "https://www.vpsa.com.br/apps/api/classificacoes-clientes"
|
7
|
+
|
8
|
+
def list(searcher = nil)
|
9
|
+
raise ArgumentError unless searcher.nil? || searcher.is_a?(Vpsa::Searcher::Operational::ClientClassSearcher)
|
10
|
+
|
11
|
+
return parse_response(self.class.get("/", :body => build_body(searcher.as_parameter), :headers => header)) if searcher
|
12
|
+
return parse_response(self.class.get("/", :body => build_body, :headers => header)) unless searcher
|
13
|
+
end
|
14
|
+
|
15
|
+
def find(id)
|
16
|
+
return parse_response(self.class.get("/#{id}", :body => build_body, :headers => header))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/vpsa/client.rb
CHANGED
@@ -8,7 +8,7 @@ module Vpsa
|
|
8
8
|
default_options.update(verify: false)
|
9
9
|
parser Proc.new {|b| JSON.parse(b) rescue b}
|
10
10
|
|
11
|
-
require_all 'vpsa/api', 'third_parties', 'entities', 'default_entries', 'provisions', 'user_data', 'installments', 'credit_limits'
|
11
|
+
require_all 'vpsa/api', 'third_parties', 'entities', 'default_entries', 'provisions', 'user_data', 'installments', 'credit_limits', 'client_classes'
|
12
12
|
|
13
13
|
attr_accessor :access_token
|
14
14
|
|
@@ -44,6 +44,10 @@ module Vpsa
|
|
44
44
|
def credit_limits
|
45
45
|
Vpsa::Api::CreditLimits.new(@access_token)
|
46
46
|
end
|
47
|
+
|
48
|
+
def client_classes
|
49
|
+
Vpsa::Api::ClientClasses.new(@access_token)
|
50
|
+
end
|
47
51
|
|
48
52
|
protected
|
49
53
|
def header
|
data/lib/vpsa/version.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Vpsa::Api::ClientClasses do
|
4
|
+
let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
|
5
|
+
|
6
|
+
describe "listing" do
|
7
|
+
before(:each) do
|
8
|
+
stub_request(:get, "https://www.vpsa.com.br/apps/api/classificacoes-clientes/").to_return(:status => 200)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should issue a get to the client classes url" do
|
12
|
+
expect(Vpsa::Api::ClientClasses).to receive(:get).with("/", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
13
|
+
|
14
|
+
Vpsa.new("abc").client_classes.list()
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should issue a get to the client classes url using the searcher" do
|
18
|
+
searcher = Vpsa::Searcher::Operational::ClientClassSearcher.new({:quantidade => 10, :inicio => 0})
|
19
|
+
|
20
|
+
expect(Vpsa::Api::ClientClasses).to receive(:get).with("/", :body => searcher.as_parameter.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
21
|
+
|
22
|
+
Vpsa.new("abc").client_classes.list(searcher)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise ArgumentError if the parameter is not a ClientClassSearcher" do
|
26
|
+
expect{Vpsa.new("abc").client_classes.list(Array.new)}.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "finding" do
|
31
|
+
before(:each) do
|
32
|
+
stub_request(:get, "https://www.vpsa.com.br/apps/api/classificacoes-clientes/5").to_return(:status => 200)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should issue a get to the client classes url" do
|
36
|
+
expect(Vpsa::Api::ClientClasses).to receive(:get).with("/5", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
37
|
+
|
38
|
+
Vpsa.new("abc").client_classes.find(5)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/vpsa/client_spec.rb
CHANGED
@@ -28,4 +28,8 @@ RSpec.describe Vpsa::Client do
|
|
28
28
|
it "should return a new Vpsa::Api::CreditLimits" do
|
29
29
|
expect(Vpsa.new("abc").credit_limits.class).to eq(Vpsa::Api::CreditLimits)
|
30
30
|
end
|
31
|
+
|
32
|
+
it "should return a new Vpsa::Api::ClientClasses" do
|
33
|
+
expect(Vpsa.new("abc").client_classes.class).to eq(Vpsa::Api::ClientClasses)
|
34
|
+
end
|
31
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vpsa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gustavo Berdugo
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- README.md
|
54
54
|
- Rakefile
|
55
55
|
- lib/vpsa.rb
|
56
|
+
- lib/vpsa/api/client_classes.rb
|
56
57
|
- lib/vpsa/api/credit_limits.rb
|
57
58
|
- lib/vpsa/api/default_entries.rb
|
58
59
|
- lib/vpsa/api/entities.rb
|
@@ -73,8 +74,10 @@ files:
|
|
73
74
|
- lib/vpsa/searcher/base.rb
|
74
75
|
- lib/vpsa/searcher/commercial/credit_limit_searcher.rb
|
75
76
|
- lib/vpsa/searcher/financial/default_entry_searcher.rb
|
77
|
+
- lib/vpsa/searcher/operational/client_class_searcher.rb
|
76
78
|
- lib/vpsa/version.rb
|
77
79
|
- spec/spec_helper.rb
|
80
|
+
- spec/vpsa/api/client_classes_spec.rb
|
78
81
|
- spec/vpsa/api/credit_limits_spec.rb
|
79
82
|
- spec/vpsa/api/default_entries_spec.rb
|
80
83
|
- spec/vpsa/api/entities_spec.rb
|
@@ -116,6 +119,7 @@ specification_version: 4
|
|
116
119
|
summary: This gem provides integration with VPSA APIs (http://www.vpsa.com.br/)
|
117
120
|
test_files:
|
118
121
|
- spec/spec_helper.rb
|
122
|
+
- spec/vpsa/api/client_classes_spec.rb
|
119
123
|
- spec/vpsa/api/credit_limits_spec.rb
|
120
124
|
- spec/vpsa/api/default_entries_spec.rb
|
121
125
|
- spec/vpsa/api/entities_spec.rb
|