fastshop_catalog 0.0.2 → 0.0.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a6239cc75029327adc4249fbf22da92061da60c
4
+ data.tar.gz: 34aa60a7b9755ab6335d76c2073d2d74adcb27f2
5
+ SHA512:
6
+ metadata.gz: 317dfac02e7b05a875e12ffec410a4d3d9e1352f18b5f41829b6a8073e4932012c7db14f67e56cf78789e05689945bf7baa7b4879078ede049d00b2fedf3c277
7
+ data.tar.gz: aa041a18add29279bb13b29b4291a486ca8f048427090919880436bb44a0fa7d09165551435cd9428848b4db7dac0872627e0c851d6c90673b46040063598e6f
@@ -13,7 +13,7 @@ module FastshopCatalog
13
13
  root_attributes = order.to_map
14
14
  adapted_items = []
15
15
  root_attributes['Itens'].each do |item|
16
- adapted_items << {'fas:PedidoItensEntity' => adapt_output(item.to_map)}
16
+ adapted_items << {'fas:PedidoItensEntity' => adapt_output(item.to_map, 'fas')}
17
17
  end
18
18
  root_attributes['Itens'] = adapted_items
19
19
  service_invoker('dadosPedido' => adapt_output(root_attributes, 'fas'))
@@ -1,3 +1,3 @@
1
1
  module FastshopCatalog
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -13,32 +13,29 @@ describe FastshopCatalog::CheckAvailabilityService do
13
13
  order.zip_code = '02029001'
14
14
  order.document = '73978898160'
15
15
  order.number = '1560'
16
- order.total_amount = "69.00"
16
+ order.total_amount = "249.00"
17
17
  order_item = FastshopCatalog::Entity::OrderItem.new
18
- order_item.sku = 'IVIEP314RED'
18
+ order_item.sku = 'SODPFC70A'
19
19
  order_item.quantity = 1
20
- order_item.price = "69.00"
20
+ order_item.price = "249.00"
21
21
  order.items = [order_item]
22
22
  order
23
23
  end
24
24
 
25
25
  let(:order_fixture) do
26
- {"tns:dadosPedido"=>{"fas:Cep"=>"02029001", "fas:Contrato"=>"1234567890", "fas:Cpf"=>"73978898160", "fas:Itens"=>[{"fas:PedidoItensEntity"=>{"tns:Quantidade"=>1, "tns:Sku"=>"IVIEP314RED", "tns:ValorUnitario"=>"69.00"}}], "fas:Numero"=>"1560", "fas:ValorTotal"=>"69.00"}}
26
+ {"tns:dadosPedido"=>{"fas:Cep"=>"02029001", "fas:Contrato"=>"1234567890", "fas:Cpf"=>"73978898160", "fas:Itens"=>[{"fas:PedidoItensEntity"=>{"fas:Quantidade"=>1, "fas:Sku"=>"SODPFC70A", "fas:ValorUnitario"=>"249.00"}}], "fas:Numero"=>"1560", "fas:ValorTotal"=>"249.00"}}
27
27
  end
28
28
 
29
29
  let(:fixture) do
30
- File.read("spec/fixtures/check_availability_not_available_response.xml")
30
+ File.read("spec/fixtures/check_availability_successful_response.xml")
31
31
  end
32
32
 
33
33
  describe "check" do
34
- it "should check that the order is not available" do
34
+ it "should check that the order is ok" do
35
35
 
36
36
  savon.expects(:retorna_dados).with(:message => order_fixture).returns(fixture)
37
37
  service = FastshopCatalog::CheckAvailabilityService.new
38
- expect{service.check(order)}.to raise_error(FastshopCatalog::ServiceException) do |e|
39
- expect(e.code).to eq(36)
40
- expect(e.description).to eq('Pedido indisponível')
41
- end
38
+ result = service.check(order)
42
39
  end
43
40
  end
44
41
  end
