Class: Scene7::Folder
- Inherits:
-
Object
- Object
- Scene7::Folder
- Defined in:
- lib/scene7/folder.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
-
#handle ⇒ Object
folderHandle.
- #has_subfolders ⇒ Object
-
#initialize(attributes) ⇒ Folder
constructor
A new instance of Folder.
- #last_modified ⇒ Object
- #path ⇒ Object
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/scene7/folder.rb', line 3 def attributes @attributes end |
Class Method Details
.all ⇒ Object
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
#destroy ⇒ Object
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 |
#handle ⇒ Object
folderHandle
43 44 45 |
# File 'lib/scene7/folder.rb', line 43 def handle attributes[:folder_handle] end |
#has_subfolders ⇒ Object
55 56 57 |
# File 'lib/scene7/folder.rb', line 55 def has_subfolders attributes[:has_subfolders] end |
#last_modified ⇒ Object
51 52 53 |
# File 'lib/scene7/folder.rb', line 51 def last_modified attributes[:last_modified] end |
#path ⇒ Object
47 48 49 |
# File 'lib/scene7/folder.rb', line 47 def path attributes[:path] end |