-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpermissions_api.rb
More file actions
25 lines (22 loc) · 883 Bytes
/
Copy pathpermissions_api.rb
File metadata and controls
25 lines (22 loc) · 883 Bytes
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
require 'mailtrap'
account_id = 3229
client = Mailtrap::Client.new(api_key: 'your-api-key')
permissions = Mailtrap::PermissionsAPI.new(account_id, client)
# Get the recursive tree of resources the current token can access
permissions.resources
# => [
# #<struct Mailtrap::PermissionResource id=4001, name="My First Project", type="project",
# access_level=1, resources=[
# #<struct Mailtrap::PermissionResource id=3816, name="My First Inbox", type="inbox",
# access_level=100, resources=[]>
# ]>
# ]
# Bulk-update user/token permissions on an account access. Combine create/update with destroy:
permissions.bulk_update(
5142, # account_access_id
[
{ resource_id: '3281', resource_type: 'account', access_level: 'viewer' },
{ resource_id: '3809', resource_type: 'inbox', _destroy: true }
]
)
# => { message: "Permissions have been updated!" }