Class: FourjawalySMS::SMSGateway
- Inherits:
-
Object
- Object
- FourjawalySMS::SMSGateway
- Defined in:
- lib/sms4jawaly_sms/sms_gateway.rb
Constant Summary collapse
- BASE_URL =
'https://api-sms.4jawaly.com/api/v1'.freeze
Instance Method Summary collapse
-
#get_balance(is_active: nil, order_by: nil, order_by_type: nil) ⇒ Hash
Get account balance and package information.
-
#initialize(api_key:, api_secret:, sender:) ⇒ SMSGateway
constructor
A new instance of SMSGateway.
-
#send_single_sms(number:, message:) ⇒ Hash
Send SMS to a single recipient.
-
#send_sms(numbers:, message:, sender: nil) ⇒ Hash
Send SMS to one or multiple recipients.
Constructor Details
#initialize(api_key:, api_secret:, sender:) ⇒ SMSGateway
Returns a new instance of SMSGateway.
11 12 13 14 |
# File 'lib/sms4jawaly_sms/sms_gateway.rb', line 11 def initialize(api_key:, api_secret:, sender:) @api_key = api_key @sender = sender end |
Instance Method Details
#get_balance(is_active: nil, order_by: nil, order_by_type: nil) ⇒ Hash
Get account balance and package information
51 52 53 54 55 56 57 58 59 |
# File 'lib/sms4jawaly_sms/sms_gateway.rb', line 51 def get_balance(is_active: nil, order_by: nil, order_by_type: nil) params = {} params[:is_active] = is_active if is_active params[:order_by] = order_by if order_by params[:order_by_type] = order_by_type if order_by_type response = get_request('balance', params) handle_response(response) end |
#send_single_sms(number:, message:) ⇒ Hash
Send SMS to a single recipient
40 41 42 |
# File 'lib/sms4jawaly_sms/sms_gateway.rb', line 40 def send_single_sms(number:, message:) send_sms(numbers: [number], message: ) end |
#send_sms(numbers:, message:, sender: nil) ⇒ Hash
Send SMS to one or multiple recipients
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sms4jawaly_sms/sms_gateway.rb', line 23 def send_sms(numbers:, message:, sender: nil) request = { numbers: numbers, message: , sender: sender || @sender } response = post_request('send', request) handle_response(response) end |