Class: Scene7::Folder

Inherits:
Object
  • Object
show all
Defined in:
lib/scene7/folder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Folder

Returns a new instance of Folder.



32
33
34
# File 'lib/scene7/folder.rb', line 32

def initialize(attributes)
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/scene7/folder.rb', line 3

def attributes
  @attributes
end

Class Method Details

.allObject



6
7
8
9
10
11
12
# File 'lib/scene7/folder.rb', line 6

def all
  response = Client.perform_request(:get_folders, :company_handle => Client.company_handle) 

  folder_hashes = response.to_hash[:get_folders_return][:folder_array][:items]

  folder_hashes.map { |folder_hash| self.new(folder_hash) }
end

.create(params) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/scene7/folder.rb', line 18

def create(params)
  raise ":folder_path is required to create a folder" unless params[:folder_path]

  base_request_params = {:company_handle => Client.company_handle, :order! => [:company_handle, :folder_path]}
  full_request_params = base_request_params.merge(params)

  response   = Client.perform_request(:create_folder, full_request_params)
  attributes = response.to_hash[:create_folder_return]

  new(attributes)
end

.find_by_handle(handle) ⇒ Object



14
15
16
# File 'lib/scene7/folder.rb', line 14

def find_by_handle(handle)
  all.detect { |folder| folder.handle == handle } 
end

Instance Method Details

#destroyObject



36
37
38
39
40
# File 'lib/scene7/folder.rb', line 36

def destroy
  response = Client.perform_request(:delete_folder, :company_handle => Client.company_handle, :folder_handle => self.handle, :order! => [:company_handle, :folder_handle])

  return response.http.code == 200
end

#handleObject

folderHandle



43
44
45
# File 'lib/scene7/folder.rb', line 43

def handle
  attributes[:folder_handle]
end

#has_subfoldersObject



55
56
57
# File 'lib/scene7/folder.rb', line 55

def has_subfolders
  attributes[:has_subfolders]
end

#last_modifiedObject



51
52
53
# File 'lib/scene7/folder.rb', line 51

def last_modified
  attributes[:last_modified]
end

#pathObject



47
48
49
# File 'lib/scene7/folder.rb', line 47

def path
  attributes[:path]
end