caplinked-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1568ddaa89503af24bb15227d4ad25a7c752fbb7
4
+ data.tar.gz: 55d9ab2ffb151391c1f879d4c448da07cba0e27b
5
+ SHA512:
6
+ metadata.gz: 98c93038ae6bcd3a146090ce82c993f396479a32864947ac108c8e1195383b6661c93c2784dc81ac65725eda135fd5b136dfde8c05f19c36f81636f1c13aa06d
7
+ data.tar.gz: 6dc46295c26db4b9e09179c2cfb1c09cb4e610a6d6df9bb43ee59c19c782f469b94deeeba14b6a6c74e7400935bdc69060cd41b4298d40e5aa3f7089d9b533e6
data/README.md ADDED
@@ -0,0 +1,326 @@
1
+ # caplinked-api
2
+
3
+ Ruby SDK for Caplinked's API
4
+ Documentation at https://developer.caplinked.com/docs
5
+
6
+ ## Quick start guide:
7
+
8
+ Add Rubygem to Bundle:
9
+
10
+ ```
11
+ gem 'caplinked-api'
12
+ ```
13
+
14
+ Assign Client
15
+
16
+ ```
17
+ client = Caplinked::Client.new api_key: 'YOUR_KEY_HERE', api_host: 'sandbox.caplinked.com', api_scheme: 'https'
18
+ ```
19
+ ## Activities:
20
+
21
+ Get Workspace Activities:
22
+
23
+ ```
24
+ get_workspace_activities = client.client.get_workspace_activities workspace_id: 1, user_id: user[:id]
25
+ ```
26
+
27
+ ## Downloads:
28
+
29
+ Create a zip file
30
+
31
+ ```
32
+ create_zip_file = client.create_zip_file workspace_id: 1, download: { folder_ids: [folder[:id], folder[:id]] }
33
+ ```
34
+
35
+ Download a single file
36
+
37
+ ```
38
+ single_file_download = client.single_file_download file_id: file_info[:id], workspace_id: 1
39
+ ```
40
+
41
+ Download status
42
+
43
+ ```
44
+ download_status = client.download_status workspace_id: 1
45
+ ```
46
+
47
+ Delete download
48
+
49
+ ```
50
+ delete_download = client.delete_download id: download[:id], workspace_id: 1
51
+ ```
52
+
53
+ Get zip
54
+
55
+ ```
56
+ get_zip = client.get_zip id: download[:id], workspace_id: 1
57
+ ```
58
+
59
+ ## Files:
60
+
61
+ Upload a File:
62
+
63
+ ```
64
+ new_file = client.upload_file workspace_id: 1, folder_id: 1, file_name: 'test_photo.jpg', file: File.read('/your/local/test_photo.jpg')
65
+ ```
66
+
67
+ Get File info:
68
+
69
+ ```
70
+ file_info = client.get_file_info id: new_file[:id], workspace_id: 1
71
+ ```
72
+
73
+ Delete File:
74
+
75
+ ```
76
+ delete_file = client.delete_file workspace_id: 1, id: file_info[:id]
77
+ ```
78
+
79
+ Update File info:
80
+
81
+ ```
82
+ update_file = client.update_file_info workspace_id: 1, id: file_info[:id], 'file[title]': 'name', 'file[index]': file[:index]
83
+ ```
84
+
85
+ Copy File:
86
+
87
+ ```
88
+ copy_file = client.copy_file id: file_info[:id], workspace_id: 1, destination_folder_id: folder[:id]
89
+ ```
90
+
91
+ Move File:
92
+
93
+ ```
94
+ move_file = client.move_file id: file_info[:id], workspace_id: 1, destination_folder_id: folder[:id]
95
+ ```
96
+
97
+ ## Folders:
98
+
99
+ Create a folder
100
+
101
+ ```
102
+ create_a_new_folder = client.create_a_new_folder workspace_id: 1, parent_id: folder[:id], name: 'name'
103
+ ```
104
+
105
+ Delete folder
106
+
107
+ ```
108
+ delete_folder = client.delete_folder workspace_id: 1, id: folder[:id]
109
+ ```
110
+
111
+ Get folder info
112
+
113
+ ```
114
+ get_folder_info = client.get_folder_info workspace_id: 1, id: folder[:id]
115
+ ```
116
+
117
+ Update folder info
118
+
119
+ ```
120
+ update_folder_info = client.update_folder_info id: folder[:id], workspace_id: 1, folder: { name: 'name', index: folder[:index]}
121
+ ```
122
+
123
+ Copy folder
124
+
125
+ ```
126
+ copy_folder = client.copy_folder id: folder[:id], workspace_id: 1, destination_folder_id: folder[:id]
127
+ ```
128
+
129
+ Move folder
130
+
131
+ ```
132
+ move_folder = client.move_folder id: folder[:id], workspace_id: 1, destination_folder_id: folder[:id]
133
+ ```
134
+
135
+ ##Groups:
136
+ List all groups in workspace
137
+
138
+ ```
139
+ list_all_groups_in_workspace = client.list_all_groups_in_workspace workspace_id: 1
140
+ ```
141
+
142
+ Create group
143
+
144
+ ```
145
+ create_group = client.create_group group: {name: 'name', workspace_id: 1, file_managing_abilities: false}
146
+ ```
147
+ Update group
148
+
149
+ ```
150
+ update_group = client.update_group id: group[:id], workspace_id: 1, group: {name: 'name', file_managing_abilities: true}
151
+ ```
152
+ Get group info
153
+
154
+ ```
155
+ get_group_info = client.get_group_info id: group[:id], workspace_id: 1
156
+ ```
157
+ Delete group
158
+
159
+ ```
160
+ get_group_info = client.get_group_info id: group[:id], workspace_id: 1
161
+ ```
162
+ Update group drm
163
+
164
+ ```
165
+ update_group_drm = client.update_group_drm id: group[:id], workspace_id: 1, group: {drm_enabled: true, drm_expires_after: 'YYYY-MM-DD'}
166
+ ```
167
+ Disable drm expiration
168
+
169
+ ```
170
+ disable_drm_expiration = client.disable_drm_expiration id: group[:id], workspace_id: 1
171
+ ```
172
+ Watermarking for group
173
+
174
+ ```
175
+ watermarking_for_group = client.watermarking_for_group id: group[:id], workspace_id: 1, group: {watermarking: true}
176
+ ```
177
+ Enable access expiration
178
+
179
+ ```
180
+ enable_access_expiration = client.enable_access_expiration id: group[:id], workspace_id: 1, group: {expire_workspace_access_at: "YYYY-MM-DD"}
181
+ ```
182
+ Disable access expiration
183
+
184
+ ```
185
+ disable_access_expiration = client.disable_access_expiration id: group[:id], workspace_id: 1
186
+ ```
187
+ Add group member
188
+
189
+ ```
190
+ add_group_member = client.add_group_member id: group[:id], user_id: user[:id], workspace_id: 1, send_email: false
191
+ ```
192
+ Remove group member
193
+
194
+ ```
195
+ remove_group_member = client.remove_group_member id: group[:id], user_id: user[:id], workspace_id: 1
196
+ ```
197
+
198
+ List all group members
199
+
200
+ ```
201
+ list_all_group_members = client.list_all_group_members id: group[:id], workspace_id: 1
202
+ ```
203
+
204
+ ##Organizations
205
+
206
+ Get organization info
207
+
208
+ ```
209
+ get_organization_info = client.get_organization_info id: organization[:id]
210
+ ```
211
+ Update organization info
212
+
213
+ ```
214
+ update_organization_info = client.update_organization_info id: organization[:id], name: 'name', description: 'description', location: 'location', billing_email: 'billing email address', url: 'url'
215
+ ```
216
+
217
+ Update organization support info
218
+
219
+ ```
220
+ update_organization_support_info = client.update_organization_support_info id: organization[:id], email: 'support email', phone_number: 'support phone number', website: 'support website'
221
+ ```
222
+ Add organization member
223
+
224
+ ```
225
+ add_organization_member = client.add_organization_member id: organization[:id], user_id: user[:id]
226
+ ```
227
+ remove organization member
228
+
229
+ ```
230
+ remove_organization_member = client.remove_organization_member id: 4639, user_id: 101
231
+ ```
232
+ show organization members
233
+
234
+ ```
235
+ show_organization_members = client.show_organization_members id: organization[:id]
236
+ ```
237
+
238
+ ##Permissions
239
+
240
+ Get folder permissions
241
+
242
+ ```
243
+ get_folder_permissions = client.get_folder_permissions id: folder[:id], workspace_id: 1, group_id: group[:id]
244
+ ```
245
+ Update folder permissions
246
+
247
+ ```
248
+ update_folder_permissions = client.update_folder_permissions id: folder[:id], workspace_id: 1, group_id: group[:id], verb: 'grant', folder_action: 'download'
249
+ ```
250
+
251
+ ##Teams
252
+
253
+ Create team
254
+
255
+ ```
256
+ create_team = client.create_team team: { name: 'name', allowed_workspaces: 5, allowed_admins: 5, drm_enabled: false, watermarking: false, suppress_emails: false }
257
+ ```
258
+ Get team info
259
+
260
+ ```
261
+ get_team_info = client.get_team_info id: team[:id]
262
+ ```
263
+
264
+ Update team info
265
+
266
+ ```
267
+ update_team = client.update_team_info id: 183, team: { name: 'name', allowed_workspaces: 10, allowed_admins: 10, drm_enabled: true, watermarking: true, suppress_emails: true }
268
+ ```
269
+ Add team member
270
+
271
+ ```
272
+ add_team_member = client.add_team_member id: team[:id], user_id: user[:id]
273
+ ```
274
+ Remove team member
275
+
276
+ ```
277
+ remove_team_member = client.remove_team_member id: team[:id], user_id: user[:id]
278
+ ```
279
+
280
+ Get list of team members
281
+
282
+ ```
283
+ get_list_of_team_members = client.get_list_of_team_members id: team[:id]
284
+ ```
285
+
286
+ ##Users
287
+
288
+ Create user
289
+
290
+ ```
291
+ create_user = client.create_user user: { email: 'email address', first_name: 'first name', last_name: 'last name', time_zone: "Pacific Time (US & Canada)" }
292
+ ```
293
+
294
+ Get user info
295
+
296
+ ```
297
+ get_user_info = client.get_user_info
298
+ ```
299
+ Update user
300
+
301
+ ```
302
+ update_user = client.update_user user: { email: 'new email address'}
303
+ ```
304
+
305
+ ##Workspace
306
+ List all workspaces for a team
307
+
308
+ ```
309
+ list_all_workspaces_for_a_team = client.list_all_workspaces_for_a_team team_id: team[:id]
310
+ ```
311
+ Create Workspace
312
+
313
+ ```
314
+ create_workspace = client.create_workspace team_id: team[:id], workspace: { name: 'name'}
315
+ ```
316
+
317
+ Get Workspace info
318
+
319
+ ```
320
+ get_workspace_info = client.get_workspace_info id: workspace[:id]
321
+ ```
322
+ Update workspace info
323
+
324
+ ```
325
+ update_workspace_info = client.update_workspace_info id: workspace[:id], workspace: {name: "name name"}
326
+ ```
@@ -0,0 +1,24 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'caplinked/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'caplinked-api'
7
+ spec.version = Caplinked::Version
8
+ spec.authors = ['Jordan Fowler', 'Jazz Garcha']
9
+ spec.email = %w(dev@caplinked.com)
10
+ spec.description = "Ruby SDK for Caplinked's API."
11
+ spec.summary = spec.description
12
+ spec.homepage = 'https://github.com/caplinked/caplinked-api-ruby'
13
+ spec.licenses = %w(MIT)
14
+
15
+ spec.files = %w(README.md caplinked-api.gemspec) + Dir['lib/**/*.rb']
16
+ spec.require_paths = %w(lib)
17
+ spec.required_ruby_version = '>= 1.9.3'
18
+
19
+ spec.add_dependency 'activesupport', '~> 4.0'
20
+ spec.add_dependency 'addressable', '~> 2.3'
21
+ spec.add_dependency 'http', '~> 2.0'
22
+ spec.add_dependency 'http-form_data', '~> 1.0'
23
+ spec.add_development_dependency 'bundler', '~> 1.0'
24
+ end
data/lib/caplinked.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'caplinked/rest/api'
2
+ require 'caplinked/client'
@@ -0,0 +1,28 @@
1
+ require 'caplinked/error'
2
+ require 'caplinked/request'
3
+ require 'caplinked/utils'
4
+ require 'caplinked/rest/api'
5
+ require 'active_support'
6
+ require 'active_support/core_ext/hash'
7
+
8
+ module Caplinked
9
+ class Client
10
+ include Caplinked::Utils
11
+ include Caplinked::REST::API
12
+ attr_accessor :api_key, :api_host, :api_scheme
13
+
14
+ # Usage:
15
+ # client = Caplinked::Client.new api_key: '...', api_host: 'sandbox.caplinked.com'
16
+ # client.upload_file file_name: '...',
17
+ def initialize(options = {})
18
+ options[:api_host] ||= 'sandbox.caplinked.com'
19
+ options[:api_scheme] ||= 'https'
20
+
21
+ options.each do |key, value|
22
+ instance_variable_set "@#{key}", value
23
+ end
24
+ yield(self) if block_given?
25
+ end
26
+ end
27
+ end
28
+
@@ -0,0 +1,17 @@
1
+ module Caplinked
2
+ class Error < StandardError
3
+ attr_reader :code, :message, :headers
4
+
5
+ class << self
6
+ def from_response(body, headers)
7
+ new(body[:error]['code'], body[:error]['message'], headers)
8
+ end
9
+ end
10
+
11
+ def initialize(code = nil, message = '', headers = {})
12
+ super(message)
13
+ @code = code
14
+ @headers = headers
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,46 @@
1
+ require 'addressable/uri'
2
+ require 'http'
3
+ require 'http/form_data'
4
+ require 'json'
5
+
6
+ module Caplinked
7
+ class Request
8
+ attr_accessor :client, :request_method, :path, :headers, :params, :uri
9
+
10
+ def initialize(client, request_method, path, options = {})
11
+ @client = client
12
+ @request_method = request_method
13
+ @uri = Addressable::URI.parse("#{client.api_scheme}://#{client.api_host}#{path}")
14
+ @path = @uri.path
15
+ @options = options
16
+ end
17
+
18
+ def perform
19
+ headers = (@options.delete(:headers) || {}).merge('X-Token' => client.api_key)
20
+ @uri.query_values = @options.delete(:params)
21
+ response = HTTP.headers(headers).request(@request_method, @uri.to_s, @options)
22
+ if response.parse.class == Hash
23
+ response_body = response.body.empty? ? '' : response.parse.symbolize_keys!
24
+ else
25
+ response_body = response.body.empty? ? '' : response.parse
26
+ end
27
+ response_headers = response.headers
28
+ fail_or_return_response_body(response.code, response_body, response_headers)
29
+ end
30
+
31
+ private
32
+ def fail_or_return_response_body(code, body, headers)
33
+ if body.class == Hash
34
+ raise(Caplinked::Error.from_response(body, headers)) if body[:error].present?
35
+ else
36
+ if body[0].present?
37
+ raise(Caplinked::Error.from_response(body, headers)) if body[0][:error].present?
38
+ else
39
+ raise(Caplinked::Error.from_response(body, headers)) if body[0].try([:error]).present?
40
+ end
41
+ end
42
+
43
+ body
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,12 @@
1
+ module Caplinked
2
+ module REST
3
+ module Activities
4
+ def get_workspace_activities(options = {})
5
+ params = options.stringify_keys.slice('workspace_id', 'user_id', 'per_page', 'page')
6
+ file_id = params.delete('workspace_id')
7
+ perform_get('/api/v1/activities/workspace/' + file_id.to_s, params)
8
+ end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ require 'caplinked/rest/activities'
2
+ require 'caplinked/rest/downloads'
3
+ require 'caplinked/rest/files'
4
+ require 'caplinked/rest/folders'
5
+ require 'caplinked/rest/groups'
6
+ require 'caplinked/rest/organizations'
7
+ require 'caplinked/rest/permissions'
8
+ require 'caplinked/rest/teams'
9
+ require 'caplinked/rest/users'
10
+ require 'caplinked/rest/workspaces'
11
+
12
+ module Caplinked
13
+ module REST
14
+ module API
15
+ include Caplinked::REST::Activities
16
+ include Caplinked::REST::Downloads
17
+ include Caplinked::REST::Files
18
+ include Caplinked::REST::Folders
19
+ include Caplinked::REST::Groups
20
+ include Caplinked::REST::Organizations
21
+ include Caplinked::REST::Permissions
22
+ include Caplinked::REST::Teams
23
+ include Caplinked::REST::Users
24
+ include Caplinked::REST::Workspaces
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,35 @@
1
+ module Caplinked
2
+ module REST
3
+ module Downloads
4
+ def create_zip_file(options = {})
5
+ params = {}
6
+ body = options.stringify_keys.slice('workspace_id', 'download')
7
+ perform_post('/api/v1/downloads', params, body.to_json, { 'Content-Type' => 'application/json' })
8
+ end
9
+
10
+ def single_file_download(options = {})
11
+ params = options.stringify_keys.slice('file_id', 'workspace_id')
12
+ file_id = params.delete('file_id')
13
+ perform_get('/api/v1/downloads/file/' + file_id.to_s, params)
14
+ end
15
+
16
+ def download_status(options = {})
17
+ params = options.stringify_keys.slice('workspace_id')
18
+ workspace_id = params.delete('workspace_id')
19
+ perform_get('/api/v1/downloads/status/' + workspace_id.to_s, nil)
20
+ end
21
+
22
+ def delete_download(options = {})
23
+ params = options.stringify_keys.slice('id', 'workspace_id')
24
+ id = params.delete('id')
25
+ perform_delete('/api/v1/downloads/' + id.to_s, params)
26
+ end
27
+
28
+ def get_zip(options = {})
29
+ params = options.stringify_keys.slice('id', 'workspace_id')
30
+ id = params.delete('id')
31
+ perform_get('/api/v1/downloads/' + id.to_s, params)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,49 @@
1
+ module Caplinked
2
+ module REST
3
+ module Files
4
+ def upload_file(options = {})
5
+ params = options.stringify_keys.slice('workspace_id', 'folder_id', 'file_name')
6
+ file = options.stringify_keys['file'].b
7
+ perform_put_with_binary_data('/api/v1/files/upload', params, file)
8
+ end
9
+
10
+ def get_file_info(options = {})
11
+ params = options.stringify_keys.slice('id', 'workspace_id', 'page_number')
12
+ file_id = params.delete('id')
13
+ perform_get('/api/v1/files/' + file_id.to_s, params)
14
+ end
15
+
16
+ def get_file_viewer(options = {})
17
+ params = options.stringify_keys.slice('id', 'workspace_id', 'expiring_token')
18
+ file_id = params.delete('id')
19
+ perform_get('/api/v1/files/' + file_id.to_s + '/viewer', params)
20
+ end
21
+
22
+ def delete_file(options = {})
23
+ params = options.stringify_keys.slice('id', 'workspace_id')
24
+ file_id = params.delete('id')
25
+ perform_delete('/api/v1/files/' + file_id.to_s, params)
26
+ end
27
+
28
+ def update_file_info(options = {})
29
+ params = options.stringify_keys.slice('id')
30
+ file_id = params.delete('id')
31
+ body = options.stringify_keys.slice('workspace_id', 'file')
32
+ perform_put('/api/v1/files/' + file_id.to_s, params, body.to_json, { 'Content-Type' => 'application/json' })
33
+ end
34
+
35
+ def copy_file(options = {})
36
+ body = options.stringify_keys.slice('id', 'workspace_id', 'destination_folder_id')
37
+ file_id = body.delete('id')
38
+ perform_post('/api/v1/files/' + file_id.to_s + '/copy', nil, body.to_json, { 'Content-Type' => 'application/json' })
39
+ end
40
+
41
+ def move_file(options = {})
42
+ body = options.stringify_keys.slice('id', 'workspace_id', 'destination_folder_id')
43
+ file_id = body.delete('id')
44
+ params = {}
45
+ perform_post('/api/v1/files/' + file_id.to_s + '/move', params, body.to_json, { 'Content-Type' => 'application/json' })
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,45 @@
1
+ module Caplinked
2
+ module REST
3
+ module Folders
4
+
5
+ def create_a_new_folder(options = {})
6
+ params = {}
7
+ body = options.stringify_keys.slice('workspace_id', 'name', 'parent_id')
8
+ perform_post('/api/v1/folders', params, body.to_json, { 'Content-Type' => 'application/json' })
9
+ end
10
+
11
+ def delete_folder(options = {})
12
+ params = options.stringify_keys.slice('id', 'workspace_id')
13
+ id = params.delete('id')
14
+ perform_delete('/api/v1/folders/' + id.to_s, params )
15
+ end
16
+
17
+ def get_folder_info(options = {})
18
+ params = options.stringify_keys.slice('id', 'workspace_id')
19
+ id = params.delete('id')
20
+ perform_get('/api/v1/folders/' + id.to_s, params)
21
+ end
22
+
23
+ def update_folder_info(options = {})
24
+ params = options.stringify_keys.slice('id')
25
+ id = params.delete('id')
26
+ body = options.stringify_keys.slice('workspace_id', 'folder')
27
+ perform_put('/api/v1/folders/' + id.to_s, params, body.to_json, { 'Content-Type' => 'application/json' })
28
+ end
29
+
30
+ def copy_folder(options = {})
31
+ params = options.stringify_keys.slice('id')
32
+ id = params.delete('id')
33
+ body = options.stringify_keys.slice('workspace_id', 'destination_folder_id')
34
+ perform_post('/api/v1/folders/' + id.to_s + '/copy', params, body.to_json, { 'Content-Type' => 'application/json' })
35
+ end
36
+
37
+ def move_folder(options = {})
38
+ params = options.stringify_keys.slice('id')
39
+ id = params.delete('id')
40
+ body = options.stringify_keys.slice('workspace_id', 'destination_folder_id')
41
+ perform_post('/api/v1/folders/' + id.to_s + '/move', params, body.to_json, { 'Content-Type' => 'application/json' })
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,84 @@
1
+ module Caplinked
2
+ module REST
3
+ module Groups
4
+
5
+ def list_all_groups_in_workspace(options = {})
6
+ params = options.stringify_keys.slice('workspace_id')
7
+ perform_get('/api/v1/groups', params)
8
+ end
9
+
10
+ def create_group(options = {})
11
+ body = options.stringify_keys.slice('group')
12
+ perform_post('/api/v1/groups', nil, body.to_json, {'Content-Type' => 'application/json'} )
13
+ end
14
+
15
+ def update_group(options = {})
16
+ body = options.stringify_keys.slice('id', 'workspace_id', 'group')
17
+ id = body.delete('id')
18
+ perform_put('/api/v1/groups/' + id.to_s, nil, body.to_json, { 'Content-Type' => 'application/json' } )
19
+ end
20
+
21
+ def get_group_info(options = {})
22
+ params = options.stringify_keys.slice('id', 'workspace_id')
23
+ id = params.delete('id')
24
+ perform_get('/api/v1/groups/' + id.to_s, params)
25
+ end
26
+
27
+ def delete_group(options = {})
28
+ params = options.stringify_keys.slice('id', 'workspace_id')
29
+ id = params.delete('id')
30
+ perform_delete('/api/v1/groups/' + id.to_s, params)
31
+ end
32
+
33
+ def update_group_drm(options = {})
34
+ body = options.stringify_keys.slice('id', 'workspace_id', 'group')
35
+ id = body.delete('id')
36
+ perform_put('/api/v1/groups/' + id.to_s + '/drm', nil, body.to_json, { 'Content-Type' => 'application/json' } )
37
+ end
38
+
39
+ def disable_drm_expiration(options = {})
40
+ body = options.stringify_keys.slice('id', 'workspace_id')
41
+ id = body.delete('id')
42
+ perform_put('/api/v1/groups/' + id.to_s + '/disable_drm_expiration', nil, body.to_json, { 'Content-Type' => 'application/json' } )
43
+ end
44
+
45
+ def watermarking_for_group(options = {})
46
+ body = options.stringify_keys.slice('id', 'workspace_id', 'group')
47
+ id = body.delete('id')
48
+ perform_put('/api/v1/groups/' + id.to_s + '/watermarking', nil, body.to_json, { 'Content-Type' => 'application/json' } )
49
+ end
50
+
51
+ def enable_access_expiration(options = {})
52
+ body = options.stringify_keys.slice('id', 'workspace_id', 'group')
53
+ id = body.delete('id')
54
+ perform_put('/api/v1/groups/' + id.to_s + '/enable_expire_access', nil, body.to_json, { 'Content-Type' => 'application/json' } )
55
+ end
56
+
57
+ def disable_access_expiration(options = {})
58
+ body = options.stringify_keys.slice('id', 'workspace_id')
59
+ id = body.delete('id')
60
+ perform_put('/api/v1/groups/' + id.to_s + '/disable_expire_access', nil, body.to_json, { 'Content-Type' => 'application/json' } )
61
+ end
62
+
63
+ def add_group_member(options = {})
64
+ params = {}
65
+ body = options.stringify_keys.slice('id', 'user_id', 'workspace_id', 'send_email')
66
+ id = body.delete('id')
67
+ perform_post('/api/v1/groups/' + id.to_s + '/memberships', params, body.to_json, { 'Content-Type' => 'application/json' } )
68
+ end
69
+
70
+ def remove_group_member(options = {})
71
+ params = options.stringify_keys.slice('id', 'user_id', 'workspace_id')
72
+ id = params.delete('id')
73
+ perform_delete('/api/v1/groups/' + id.to_s + '/memberships', params )
74
+ end
75
+
76
+ def list_all_group_members(options = {})
77
+ params = options.stringify_keys.slice('id', 'workspace_id')
78
+ id = params.delete('id')
79
+ perform_get('/api/v1/groups/' + id.to_s + '/memberships', params )
80
+ end
81
+
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,45 @@
1
+ module Caplinked
2
+ module REST
3
+ module Organizations
4
+
5
+ def get_organization_info(options = {})
6
+ params = options.stringify_keys.slice('id')
7
+ id = params.delete('id')
8
+ perform_get('/api/v1/organizations/' + id.to_s, nil )
9
+ end
10
+
11
+ def update_organization_info(options = {})
12
+ params = {}
13
+ body = options.stringify_keys.slice('id', 'name', 'description', 'location', 'billing_email', 'url')
14
+ id = body.delete('id')
15
+ perform_put('/api/v1/organizations/' + id.to_s, params, body.to_json, { 'Content-Type' => 'application/json' } )
16
+ end
17
+
18
+ def update_organization_support_info(options = {})
19
+ params = {}
20
+ body = options.stringify_keys.slice('id', 'phone_number', 'email', 'website')
21
+ id = body.delete('id')
22
+ perform_put('/api/v1/organizations/' + id.to_s + '/support_information', params, body.to_json, { 'Content-Type' => 'application/json' } )
23
+ end
24
+
25
+ def add_organization_member(options = {})
26
+ params = {}
27
+ body = options.stringify_keys.slice('id', 'user_id')
28
+ id = body.delete('id')
29
+ perform_post('/api/v1/organizations/' + id.to_s + '/memberships', params, body.to_json, { 'Content-Type' => 'application/json' } )
30
+ end
31
+
32
+ def remove_organization_member(options = {})
33
+ params = options.stringify_keys.slice('id', 'user_id')
34
+ id = params.delete('id')
35
+ perform_delete('/api/v1/organizations/' + id.to_s + '/memberships', params )
36
+ end
37
+
38
+ def show_organization_members(options = {})
39
+ params = options.stringify_keys.slice('id')
40
+ id = params.delete('id')
41
+ perform_get('/api/v1/organizations/' + id.to_s + '/memberships', nil )
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,20 @@
1
+ module Caplinked
2
+ module REST
3
+ module Permissions
4
+
5
+ def get_folder_permissions(options = {})
6
+ params = options.stringify_keys.slice('id', 'workspace_id', 'group_id')
7
+ id = params.delete('id')
8
+ perform_get('/api/v1/permissions/folders/' + id.to_s, params )
9
+ end
10
+
11
+ def update_folder_permissions(options = {})
12
+ params = options.stringify_keys.slice('id')
13
+ id = params.delete('id')
14
+ body = options.stringify_keys.slice('workspace_id', 'group_id', 'verb', 'folder_action')
15
+ perform_put('/api/v1/permissions/folders/' + id.to_s, nil, body.to_json, {'Content-Type' => 'application/json'} )
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,44 @@
1
+ module Caplinked
2
+ module REST
3
+ module Teams
4
+
5
+ def create_team(options = {})
6
+ body = options.stringify_keys.slice('team')
7
+ perform_post('/api/v1/teams', nil, body.to_json, {'Content-Type' => 'application/json'} )
8
+ end
9
+
10
+ def get_team_info(options = {})
11
+ params = options.stringify_keys.slice('id')
12
+ id = params.delete('id')
13
+ perform_get('/api/v1/teams/' + id.to_s, nil )
14
+ end
15
+
16
+ def update_team_info(options = {})
17
+ params = {}
18
+ body = options.stringify_keys.slice('id', 'team')
19
+ id = body.delete('id')
20
+ perform_put('/api/v1/teams/' + id.to_s, params, body.to_json, { 'Content-Type' => 'application/json' } )
21
+ end
22
+
23
+ def add_team_member(options = {})
24
+ params = {}
25
+ body = options.stringify_keys.slice('id', 'user_id')
26
+ id = body.delete('id')
27
+ perform_post('/api/v1/teams/' + id.to_s + '/memberships', params, body.to_json, { 'Content-Type' => 'application/json' } )
28
+ end
29
+
30
+ def remove_team_member(options = {})
31
+ params = options.stringify_keys.slice('id', 'user_id')
32
+ id = params.delete('id')
33
+ perform_delete('/api/v1/teams/' + id.to_s + '/memberships', params )
34
+ end
35
+
36
+ def get_list_of_team_members(options = {})
37
+ params = options.stringify_keys.slice('id')
38
+ id = params.delete('id')
39
+ perform_get('/api/v1/teams/' + id.to_s + '/memberships', nil )
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,21 @@
1
+ module Caplinked
2
+ module REST
3
+ module Users
4
+
5
+ def create_user(options = {})
6
+ body = options.stringify_keys.slice('user')
7
+ perform_post('/api/v1/users', nil, body.to_json, {'Content-Type' => 'application/json'} )
8
+ end
9
+
10
+ def get_user_info(options = {})
11
+ perform_get('/api/v1/users/me', nil )
12
+ end
13
+
14
+ def update_user(options = {})
15
+ body = options.stringify_keys.slice('user')
16
+ perform_put('/api/v1/users/me', nil, body.to_json, {'Content-Type' => 'application/json'} )
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ module Caplinked
2
+ module REST
3
+ module Workspaces
4
+
5
+ def list_all_workspaces_for_a_team(options = {})
6
+ params = options.stringify_keys.slice('team_id')
7
+ perform_get('/api/v1/workspaces', params)
8
+ end
9
+
10
+ def create_workspace(options = {})
11
+ body = options.stringify_keys.slice('team_id', 'workspace')
12
+ perform_post('/api/v1/workspaces', nil, body.to_json, {'Content-Type' => 'application/json'} )
13
+ end
14
+
15
+ def get_workspace_info(options = {})
16
+ params = options.stringify_keys.slice('id')
17
+ id = params.delete('id')
18
+ perform_get('/api/v1/workspaces/' + id.to_s, nil)
19
+ end
20
+
21
+ def update_workspace_info(options = {})
22
+ params = {}
23
+ body = options.stringify_keys.slice('id', 'workspace')
24
+ id = body.delete('id')
25
+ perform_put('/api/v1/workspaces/' + id.to_s, params, body.to_json, { 'Content-Type' => 'application/json' } )
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,32 @@
1
+ require 'caplinked/utils'
2
+ require 'caplinked/request'
3
+ require 'active_support'
4
+
5
+ module Caplinked
6
+ module Utils
7
+ def perform_get(path, params = {})
8
+ perform_request(:get, path, { params: params })
9
+ end
10
+
11
+ def perform_delete(path, params = {})
12
+ perform_request(:delete, path, { params: params })
13
+ end
14
+
15
+ def perform_put(path, params = {}, body = {}, headers = {})
16
+ perform_request(:put, path, { params: params, body: body, headers: headers })
17
+ end
18
+
19
+ def perform_post(path, params = {}, body = {}, headers = {})
20
+ perform_request(:post, path, { params: params, body: body, headers: headers })
21
+ end
22
+
23
+ def perform_put_with_binary_data(path, params = {}, file)
24
+ perform_request(:put, path, { params: params, body: file })
25
+ end
26
+
27
+ private
28
+ def perform_request(request_method, path, options = {})
29
+ Caplinked::Request.new(self, request_method, path, options).perform
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,45 @@
1
+ module Caplinked
2
+ module Version
3
+ module_function
4
+
5
+ # @return [Integer]
6
+ def major
7
+ 0
8
+ end
9
+
10
+ # @return [Integer]
11
+ def minor
12
+ 1
13
+ end
14
+
15
+ # @return [Integer]
16
+ def patch
17
+ 0
18
+ end
19
+
20
+ # @return [Integer, NilClass]
21
+ def pre
22
+ nil
23
+ end
24
+
25
+ # @return [Hash]
26
+ def to_h
27
+ {
28
+ major: major,
29
+ minor: minor,
30
+ patch: patch,
31
+ pre: pre,
32
+ }
33
+ end
34
+
35
+ # @return [Array]
36
+ def to_a
37
+ [major, minor, patch, pre].compact
38
+ end
39
+
40
+ # @return [String]
41
+ def to_s
42
+ to_a.join('.')
43
+ end
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: caplinked-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jordan Fowler
8
+ - Jazz Garcha
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-12-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '4.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '4.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: addressable
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.3'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: http
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '2.0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '2.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: http-form_data
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: bundler
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.0'
84
+ description: Ruby SDK for Caplinked's API.
85
+ email:
86
+ - dev@caplinked.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - README.md
92
+ - caplinked-api.gemspec
93
+ - lib/caplinked.rb
94
+ - lib/caplinked/client.rb
95
+ - lib/caplinked/error.rb
96
+ - lib/caplinked/request.rb
97
+ - lib/caplinked/rest/activities.rb
98
+ - lib/caplinked/rest/api.rb
99
+ - lib/caplinked/rest/downloads.rb
100
+ - lib/caplinked/rest/files.rb
101
+ - lib/caplinked/rest/folders.rb
102
+ - lib/caplinked/rest/groups.rb
103
+ - lib/caplinked/rest/organizations.rb
104
+ - lib/caplinked/rest/permissions.rb
105
+ - lib/caplinked/rest/teams.rb
106
+ - lib/caplinked/rest/users.rb
107
+ - lib/caplinked/rest/workspaces.rb
108
+ - lib/caplinked/utils.rb
109
+ - lib/caplinked/version.rb
110
+ homepage: https://github.com/caplinked/caplinked-api-ruby
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 1.9.3
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.4.5
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Ruby SDK for Caplinked's API.
134
+ test_files: []