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, exetel_url, matchurl?, new_reference_number, response_to_hash

Constructor Details

#initialize(config) ⇒ Receiver

Returns a new instance of Receiver.



8
9
10
# File 'lib/receiver.rb', line 8

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/receiver.rb', line 7

def config
  @config
end

Class Method Details

.api_pathObject



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

def api_path
  'api_sms_mvn_inbox.php'
end

.request_fieldsObject



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

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

.response_fieldsObject



24
25
26
# File 'lib/receiver.rb', line 24

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

Instance Method Details

#receive(from_mobile_number) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/receiver.rb', line 12

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