Class: ExetelSms::Receiver

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Defined in:
lib/receiver.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

build_url, encode, new_reference_number, response_to_hash

Constructor Details

#initialize(config) ⇒ Receiver

Returns a new instance of Receiver.



11
12
13
# File 'lib/receiver.rb', line 11

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



10
11
12
# File 'lib/receiver.rb', line 10

def config
  @config
end

Class Method Details

.exetel_urlObject



35
36
37
# File 'lib/receiver.rb', line 35

def exetel_url
  'https://www.exetel.com.au/sendsms/api_sms_mvn_inbox.php?'
end

.request_fieldsObject



31
32
33
# File 'lib/receiver.rb', line 31

def request_fields
  [:username, :password, :mobilenumber]
end

.response_fieldsObject



27
28
29
# File 'lib/receiver.rb', line 27

def response_fields
  [:status, :exetel_id, :from_mobile_number, :received_at, :notes, :message]
end

Instance Method Details

#receive(from_mobile_number) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/receiver.rb', line 15

def receive(from_mobile_number)
  url = self.class.build_url(
    :username => @config.username,
    :password => @config.password,
    :mobilenumber => from_mobile_number
  )
  
  self.class.response_to_hash(ExetelSms::Client.request(url))
end