Class: Basecamp3::Vault

Inherits:
Model
  • Object
show all
Includes:
Concerns::Bucketable, Concerns::Creatorable, Concerns::Parentable
Defined in:
lib/basecamp3/models/vault.rb

Overview

Constant Summary

REQUIRED_FIELDS =
%w(title)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Parentable

#parent

Methods included from Concerns::Bucketable

#bucket

Methods included from Concerns::Creatorable

#creator

Methods inherited from Model

#initialize

Constructor Details

This class inherits a constructor from Basecamp3::Model

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at



9
10
11
# File 'lib/basecamp3/models/vault.rb', line 9

def created_at
  @created_at
end

#documents_countObject

Returns the value of attribute documents_count



9
10
11
# File 'lib/basecamp3/models/vault.rb', line 9

def documents_count
  @documents_count
end

#idObject

Returns the value of attribute id



9
10
11
# File 'lib/basecamp3/models/vault.rb', line 9

def id
  @id
end

#statusObject

Returns the value of attribute status



9
10
11
# File 'lib/basecamp3/models/vault.rb', line 9

def status
  @status
end

#titleObject

Returns the value of attribute title



9
10
11
# File 'lib/basecamp3/models/vault.rb', line 9

def title
  @title
end

#updated_atObject

Returns the value of attribute updated_at



9
10
11
# File 'lib/basecamp3/models/vault.rb', line 9

def updated_at
  @updated_at
end

#uploads_countObject

Returns the value of attribute uploads_count



9
10
11
# File 'lib/basecamp3/models/vault.rb', line 9

def uploads_count
  @uploads_count
end

#vaults_countObject

Returns the value of attribute vaults_count



9
10
11
# File 'lib/basecamp3/models/vault.rb', line 9

def vaults_count
  @vaults_count
end

Class Method Details

.all(bucket_id, parent_id, params = {}) ⇒ Array<Basecamp3::Vault>

Returns a paginated list of active vaults.

Parameters:

  • params (Hash) (defaults to: {})

    additional parameters

Options Hash (params):

  • :page (Integer) — default: optional

    to paginate results

Returns:



40
41
42
# File 'lib/basecamp3/models/vault.rb', line 40

def self.all(bucket_id, parent_id, params = {})
  Basecamp3.request.get("/buckets/#{bucket_id}/vaults/#{parent_id}/vaults", params, Basecamp3::Vault)
end

.create(bucket_id, parent_id, data) ⇒ Basecamp3::Vault

Creates a vault

Parameters:

  • bucket_id (Integer)

    the id of the bucket

  • parent_id (Integer)

    the id of the parent

  • data (Hash)

    the data to create a vault with

  • params (Hash)

    a customizable set of options

Returns:



62
63
64
65
# File 'lib/basecamp3/models/vault.rb', line 62

def self.create(bucket_id, parent_id, data)
  self.validate_required(data)
  Basecamp3.request.post("/buckets/#{bucket_id}/vaults/#{parent_id}/vaults", data, Basecamp3::Vault)
end

.find(bucket_id, id) ⇒ Basecamp3::Vault

Returns the vault.

Parameters:

  • bucket_id (Integer)

    the id of the bucket

  • id (Integer)

    the id of the vault

Returns:



50
51
52
# File 'lib/basecamp3/models/vault.rb', line 50

def self.find(bucket_id, id)
  Basecamp3.request.get("/buckets/#{bucket_id}/vaults/#{id}", {}, Basecamp3::Vault)
end

.update(bucket_id, id, data) ⇒ Basecamp3::Vault

Updates the vault

Parameters:

  • bucket_id (Integer)

    the id of the bucket

  • id (Integer)

    the id of the vault

  • data (Hash)

    the data to update the vault with

  • params (Hash)

    a customizable set of options

Returns:



75
76
77
78
# File 'lib/basecamp3/models/vault.rb', line 75

def self.update(bucket_id, id, data)
  self.validate_required(data)
  Basecamp3.request.put("/buckets/#{bucket_id}/vaults/#{id}", data, Basecamp3::Vault)
end

Instance Method Details

#documentsArray<Basecamp3::Document>

Returns a list of related documents.

Returns:



23
24
25
# File 'lib/basecamp3/models/vault.rb', line 23

def documents
  @mapped_documents ||= Basecamp3::Document.all(bucket.id, id)
end

#vaultsArray<Basecamp3::Vault>

Returns a list of related vaults.

Returns:



30
31
32
# File 'lib/basecamp3/models/vault.rb', line 30

def vaults
  @mapped_vaults ||= Basecamp3::Vault.all(bucket.id, id)
end