Class: SMSApi::SMS::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/client_smsapi/sms/message.rb,
lib/client_smsapi/sms/message/eco.rb,
lib/client_smsapi/sms/message/pro.rb,
lib/client_smsapi/sms/message/2way.rb

Direct Known Subclasses

Eco, Pro, TwoWay

Defined Under Namespace

Classes: Eco, Pro, TwoWay

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to:, from:, body:) ⇒ Message

Returns a new instance of Message.



10
11
12
13
14
# File 'lib/client_smsapi/sms/message.rb', line 10

def initialize(to:, from:, body:)
  @to   = to
  @from = from
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/client_smsapi/sms/message.rb', line 8

def body
  @body
end

#fromObject (readonly)

Returns the value of attribute from.



8
9
10
# File 'lib/client_smsapi/sms/message.rb', line 8

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



8
9
10
# File 'lib/client_smsapi/sms/message.rb', line 8

def to
  @to
end

Instance Method Details

#to_paramsObject



23
24
25
26
27
28
29
# File 'lib/client_smsapi/sms/message.rb', line 23

def to_params
  @params ||= {
    from: from.to_s,
    to: to.to_s,
    message: body
  }
end

#valid?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'lib/client_smsapi/sms/message.rb', line 16

def valid?
  @valid ||= begin
    Validators::MessageBodyValidator.valid_body?(body)
    Validators::PhoneNumberValidator.valid_number?(to)
  end
end