vpsa 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b83504637726dcc96a9af21b27cb95b2cc9d7b3
4
- data.tar.gz: d686f63182c11dd2afa8ece5cea4aeebbe98d7b2
3
+ metadata.gz: f23262c3a25b0567dc11bdb3314225b29149e04c
4
+ data.tar.gz: 4818849bda0ea46d1e6ed5caab06d66e8255739a
5
5
  SHA512:
6
- metadata.gz: 9e6fa358a1cebcb81806474e61da5f1129765e838ab95f274eec70dc68295ba72e5fdabdb31f3913ca96945999973305063f1dbec68c7ac37c420bfa2468f3e6
7
- data.tar.gz: ce71bc81b21add9261882d845b9961b2ffe3140f8f4d31b5840be17401eb21f142d6c5e415a08fb88d792eb179388895c39233b46cff31ed87c7d48314ffdee2
6
+ metadata.gz: 84c336bed07a36bac651d96361b3097f5f8a60a3dac239c2b0800a64b7ae0f390a7395e5a30a4659a3a7ca8edc4d5fbceb3f7e7850c312ffdfc239d649dd7e5e
7
+ data.tar.gz: 0df9e86b4051947959aebdbe3ebec7d7f0b857fe058ed791b7052efa769c88246af6c415060e407b2847ea5c6d86e3d7b44a12655b708ec234e3b33f5ddfbb33
data/README.md CHANGED
@@ -30,13 +30,17 @@ Create a new instance of VPSA class passing your access token:
30
30
 
31
31
  With the client instance, you can access the following resources:
32
32
 
33
- * Terceiros (client.third_parties) **Listing, finding and creation**
34
- * Entidades (client.entities) **Listing and finding**
33
+ * Classes de Clientes (client.client_classes) **Listing and finding**
34
+ * Limite de Créditos (client.credit_limits) ** Listing and block history **
35
35
  * Lançamentos Padrões (client.default_entries) **Listing and finding**
36
+ * Entidades (client.entities) **Listing and finding**
37
+ * Configuração de crédito (client.installments) **Saving and information**
38
+ * Pedidos de venda (client.orders) **Listing and finding**
36
39
  * Provisões (client.provisions) **Only Creation**
40
+ * Contas a Receber (client.receipts) **Listing and finding**
41
+ * Histórico de Vendas (client.sales_history) **Finding and more details **
42
+ * Terceiros (client.third_parties) **Listing, finding, creation, credit limit information, credit limit updating, blocking/unblocking credit**
37
43
  * Dados Login (client.user_data)
38
- * Classes de Clientes (client.client_classes) **Listing and finding**
39
- * Contas a Receber (client.receipts) **Only listing**
40
44
 
41
45
  ## Using the resources
42
46
  ### Listing
@@ -48,9 +52,11 @@ Currently the following entities are implemented:
48
52
 
49
53
  * [Terceiros](lib/vpsa/searcher/administrative/third_party_searcher.rb)
50
54
  * [Entidades](lib/vpsa/searcher/administrative/entity_searcher.rb)
55
+ * [Limite de Crédito](lib/vpsa/searcher/commercial/credit_limit_searcher.rb)
51
56
  * [Lançamentos Padrões](lib/vpsa/searcher/financial/default_entry_searcher.rb)
52
57
  * [Contas a Receber](lib/vpsa/searcher/financial/receipt_searcher.rb)
53
58
  * [Classes de Clientes](lib/vpsa/searcher/operational/client_class_searcher.rb)
59
+ * [Pedidos de Venda](lib/vpsa/searcher/operational/order_searcher.rb)
54
60
 
55
61
  ### Finding
56
62
  All resources implement a **find** method.
@@ -78,14 +84,14 @@ You can get the token owner information by calling the following method:
78
84
  ```
79
85
 
80
86
  ### Reading the response
81
- All methods return a Vpsa::Client::Response object. This objects contains the following attributes:
87
+ All methods return a Vpsa::Client::Response object. This object contains the following attributes:
82
88
 
83
89
  ```ruby
84
90
  response = Vpsa.new(YOUR_ACCESS_TOKEN).third_parties.list
85
91
 
