Class: Bulksms::Service

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Service

Returns a new instance of Service.



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

def initialize(opts = {})
  @account = Account.new(opts)
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



5
6
7
# File 'lib/bulksms/service.rb', line 5

def 
  @account
end

Instance Method Details

#deliver(*args) ⇒ Object

Send a single message or multiple messages.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bulksms/service.rb', line 12

def deliver(*args)
  msg = args.shift
  opts = args.shift || {}
  case msg
  when Hash
    msg = Message.new(msg)
  when Array
    msg = msg.map{|m| m.is_a?(Message) ? m : Message.new(m)}
  end
  send_request(msg)
end