Class: Mailchimp::Folders

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Folders

Returns a new instance of Folders.



7
8
9
# File 'lib/mailchimp/api.rb', line 7

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



5
6
7
# File 'lib/mailchimp/api.rb', line 5

def master
  @master
end

Instance Method Details

#add(name, type) ⇒ Hash

Add a new folder to file campaigns, autoresponders, or templates in

Parameters:

  • name (String)

    a unique name for a folder (max 100 bytes)

  • type (String)

    the type of folder to create - one of “campaign”, “autoresponder”, or “template”.

Returns:

  • (Hash)

    with a single value:

    • Int

      folder_id the folder_id of the newly created folder.



16
17
18
19
# File 'lib/mailchimp/api.rb', line 16

def add(name, type)
    _params = {:name => name, :type => type}
    return @master.call 'folders/add', _params
end

#del(fid, type) ⇒ Hash

Delete a campaign, autoresponder, or template folder. Note that this will simply make whatever was in the folder appear unfiled, no other data is removed

Parameters:

  • fid (Int)

    the folder id to delete - retrieve from folders/list()

  • type (String)

    the type of folder to delete - either “campaign”, “autoresponder”, or “template”

Returns:

  • (Hash)

    with a single entry:

    • Bool

      complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.



26
27
28
29
# File 'lib/mailchimp/api.rb', line 26

def del(fid, type)
    _params = {:fid => fid, :type => type}
    return @master.call 'folders/del', _params
end

#list(type) ⇒ Array

List all the folders of a certain type

Parameters:

  • type (String)

    the type of folders to return “campaign”, “autoresponder”, or “template”

Returns:

  • (Array)

    structs for each folder, including:

    • Int

      folder_id Folder Id for the given folder, this can be used in the campaigns/list() function to filter on.

    • String

      name Name of the given folder

    • String

      date_created The date/time the folder was created

    • String

      type The type of the folders being returned, just to make sure you know.

    • Int

      cnt number of items in the folder.



39
40
41
42
# File 'lib/mailchimp/api.rb', line 39

def list(type)
    _params = {:type => type}
    return @master.call 'folders/list', _params
end

#update(fid, name, type) ⇒ Hash

Update the name of a folder for campaigns, autoresponders, or templates

Parameters:

  • fid (Int)

    the folder id to update - retrieve from folders/list()

  • name (String)

    a new, unique name for the folder (max 100 bytes)

  • type (String)

    the type of folder to update - one of “campaign”, “autoresponder”, or “template”.

Returns:

  • (Hash)

    with a single entry:

    • Bool

      complete whether the call worked. reallistically this will always be true as errors will be thrown otherwise.



50
51
52
53
# File 'lib/mailchimp/api.rb', line 50

def update(fid, name, type)
    _params = {:fid => fid, :name => name, :type => type}
    return @master.call 'folders/update', _params
end