vpsa 0.0.24 → 0.0.25

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5dfa39f31909f7b3b8c24d0fc77c8af59a465dbe
4
- data.tar.gz: de14e5651f1c64f01d8b8c3529c76e690df91d21
3
+ metadata.gz: e5b67f006069498991e524f4086423da8ebebe76
4
+ data.tar.gz: a97425c1bf62fd038a4f8cc5920ab659e565bc3b
5
5
  SHA512:
6
- metadata.gz: 06a3c28265941b73787cebbaa25c87f96d6281a57b20fcf0bdee33dd5d822878b6261e3d022ba05c30799dc3820d8b2b8c4bdff7ab1a164b1d3488bc12785fda
7
- data.tar.gz: 50902f8bc67f2e40a33bcd7e37e98451eb9ba1a03c991913e7d0365137d44d9e25aeebc6bddbafa6331d5b94cba3bd1449fa2ae220de48710eb906c54a082e07
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
@@ -1,3 +1,3 @@
1
1
  module Vpsa
2
- VERSION = "0.0.24"
2
+ VERSION = "0.0.25"
3
3
  end
@@ -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.24
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-08-19 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty