Class: MessageQuickly::Messaging::Delivery

Inherits:
Object
  • Object
show all
Defined in:
lib/message_quickly/messaging/delivery.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Delivery

Returns a new instance of Delivery.

Yields:

  • (_self)

Yield Parameters:



8
9
10
11
12
# File 'lib/message_quickly/messaging/delivery.rb', line 8

def initialize(options = {})
  self.message ||= MessageQuickly::Messaging::Message.new
  options.each { |key, value| instance_variable_set("@#{key}", value) }
  yield self if block_given?
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/message_quickly/messaging/delivery.rb', line 5

def id
  @id
end

#messageObject

Returns the value of attribute message.



5
6
7
# File 'lib/message_quickly/messaging/delivery.rb', line 5

def message
  @message
end

#notification_typeObject

must be of values: REGULAR, SILENT_PUSH, NO_PUSH



6
7
8
# File 'lib/message_quickly/messaging/delivery.rb', line 6

def notification_type
  @notification_type
end

#recipientObject

Returns the value of attribute recipient.



5
6
7
# File 'lib/message_quickly/messaging/delivery.rb', line 5

def recipient
  @recipient
end

Instance Method Details

#build_message {|self.message| ... } ⇒ Object

Yields:



14
15
16
# File 'lib/message_quickly/messaging/delivery.rb', line 14

def build_message
  yield self.message
end

#to_hashObject



18
19
20
21
22
23
24
25
# File 'lib/message_quickly/messaging/delivery.rb', line 18

def to_hash
  hash = {}
  hash.merge!(recipient: recipient.to_hash) if recipient
  hash.merge!(message: message.to_hash) if message
  hash.merge!(notification_type: notification_type) if notification_type
  hash.merge!(filedata: Faraday::UploadIO.new(message.attachment.file, message.attachment.file_type)) if message.attachment && message.attachment.file?
  hash
end