@@ -6,25 +6,25 @@ describe FastshopCatalog::CheckAvailabilityService do
6
6
  let(:order) do
7
7
  order = FastshopCatalog::Entity::Order.new
8
8
  order.contract_code = '1234567890'
9
- order.zip_code = '02029001'
9
+ order.zip_code = '04562030'
10
10
  order.document = '73978898160'
11
11
  order.number = '1560'
12
- order.total_amount = "69.00"
12
+ order.total_amount = "249.00"
13
+ order.delivery_type = "P"
14
+ order.partner_order_number = "1234568119"
15
+
13
16
  order_item = FastshopCatalog::Entity::OrderItem.new
14
- order_item.sku = 'IVIEP314RED'
17
+ order_item.sku = 'SODPFC70A'
15
18
  order_item.quantity = 1
16
- order_item.price = "69.00"
19
+ order_item.price = "249.00"
17
20
  order.items = [order_item]
18
21
  order
19
22
  end
20
23
 
21
24
  describe "check integration", :integration => true do
22
- it "should check that the order is not available" do
25
+ it "should check that the order is ok" do
23
26
  service = FastshopCatalog::CheckAvailabilityService.new
24
- expect{service.check(order)}.to raise_error(FastshopCatalog::ServiceException) do |e|
25
- expect(e.code).to eq(36)
26
- expect(e.description).to eq('Pedido indisponível')
27
- end
27
+ result = service.check(order)
28
28
  end
29
29
  end
30
30
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require "spec_helper"
2
3
 
3
4
  describe FastshopCatalog::OrderPlacementService do
@@ -5,20 +6,20 @@ describe FastshopCatalog::OrderPlacementService do
5
6
  let(:contract_number) do
6
7
  "1234567890"
7
8
  end
8
-
9
+
9
10
  let(:order) do
10
11
  order = FastshopCatalog::Entity::Order.new
11
12
  order.contract_code = '1234567890'
12
- order.zip_code = '02029001'
13
+ order.zip_code = '04562030'
13
14
  order.document = '73978898160'
14
- order.number = '1560'
15
- order.total_amount = "69.00"
15
+ order.number = '5'
16
+ order.total_amount = "249.00"
16
17
  order.delivery_type = "P"
17
18
  order.partner_order_number = "1234568119"
18
19
  order_item = FastshopCatalog::Entity::OrderItem.new
19
- order_item.sku = 'IVIEP314RED'
20
+ order_item.sku = 'SODPFC70A'
20
21
  order_item.quantity = 1
21
- order_item.price = "69.00"
22
+ order_item.price = "249.00"
22
23
  order.items = [order_item]
23
24
  order
24
25
  end
@@ -30,9 +31,11 @@ describe FastshopCatalog::OrderPlacementService do
30
31
  describe "place_order integration", :integration => true do
31
32
 
32
33
  it "should raise cart not identified" do
33
- expect{service.place_order(order)}.to raise_error(FastshopCatalog::ServiceException) do |e|
34
- expect(e.code).to eq(37)
35
- expect(e.description).to eq('Carrinho nao identificado no sistema')
34
+ begin
35
+ service.place_order(order)
36
+ rescue FastshopCatalog::ServiceException => e
37
+ expect(e.code).to eq(15)
38
+ expect(e.description).to eq('Endereço nao encontrado')
36
39
  end
37
40
  end
38
41
 
@@ -1,6 +1,7 @@
1
+ # encoding: utf-8
1
2
  require "spec_helper"
2
3
 
3
- describe FastshopCatalog::OrderPlacementService do
4
+ describe FastshopCatalog::ParticipantService do
4
5
 
5
6
  let(:contract_number) do
6
7
  "1234567890"
@@ -17,8 +18,10 @@ describe FastshopCatalog::OrderPlacementService do
17
18
  describe "insert integration", :integration => true do
18
19
 
19
20
  it "should insert the participant and return a null token" do
