Module: RmsApiRuby::SoapApi
- Included in:
- Inventory, Order
- Defined in:
- lib/rms_api_ruby/soap_api.rb,
lib/rms_api_ruby/soap_api/client.rb
Defined Under Namespace
Classes: Client
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
13
14
15
|
# File 'lib/rms_api_ruby/soap_api.rb', line 13
def method_missing(method, *args)
api_methods.include?(method) ? call_api(method, args.first) : super
end
|
Instance Method Details
#api_methods ⇒ Object
5
6
7
|
# File 'lib/rms_api_ruby/soap_api.rb', line 5
def api_methods
raise NotImplementedError, "You must implement #{self}::#{__method__}"
end
|
#call_api(method, args) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/rms_api_ruby/soap_api.rb', line 21
def call_api(method, args)
Flow.new.
chain(response: :response) { soap_client.new(method, args) }.
on_dam { |error| handle_error(error) }.
outflow.
try(:response)
end
|
#handle_error(error) ⇒ Object
#respond_to_missing?(method, include_private = false) ⇒ Boolean
17
18
19
|
# File 'lib/rms_api_ruby/soap_api.rb', line 17
def respond_to_missing?(method, include_private = false)
api_methods.include?(method) || super
end
|
#soap_client ⇒ Object
9
10
11
|
# File 'lib/rms_api_ruby/soap_api.rb', line 9
def soap_client
raise NotImplementedError, "You must implement #{self}::#{__method__}"
end
|