basecamp3 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +2 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +65 -0
  8. data/Rakefile +6 -0
  9. data/basecamp3.gemspec +38 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/docs/Basecamp3.html +367 -0
  13. data/docs/Basecamp3/Campfire.html +901 -0
  14. data/docs/Basecamp3/CampfireLine.html +1025 -0
  15. data/docs/Basecamp3/Comment.html +1284 -0
  16. data/docs/Basecamp3/Concerns.html +117 -0
  17. data/docs/Basecamp3/Concerns/Bucketable.html +211 -0
  18. data/docs/Basecamp3/Concerns/Commentable.html +285 -0
  19. data/docs/Basecamp3/Concerns/Creatorable.html +209 -0
  20. data/docs/Basecamp3/Concerns/Parentable.html +211 -0
  21. data/docs/Basecamp3/Concerns/Recordingable.html +189 -0
  22. data/docs/Basecamp3/Concerns/Recordingable/ClassMethods.html +236 -0
  23. data/docs/Basecamp3/Document.html +1262 -0
  24. data/docs/Basecamp3/Forward.html +1070 -0
  25. data/docs/Basecamp3/Inbox.html +840 -0
  26. data/docs/Basecamp3/Message.html +1262 -0
  27. data/docs/Basecamp3/MessageBoard.html +840 -0
  28. data/docs/Basecamp3/MessageType.html +1160 -0
  29. data/docs/Basecamp3/Model.html +236 -0
  30. data/docs/Basecamp3/Person.html +1288 -0
  31. data/docs/Basecamp3/Project.html +1280 -0
  32. data/docs/Basecamp3/Question.html +1050 -0
  33. data/docs/Basecamp3/QuestionAnswer.html +887 -0
  34. data/docs/Basecamp3/Questionnaire.html +840 -0
  35. data/docs/Basecamp3/Request.html +933 -0
  36. data/docs/Basecamp3/ResponseParser.html +303 -0
  37. data/docs/Basecamp3/Schedule.html +840 -0
  38. data/docs/Basecamp3/ScheduleEntry.html +1560 -0
  39. data/docs/Basecamp3/Todo.html +1726 -0
  40. data/docs/Basecamp3/TodoList.html +1480 -0
  41. data/docs/Basecamp3/TodoSet.html +980 -0
  42. data/docs/Basecamp3/TypeMapper.html +329 -0
  43. data/docs/Basecamp3/Vault.html +1514 -0
  44. data/docs/_index.html +415 -0
  45. data/docs/class_list.html +51 -0
  46. data/docs/css/common.css +1 -0
  47. data/docs/css/full_list.css +58 -0
  48. data/docs/css/style.css +492 -0
  49. data/docs/file.README.html +157 -0
  50. data/docs/file_list.html +56 -0
  51. data/docs/frames.html +17 -0
  52. data/docs/index.html +157 -0
  53. data/docs/js/app.js +248 -0
  54. data/docs/js/full_list.js +216 -0
  55. data/docs/js/jquery.js +4 -0
  56. data/docs/method_list.html +1875 -0
  57. data/docs/top-level-namespace.html +110 -0
  58. data/lib/basecamp3.rb +61 -0
  59. data/lib/basecamp3/concerns/bucketable.rb +17 -0
  60. data/lib/basecamp3/concerns/commentable.rb +15 -0
  61. data/lib/basecamp3/concerns/creatorable.rb +16 -0
  62. data/lib/basecamp3/concerns/parentable.rb +17 -0
  63. data/lib/basecamp3/concerns/recordingable.rb +22 -0
  64. data/lib/basecamp3/model.rb +23 -0
  65. data/lib/basecamp3/models/campfire.rb +42 -0
  66. data/lib/basecamp3/models/campfire_line.rb +52 -0
  67. data/lib/basecamp3/models/comment.rb +65 -0
  68. data/lib/basecamp3/models/document.rb +71 -0
  69. data/lib/basecamp3/models/forward.rb +40 -0
  70. data/lib/basecamp3/models/inbox.rb +31 -0
  71. data/lib/basecamp3/models/message.rb +73 -0
  72. data/lib/basecamp3/models/message_board.rb +31 -0
  73. data/lib/basecamp3/models/message_type.rb +68 -0
  74. data/lib/basecamp3/models/person.rb +46 -0
  75. data/lib/basecamp3/models/project.rb +70 -0
  76. data/lib/basecamp3/models/question.rb +43 -0
  77. data/lib/basecamp3/models/question_answer.rb +35 -0
  78. data/lib/basecamp3/models/questionnaire.rb +31 -0
  79. data/lib/basecamp3/models/schedule.rb +31 -0
  80. data/lib/basecamp3/models/schedule_entry.rb +93 -0
  81. data/lib/basecamp3/models/todo.rb +108 -0
  82. data/lib/basecamp3/models/todo_list.rb +77 -0
  83. data/lib/basecamp3/models/todo_set.rb +33 -0
  84. data/lib/basecamp3/models/vault.rb +79 -0
  85. data/lib/basecamp3/request.rb +163 -0
  86. data/lib/basecamp3/response_parser.rb +44 -0
  87. data/lib/basecamp3/type_mapper.rb +53 -0
  88. data/lib/basecamp3/version.rb +3 -0
  89. metadata +202 -0
