Class: ExetelSms::Sender
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
build_url, encode, new_reference_number, response_to_hash
Constructor Details
#initialize(config) ⇒ Sender
Returns a new instance of Sender.
11
12
13
|
# File 'lib/sender.rb', line 11
def initialize(config)
@config = config
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
10
11
12
|
# File 'lib/sender.rb', line 10
def config
@config
end
|
Class Method Details
.exetel_url ⇒ Object
39
40
41
42
|
# File 'lib/sender.rb', line 39
def exetel_url
'https://www.exetel.com.au/sendsms/api_sms.php?'
end
|
.request_fields ⇒ Object
35
36
37
|
# File 'lib/sender.rb', line 35
def request_fields
[:username, :password, :mobilenumber, :message, :sender, :messagetype, :referencenumber]
end
|
.response_fields ⇒ Object
31
32
33
|
# File 'lib/sender.rb', line 31
def response_fields
[:status, :to_mobile_number, :reference_number, :exetel_id, :notes]
end
|
Instance Method Details
#send(to_mobile_number, msg, from_mobile_number, reference_number) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/sender.rb', line 15
def send(to_mobile_number, msg, from_mobile_number, reference_number)
url = self.class.build_url(
:username => @config.username,
:password => @config.password,
:sender => from_mobile_number,
:message => msg,
:messagetype => 'Text',
:referencenumber => reference_number,
:mobilenumber => to_mobile_number
)
self.class.response_to_hash(ExetelSms::Client.request(url))
end
|