Class: Bulksms::Message

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

Overview

Encapsulates a message to be sent by the gateway

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Message

Returns a new instance of Message.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bulksms/message.rb', line 15

def initialize(opts = {})
  @message = opts[:message]
  @recipient = opts[:recipient]
  @msg_class = opts[:message_class] || Bulksms.config.message_class
  @want_report = 0
  @routing_group = opts[:routing_group] || Bulksms.config.routing_group
  @source_id = ''
  @test_always_succeed = opts[:test_always_succeed] || 0
  @test_always_fail = opts[:test_always_fail] || 0
  @concat_text_sms = 0
  @concat_max_parts = 2
end

Instance Attribute Details

#concat_max_partsObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def concat_max_parts
  @concat_max_parts
end

#concat_text_smsObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def concat_text_sms
  @concat_text_sms
end

#messageObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def message
  @message
end

#msg_classObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def msg_class
  @msg_class
end

#recipientObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def recipient
  @recipient
end

#routing_groupObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def routing_group
  @routing_group
end

#source_idObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def source_id
  @source_id
end

#test_always_failObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def test_always_fail
  @test_always_fail
end

#test_always_succeedObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def test_always_succeed
  @test_always_succeed
end

#want_reportObject

The various attributes for a message as defined by the BulkSMS HTTP API. For full details on the different attributes see:

http://www.bulksms.co.uk/docs/eapi/submission/send_sms/


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

def want_report
  @want_report
end

Instance Method Details

#to_paramsObject

Returns a message as a http query string for use by other gateway services



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bulksms/message.rb', line 30

def to_params
  raise "Missing message!" if @message.to_s.empty?
  raise "Missing recipient!" if @recipient.to_s.empty?
  {
    'message' => @message,
    'msisdn' => @recipient,
    'msg_class' => @msg_class,
    'want_report' => @want_report,
    'routing_group' => @routing_group,
    'source_id' => @source_id,
    'test_always_succeed' => @test_always_succeed,
    'test_always_fail' => @test_always_fail,
    'allow_concat_text_sms' => @concat_text_sms,
    'concat_text_sms_max_parts' => @concat_max_parts
  }
end