vpsa 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vpsa/api/third_parties.rb +6 -0
- data/lib/vpsa/version.rb +1 -1
- data/spec/vpsa/api/third_parties_spec.rb +44 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5b67f006069498991e524f4086423da8ebebe76
|
4
|
+
data.tar.gz: a97425c1bf62fd038a4f8cc5920ab659e565bc3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 982cbde6b5341c8834472473d960cb4e6a2b2a9e22aebf85be9f3c244b8c1818b8aa7977fc5e42c521e050d1a7d459c6ce58f73e69426490529bab02edddc8d5
|
7
|
+
data.tar.gz: 3a997e2d4a3e7721a58705d40b40a58ba31ac6e2b236102e52bd47609392b79e055343573b9a528faf0f80111c65dd108e9dd5e9234b4c00e655c7d4d6f0ef88
|
@@ -24,6 +24,12 @@ module Vpsa
|
|
24
24
|
raise ArgumentError
|
25
25
|
end
|
26
26
|
alias :new :create
|
27
|
+
|
28
|
+
def update(id, data)
|
29
|
+
return parse_response(self.class.put("/#{id}", :body => build_body(data), :headers => header)) if data.is_a?(Hash)
|
30
|
+
return parse_response(self.class.put("/#{id}", :body => build_body(data.as_parameter), :headers => header)) if data.is_a?(Vpsa::Entity::Administrative::ThirdParty)
|
31
|
+
raise ArgumentError
|
32
|
+
end
|
27
33
|
|
28
34
|
def credit_limit_information(id)
|
29
35
|
return parse_response(self.class.get("/#{id}/limites_credito", :body => build_body, :headers => header))
|
data/lib/vpsa/version.rb
CHANGED
@@ -83,6 +83,50 @@ RSpec.describe Vpsa::Api::ThirdParties do
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
|
+
|
87
|
+
describe "updating" do
|
88
|
+
let(:third_party_params) {{:nome => "Nome do terceiro", :documento => "023.168.132-00", :token => "abc"}}
|
89
|
+
|
90
|
+
before(:each) do
|
91
|
+
@third_party = Vpsa::Entity::Administrative::ThirdParty.new({"id" => "5", "nome" => "Nome do terceiro", "documento" => "023.168.132-00",
|
92
|
+
"rg" => "42.943.412-1", "dataNascimento" => "12-08-1980"})
|
93
|
+
|
94
|
+
@third_party.emails = ["email@email.com", "other@email.com"]
|
95
|
+
|
96
|
+
@third_party.enderecos << Vpsa::Entity::Administrative::Address.new({"tipo" => "AVENIDA", "logradouro" => "9 de Julho", "numero" => "900", "bairro" => "CENTRO",
|
97
|
+
"complemento" => "APTO 1", "cep" => "12000111", "codigoIBGECidade" => "3554102", "tipoEndereco" => "ENDERECO_COBRANCA"})
|
98
|
+
@third_party.enderecos << Vpsa::Entity::Administrative::Address.new({"tipo" => "RUA", "logradouro" => "15 de Novembro", "numero" => "1020", "bairro" => "JD. MARIA",
|
99
|
+
"complemento" => "APTO 1", "cep" => "12600123", "codigoIBGECidade" => "3554102", "tipoEndereco" => "ENDERECO_SEDE"})
|
100
|
+
|
101
|
+
@third_party.telefones << Vpsa::Entity::Administrative::Phone.new({"ddi" => "55", "ddd" => "12", "numero" => "12341234"})
|
102
|
+
@third_party.telefones << Vpsa::Entity::Administrative::Phone.new({"ddi" => "0", "ddd" => "31", "numero" => "12340000", "ramal" => "1234"})
|
103
|
+
|
104
|
+
@third_party.classes = ["SOCIO_PROPRIETARIO", "FUNCIONARIO"]
|
105
|
+
|
106
|
+
stub_request(:put, "#{Vpsa::API_ADDRESS}/terceiros/5").to_return(:status => 200)
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "with raw parameters" do
|
110
|
+
it "should put to the third party url" do
|
111
|
+
expect(Vpsa::Api::ThirdParties).to receive(:put).with("/5", :body => third_party_params.to_json, :headers => header).and_call_original
|
112
|
+
|
113
|
+
Vpsa.new("abc").third_parties.update(5, {:nome => "Nome do terceiro", :documento => "023.168.132-00"})
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "with entity parameter" do
|
118
|
+
it "should put to the third party url" do
|
119
|
+
expect(Vpsa::Api::ThirdParties).to receive(:put).with("/5", :body => @third_party.as_parameter.merge!(:token => "abc").to_json, :headers => header).and_call_original
|
120
|
+
Vpsa.new("abc").third_parties.update(5, @third_party)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "with invalid parameter" do
|
125
|
+
it "should raise ArgumentError when passing neither a Hash nor a ThirdParty" do
|
126
|
+
expect{Vpsa.new("abc").third_parties.update(Array.new)}.to raise_error(ArgumentError)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
86
130
|
|
87
131
|
describe "credit limit" do
|
88
132
|
context "information" do
|
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.
|
4
|
+
version: 0.0.25
|
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-
|
11
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|