class Basecamp3::Document

A model for Basecamp's Document

{github.com/basecamp/bc3-api/blob/master/sections/documents.md#documents For more information, see the official Basecamp3 API documentation for Documents}

Constants

REQUIRED_FIELDS

Attributes

content[RW]
created_at[RW]
id[RW]
status[RW]
title[RW]
updated_at[RW]

Public Class Methods

all(bucket_id, parent_id, params = {}) click to toggle source

Returns a paginated list of active documents.

@param [Integer] bucket_id the id of the bucket @param [Integer] parent_id the id of the parent @param [Hash] params additional parameters @option params [Integer] :page (optional) to paginate results

@return [Array<Basecamp3::Document>]

# File lib/basecamp3/models/document.rb, line 28
def self.all(bucket_id, parent_id, params = {})
  Basecamp3.request.get("/buckets/#{bucket_id}/vaults/#{parent_id}/documents", params, Basecamp3::Document)
end
create(bucket_id, parent_id, data) click to toggle source

Creates a document.

@param [Integer] bucket_id the id of the bucket @param [Integer] parent_id the id of the parent @param [Hash] data the data to create a Document with @option params [Integer] :title (required) the title of the document @option params [String] :content (required) the body of the document @option params [String] :status (optional) set to active to publish immediately

@return [Basecamp3::Document]

# File lib/basecamp3/models/document.rb, line 52
def self.create(bucket_id, parent_id, data)
  self.validate_required(data)
  Basecamp3.request.post("/buckets/#{bucket_id}/vaults/#{parent_id}/documents", data, Basecamp3::Document)
end
find(bucket_id, id) click to toggle source

Returns the document.

@param [Integer] bucket_id the id of the bucket @param [Integer] id the id of the document

@return [Basecamp3::Document]

# File lib/basecamp3/models/document.rb, line 38
def self.find(bucket_id, id)
  Basecamp3.request.get("/buckets/#{bucket_id}/documents/#{id}", {}, Basecamp3::Document)
end
update(bucket_id, id, data) click to toggle source

Updates the document.

@param [Integer] bucket_id the id of the bucket @param [Integer] id the id of the document @param [Hash] data the data to update the document with @option params [Integer] :title (required) the title of the document @option params [String] :content (required) the body of the document @option params [String] :status (optional) set to active to publish immediately

@return [Basecamp3::Document]

# File lib/basecamp3/models/document.rb, line 67
def self.update(bucket_id, id, data)
  self.validate_required(data)
  Basecamp3.request.put("/buckets/#{bucket_id}/documents/#{id}", data, Basecamp3::Document)
end