@@ -0,0 +1,35 @@
1
+ # A model for Basecamp's Question Answer
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/question_answers.md#question-answers For more information, see the official Basecamp3 API documentation for Question Answers}
4
+ class Basecamp3::QuestionAnswer < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+ include Basecamp3::Concerns::Parentable
8
+
9
+ attr_accessor :id,
10
+ :status,
11
+ :created_at,
12
+ :updated_at,
13
+ :content,
14
+ :group_on
15
+
16
+ # Returns a paginated list of answers.
17
+ #
18
+ # @param [Hash] params additional parameters
19
+ # @option params [Integer] :page (optional) to paginate results
20
+ #
21
+ # @return [Array<Basecamp3::QuestionAnswer>]
22
+ def self.all(bucket_id, parent_id, params = {})
23
+ Basecamp3.request.get("/buckets/#{bucket_id}/questions/#{parent_id}/answers", params, Basecamp3::QuestionAnswer)
24
+ end
25
+
26
+ # Returns the answer.
27
+ #
28
+ # @param [Integer] bucket_id the id of the bucket
29
+ # @param [Integer] id the id of the question
30
+ #
31
+ # @return [Basecamp3::QuestionAnswer]
32
+ def self.find(bucket_id, id)
33
+ Basecamp3.request.get("/buckets/#{bucket_id}/question_answers/#{id}", {}, Basecamp3::QuestionAnswer)
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ # A model for Basecamp's Questionnaire
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/questionnaires.md#questionnaires For more information, see the official Basecamp3 API documentation for Questionnaires}
4
+ class Basecamp3::Questionnaire < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+
8
+ attr_accessor :id,
9
+ :status,
10
+ :created_at,
11
+ :updated_at,
12
+ :name,
13
+ :questions_count
14
+
15
+ # Returns a list of related questions.
16
+ #
17
+ # @return [Array<Basecamp3::Question>]
18
+ def questions
19
+ @mapped_questions ||= Basecamp3::Question.all(bucket.id, id)
20
+ end
21
+
22
+ # Returns the questionnaire.
23
+ #
24
+ # @param [Integer] bucket_id the id of the bucket
25
+ # @param [Integer] id the id of the questionnaire
26
+ #
27
+ # @return [Basecamp3::Questionnaire]
28
+ def self.find(bucket_id, id)
29
+ Basecamp3.request.get("/buckets/#{bucket_id}/questionnaires/#{id}", {}, Basecamp3::Questionnaire)
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ # A model for Basecamp's Schedule
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/schedules.md#schedules For more information, see the official Basecamp3 API documentation for Schedules}
4
+ class Basecamp3::Schedule < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+
8
+ attr_accessor :id,
9
+ :status,
10
+ :created_at,
11
+ :updated_at,
12
+ :title,
13
+ :entries_count
14
+
15
+ # Returns a list of related entries.
16
+ #
17
+ # @return [Array<Basecamp3::ScheduleEntry>]
18
+ def entries
19
+ @mapped_entries ||= Basecamp3::ScheduleEntry.all(bucket.id, id)
20
+ end
21
+
22
+ # Returns the schedule.
23
+ #
24
+ # @param [Integer] bucket_id the id of the bucket
25
+ # @param [Integer] id the id of the schedule
26
+ #
27
+ # @return [Basecamp3::Schedule]
28
+ def self.find(bucket_id, id)
29
+ Basecamp3.request.get("/buckets/#{bucket_id}/schedules/#{id}", {}, Basecamp3::Schedule)
30
+ end
31
+ end
@@ -0,0 +1,93 @@
1
+ # A model for Basecamp's Schedule Entry
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/schedule_entries.md#schedule-entries For more information, see the official Basecamp3 API documentation for Schedule entries}
4
+ class Basecamp3::ScheduleEntry < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+ include Basecamp3::Concerns::Parentable
8
+ include Basecamp3::Concerns::Recordingable
9
+ include Basecamp3::Concerns::Commentable
10
+
11
+ attr_accessor :id,
12
+ :status,
13
+ :created_at,
14
+ :updated_at,
15
+ :summary,
16
+ :description,
17
+ :starts_at,
18
+ :ends_at,
19
+ :all_day
20
+
21
+ REQUIRED_FIELDS = %w(summary starts_at ends_at)
22
+
23
+ # Returns a list of related participants.
24
+ #
25
+ # @return [Array<Basecamp3::Person>]
26
+ def participants
27
+ return [] if @participants.nil?
28
+
29
+ @mapped_participants ||= @participants.map{ |p| Basecamp3::Person.new(p) }
30
+ end
31
+
32
+ # Returns a paginated list of active schedule entries.
33
+ #
34
+ # @param [Hash] params additional parameters
35
+ # @option params [Integer] :page (optional) to paginate results
36
+ # @option params [Integer] :status (optional) when set to archived or trashed, will return archived or trashed schedule entries that are in this schedule
37
+ #
38
+ # @return [Array<Basecamp3::ScheduleEntry>]
39
+ def self.all(bucket_id, parent_id, params = {})
40
+ Basecamp3.request.get("/buckets/#{bucket_id}/schedules/#{parent_id}/entries", params, Basecamp3::ScheduleEntry)
41
+ end
42
+
43
+ # Returns the schedule entry.
44
+ #
45
+ # @param [Integer] bucket_id the id of the bucket
46
+ # @param [Integer] id the id of the schedule entry
47
+ #
48
+ # @return [Basecamp3::ScheduleEntry]
49
+ def self.find(bucket_id, id)
50
+ Basecamp3.request.get("/buckets/#{bucket_id}/schedule_entries/#{id}", {}, Basecamp3::ScheduleEntry)
51
+ end
52
+
53
+
54
+ # Creates a schedule entry.
55
+ #
56
+ # @param [Integer] bucket_id the id of the bucket
57
+ # @param [Integer] parent_id the id of the schedule
58
+ # @param [Hash] data the data to create a schedule entry with
59
+ # @option params [Integer] :summary (required) what this schedule entry is about
60
+ # @option params [Integer] :starts_at (required) timestamp for when this schedule entry begins
61
+ # @option params [Integer] :ends_at (required) timestamp for when this schedule entry ends
62
+ # @option params [String] :description (optional) containing more information about the schedule entry
63
+ # @option params [Array<Integer>] :participant_ids (optional) an array of people IDs that will participate in this entry
64
+ # @option params [Boolean] :all_day (optional) when set to true, the schedule entry will not have a specific start or end time,
65
+ # and instead will be held for the entire day or days denoted in starts_at and ends_at
66
+ # @option params [Boolean] :notify (optional) when set to true, will notify the participants about the entry
67
+ #
68
+ # @return [Basecamp3::ScheduleEntry]
69
+ def self.create(bucket_id, parent_id, data)
70
+ self.validate_required(data)
71
+ Basecamp3.request.post("/buckets/#{bucket_id}/schedules/#{parent_id}/entries", data, Basecamp3::ScheduleEntry)
72
+ end
73
+
74
+ # Updates the schedule entry.
75
+ #
76
+ # @param [Integer] bucket_id the id of the bucket
77
+ # @param [Integer] id the id of the schedule entry
78
+ # @param [Hash] data the data to update the schedule entry with
79
+ # @option params [Integer] :summary (required) what this schedule entry is about
80
+ # @option params [Integer] :starts_at (required) timestamp for when this schedule entry begins
81
+ # @option params [Integer] :ends_at (required) timestamp for when this schedule entry ends
82
+ # @option params [String] :description (optional) containing more information about the schedule entry
83
+ # @option params [Array<Integer>] :participant_ids (optional) an array of people IDs that will participate in this entry
84
+ # @option params [Boolean] :all_day (optional) when set to true, the schedule entry will not have a specific start or end time,
85
+ # and instead will be held for the entire day or days denoted in starts_at and ends_at
86
+ # @option params [Boolean] :notify (optional) when set to true, will notify the participants about the entry
87
+ #
88
+ # @return [Basecamp3::ScheduleEntry]
89
+ def self.update(bucket_id, id, data)
90
+ self.validate_required(data)
91
+ Basecamp3.request.put("/buckets/#{bucket_id}/schedule_entries/#{id}", data, Basecamp3::ScheduleEntry)
92
+ end
93
+ end
@@ -0,0 +1,108 @@
1
+ # A model for Basecamp's TODO
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/todos.md#to-dos For more information, see the official Basecamp3 API documentation for TODOs}
4
+ class Basecamp3::Todo < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+ include Basecamp3::Concerns::Parentable
8
+ include Basecamp3::Concerns::Recordingable
9
+ include Basecamp3::Concerns::Commentable
10
+
11
+ attr_accessor :id,
12
+ :status,
13
+ :created_at,
14
+ :updated_at,
15
+ :content,
16
+ :description,
17
+ :starts_on,
18
+ :due_on
19
+
20
+ REQUIRED_FIELDS = %w(content)
21
+
22
+ # Returns a list of related assignees.
23
+ #
24
+ # @return [Array<Basecamp3::Person>]
25
+ def assignees
26
+ @mapped_assignees ||= @assignees.map{ |a| Basecamp3::Person.new(a) }
27
+ end
28
+
29
+ # Returns a paginated list of active TODOs.
30
+ #
31
+ # @param [Hash] params additional parameters
32
+ # @option params [String] :status (optional) when set to archived or trashed, will return archived or trashed to-dos that are in this list
33
+ # @option params [Boolean] :completed (optional) when set to true, will only return to-dos that are completed
34
+ # @option params [Integer] :page (optional) to paginate results
35
+ #
36
+ # @return [Array<Basecamp3::Todo>]
37
+ def self.all(bucket_id, parent_id, params = {})
38
+ Basecamp3.request.get("/buckets/#{bucket_id}/todolists/#{parent_id}/todos", params, Basecamp3::Todo)
39
+ end
40
+
41
+ # Returns the TODO.
42
+ #
43
+ # @param [Integer] bucket_id the id of the bucket
44
+ # @param [Integer] id the id of the TODO
45
+ #
46
+ # @return [Basecamp3::Todo]
47
+ def self.find(bucket_id, id)
48
+ Basecamp3.request.get("/buckets/#{bucket_id}/todos/#{id}", {}, Basecamp3::Todo)
49
+ end
50
+
51
+ # Creates a TODO.
52
+ #
53
+ # @param [Integer] bucket_id the id of the bucket
54
+ # @param [Integer] parent_id the id of the TODO list
55
+ # @param [Hash] data the data to create a TODO with
56
+ # @option params [String] :content (required) for what the to-do is for
57
+ # @option params [String] :description (optional) containing information about the to-do
58
+ # @option params [Array<Integer>] :assignee_ids (optional) an array of people that will be assigned to this to-do
59
+ # @option params [Boolean] :notify (optional) when set to true, will notify the assignees about being assigned
60
+ # @option params [Date] :due_on (optional) a date when the to-do should be completed
61
+ # @option params [Date] :starts_on (optional) allows the to-do to run from this date to the due_on date
62
+ #
63
+ # @return [Basecamp3::Todo]
64
+ def self.create(bucket_id, parent_id, data)
65
+ self.validate_required(data)
66
+ Basecamp3.request.post("/buckets/#{bucket_id}/todolists/#{parent_id}/todos", data, Basecamp3::Todo)
67
+ end
68
+
69
+ # Updates the TODO.
70
+ #
71
+ # REMEMBER: Pass all existing parameters in addition to those being updated!
72
+ #
73
+ # @param [Integer] bucket_id the id of the bucket
74
+ # @param [Integer] id the id of the TODO
75
+ # @param [Hash] data the data to update the TODO with
76
+ # @option params [String] :content (required) for what the to-do is for
77
+ # @option params [String] :description (optional) containing information about the to-do
78
+ # @option params [Array<Integer>] :assignee_ids (optional) an array of people that will be assigned to this to-do
79
+ # @option params [Boolean] :notify (optional) when set to true, will notify the assignees about being assigned
80
+ # @option params [Date] :due_on (optional) a date when the to-do should be completed
81
+ # @option params [Date] :starts_on (optional) allows the to-do to run from this date to the due_on date
82
+ #
83
+ # @return [Basecamp3::Todo]
84
+ def self.update(bucket_id, id, data)
85
+ self.validate_required(data)
86
+ Basecamp3.request.put("/buckets/#{bucket_id}/todos/#{id}", data, Basecamp3::Todo)
87
+ end
88
+
89
+ # Completes the TODO.
90
+ #
91
+ # @param [Integer] bucket_id the id of the bucket
92
+ # @param [Integer] id the id of the TODO
93
+ #
94
+ # @return [Boolean]
95
+ def self.complete(bucket_id, id)
96
+ Basecamp3.request.post("/buckets/#{bucket_id}/todos/#{id}/completion")
97
+ end
98
+
99
+ # Incompletes the TODO.
100
+ #
101
+ # @param [Integer] bucket_id the id of the bucket
102
+ # @param [Integer] id the id of the TODO
103
+ #
104
+ # @return [Boolean]
105
+ def self.incomplete(bucket_id, id)
106
+ Basecamp3.request.delete("/buckets/#{bucket_id}/todos/#{id}/completion")
107
+ end
108
+ end
@@ -0,0 +1,77 @@
1
+ # A model for Basecamp's TODO List
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/todolists.md#to-do-lists For more information, see the official Basecamp3 API documentation for TODO lists}
4
+ class Basecamp3::TodoList < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+ include Basecamp3::Concerns::Parentable
8
+ include Basecamp3::Concerns::Recordingable
9
+ include Basecamp3::Concerns::Commentable
10
+
11
+ attr_accessor :id,
12
+ :status,
13
+ :created_at,
14
+ :updated_at,
15
+ :name,
16
+ :description,
17
+ :completed,
18
+ :completed_ratio
19
+
20
+ REQUIRED_FIELDS = %w(name)
21
+
22
+ # Returns a list of related todos.
23
+ #
24
+ # @return [Array<Basecamp3::Todo>]
25
+ def todos
26
+ @mapped_todos ||= Basecamp3::Todo.all(bucket.id, id)
27
+ end
28
+
29
+ # Returns a paginated list of active TODO lists.
30
+ #
31
+ # @param [Hash] params additional parameters
32
+ # @option params [String] :status (optional) when set to archived or trashed, will return archived or trashed to-do lists that are in this to-do list
33
+ # @option params [Integer] :page (optional) to paginate results
34
+ #
35
+ # @return [Array<Basecamp3::TodoList>]
36
+ def self.all(bucket_id, parent_id, params = {})
37
+ Basecamp3.request.get("/buckets/#{bucket_id}/todosets/#{parent_id}/todolists", params, Basecamp3::TodoList)
38
+ end
39
+
40
+ # Returns the TODO list.
41
+ #
42
+ # @param [Integer] bucket_id the id of the bucket
43
+ # @param [Integer] id the id of the TODO list
44
+ #
45
+ # @return [Basecamp3::TodoList]
46
+ def self.find(bucket_id, id)
47
+ Basecamp3.request.get("/buckets/#{bucket_id}/todolists/#{id}", {}, Basecamp3::TodoList)
48
+ end
49
+
50
+ # Creates a TODO list.
51
+ #
52
+ # @param [Integer] bucket_id the id of the bucket
53
+ # @param [Integer] parent_id the id of the TODO set
54
+ # @param [Hash] data the data to create a TODO list with
55
+ # @option params [String] :name (required) the name of the to-do list
56
+ # @option params [String] :description (optional) containing information about the to-do list
57
+ #
58
+ # @return [Basecamp3::TodoList]
59
+ def self.create(bucket_id, parent_id, data)
60
+ self.validate_required(data)
61
+ Basecamp3.request.post("/buckets/#{bucket_id}/todosets/#{parent_id}/todolists", data, Basecamp3::TodoList)
62
+ end
63
+
64
+ # Updates the TODO list.
65
+ #
66
+ # @param [Integer] bucket_id the id of the bucket
67
+ # @param [Integer] id the id of the TODO list
68
+ # @param [Hash] data the data to create the TODO list with
69
+ # @option params [String] :name (required) the name of the to-do list
70
+ # @option params [String] :description (optional) containing information about the to-do list
71
+ #
72
+ # @return [Basecamp3::TodoList]
73
+ def self.update(bucket_id, id, data)
74
+ self.validate_required(data)
75
+ Basecamp3.request.put("/buckets/#{bucket_id}/todolists/#{id}", data, Basecamp3::TodoList)
76
+ end
77
+ end
@@ -0,0 +1,33 @@
1
+ # A model for Basecamp's TODO Set
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/todosets.md#to-do-sets For more information, see the official Basecamp3 API documentation for TODO sets}
4
+ class Basecamp3::TodoSet < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+
8
+ attr_accessor :id,
9
+ :status,
10
+ :created_at,
11
+ :updated_at,
12
+ :name,
13
+ :todolists_count,
14
+ :completed,
15
+ :completed_ratio
16
+
17
+ # Returns a list of related todo lists.
18
+ #
19
+ # @return [Array<Basecamp3::TodoList>]
20
+ def todo_lists
21
+ @mapped_todo_lists ||= Basecamp3::TodoList.all(bucket.id, id)
22
+ end
23
+
24
+ # Returns the TODO set.
25
+ #
26
+ # @param [Integer] bucket_id the id of the bucket
27
+ # @param [Integer] id the id of the TODO set
28
+ #
29
+ # @return [Basecamp3::TodoSet]
30
+ def self.find(bucket_id, id)
31
+ Basecamp3.request.get("/buckets/#{bucket_id}/todosets/#{id}", {}, Basecamp3::TodoSet)
32
+ end
33
+ end
@@ -0,0 +1,79 @@
1
+ # A model for Basecamp's Vault
2
+ #
3
+ # {https://github.com/basecamp/bc3-api/blob/master/sections/vaults.md#vaults For more information, see the official Basecamp3 API documentation for Vaults}
4
+ class Basecamp3::Vault < Basecamp3::Model
5
+ include Basecamp3::Concerns::Creatorable
6
+ include Basecamp3::Concerns::Bucketable
7
+ include Basecamp3::Concerns::Parentable
8
+
9
+ attr_accessor :id,
10
+ :status,
11
+ :created_at,
12
+ :updated_at,
13
+ :title,
14
+ :documents_count,
15
+ :uploads_count,
16
+ :vaults_count
17
+
18
+ REQUIRED_FIELDS = %w(title)
19
+
20
+ # Returns a list of related documents.
21
+ #
22
+ # @return [Array<Basecamp3::Document>]
23
+ def documents
24
+ @mapped_documents ||= Basecamp3::Document.all(bucket.id, id)
25
+ end
26
+
27
+ # Returns a list of related vaults.
28
+ #
29
+ # @return [Array<Basecamp3::Vault>]
30
+ def vaults
31
+ @mapped_vaults ||= Basecamp3::Vault.all(bucket.id, id)
32
+ end
33
+
34
+ # Returns a paginated list of active vaults.
35
+ #
36
+ # @param [Hash] params additional parameters
37
+ # @option params [Integer] :page (optional) to paginate results
38
+ #
39
+ # @return [Array<Basecamp3::Vault>]
40
+ def self.all(bucket_id, parent_id, params = {})
41
+ Basecamp3.request.get("/buckets/#{bucket_id}/vaults/#{parent_id}/vaults", params, Basecamp3::Vault)
42
+ end
43
+
44
+ # Returns the vault.
45
+ #
46
+ # @param [Integer] bucket_id the id of the bucket
47
+ # @param [Integer] id the id of the vault
48
+ #
49
+ # @return [Basecamp3::Vault]
50
+ def self.find(bucket_id, id)
51
+ Basecamp3.request.get("/buckets/#{bucket_id}/vaults/#{id}", {}, Basecamp3::Vault)
52
+ end
53
+
54
+ # Creates a vault
55
+ #
56
+ # @param [Integer] bucket_id the id of the bucket
57
+ # @param [Integer] parent_id the id of the parent
58
+ # @param [Hash] data the data to create a vault with
59
+ # @option params [String] :title (required) the name of the vault
60
+ #
61
+ # @return [Basecamp3::Vault]
62
+ def self.create(bucket_id, parent_id, data)
63
+ self.validate_required(data)
64
+ Basecamp3.request.post("/buckets/#{bucket_id}/vaults/#{parent_id}/vaults", data, Basecamp3::Vault)
65
+ end
66
+
67
+ # Updates the vault
68
+ #
69
+ # @param [Integer] bucket_id the id of the bucket
70
+ # @param [Integer] id the id of the vault
71
+ # @param [Hash] data the data to update the vault with
72
+ # @option params [String] :title (required) the name of the vault
73
+ #
74
+ # @return [Basecamp3::Vault]
75
+ def self.update(bucket_id, id, data)
76
+ self.validate_required(data)
77
+ Basecamp3.request.put("/buckets/#{bucket_id}/vaults/#{id}", data, Basecamp3::Vault)
78
+ end
79
+ end