Class: MailUp::Console::Images

Inherits:
Object
  • Object
show all
Defined in:
lib/mailup/console/images.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ Images

Returns a new instance of Images.



6
7
8
# File 'lib/mailup/console/images.rb', line 6

def initialize(api)
    @api = api
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



4
5
6
# File 'lib/mailup/console/images.rb', line 4

def api
  @api
end

Instance Method Details

#add_image(image) ⇒ Array

Add a new image to the shared images list.

Examples:


image = {
  Name: "TemplateHeader.jpg",
  Data: "..."
}
images = mailup.console.images.add_image(image)
images.size
=> 51

Parameters:

  • image (Hash)

    A hash of image attributes:

Options Hash (image):

  • Name (String)

    of the image.

  • Base64 (String)

    data for the image.

Returns:

  • (Array)

    An array of Image strings.

See Also:



46
47
48
# File 'lib/mailup/console/images.rb', line 46

def add_image(image)
  @api.post("#{@api.path}/Images", body:image)
end

#delete_image(path) ⇒ Boolean

Delete the image corresponding to the provided full path name.

Examples:


delete = mailup.console.images.delete_image("#{image_path}")
=> true

Parameters:

  • path (String)

    The path of the image to delete.

Returns:

  • (Boolean)

    ‘true` if successful.

See Also:



63
64
65
# File 'lib/mailup/console/images.rb', line 63

def delete_image(path)
  @api.delete("#{@api.path}/Images", body: path.to_s)
end

#listArray<String>

Get the list of all shared images for the current console.

Examples:


images = mailup.console.images.list
images.size
=> 50

Returns:

  • (Array<String>)

    An array of Image strings.

See Also:



22
23
24
# File 'lib/mailup/console/images.rb', line 22

def list
  @api.get("#{@api.path}/Images")
end