/
recordings.rb
84 lines (76 loc) · 3.18 KB
/
recordings.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# frozen_string_literal: true
module Camper
class Client
# Defines methods related to recordings.
# @see https://github.com/basecamp/bc3-api/blob/master/sections/recordings.md
module RecordingsAPI
# Get a paginated response of recordings of a given type
#
# @example
# client.recordings('Todo')
# @example
# client.recordings(
# 'Document',
# bucket: [1,2],
# status: 'archived',
# sort: 'updated_at',
# direction: 'asc'
# )
#
# @param type [String] type of the recording
# @param options [Hash] extra options to filter the recordings to be resulted
# @return [PaginatedResponse<Resource>]
# @raise [Error::InvalidParameter] if type is not one of the allowed types
# @see https://github.com/basecamp/bc3-api/blob/master/sections/recordings.md#get-recordings
def recordings(type, options = {})
raise Error::InvalidParameter, type unless RecordingTypes.all.include?(type)
get('/projects/recordings', query: options.merge(type: type))
end
# Trash a given recording
#
# @example
# client.trash_recording(my_todo)
# @example
# client.trash_recording(my_message)
#
# @param recording [Resource] a resource of a valid recording type
# @raise [Error::InvalidParameter] if type field in recording param
# is not one of the allowed types
# @see https://github.com/basecamp/bc3-api/blob/master/sections/recordings.md#trash-a-recording
def trash_recording(recording)
raise Error::InvalidParameter, recording unless RecordingTypes.all.include?(recording.type)
put("/buckets/#{recording.bucket.id}/recordings/#{recording.id}/status/trashed")
end
# Archive a given recording
#
# @example
# client.archive_recording(my_todo)
# @example
# client.archive_recording(my_message)
#
# @param recording [Resource] a resource of a valid recording type
# @raise [Error::InvalidParameter] if type field in recording param
# is not one of the allowed types
# @see https://github.com/basecamp/bc3-api/blob/master/sections/recordings.md#archive-a-recording
def archive_recording(recording)
raise Error::InvalidParameter, recording unless RecordingTypes.all.include?(recording.type)
put("/buckets/#{recording.bucket.id}/recordings/#{recording.id}/status/archived")
end
# Unarchive a given recording
#
# @example
# client.unarchive_recording(my_todo)
# @example
# client.unarchive_recording(my_message)
#
# @param recording [Resource] a resource of a valid recording type
# @raise [Error::InvalidParameter] if type field in recording param
# is not one of the allowed types
# @see https://github.com/basecamp/bc3-api/blob/master/sections/recordings.md#unarchive-a-recording
def unarchive_recording(recording)
raise Error::InvalidParameter, recording unless RecordingTypes.all.include?(recording.type)
put("/buckets/#{recording.bucket.id}/recordings/#{recording.id}/status/active")
end
end
end
end