Class: CynSms::APIController
- Inherits:
-
BaseController
- Object
- BaseController
- CynSms::APIController
- Defined in:
- lib/cyn_sms/controllers/api_controller.rb
Overview
APIController
Class Attribute Summary collapse
-
.instance ⇒ Object
Returns the value of attribute instance.
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_send_sms(api_key, to, sms, from) ⇒ Object
TODO: type endpoint description here sms.cynojine.com/sms-api/info (user panel) phone number can be a valid phone number or a String.
-
#get_balance_check(options = {}, _query_parameters = nil) ⇒ Object
Checking SMS Balance supported by this endpoint.
- #instance ⇒ Object
Methods inherited from BaseController
#execute_request, #initialize, #validate_parameters, #validate_response
Constructor Details
This class inherits a constructor from CynSms::BaseController
Class Attribute Details
.instance ⇒ Object
Returns the value of attribute instance.
12 13 14 |
# File 'lib/cyn_sms/controllers/api_controller.rb', line 12 def instance @instance end |
Instance Method Details
#create_send_sms(api_key, to, sms, from) ⇒ Object
TODO: type endpoint description here sms.cynojine.com/sms-api/info (user panel) phone number can be a valid phone number or a String
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cyn_sms/controllers/api_controller.rb', line 28 def create_send_sms(api_key, to, sms, from) # Prepare query url. _path_url = '/api?action=send-sms' _query_builder = Configuration.base_uri.dup _query_builder << _path_url _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, { 'api key' => api_key, 'to' => to, 'sms' => sms, 'from' => from }, array_serialization: Configuration.array_serialization ) _query_url = APIHelper.clean_url _query_builder # Prepare and execute HttpRequest. _request = @http_client.post( _query_url ) _context = execute_request(_request) validate_response(_context) # Return appropriate response type. _context.response.raw_body end |
#get_balance_check(options = {}, _query_parameters = nil) ⇒ Object
Checking SMS Balance supported by this endpoint.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cyn_sms/controllers/api_controller.rb', line 63 def get_balance_check( = {}, _query_parameters = nil) # Prepare query url. _path_url = '/api?action=check-balance' _query_builder = Configuration.base_uri.dup _query_builder << _path_url _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, { 'api_key' => ['api_key'], 'response' => ['response'] }, array_serialization: Configuration.array_serialization ) _query_builder = APIHelper.append_url_with_query_parameters( _query_builder, _query_parameters, array_serialization: Configuration.array_serialization ) _query_url = APIHelper.clean_url _query_builder # Prepare and execute HttpRequest. _request = @http_client.get( _query_url ) _context = execute_request(_request) validate_response(_context) end |
#instance ⇒ Object
15 16 17 |
# File 'lib/cyn_sms/controllers/api_controller.rb', line 15 def instance self.class.instance end |