fastshop_catalog 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastshop_catalog.rb +1 -0
- data/lib/fastshop_catalog/base_service.rb +10 -8
- data/lib/fastshop_catalog/catalog_service.rb +1 -1
- data/lib/fastshop_catalog/check_availability_service.rb +1 -1
- data/lib/fastshop_catalog/external_dne_service.rb +1 -1
- data/lib/fastshop_catalog/order_placement_service.rb +1 -1
- data/lib/fastshop_catalog/order_status_service.rb +1 -1
- data/lib/fastshop_catalog/participant_service.rb +2 -2
- data/lib/fastshop_catalog/product_service.rb +1 -1
- data/lib/fastshop_catalog/service_urls.rb +41 -0
- data/lib/fastshop_catalog/version.rb +1 -1
- data/spec/fastshop_catalog/base_service_spec.rb +3 -13
- data/spec/fastshop_catalog/service_urls_spec.rb +20 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d68f0540ed875634364fe3981b000ccbfe1399df
|
4
|
+
data.tar.gz: 934adc99a896278af769a3912d69d4adaf4f1fe6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84293e29c8ed9450566cdf92a624b82b650ac3861ffc8c634003a84fe8db31915fe8c822ac9e913fcffd37616a3dfad72d9f1a9707a0e516090f1c9ca7075b1d
|
7
|
+
data.tar.gz: cc0d60e81043a39d5965edbd4bd0d1b579c00c2f99246eadc5ce35d0b813b058aa2786e0fc0537d480e298591f48cecd66c94ca880cb0ae7867ef1dc455c7aa3
|
data/lib/fastshop_catalog.rb
CHANGED
@@ -17,4 +17,5 @@ require_relative "fastshop_catalog/check_availability_service"
|
|
17
17
|
require_relative "fastshop_catalog/order_status_service"
|
18
18
|
require_relative "fastshop_catalog/participant_service"
|
19
19
|
require_relative "fastshop_catalog/service_exception"
|
20
|
+
require_relative "fastshop_catalog/service_urls"
|
20
21
|
HTTPI.log_level = :info
|
@@ -4,8 +4,6 @@ module FastshopCatalog
|
|
4
4
|
AUX_LOG = Logger.new(STDOUT)
|
5
5
|
AUX_LOG.level = Logger::WARN
|
6
6
|
|
7
|
-
DEFAULT_BASE_URL = 'http://www.fastincentivos.com.br'
|
8
|
-
|
9
7
|
class << self
|
10
8
|
attr_accessor :log_level
|
11
9
|
attr_accessor :base_url
|
@@ -13,7 +11,11 @@ module FastshopCatalog
|
|
13
11
|
end
|
14
12
|
|
15
13
|
def service_url
|
16
|
-
|
14
|
+
env = "development"
|
15
|
+
|
16
|
+
env = Rails.env if defined?(Rails)
|
17
|
+
url_service = FastshopCatalog::ServiceUrls.new(env)
|
18
|
+
@service_url ||= url_service.url_for(@service)
|
17
19
|
end
|
18
20
|
|
19
21
|
def action
|
@@ -23,7 +25,7 @@ module FastshopCatalog
|
|
23
25
|
def self.camelize(val)
|
24
26
|
val.to_s.split('_').map {|w| w.capitalize}.join
|
25
27
|
end
|
26
|
-
|
28
|
+
|
27
29
|
def encrypt(payload)
|
28
30
|
require_relative 'crypto'
|
29
31
|
Crypto.new.encrypt(payload.to_s)
|
@@ -31,9 +33,9 @@ module FastshopCatalog
|
|
31
33
|
|
32
34
|
def initialize(params={})
|
33
35
|
@@log_level ||= :info
|
34
|
-
default_params = {:wsdl => "#{service_url}?wsdl", :soap_version => 2, :namespaces =>
|
35
|
-
{"xmlns:x" => "http://www.w3.org/2005/08/addressing"}, :soap_header =>
|
36
|
-
{"x:To" => service_url, "x:Action" => "http://tempuri.org/#{action}"}, :log_level =>
|
36
|
+
default_params = {:wsdl => "#{service_url}?wsdl", :soap_version => 2, :namespaces =>
|
37
|
+
{"xmlns:x" => "http://www.w3.org/2005/08/addressing"}, :soap_header =>
|
38
|
+
{"x:To" => service_url, "x:Action" => "http://tempuri.org/#{action}"}, :log_level =>
|
37
39
|
@log_level}
|
38
40
|
@client = Savon.client(recursive_merge(default_params, params))
|
39
41
|
HTTPI.log = false
|
@@ -50,7 +52,7 @@ module FastshopCatalog
|
|
50
52
|
end
|
51
53
|
result[@return_key]
|
52
54
|
end
|
53
|
-
|
55
|
+
|
54
56
|
def service_invoker_with_encryption(encrypted_payload_key, parameters={})
|
55
57
|
encrypted_payload = encrypt(parameters[encrypted_payload_key])
|
56
58
|
FastshopCatalog::BaseService::AUX_LOG.debug('Encrypted payload: ' + encrypted_payload)
|
@@ -2,7 +2,7 @@ module FastshopCatalog
|
|
2
2
|
class CheckAvailabilityService < FastshopCatalog::BaseService
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@service =
|
5
|
+
@service = :consulta_disponibilidade
|
6
6
|
@interface = 'IConsultaDisponibilidade'
|
7
7
|
@soap_method = :retorna_dados
|
8
8
|
@return_key = 'Disponibilidade'
|
@@ -2,7 +2,7 @@ module FastshopCatalog
|
|
2
2
|
class ExternalDneService < FastshopCatalog::BaseService
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@service =
|
5
|
+
@service = :consulta_dne_externo
|
6
6
|
@interface = 'IConsultaDneExterno'
|
7
7
|
@soap_method = :consultar
|
8
8
|
@return_key = 'Dne'
|
@@ -2,7 +2,7 @@ module FastshopCatalog
|
|
2
2
|
class OrderPlacementService < FastshopCatalog::BaseService
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@service =
|
5
|
+
@service = :colocacao_pedido
|
6
6
|
@interface = 'IColocacaoPedido'
|
7
7
|
@soap_method = :incluir_pedido
|
8
8
|
@return_key = 'NumeroPedidoFast'
|
@@ -2,7 +2,7 @@ module FastshopCatalog
|
|
2
2
|
class OrderStatusService < FastshopCatalog::BaseService
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@service =
|
5
|
+
@service = :consulta_status
|
6
6
|
@interface = 'IConsultaStatusPedido'
|
7
7
|
@soap_method = :retorna_dados
|
8
8
|
@return_key = 'Lista'
|
@@ -2,7 +2,7 @@ module FastshopCatalog
|
|
2
2
|
class ParticipantService < FastshopCatalog::BaseService
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@service =
|
5
|
+
@service = :participante
|
6
6
|
@interface = 'IParticipante'
|
7
7
|
@soap_method = :cadastrar_participante
|
8
8
|
@return_key = 'Token'
|
@@ -12,7 +12,7 @@ module FastshopCatalog
|
|
12
12
|
def insert(participant)
|
13
13
|
payload = participant.to_json.to_s
|
14
14
|
AUX_LOG.debug('Participant as json: ' + payload)
|
15
|
-
service_invoker_with_encryption('entrada', 'contrato' => participant.contract_code,
|
15
|
+
service_invoker_with_encryption('entrada', 'contrato' => participant.contract_code,
|
16
16
|
'entrada' => payload)
|
17
17
|
end
|
18
18
|
|
@@ -2,7 +2,7 @@ module FastshopCatalog
|
|
2
2
|
class ProductService < FastshopCatalog::BaseService
|
3
3
|
|
4
4
|
def initialize
|
5
|
-
@service =
|
5
|
+
@service = :consulta_produto
|
6
6
|
@interface = 'IConsultaProduto'
|
7
7
|
@soap_method = :busca_produto
|
8
8
|
@return_key = 'ProdutoDados'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module FastshopCatalog
|
2
|
+
class ServiceUrls
|
3
|
+
DEFAULT_BASE_URL = 'http://www.fastincentivos.com.br'
|
4
|
+
|
5
|
+
PRODUCTION_URLS = {
|
6
|
+
catalogo: "http://www.fastincentivos.com.br:8081/Catalogo.svc/service",
|
7
|
+
consulta_disponibilidade: "http://www.fastincentivos.com.br:8084/ConsultaDisponibilidade.svc/service",
|
8
|
+
consulta_dne_externo: "http://www.fastincentivos.com.br:8086/ConsultaDneExterno.svc/service",
|
9
|
+
colocacao_pedido: "http://www.fastincentivos.com.br:8082/ColocacaoPedido.svc/service",
|
10
|
+
consulta_status: "http://www.fastincentivos.com.br:8090/ConsultaStatusPedido.svc/service",
|
11
|
+
participante: "http://www.fastincentivos.com.br:8093/Participante.svc/service",
|
12
|
+
consulta_produto: "#{DEFAULT_BASE_URL}/FastServices.WsConsultaProduto/ConsultaProduto.svc/service"
|
13
|
+
}
|
14
|
+
|
15
|
+
HOMOLOG_URLS = {
|
16
|
+
catalogo: "#{DEFAULT_BASE_URL}/FastServices.WsCatalogo/Catalogo.svc/service",
|
17
|
+
consulta_disponibilidade: "#{DEFAULT_BASE_URL}/FastServices.WsConsultaDisponibilidade/ConsultaDisponibilidade.svc/service",
|
18
|
+
consulta_dne_externo: "#{DEFAULT_BASE_URL}/FastServices.WsConsultaDneExterno/ConsultaDneExterno.svc/service",
|
19
|
+
colocacao_pedido: "#{DEFAULT_BASE_URL}/FastServices.WsColocacaoPedido/ColocacaoPedido.svc/service",
|
20
|
+
consulta_status: "#{DEFAULT_BASE_URL}/FastServices.WsConsultaStatusPedido/ConsultaStatusPedido.svc/service",
|
21
|
+
participante: "#{DEFAULT_BASE_URL}/FastServices.WsParticipante/Participante.svc/service",
|
22
|
+
consulta_produto: "#{DEFAULT_BASE_URL}/FastServices.WsConsultaProduto/ConsultaProduto.svc/service"
|
23
|
+
}
|
24
|
+
attr_reader :env
|
25
|
+
|
26
|
+
def initialize(env)
|
27
|
+
@env = env
|
28
|
+
end
|
29
|
+
|
30
|
+
def url_for(serv)
|
31
|
+
url = ""
|
32
|
+
if env == "production"
|
33
|
+
url = PRODUCTION_URLS.fetch(serv)
|
34
|
+
else
|
35
|
+
url = HOMOLOG_URLS.fetch(serv)
|
36
|
+
end
|
37
|
+
|
38
|
+
url
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -9,13 +9,13 @@ describe FastshopCatalog::BaseService do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
describe "initialization" do
|
14
|
-
|
14
|
+
|
15
15
|
let(:service) do
|
16
16
|
class TempService < FastshopCatalog::BaseService
|
17
17
|
def initialize
|
18
|
-
@service =
|
18
|
+
@service = :catalogo
|
19
19
|
@interface = 'ISomeInterface'
|
20
20
|
@soap_method = :some_method
|
21
21
|
@return_key = 'SomeName'
|
@@ -25,16 +25,6 @@ describe FastshopCatalog::BaseService do
|
|
25
25
|
TempService.new
|
26
26
|
end
|
27
27
|
|
28
|
-
it 'should return the correct service_url' do
|
29
|
-
expect(service.service_url).to eq('http://www.fastincentivos.com.br/SomePath/some_service')
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should return the correct service_url if base_url changed' do
|
33
|
-
FastshopCatalog::BaseService.base_url = 'http://yourserverhere.com'
|
34
|
-
expect(service.service_url).to eq('http://yourserverhere.com/SomePath/some_service')
|
35
|
-
FastshopCatalog::BaseService.base_url = FastshopCatalog::BaseService::DEFAULT_BASE_URL
|
36
|
-
end
|
37
|
-
|
38
28
|
it 'should return the correct action' do
|
39
29
|
expect(service.action).to eq('ISomeInterface/SomeMethod')
|
40
30
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe FastshopCatalog::ServiceUrls do
|
4
|
+
it "should return homolog url" do
|
5
|
+
subject = FastshopCatalog::ServiceUrls.new("development")
|
6
|
+
|
7
|
+
url = subject.url_for(:catalogo)
|
8
|
+
|
9
|
+
expect(url).to eql("http://www.fastincentivos.com.br/FastServices.WsCatalogo/Catalogo.svc/service")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return production url" do
|
13
|
+
subject = FastshopCatalog::ServiceUrls.new("production")
|
14
|
+
|
15
|
+
url = subject.url_for(:catalogo)
|
16
|
+
|
17
|
+
expect(url).to eql("http://www.fastincentivos.com.br:8081/Catalogo.svc/service")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastshop_catalog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thiago Ganzarolli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/fastshop_catalog/participant_service.rb
|
112
112
|
- lib/fastshop_catalog/product_service.rb
|
113
113
|
- lib/fastshop_catalog/service_exception.rb
|
114
|
+
- lib/fastshop_catalog/service_urls.rb
|
114
115
|
- lib/fastshop_catalog/time.rb
|
115
116
|
- lib/fastshop_catalog/version.rb
|
116
117
|
- password_util.rb
|
@@ -132,6 +133,7 @@ files:
|
|
132
133
|
- spec/fastshop_catalog/participant_factory.rb
|
133
134
|
- spec/fastshop_catalog/participant_service_spec.rb
|
134
135
|
- spec/fastshop_catalog/product_service_spec.rb
|
136
|
+
- spec/fastshop_catalog/service_urls_spec.rb
|
135
137
|
- spec/fixtures/catalog_service_successful_response.xml
|
136
138
|
- spec/fixtures/catalog_service_wrong_contract_response.xml
|
137
139
|
- spec/fixtures/check_availability_successful_response.xml
|
@@ -195,6 +197,7 @@ test_files:
|
|
195
197
|
- spec/fastshop_catalog/participant_factory.rb
|
196
198
|
- spec/fastshop_catalog/participant_service_spec.rb
|
197
199
|
- spec/fastshop_catalog/product_service_spec.rb
|
200
|
+
- spec/fastshop_catalog/service_urls_spec.rb
|
198
201
|
- spec/fixtures/catalog_service_successful_response.xml
|
199
202
|
- spec/fixtures/catalog_service_wrong_contract_response.xml
|
200
203
|
- spec/fixtures/check_availability_successful_response.xml
|