vpsa 0.0.23 → 0.0.24
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.
- checksums.yaml +4 -4
- data/README.md +14 -10
- data/lib/vpsa/api/companies.rb +20 -0
- data/lib/vpsa/api/sellers.rb +20 -0
- data/lib/vpsa/client.rb +9 -1
- data/lib/vpsa/searcher/administrative/company_searcher.rb +10 -0
- data/lib/vpsa/searcher/operational/seller_searcher.rb +11 -0
- data/lib/vpsa/version.rb +1 -1
- data/spec/vpsa/api/companies_spec.rb +41 -0
- data/spec/vpsa/api/sellers_spec.rb +41 -0
- data/spec/vpsa/client_spec.rb +8 -0
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dfa39f31909f7b3b8c24d0fc77c8af59a465dbe
|
4
|
+
data.tar.gz: de14e5651f1c64f01d8b8c3529c76e690df91d21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06a3c28265941b73787cebbaa25c87f96d6281a57b20fcf0bdee33dd5d822878b6261e3d022ba05c30799dc3820d8b2b8c4bdff7ab1a164b1d3488bc12785fda
|
7
|
+
data.tar.gz: 50902f8bc67f2e40a33bcd7e37e98451eb9ba1a03c991913e7d0365137d44d9e25aeebc6bddbafa6331d5b94cba3bd1449fa2ae220de48710eb906c54a082e07
|
data/README.md
CHANGED
@@ -31,16 +31,18 @@ Create a new instance of VPSA class passing your access token:
|
|
31
31
|
With the client instance, you can access the following resources:
|
32
32
|
|
33
33
|
* Classes de Clientes (client.client_classes) **Listing and finding**
|
34
|
-
* Limite de Créditos (client.credit_limits) ** Listing and block history **
|
35
|
-
* Lançamentos Padrões (client.default_entries) **Listing and finding**
|
36
|
-
* Entidades (client.entities) **Listing and finding**
|
37
34
|
* Configuração de crédito (client.installments) **Saving and information**
|
38
|
-
* Pedidos de venda (client.orders) **Listing and finding**
|
39
|
-
* Provisões (client.provisions) **Only Creation**
|
40
35
|
* Contas a Receber (client.receipts) **Listing and finding**
|
36
|
+
* Dados Login (client.user_data)
|
37
|
+
* Empresas (client.companies) **Listing and finding**
|
38
|
+
* Entidades (client.entities) **Listing and finding**
|
41
39
|
* Histórico de Vendas (client.sales_history) **Finding and more details **
|
40
|
+
* Lançamentos Padrões (client.default_entries) **Listing and finding**
|
41
|
+
* Limite de Créditos (client.credit_limits) **Listing and block history**
|
42
|
+
* Pedidos de venda (client.orders) **Listing and finding**
|
43
|
+
* Provisões (client.provisions) **Only Creation**
|
44
|
+
* Representantes (client.sellers) **Listing and finding**
|
42
45
|
* Terceiros (client.third_parties) **Listing, finding, creation, credit limit information, credit limit updating, blocking/unblocking credit**
|
43
|
-
* Dados Login (client.user_data)
|
44
46
|
|
45
47
|
## Using the resources
|
46
48
|
### Listing
|
@@ -50,13 +52,15 @@ It can accept an Entity object that reflects the searchable API fields.
|
|
50
52
|
|
51
53
|
Currently the following entities are implemented:
|
52
54
|
|
53
|
-
* [
|
55
|
+
* [Classes de Clientes](lib/vpsa/searcher/operational/client_class_searcher.rb)
|
56
|
+
* [Contas a Receber](lib/vpsa/searcher/financial/receipt_searcher.rb)
|
57
|
+
* [Empresas](lib/vpsa/searcher/administrative/company_searcher.rb)
|
54
58
|
* [Entidades](lib/vpsa/searcher/administrative/entity_searcher.rb)
|
55
|
-
* [Limite de Crédito](lib/vpsa/searcher/commercial/credit_limit_searcher.rb)
|
56
59
|
* [Lançamentos Padrões](lib/vpsa/searcher/financial/default_entry_searcher.rb)
|
57
|
-
* [
|
58
|
-
* [Classes de Clientes](lib/vpsa/searcher/operational/client_class_searcher.rb)
|
60
|
+
* [Limite de Crédito](lib/vpsa/searcher/commercial/credit_limit_searcher.rb)
|
59
61
|
* [Pedidos de Venda](lib/vpsa/searcher/operational/order_searcher.rb)
|
62
|
+
* [Representantes](lib/vpsa/searcher/operational/seller_searcher.rb)
|
63
|
+
* [Terceiros](lib/vpsa/searcher/administrative/third_party_searcher.rb)
|
60
64
|
|
61
65
|
### Finding
|
62
66
|
All resources implement a **find** method.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Vpsa
|
2
|
+
module Api
|
3
|
+
class Companies < Client
|
4
|
+
require_all 'vpsa/searcher/administrative', 'company_searcher'
|
5
|
+
|
6
|
+
base_uri "#{Vpsa::API_ADDRESS}/empresas"
|
7
|
+
|
8
|
+
def list(searcher = nil)
|
9
|
+
raise ArgumentError unless searcher.nil? || searcher.is_a?(Vpsa::Searcher::Administrative::CompanySearcher)
|
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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Vpsa
|
2
|
+
module Api
|
3
|
+
class Sellers < Client
|
4
|
+
require_all 'vpsa/searcher/operational', 'seller_searcher'
|
5
|
+
|
6
|
+
base_uri "#{Vpsa::API_ADDRESS}/representantes"
|
7
|
+
|
8
|
+
def list(searcher = nil)
|
9
|
+
raise ArgumentError unless searcher.nil? || searcher.is_a?(Vpsa::Searcher::Operational::SellerSearcher)
|
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
@@ -11,7 +11,7 @@ module Vpsa
|
|
11
11
|
parser Proc.new {|b| JSON.parse(b) rescue b}
|
12
12
|
|
13
13
|
require_all 'vpsa/api', 'third_parties', 'entities', 'default_entries', 'provisions', 'user_data', 'installments', 'credit_limits',
|
14
|
-
'client_classes', 'receipts', 'sales_history', 'orders'
|
14
|
+
'client_classes', 'receipts', 'sales_history', 'orders', 'companies', 'sellers'
|
15
15
|
|
16
16
|
attr_accessor :access_token
|
17
17
|
|
@@ -63,6 +63,14 @@ module Vpsa
|
|
63
63
|
def orders
|
64
64
|
Vpsa::Api::Orders.new(@access_token)
|
65
65
|
end
|
66
|
+
|
67
|
+
def companies
|
68
|
+
Vpsa::Api::Companies.new(@access_token)
|
69
|
+
end
|
70
|
+
|
71
|
+
def sellers
|
72
|
+
Vpsa::Api::Sellers.new(@access_token)
|
73
|
+
end
|
66
74
|
|
67
75
|
protected
|
68
76
|
def header
|
data/lib/vpsa/version.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Vpsa::Api::Companies do
|
4
|
+
let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
|
5
|
+
|
6
|
+
describe "listing" do
|
7
|
+
before(:each) do
|
8
|
+
stub_request(:get, "#{Vpsa::API_ADDRESS}/empresas/").to_return(:status => 200)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should issue a get to the companies url" do
|
12
|
+
expect(Vpsa::Api::Companies).to receive(:get).with("/", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
13
|
+
|
14
|
+
Vpsa.new("abc").companies.list()
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should issue a get to the companies url using the searcher" do
|
18
|
+
searcher = Vpsa::Searcher::Administrative::CompanySearcher.new({:quantidade => 10, :inicio => 0})
|
19
|
+
|
20
|
+
expect(Vpsa::Api::Companies).to receive(:get).with("/", :body => searcher.as_parameter.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
21
|
+
|
22
|
+
Vpsa.new("abc").companies.list(searcher)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise ArgumentError if the parameter is not a CompanySearcher" do
|
26
|
+
expect{Vpsa.new("abc").companies.list(Array.new)}.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "finding" do
|
31
|
+
before(:each) do
|
32
|
+
stub_request(:get, "#{Vpsa::API_ADDRESS}/empresas/5").to_return(:status => 200)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should issue a get to the company url" do
|
36
|
+
expect(Vpsa::Api::Companies).to receive(:get).with("/5", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
37
|
+
|
38
|
+
Vpsa.new("abc").companies.find(5)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Vpsa::Api::Sellers do
|
4
|
+
let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
|
5
|
+
|
6
|
+
describe "listing" do
|
7
|
+
before(:each) do
|
8
|
+
stub_request(:get, "#{Vpsa::API_ADDRESS}/representantes/").to_return(:status => 200)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should issue a get to the sellers url" do
|
12
|
+
expect(Vpsa::Api::Sellers).to receive(:get).with("/", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
13
|
+
|
14
|
+
Vpsa.new("abc").sellers.list()
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should issue a get to the sellers url using the searcher" do
|
18
|
+
searcher = Vpsa::Searcher::Operational::SellerSearcher.new({:quantidade => 10, :inicio => 0})
|
19
|
+
|
20
|
+
expect(Vpsa::Api::Sellers).to receive(:get).with("/", :body => searcher.as_parameter.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
|
21
|
+
|
22
|
+
Vpsa.new("abc").sellers.list(searcher)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise ArgumentError if the parameter is not a SellerSearcher" do
|
26
|
+
expect{Vpsa.new("abc").sellers.list(Array.new)}.to raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "finding" do
|
31
|
+
before(:each) do
|
32
|
+
stub_request(:get, "#{Vpsa::API_ADDRESS}/representantes/5").to_return(:status => 200)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should issue a get to the seller url" do
|
36
|
+
expect(Vpsa::Api::Sellers).to receive(:get).with("/5", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
|
37
|
+
|
38
|
+
Vpsa.new("abc").sellers.find(5)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/vpsa/client_spec.rb
CHANGED
@@ -40,4 +40,12 @@ RSpec.describe Vpsa::Client do
|
|
40
40
|
it "should return a new Vpsa::Api::Orders" do
|
41
41
|
expect(Vpsa.new("abc").orders.class).to eq(Vpsa::Api::Orders)
|
42
42
|
end
|
43
|
+
|
44
|
+
it "should return a new Vpsa::Api::Companies" do
|
45
|
+
expect(Vpsa.new("abc").companies.class).to eq(Vpsa::Api::Companies)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return a new Vpsa::Api::Sellers" do
|
49
|
+
expect(Vpsa.new("abc").sellers.class).to eq(Vpsa::Api::Sellers)
|
50
|
+
end
|
43
51
|
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.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gustavo Berdugo
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- Rakefile
|
55
55
|
- lib/vpsa.rb
|
56
56
|
- lib/vpsa/api/client_classes.rb
|
57
|
+
- lib/vpsa/api/companies.rb
|
57
58
|
- lib/vpsa/api/credit_limits.rb
|
58
59
|
- lib/vpsa/api/default_entries.rb
|
59
60
|
- lib/vpsa/api/entities.rb
|
@@ -62,6 +63,7 @@ files:
|
|
62
63
|
- lib/vpsa/api/provisions.rb
|
63
64
|
- lib/vpsa/api/receipts.rb
|
64
65
|
- lib/vpsa/api/sales_history.rb
|
66
|
+
- lib/vpsa/api/sellers.rb
|
65
67
|
- lib/vpsa/api/third_parties.rb
|
66
68
|
- lib/vpsa/api/user_data.rb
|
67
69
|
- lib/vpsa/client.rb
|
@@ -72,6 +74,7 @@ files:
|
|
72
74
|
- lib/vpsa/entity/commercial/credit_limit.rb
|
73
75
|
- lib/vpsa/entity/commercial/installment.rb
|
74
76
|
- lib/vpsa/init_from_hash.rb
|
77
|
+
- lib/vpsa/searcher/administrative/company_searcher.rb
|
75
78
|
- lib/vpsa/searcher/administrative/entity_searcher.rb
|
76
79
|
- lib/vpsa/searcher/administrative/third_party_searcher.rb
|
77
80
|
- lib/vpsa/searcher/base.rb
|
@@ -80,9 +83,11 @@ files:
|
|
80
83
|
- lib/vpsa/searcher/financial/receipt_searcher.rb
|
81
84
|
- lib/vpsa/searcher/operational/client_class_searcher.rb
|
82
85
|
- lib/vpsa/searcher/operational/order_searcher.rb
|
86
|
+
- lib/vpsa/searcher/operational/seller_searcher.rb
|
83
87
|
- lib/vpsa/version.rb
|
84
88
|
- spec/spec_helper.rb
|
85
89
|
- spec/vpsa/api/client_classes_spec.rb
|
90
|
+
- spec/vpsa/api/companies_spec.rb
|
86
91
|
- spec/vpsa/api/credit_limits_spec.rb
|
87
92
|
- spec/vpsa/api/default_entries_spec.rb
|
88
93
|
- spec/vpsa/api/entities_spec.rb
|
@@ -91,6 +96,7 @@ files:
|
|
91
96
|
- spec/vpsa/api/provisions_spec.rb
|
92
97
|
- spec/vpsa/api/receipts_spec.rb
|
93
98
|
- spec/vpsa/api/sales_history_spec.rb
|
99
|
+
- spec/vpsa/api/sellers_spec.rb
|
94
100
|
- spec/vpsa/api/third_parties_spec.rb
|
95
101
|
- spec/vpsa/api/user_data_spec.rb
|
96
102
|
- spec/vpsa/client_spec.rb
|
@@ -128,6 +134,7 @@ summary: This gem provides integration with VPSA APIs (http://www.vpsa.com.br/)
|
|
128
134
|
test_files:
|
129
135
|
- spec/spec_helper.rb
|
130
136
|
- spec/vpsa/api/client_classes_spec.rb
|
137
|
+
- spec/vpsa/api/companies_spec.rb
|
131
138
|
- spec/vpsa/api/credit_limits_spec.rb
|
132
139
|
- spec/vpsa/api/default_entries_spec.rb
|
133
140
|
- spec/vpsa/api/entities_spec.rb
|
@@ -136,6 +143,7 @@ test_files:
|
|
136
143
|
- spec/vpsa/api/provisions_spec.rb
|
137
144
|
- spec/vpsa/api/receipts_spec.rb
|
138
145
|
- spec/vpsa/api/sales_history_spec.rb
|
146
|
+
- spec/vpsa/api/sellers_spec.rb
|
139
147
|
- spec/vpsa/api/third_parties_spec.rb
|
140
148
|
- spec/vpsa/api/user_data_spec.rb
|
141
149
|
- spec/vpsa/client_spec.rb
|