Class: Minitext::Message

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to:, body:, gateway:, from: nil, messaging_service_sid: nil, media_url: nil) ⇒ Message

Returns a new instance of Message.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/minitext/message.rb', line 5

def initialize(to:, body:, gateway:, from: nil, messaging_service_sid: nil, media_url: nil)
  if from.nil? && messaging_service_sid.nil?
    raise ArgumentError.new("must supply either the 'from' or 'messaging_service_sid' argument")
  end

  @gateway = gateway
  @messaging_service_sid = messaging_service_sid
  @from = from
  @to = to
  @body = body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/minitext/message.rb', line 3

def body
  @body
end

#fromObject

Returns the value of attribute from.



3
4
5
# File 'lib/minitext/message.rb', line 3

def from
  @from
end

#gatewayObject

Returns the value of attribute gateway.



3
4
5
# File 'lib/minitext/message.rb', line 3

def gateway
  @gateway
end

#media_urlObject

Returns the value of attribute media_url.



3
4
5
# File 'lib/minitext/message.rb', line 3

def media_url
  @media_url
end

#messaging_service_sidObject

Returns the value of attribute messaging_service_sid.



3
4
5
# File 'lib/minitext/message.rb', line 3

def messaging_service_sid
  @messaging_service_sid
end

#toObject

Returns the value of attribute to.



3
4
5
# File 'lib/minitext/message.rb', line 3

def to
  @to
end

Instance Method Details

#deliverObject



17
18
19
# File 'lib/minitext/message.rb', line 17

def deliver
  gateway.deliver(self)
end