Class: Mailchimp::Gallery

Inherits:
Object
  • Object
show all
Defined in:
lib/mailchimp/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Gallery

Returns a new instance of Gallery.



2277
2278
2279
# File 'lib/mailchimp/api.rb', line 2277

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



2275
2276
2277
# File 'lib/mailchimp/api.rb', line 2275

def master
  @master
end

Instance Method Details

#add_file_to_folder(file_id, folder_id) ⇒ Boolean

Add a file to a folder

Parameters:

  • file_id (Int)

    the id of the file you want to add to a folder, as returned by the list call

  • folder_id (Int)

    the id of the folder to add the file to, as returned by the listFolders call

Returns:

  • (Boolean)

    true/false for success/failure



2341
2342
2343
2344
# File 'lib/mailchimp/api.rb', line 2341

def add_file_to_folder(file_id, folder_id)
    _params = {:file_id => file_id, :folder_id => folder_id}
    return @master.call 'gallery/add-file-to-folder', _params
end

#add_folder(name) ⇒ Hash

Adds a folder to the file gallery

Parameters:

  • name (String)

    the name of the folder to add (255 character max)

Returns:

  • (Hash)

    the new data for the created folder

    • Int

      data.id the id of the new folder



2324
2325
2326
2327
# File 'lib/mailchimp/api.rb', line 2324

def add_folder(name)
    _params = {:name => name}
    return @master.call 'gallery/add-folder', _params
end

#list(opts = []) ⇒ Hash

Return a section of the image gallery

Parameters:

  • opts (Hash) (defaults to: [])

    various options for controlling returned data

    • String

      type optional the gallery type to return - images or files - default to images

    • Int

      start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)

    • Int

      limit optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100

    • String

      sort_by optional field to sort by - one of size, time, name - defaults to time

    • String

      sort_dir optional field to sort by - one of asc, desc - defaults to desc

    • String

      search_term optional a term to search for in names

    • Int

      folder_id optional to return files that are in a specific folder. id returned by the list-folders call

Returns:

  • (Hash)

    the matching gallery items

    • Int

      total the total matching items

    • Array

      data structs for each item included in the set, including:

      - [Int] id the id of the file
      - [String] name the file name
      - [String] time the creation date for the item
      - [Int] size the file size in bytes
      - [String] full the url to the actual item in the gallery
      - [String] thumb a url for a thumbnail that can be used to represent the item, generally an image thumbnail or an icon for a file type
      


2299
2300
2301
2302
# File 'lib/mailchimp/api.rb', line 2299

def list(opts=[])
    _params = {:opts => opts}
    return @master.call 'gallery/list', _params
end

#list_folders(opts = []) ⇒ Hash

Return a list of the folders available to the file gallery

Parameters:

  • opts (Hash) (defaults to: [])

    various options for controlling returned data

    • Int

      start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)

    • Int

      limit optional for large data sets, the number of results to return - defaults to 25, upper limit set at 100

    • String

      search_term optional a term to search for in names

Returns:

  • (Hash)

    the matching gallery folders

    • Int

      total the total matching folders

    • Array

      data structs for each folder included in the set, including:

      - [Int] id the id of the folder
      - [String] name the file name
      - [Int] file_count the number of files in the folder
      


2315
2316
2317
2318
# File 'lib/mailchimp/api.rb', line 2315

def list_folders(opts=[])
    _params = {:opts => opts}
    return @master.call 'gallery/list-folders', _params
end

#remove_all_files_from_folder(folder_id) ⇒ Boolean

Remove all files from a folder (Note that the files are not deleted, they are only removed from the folder)

Parameters:

  • folder_id (Int)

    the id of the folder to remove the file from, as returned by the listFolders call

Returns:

  • (Boolean)

    true/false for success/failure



2358
2359
2360
2361
# File 'lib/mailchimp/api.rb', line 2358

def remove_all_files_from_folder(folder_id)
    _params = {:folder_id => folder_id}
    return @master.call 'gallery/remove-all-files-from-folder', _params
end

#remove_file_from_folder(file_id, folder_id) ⇒ Boolean

Remove a file from a folder

Parameters:

  • file_id (Int)

    the id of the file you want to remove from the folder, as returned by the list call

  • folder_id (Int)

    the id of the folder to remove the file from, as returned by the listFolders call

Returns:

  • (Boolean)

    true/false for success/failure



2350
2351
2352
2353
# File 'lib/mailchimp/api.rb', line 2350

def remove_file_from_folder(file_id, folder_id)
    _params = {:file_id => file_id, :folder_id => folder_id}
    return @master.call 'gallery/remove-file-from-folder', _params
end

#remove_folder(folder_id) ⇒ Boolean

Remove a folder

Parameters:

  • folder_id (Int)

    the id of the folder to remove, as returned by the listFolders call

Returns:

  • (Boolean)

    true/false for success/failure



2332
2333
2334
2335
# File 'lib/mailchimp/api.rb', line 2332

def remove_folder(folder_id)
    _params = {:folder_id => folder_id}
    return @master.call 'gallery/remove-folder', _params
end