Class: FastshopCatalog::BaseService
- Inherits:
-
Object
- Object
- FastshopCatalog::BaseService
- Defined in:
- lib/fastshop_catalog/base_service.rb
Direct Known Subclasses
CatalogService, CheckAvailabilityService, ExternalDneService, OrderPlacementService, OrderStatusService, ParticipantService, ProductService
Constant Summary collapse
- AUX_LOG =
Logger.new(STDOUT)
Class Attribute Summary collapse
-
.base_url ⇒ Object
Returns the value of attribute base_url.
-
.crypto_key ⇒ Object
Returns the value of attribute crypto_key.
-
.log_level ⇒ Object
Returns the value of attribute log_level.
Class Method Summary collapse
Instance Method Summary collapse
- #action ⇒ Object
- #encrypt(payload) ⇒ Object
-
#initialize(params = {}) ⇒ BaseService
constructor
A new instance of BaseService.
- #service_url ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ BaseService
Returns a new instance of BaseService.
34 35 36 37 38 39 40 41 42 |
# File 'lib/fastshop_catalog/base_service.rb', line 34 def initialize(params={}) @@log_level ||= :info default_params = {:wsdl => "#{service_url}?wsdl", :soap_version => 2, :namespaces => {"xmlns:x" => "http://www.w3.org/2005/08/addressing"}, :soap_header => {"x:To" => service_url, "x:Action" => "http://tempuri.org/#{action}"}, :log_level => @log_level} @client = Savon.client(recursive_merge(default_params, params)) HTTPI.log = false end |
Class Attribute Details
.base_url ⇒ Object
Returns the value of attribute base_url.
9 10 11 |
# File 'lib/fastshop_catalog/base_service.rb', line 9 def base_url @base_url end |
.crypto_key ⇒ Object
Returns the value of attribute crypto_key.
10 11 12 |
# File 'lib/fastshop_catalog/base_service.rb', line 10 def crypto_key @crypto_key end |
.log_level ⇒ Object
Returns the value of attribute log_level.
8 9 10 |
# File 'lib/fastshop_catalog/base_service.rb', line 8 def log_level @log_level end |
Class Method Details
.camelize(val) ⇒ Object
25 26 27 |
# File 'lib/fastshop_catalog/base_service.rb', line 25 def self.camelize(val) val.to_s.split('_').map {|w| w.capitalize}.join end |
Instance Method Details
#action ⇒ Object
21 22 23 |
# File 'lib/fastshop_catalog/base_service.rb', line 21 def action @action ||= "#{@interface}/#{BaseService.camelize(@soap_method)}" end |
#encrypt(payload) ⇒ Object
29 30 31 32 |
# File 'lib/fastshop_catalog/base_service.rb', line 29 def encrypt(payload) require_relative 'crypto' Crypto.new.encrypt(payload.to_s) end |
#service_url ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/fastshop_catalog/base_service.rb', line 13 def service_url env = "development" env = Rails.env if defined?(Rails) url_service = FastshopCatalog::ServiceUrls.new(env) @service_url ||= url_service.url_for(@service) end |