Class: Voxbone
- Inherits:
-
Object
- Object
- Voxbone
- Defined in:
- lib/voxbone/voxbone.rb
Instance Attribute Summary collapse
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
Instance Method Summary collapse
-
#initialize(params) ⇒ Object
constructor
Instantiate a Voxbone object.
-
#method_missing(method_name, params = {}) ⇒ Hash
Provides the dispatcher to the available SOAP methods defined in the WSDL.
Constructor Details
#initialize(params) ⇒ Object
Instantiate a Voxbone object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/voxbone/voxbone.rb', line 19 def initialize(params) raise ArgumentError, ":username required" if params[:username].nil? raise ArgumentError, ":password required" if params[:password].nil? config_savon(params) @user_token = create_user_token(params) @client = Savon::Client.new do wsdl.document = params[:base_uri] || 'http://www.voxbone.com/VoxAPI/services/VoxAPI?WSDL' wsdl.namespace = 'http://www.voxbone.com/VoxAPI' end @methods = @client.wsdl.soap_actions end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, params = {}) ⇒ Hash
Provides the dispatcher to the available SOAP methods defined in the WSDL
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/voxbone/voxbone.rb', line 43 def method_missing(method_name, params={}) if @methods.include? method_name response = @client.request :vox, method_name do prepare_soap(soap, capitalize_params(params)) end response.to_hash else raise NoMethodError, "The method #{method_name.to_s} does not exist." end end |
Instance Attribute Details
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
2 3 4 |
# File 'lib/voxbone/voxbone.rb', line 2 def methods @methods end |