Class: Scene7::Client
- Inherits:
-
Object
- Object
- Scene7::Client
- Defined in:
- lib/scene7/client.rb
Constant Summary collapse
- CONFIG_FIELDS =
[:subdomain, :user, :password, :app_name, :app_version].freeze
- NAMESPACE =
"http://www.scene7.com/IpsApi/xsd/2010-01-31"
Class Method Summary collapse
- .client ⇒ Object
- .company_handle ⇒ Object
- .configure(options) ⇒ Object
- .header ⇒ Object
- .input_for_action(action) ⇒ Object
- .perform_request(action, body_params) ⇒ Object
- .reset_configuration ⇒ Object
Class Method Details
.client ⇒ Object
24 25 26 27 28 29 |
# File 'lib/scene7/client.rb', line 24 def client Savon::Client.new do wsdl.namespace = NAMESPACE wsdl.endpoint = configuration.endpoint end end |
.company_handle ⇒ Object
47 48 49 |
# File 'lib/scene7/client.rb', line 47 def company_handle @@company_handle ||= Company.find_by_name(configuration.app_name).handle end |
.configure(options) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/scene7/client.rb', line 11 def configure() params = CONFIG_FIELDS.map { |field| [field] } @@configuration = Config.new(*params) self end |
.header ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/scene7/client.rb', line 39 def header if configuration.blank? raise 'Call Scene7::Client.configure with your configuration first.' else configuration.header end end |
.input_for_action(action) ⇒ Object
51 52 53 |
# File 'lib/scene7/client.rb', line 51 def input_for_action(action) action.to_s.camelize(:lower) + 'Param' end |
.perform_request(action, body_params) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/scene7/client.rb', line 31 def perform_request(action, body_params) client.request(:ns, action) do soap.input = [input_for_action(action), {:xmlns => "http://www.scene7.com/IpsApi/xsd/2010-01-31" }] soap.header = header soap.body = body_params end end |
.reset_configuration ⇒ Object
19 20 21 22 |
# File 'lib/scene7/client.rb', line 19 def reset_configuration @@configuration = nil @@company_handle = nil end |