Class: SmswayApi::Message
- Inherits:
-
Object
- Object
- SmswayApi::Message
- Defined in:
- lib/smsway_api/message.rb
Defined Under Namespace
Constant Summary collapse
- TYPES =
[:flashsms, :sms, :vcard, :wappush]
Instance Attribute Summary collapse
-
#recepients ⇒ Object
readonly
Returns the value of attribute recepients.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#add_recipient(recepient = {}) ⇒ Object
add recepient recepient (Hash or String) options for recipient allowed options are: phone: phone number client_id: sms id in your system time_send: Time of sms sending validity_period: Date of if String is given than it means only phone.
- #build(xml, start_index = 0) ⇒ Object
-
#initialize(type = :sms) ⇒ Message
constructor
A new instance of Message.
Constructor Details
Instance Attribute Details
#recepients ⇒ Object (readonly)
Returns the value of attribute recepients.
5 6 7 |
# File 'lib/smsway_api/message.rb', line 5 def recepients @recepients end |
#sender ⇒ Object
Returns the value of attribute sender.
3 4 5 |
# File 'lib/smsway_api/message.rb', line 3 def sender @sender end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/smsway_api/message.rb', line 6 def type @type end |
Instance Method Details
#add_recipient(recepient = {}) ⇒ Object
add recepient recepient (Hash or String) options for recipient allowed options are:
phone: phone number
client_id: sms id in your system
time_send: Time of sms sending
validity_period: Date of
if String is given than it means only phone
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/smsway_api/message.rb', line 38 def add_recipient(recepient = {}) if recepient.is_a?(String) # convert string value to correct hash recepient = {phone: recepient} end recepient[:phone] = format_phone(recepient[:phone]) @recepients.push(recepient) # time-send format: YYYY-MM-DD HH:MM # validity_period format: YYYY-MM-DD HH:MM end |
#build(xml, start_index = 0) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/smsway_api/message.rb', line 20 def build(xml, start_index = 0) xml.(type: @type) do xml.sender @sender yield(xml) @recepients.each.with_index do |r, index| xml.abonent(r.merge(number_sms: start_index + index)) end end end |