Class: Fex::Service
- Inherits:
-
Object
- Object
- Fex::Service
- Extended by:
- Forwardable
- Defined in:
- lib/fex/service.rb
Overview
This is a wrapper around Savon, with more or less intelligent defaults.
Instance Attribute Summary collapse
-
#defaults ⇒ Object
readonly
Defaults are any values that always exist on this service.
-
#name ⇒ Object
readonly
The name determines the name of the WSDL file located in the wsdl directory in the root of the gem.
-
#response ⇒ Object
readonly
The response is the class that will handle building a response.
Instance Method Summary collapse
- #call(operation, message, options = {}) ⇒ Object
- #client ⇒ Object
- #client_options ⇒ Object
-
#initialize(options) ⇒ Service
constructor
A new instance of Service.
- #wsdl ⇒ Object
Constructor Details
#initialize(options) ⇒ Service
Returns a new instance of Service.
25 26 27 28 29 30 31 |
# File 'lib/fex/service.rb', line 25 def initialize() @name = .fetch(:name) @client_options = [:client] || {} @wsdl = [:wsdl] @defaults = [:defaults] || {} @response = .fetch(:response) end |
Instance Attribute Details
#defaults ⇒ Object (readonly)
Defaults are any values that always exist on this service. Examples are the credentials and the version.
19 20 21 |
# File 'lib/fex/service.rb', line 19 def defaults @defaults end |
#name ⇒ Object (readonly)
The name determines the name of the WSDL file located in the wsdl directory in the root of the gem. The full path will be calculated by the WSDL
class.
15 16 17 |
# File 'lib/fex/service.rb', line 15 def name @name end |
#response ⇒ Object (readonly)
The response is the class that will handle building a response. The default is the generic Response
class.
23 24 25 |
# File 'lib/fex/service.rb', line 23 def response @response end |
Instance Method Details
#call(operation, message, options = {}) ⇒ Object
41 42 43 44 45 |
# File 'lib/fex/service.rb', line 41 def call(operation, , = {}) opts = {message: defaults.deep_merge()}.deep_merge() savon_response = client.call(operation, opts) response.new(savon_response) end |
#client ⇒ Object
37 38 39 |
# File 'lib/fex/service.rb', line 37 def client Savon.client() end |
#client_options ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/fex/service.rb', line 47 def = { wsdl: wsdl, convert_request_keys_to: :camelcase, pretty_print_xml: true } .deep_merge(@client_options) end |