Class: GhasedakApi

Inherits:
Object
  • Object
show all
Defined in:
lib/ghasedak.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key = ENV['ghasedak_key'], linenumber = "10008566") ⇒ GhasedakApi

Returns a new instance of GhasedakApi.



4
5
6
7
# File 'lib/ghasedak.rb', line 4

def initialize(api_key=ENV['ghasedak_key'], linenumber="10008566")
    @api_key = api_key 
    @linenumber = linenumber
end

Instance Method Details

#send_pair_sms(receptors, message) ⇒ Object

Sending pair SMS



21
22
23
24
25
26
27
28
29
# File 'lib/ghasedak.rb', line 21

def send_pair_sms(receptors, message)
    request = HTTParty.post(
        'http://api.ghasedak.io/v2/sms/send/pair', 
        headers: {"apikey" => @api_key, "cache-control" => "no-cache", "content-type" => "application/x-www-form-urlencoded"},
        body: {"receptor" => receptors, "message" => message, "linenumber" => @linenumber}
    )

    return request.code 
end

#send_simple_sms(receptor, message) ⇒ Object

Sending simple SMS



10
11
12
13
14
15
16
17
18
# File 'lib/ghasedak.rb', line 10

def send_simple_sms(receptor, message)
    request = HTTParty.post(
        'http://api.ghasedak.io/v2/sms/send/simple', 
        headers: {"apikey" => @api_key, "cache-control" => "no-cache", "content-type" => "application/x-www-form-urlencoded"},
        body: {"receptor" => receptor, "message" => message, "linenumber" => @linenumber}
    )

    return request.code # For receptor's safety, just returns status code. 
end