86
- response.status # Contains the status code of the request
87
- response.payload # Contains the return data (JSON) of the request
88
- response.raw_response # Contains the HTTParty response object
92
+ response.status # Contains the status code of the request
93
+ response.payload # Contains the return data (JSON) of the request
94
+ response.raw_response # Contains the HTTParty response object
89
95
  ```
90
96
 
91
97
  ## Contributing
@@ -0,0 +1,20 @@
1
+ module Vpsa
2
+ module Api
3
+ class Orders < Client
4
+ require_all 'vpsa/searcher/operational', 'order_searcher'
5
+
6
+ base_uri "#{Vpsa::API_ADDRESS}/pedidos"
7
+
8
+ def list(searcher = nil)
9
+ raise ArgumentError unless searcher.nil? || searcher.is_a?(Vpsa::Searcher::Operational::OrderSearcher)
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
@@ -1,17 +1,16 @@
1
1
  module Vpsa
2
2
  module Api
3
- class Sales < Client
3
+ class SalesHistory < Client
4
4
 
5
5
  base_uri "#{Vpsa::API_ADDRESS}/externa/historico-vendas-terceiro"
6
6
 
7
- def sales_history(id)
7
+ def find(id)
8
8
  return parse_response(self.class.get("/buscar?terceiro=#{id}", :body => build_body, :headers => header))
9
9
  end
10
10
 
11
- def sales_history_more_details(idTerceiro)
11
+ def more_details(idTerceiro)
12
12
  return parse_response(self.class.get("/detalhar?terceiro=#{idTerceiro}", :body => build_body, :headers => header))
13
- end
14
-
13
+ end
15
14
  end
16
15
  end
17
16
  end
data/lib/vpsa/client.rb CHANGED
@@ -10,7 +10,8 @@ module Vpsa
10
10
  default_options.update(verify: false)
11
11
  parser Proc.new {|b| JSON.parse(b) rescue b}
12
12
 
13
- require_all 'vpsa/api', 'third_parties', 'entities', 'default_entries', 'provisions', 'user_data', 'installments', 'credit_limits', 'client_classes', 'receipts', 'sales'
13
+ require_all 'vpsa/api', 'third_parties', 'entities', 'default_entries', 'provisions', 'user_data', 'installments', 'credit_limits',
14
+ 'client_classes', 'receipts', 'sales_history', 'orders'
14
15
 
15
16
  attr_accessor :access_token
16
17
 
@@ -55,8 +56,12 @@ module Vpsa
55
56
  Vpsa::Api::ClientClasses.new(@access_token)
56
57
  end
57
58
 
58
- def sales
59
- Vpsa::Api::Sales.new(@access_token)
59
+ def sales_history
60
+ Vpsa::Api::SalesHistory.new(@access_token)
61
+ end
62
+
63
+ def orders
64
+ Vpsa::Api::Orders.new(@access_token)
60
65
  end
61
66
 
62
67
  protected
@@ -0,0 +1,11 @@
1
+ require 'vpsa/searcher/base'
2
+
3
+ module Vpsa
4
+ module Searcher
5
+ module Operational
6
+ class OrderSearcher < Base
7
+ attr_accessor :desde, :ate, :entidades, :"alteradoApos", :terceiro
8
+ end
9
+ end
10
+ end
11
+ end
data/lib/vpsa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vpsa
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Vpsa::Api::Orders 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}/pedidos/").to_return(:status => 200)
9
+ end
10
+
11
+ it "should issue a get to the orders url" do
12
+ expect(Vpsa::Api::Orders).to receive(:get).with("/", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
13
+
14
+ Vpsa.new("abc").orders.list()
15
+ end
16
+
17
+ it "should issue a get to the orders url using the searcher" do
18
+ searcher = Vpsa::Searcher::Operational::OrderSearcher.new({:quantidade => 10, :inicio => 0})
19
+
20
+ expect(Vpsa::Api::Orders).to receive(:get).with("/", :body => searcher.as_parameter.merge!({:token => "abc"}).to_json, :headers => header).and_call_original
21
+
22
+ Vpsa.new("abc").orders.list(searcher)
23
+ end
24
+
25
+ it "should raise ArgumentError if the parameter is not a OrderSearcher" do
26
+ expect{Vpsa.new("abc").orders.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}/pedidos/5").to_return(:status => 200)
33
+ end
34
+
35
+ it "should issue a get to the order url" do
36
+ expect(Vpsa::Api::Orders).to receive(:get).with("/5", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
37
+
38
+ Vpsa.new("abc").orders.find(5)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Vpsa::Api::SalesHistory do
4
+ let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
5
+
6
+ describe "information" do
7
+ before(:each) do
8
+ stub_request(:get, "#{Vpsa::API_ADDRESS}/externa/historico-vendas-terceiro/buscar?terceiro=1").
9
+ with(:body => "{\"token\":\"abc\"}",
10
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
11
+ to_return(:status => 200, :body => "", :headers => {})
12
+ end
13
+
14
+ it "should issue a get to the find url" do
15
+ expect(Vpsa::Api::SalesHistory).to receive(:get).with("/buscar?terceiro=1", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
16
+
17
+ Vpsa.new("abc").sales_history.find(1)
18
+ end
19
+ end
20
+
21
+ describe "more details" do
22
+ before(:each) do
23
+ stub_request(:get, "#{Vpsa::API_ADDRESS}/externa/historico-vendas-terceiro/detalhar?terceiro=1").
24
+ with(:body => "{\"token\":\"abc\"}",
25
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
26
+ to_return(:status => 200, :body => "", :headers => {})
27
+ end
28
+
29
+ it "should issue a get to the more details url" do
30
+ expect(Vpsa::Api::SalesHistory).to receive(:get).with("/detalhar?terceiro=1", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
31
+
32
+ Vpsa.new("abc").sales_history.more_details(1)
33
+ end
34
+ end
35
+ end
@@ -32,4 +32,12 @@ RSpec.describe Vpsa::Client do
32
32
  it "should return a new Vpsa::Api::ClientClasses" do
33
33
  expect(Vpsa.new("abc").client_classes.class).to eq(Vpsa::Api::ClientClasses)
34
34
  end
35
+
36
+ it "should return a new Vpsa::Api::SalesHistory" do
37
+ expect(Vpsa.new("abc").sales_history.class).to eq(Vpsa::Api::SalesHistory)
38
+ end
39
+
40
+ it "should return a new Vpsa::Api::Orders" do
41
+ expect(Vpsa.new("abc").orders.class).to eq(Vpsa::Api::Orders)
42
+ end
35
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Berdugo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -58,9 +58,10 @@ files:
58
58
  - lib/vpsa/api/default_entries.rb
59
59
  - lib/vpsa/api/entities.rb
60
60
  - lib/vpsa/api/installments.rb
61
+ - lib/vpsa/api/orders.rb
61
62
  - lib/vpsa/api/provisions.rb
62
63
  - lib/vpsa/api/receipts.rb
63
- - lib/vpsa/api/sales.rb
64
+ - lib/vpsa/api/sales_history.rb
64
65
  - lib/vpsa/api/third_parties.rb
65
66
  - lib/vpsa/api/user_data.rb
66
67
  - lib/vpsa/client.rb
@@ -78,6 +79,7 @@ files:
78
79
  - lib/vpsa/searcher/financial/default_entry_searcher.rb
79
80
  - lib/vpsa/searcher/financial/receipt_searcher.rb
80
81
  - lib/vpsa/searcher/operational/client_class_searcher.rb
82
+ - lib/vpsa/searcher/operational/order_searcher.rb
81
83
  - lib/vpsa/version.rb
82
84
  - spec/spec_helper.rb
83
85
  - spec/vpsa/api/client_classes_spec.rb
@@ -85,9 +87,10 @@ files:
85
87
  - spec/vpsa/api/default_entries_spec.rb
86
88
  - spec/vpsa/api/entities_spec.rb
87
89
  - spec/vpsa/api/installments_spec.rb
90
+ - spec/vpsa/api/orders_spec.rb
88
91
  - spec/vpsa/api/provisions_spec.rb
89
92
  - spec/vpsa/api/receipts_spec.rb
90
- - spec/vpsa/api/sales_spec.rb
93
+ - spec/vpsa/api/sales_history_spec.rb
91
94
  - spec/vpsa/api/third_parties_spec.rb
92
95
  - spec/vpsa/api/user_data_spec.rb
93
96
  - spec/vpsa/client_spec.rb
@@ -129,9 +132,10 @@ test_files:
129
132
  - spec/vpsa/api/default_entries_spec.rb
130
133
  - spec/vpsa/api/entities_spec.rb
131
134
  - spec/vpsa/api/installments_spec.rb
135
+ - spec/vpsa/api/orders_spec.rb
132
136
  - spec/vpsa/api/provisions_spec.rb
133
137
  - spec/vpsa/api/receipts_spec.rb
134
- - spec/vpsa/api/sales_spec.rb
138
+ - spec/vpsa/api/sales_history_spec.rb
135
139
  - spec/vpsa/api/third_parties_spec.rb
136
140
  - spec/vpsa/api/user_data_spec.rb
137
141
  - spec/vpsa/client_spec.rb
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe Vpsa::Api::Sales do
4
- let(:header) {{"Content-Type" => "application/json", "Accept" => "application/json"}}
5
-
6
- describe "information" do
7
-
8
- before(:each) do
9
- stub_request(:get, "#{Vpsa::API_ADDRESS}/externa/historico-vendas-terceiro/buscar?terceiro=1").
10
- with(:body => "{\"token\":\"abc\"}",
11
- :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json'}).
12
- to_return(:status => 200, :body => "", :headers => {})
13
-
14
- end
15
-
16
- it "should issue a get to the sales url" do
17
- expect(Vpsa::Api::Sales).to receive(:get).with("/buscar?terceiro=1", :body => {:token => "abc"}.to_json, :headers => header).and_call_original
18
-
19
- Vpsa.new("abc").sales.sales_history(1)
20
- end
21
- end
22
-
23
- end