Class: Fourjawaly::SMSGateway
- Inherits:
-
Object
- Object
- Fourjawaly::SMSGateway
- Defined in:
- lib/fourjawaly/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_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.
9 10 11 12 13 14 |
# File 'lib/fourjawaly/sms_gateway.rb', line 9 def initialize(api_key, api_secret, sender) @api_key = api_key @sender = sender @http = Net::HTTP.new(uri.host, uri.port) @http.use_ssl = true end |
Instance Method Details
#get_balance(is_active: nil, order_by: nil, order_by_type: nil) ⇒ Hash
Get account balance and package information
40 41 42 43 44 45 46 47 |
# File 'lib/fourjawaly/sms_gateway.rb', line 40 def get_balance(is_active: nil, order_by: nil, order_by_type: nil) params = {} params[:is_active] = is_active unless is_active.nil? params[:order_by] = order_by if order_by params[:order_by_type] = order_by_type if order_by_type get_request('balance', params) end |
#send_sms(numbers, message, sender = nil) ⇒ Hash
Send SMS to one or multiple recipients
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fourjawaly/sms_gateway.rb', line 22 def send_sms(numbers, , sender = nil) numbers = [numbers] unless numbers.is_a?(Array) payload = { numbers: numbers, message: , sender: sender || @sender } post_request('send', payload) end |