Class: GreenSMS::API::Module
- Inherits:
-
Object
- Object
- GreenSMS::API::Module
- Defined in:
- lib/greensms/api/module.rb
Instance Attribute Summary collapse
-
#function_name ⇒ Object
readonly
Returns the value of attribute function_name.
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#module_schema ⇒ Object
readonly
Returns the value of attribute module_schema.
Instance Method Summary collapse
- #api_func(kwargs = {}) ⇒ Object
-
#initialize(rest_client, module_schema, kwargs, module_name, function_name) ⇒ Module
constructor
A new instance of Module.
Constructor Details
#initialize(rest_client, module_schema, kwargs, module_name, function_name) ⇒ Module
Returns a new instance of Module.
10 11 12 13 14 15 |
# File 'lib/greensms/api/module.rb', line 10 def initialize(rest_client, module_schema, kwargs, module_name, function_name) @rest_client = rest_client @module_schema = module_schema @params = {} kwargs.each { |name, value| @params[name] = value } end |
Instance Attribute Details
#function_name ⇒ Object (readonly)
Returns the value of attribute function_name.
8 9 10 |
# File 'lib/greensms/api/module.rb', line 8 def function_name @function_name end |
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
7 8 9 |
# File 'lib/greensms/api/module.rb', line 7 def module_name @module_name end |
#module_schema ⇒ Object (readonly)
Returns the value of attribute module_schema.
6 7 8 |
# File 'lib/greensms/api/module.rb', line 6 def module_schema @module_schema end |
Instance Method Details
#api_func(kwargs = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/greensms/api/module.rb', line 17 def api_func(kwargs = {}) kwargs = kwargs.transform_keys(&:to_s) if !@module_schema.nil? errors = GreenSMS.validate(@module_schema, kwargs) if !errors.nil? return errors end end api_params = {} kwargs.each { |name, value| api_params[name] = value } request_params = @params.clone request_params["params"] = api_params response = @rest_client.request(request_params) return response end |