Class: Eztexting::Sms

Inherits:
Base
  • Object
show all
Defined in:
lib/eztexting/sms.rb

Class Method Summary collapse

Methods inherited from Base

do_post, processed_reponse

Class Method Details

.multi(messages) ⇒ Array

Send Out Multiple Messages

Parameters:

  • messages (Array)

    is an array of hashes which are hashes that are identical to the hash passed into the single SMS method. This requires the same keys as the single method

Returns:

  • (Array)

    The return is an array of two elements, the mapped error code according to the extexting and the raw response



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/eztexting/sms.rb', line 19

def self.multi(messages)
  location = "/sending"
  results = []
    
  messages.each_with_index do |msg, i|
    opts = msg
    response = self.do_post(location,opts)
    response_result = self.process(response)
    results << {:message => i, :result => response_result}
  end
  
  return results
end

.single(opts = {}) ⇒ Array

Send out a singular SMS

Parameters:

  • opts (Hash) (defaults to: {})

    is a hash with keys/value pairs of subject, message and phone number. The phonenumber, subject and message are required by the API

Returns:

  • (Array)

    The return is an array of two elements, the mapped error code according to the extexting and the raw response



7
8
9
10
11
12
13
14
# File 'lib/eztexting/sms.rb', line 7

def self.single(opts={})
  location = "/sending"
  
  response = self.do_post(location,opts)
  response_result = self.process(response)

  return self.processed_reponse(response_result,response)  
end