20
- result = service.insert(participant)
21
- expect(result).to be_nil
21
+ expect{service.insert(participant)}.to raise_error(FastshopCatalog::ServiceException) do |e|
22
+ expect(e.code).to eq(45)
23
+ expect(e.description).to eq('Email já cadastrado')
24
+ end
22
25
  end
23
26
 
24
27
  it "should raise incompatible address exception" do
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  require "spec_helper"
2
3
 
3
4
  describe FastshopCatalog::OrderPlacementService do
@@ -35,8 +36,8 @@ describe FastshopCatalog::OrderPlacementService do
35
36
  File.read("spec/fixtures/order_placement_successful_payload.json")
36
37
  end
37
38
 
38
- let(:fixture_cart_not_identified) do
39
- File.read("spec/fixtures/order_placement_cart_not_identified.xml")
39
+ let(:fixture_address_not_found) do
40
+ File.read("spec/fixtures/order_placement_address_not_found.xml")
40
41
  end
41
42
 
42
43
  let(:fixture_wrong_contract) do
@@ -48,10 +49,10 @@ describe FastshopCatalog::OrderPlacementService do
48
49
  it "should raise cart not identified" do
49
50
  encrypted_payload = service.encrypt(order_attr)
50
51
  savon.expects(:incluir_pedido).with(:message => {'tns:contrato' => contract_number,
51
- 'tns:entrada' => encrypted_payload, 'tns:salt' => ''}).returns(fixture_cart_not_identified)
52
+ 'tns:entrada' => encrypted_payload, 'tns:salt' => ''}).returns(fixture_address_not_found)
52
53
  expect{service.place_order(order)}.to raise_error(FastshopCatalog::ServiceException) do |e|
53
- expect(e.code).to eq(37)
54
- expect(e.description).to eq('Carrinho nao identificado no sistema')
54
+ expect(e.code).to eq(15)
55
+ expect(e.description).to eq('Endereço nao encontrado')
55
56
  end
56
57
  end
57
58
 
@@ -1,3 +1,4 @@
1
+
1
2
  <?xml version="1.0" encoding="UTF-8"?>
2
3
  <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
3
4
  <s:Header>
@@ -5,7 +6,7 @@
5
6
  </s:Header>
6
7
  <s:Body>
7
8
  <RetornaDadosResponse xmlns="http://tempuri.org/">
8
- <RetornaDadosResult>{"Disponibilidade":null,"Retorno":{"IdRetorno":36,"MsgRetorno":"Pedido indisponível"}}</RetornaDadosResult>
9
+ <RetornaDadosResult>{"Disponibilidade":{"EntregaDatas":[],"PrazoDias":2,"ValorFrete":10.11},"Retorno":{"IdRetorno":0,"MsgRetorno":"OK"}}</RetornaDadosResult>
9
10
  </RetornaDadosResponse>
10
11
  </s:Body>
11
12
  </s:Envelope>
@@ -1,11 +1,10 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
1
  <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
3
2
  <s:Header>
4
3
  <a:Action s:mustUnderstand="1">http://tempuri.org/IColocacaoPedido/IncluirPedidoResponse</a:Action>
5
4
  </s:Header>
6
5
  <s:Body>
7
6
  <IncluirPedidoResponse xmlns="http://tempuri.org/">
8
- <IncluirPedidoResult>{"NumeroPedidoFast":null,"Retorno":{"IdRetorno":37,"MsgRetorno":"Carrinho nao identificado no sistema"}}</IncluirPedidoResult>
7
+ <IncluirPedidoResult>{"NumeroPedidoFast":null,"Retorno":{"IdRetorno":15,"MsgRetorno":"Endereço nao encontrado"}}</IncluirPedidoResult>
9
8
  </IncluirPedidoResponse>
10
9
  </s:Body>
11
10
  </s:Envelope>
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'savon/mock/spec_helper'
2
2
  require 'json'
3
3
  require_relative '../lib/fastshop_catalog'
