Class: UI::ImageAttachment

Inherits:
Object
  • Object
show all
Defined in:
lib/ui/image_attachment.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ ImageAttachment

Returns a new instance of ImageAttachment.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ui/image_attachment.rb', line 5

def initialize(url)
  @template = {
    recipient: {
      id: nil
    },
    message: {
      attachment: {
        type: 'image',
        payload: {
          url: url
        }
      }
    }
  }
end

Instance Method Details

#build(user) ⇒ Object



26
27
28
29
# File 'lib/ui/image_attachment.rb', line 26

def build(user)
  @template[:recipient][:id] = user.id
  @template
end

#send(user) ⇒ Object



21
22
23
24
# File 'lib/ui/image_attachment.rb', line 21

def send(user)
  formed = build(user)
  Bot.deliver(formed, access_token: ENV['ACCESS_TOKEN'])
end