Class: Net::SMS::BulkSMS::Message

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

Overview

Encapsulates a message to be sent by the gateway

Constant Summary collapse

FLASH_SMS =
0
NORMAL_SMS =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, recipient) ⇒ Message



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

def initialize(message, recipient)
  @message = message
  @recipient = recipient
  @msg_class = NORMAL_SMS
  @want_report = 0
  @routing_group = 2
  @source_id = ''
  @test_always_succeed = 0
  @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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

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/


14
15
16
# File 'lib/net/sms/bulksms/message.rb', line 14

def want_report
  @want_report
end

Instance Method Details

#to_http_queryObject

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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/net/sms/bulksms/message.rb', line 34

def to_http_query
  params = {
    '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
  }
  query_string = params.collect { |x, y| "#{x}=#{y}" }.join('&')
  URI.encode(query_string)
end