4
+ require File.expand_path('../fastshop_catalog/participant_factory', __FILE__)
4
5
  FastshopCatalog::BaseService.log_level = :debug
5
6
  FastshopCatalog::BaseService::AUX_LOG.level = Logger::DEBUG
6
7
  if ENV['integration'] == 'false'
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastshop_catalog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Thiago Ganzarolli
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-28 00:00:00.000000000 Z
11
+ date: 2013-11-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,65 +27,57 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: pry
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: savon
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: Integração com webservices da FastShop
@@ -98,7 +87,6 @@ executables: []
98
87
  extensions: []
99
88
  extra_rdoc_files: []
100
89
  files:
101
- - .DS_Store
102
90
  - .gitignore
103
91
  - Gemfile
104
92
  - Gemfile.lock
@@ -146,11 +134,11 @@ files:
146
134
  - spec/fastshop_catalog/product_service_spec.rb
147
135
  - spec/fixtures/catalog_service_successful_response.xml
148
136
  - spec/fixtures/catalog_service_wrong_contract_response.xml
149
- - spec/fixtures/check_availability_not_available_response.xml
137
+ - spec/fixtures/check_availability_successful_response.xml
150
138
  - spec/fixtures/external_dne_service_successful_response.xml
151
139
  - spec/fixtures/external_dne_service_wrong_contract_response.xml
152
140
  - spec/fixtures/external_dne_service_wrong_zip_response.xml
153
- - spec/fixtures/order_placement_cart_not_identified.xml
141
+ - spec/fixtures/order_placement_address_not_found.xml
154
142
  - spec/fixtures/order_placement_successful_delivery_payload.json
155
143
  - spec/fixtures/order_placement_successful_payload.json
156
144
  - spec/fixtures/order_status_service_order_not_found_response.xml
@@ -167,27 +155,26 @@ files:
167
155
  homepage: ''
168
156
  licenses:
169
157
  - MIT
158
+ metadata: {}
170
159
  post_install_message:
171
160
  rdoc_options: []
172
161
  require_paths:
173
162
  - lib
174
163
  required_ruby_version: !ruby/object:Gem::Requirement
175
- none: false
176
164
  requirements:
177
- - - ! '>='
165
+ - - '>='
178
166
  - !ruby/object:Gem::Version
179
167
  version: '0'
180
168
  required_rubygems_version: !ruby/object:Gem::Requirement
181
- none: false
182
169
  requirements:
183
- - - ! '>='
170
+ - - '>='
184
171
  - !ruby/object:Gem::Version
185
172
  version: '0'
186
173
  requirements: []
187
174
  rubyforge_project:
188
- rubygems_version: 1.8.23
175
+ rubygems_version: 2.1.9
189
176
  signing_key:
190
- specification_version: 3
177
+ specification_version: 4
191
178
  summary: FastShop integrações
192
179
  test_files:
193
180
  - spec/.DS_Store
@@ -210,11 +197,11 @@ test_files:
210
197
  - spec/fastshop_catalog/product_service_spec.rb
211
198
  - spec/fixtures/catalog_service_successful_response.xml
212
199
  - spec/fixtures/catalog_service_wrong_contract_response.xml
213
- - spec/fixtures/check_availability_not_available_response.xml
200
+ - spec/fixtures/check_availability_successful_response.xml
214
201
  - spec/fixtures/external_dne_service_successful_response.xml
215
202
  - spec/fixtures/external_dne_service_wrong_contract_response.xml
216
203
  - spec/fixtures/external_dne_service_wrong_zip_response.xml
217
- - spec/fixtures/order_placement_cart_not_identified.xml
204
+ - spec/fixtures/order_placement_address_not_found.xml
218
205
  - spec/fixtures/order_placement_successful_delivery_payload.json
219
206
  - spec/fixtures/order_placement_successful_payload.json
220
207
  - spec/fixtures/order_status_service_order_not_found_response.xml
data/.DS_Store DELETED
Binary file