Class: MaxApiClient::ImageAttachment

Inherits:
Attachment show all
Defined in:
lib/max_api_client/attachments.rb,
sig/max_api_client.rbs

Overview

Attachment wrapper for uploaded or remote images.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token: nil, photos: nil, url: nil) ⇒ ImageAttachment

Returns a new instance of ImageAttachment.



29
30
31
32
33
# File 'lib/max_api_client/attachments.rb', line 29

def initialize(token: nil, photos: nil, url: nil)
  super(token:)
  @photos = photos
  @url = url
end

Instance Attribute Details

#photosObject (readonly)

Returns the value of attribute photos.



27
28
29
# File 'lib/max_api_client/attachments.rb', line 27

def photos
  @photos
end

#urlObject (readonly)

Returns the value of attribute url.



27
28
29
# File 'lib/max_api_client/attachments.rb', line 27

def url
  @url
end

Instance Method Details

#payloadObject



35
36
37
38
39
40
# File 'lib/max_api_client/attachments.rb', line 35

def payload
  return { token: token } if token
  return { url: url } if url

  { photos: photos }
end

#to_hObject



42
43
44
# File 'lib/max_api_client/attachments.rb', line 42

def to_h
  { type: "image", payload: }
end