-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
253 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Permission templates | ||
|
||
[Permission template attributes](https://developers.lokalise.com/reference/permission-template-object) | ||
|
||
## Fetch permission templates | ||
|
||
[API doc](https://developers.lokalise.com/reference/list-all-permission-templates) | ||
|
||
```ruby | ||
permission_templates = test_client.permission_templates team_id | ||
|
||
template = permission_templates[0] | ||
|
||
template.id # => 1 | ||
template.role # => "Manager" | ||
template.permissions # => ['branches_main_modify', ...] | ||
template.description # => 'Manage project settings ...' | ||
template.tag # => 'Full access' | ||
template.tagColor # => 'green' | ||
template.tagInfo # => '' | ||
template.doesEnableAllReadOnlyLanguages # => true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module RubyLokaliseApi | ||
module Collections | ||
class PermissionTemplates < Base | ||
ENDPOINT = RubyLokaliseApi::Endpoints::PermissionTemplatesEndpoint | ||
RESOURCE = RubyLokaliseApi::Resources::PermissionTemplate | ||
DATA_KEY = 'roles' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
lib/ruby_lokalise_api/endpoints/permission_templates_endpoint.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module RubyLokaliseApi | ||
module Endpoints | ||
class PermissionTemplatesEndpoint < MainEndpoint | ||
private | ||
|
||
def base_query(team_id) | ||
{ | ||
teams: [team_id, :roles] | ||
} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
module RubyLokaliseApi | ||
module Resources | ||
class PermissionTemplate < Base | ||
MAIN_PARAMS = %i[nil].freeze | ||
no_support_for %i[update destroy reload_data] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module RubyLokaliseApi | ||
module Rest | ||
module PermissionTemplates | ||
# Returns permission tempates for a team | ||
# | ||
# @see https://developers.lokalise.com/reference/list-all-permission-templates | ||
# @return [RubyLokaliseApi::Collections::PermissionTemplates] | ||
# @param team_id [Integer, String] | ||
def permission_templates(team_id) | ||
name = 'PermissionTemplates' | ||
params = { query: team_id } | ||
|
||
data = endpoint(name: name, params: params).do_get | ||
|
||
collection name, data | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module RubyLokaliseApi | ||
VERSION = '9.1.0' | ||
VERSION = '9.2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
"create_branches", | ||
"activity", | ||
"statistics" | ||
] | ||
], | ||
"role_id": 5 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"roles": [ | ||
{ | ||
"id": 1, | ||
"role": "Manager", | ||
"permissions": [ | ||
"activity", | ||
"branches_main_modify", | ||
"branches_create", | ||
"branches_merge", | ||
"statistics", | ||
"tasks", | ||
"contributors", | ||
"settings", | ||
"manage_languages", | ||
"download", | ||
"upload", | ||
"glossary_delete", | ||
"glossary_edit", | ||
"manage_keys", | ||
"screenshots", | ||
"review", | ||
"custom_status_modify" | ||
], | ||
"description": "Manage project settings, contributors and tasks", | ||
"tag": "Full access", | ||
"tagColor": "green", | ||
"tagInfo": null, | ||
"doesEnableAllReadOnlyLanguages": true | ||
}, | ||
{ | ||
"id": 2, | ||
"role": "Developer", | ||
"permissions": [ | ||
"activity", | ||
"branches_main_modify", | ||
"branches_create", | ||
"download", | ||
"upload", | ||
"manage_keys", | ||
"screenshots" | ||
], | ||
"description": "Create keys, upload and download content", | ||
"tag": "Advanced", | ||
"tagColor": "cyan", | ||
"tagInfo": null, | ||
"doesEnableAllReadOnlyLanguages": true | ||
}, | ||
{ | ||
"id": 3, | ||
"role": "Content creator", | ||
"permissions": [ | ||
"activity", | ||
"manage_keys", | ||
"manage_languages", | ||
"screenshots", | ||
"branches_main_modify" | ||
], | ||
"description": "Create, translate and edit keys, manage screenshots", | ||
"tag": "Advanced", | ||
"tagColor": "cyan", | ||
"tagInfo": null, | ||
"doesEnableAllReadOnlyLanguages": true | ||
}, | ||
{ | ||
"id": 4, | ||
"role": "Reviewer", | ||
"permissions": ["branches_main_modify", "review", "custom_status_modify"], | ||
"description": "Translate keys, control key statuses", | ||
"tag": "Basic", | ||
"tagColor": "grey", | ||
"tagInfo": "All users, regardless of their assigned roles and permissions, are granted entry-level access, such as: View glossary, View source content, Collaborate via comments, Limited access to editor, Generate API tokens", | ||
"doesEnableAllReadOnlyLanguages": false | ||
}, | ||
{ | ||
"id": 5, | ||
"role": "Translator", | ||
"permissions": ["branches_main_modify"], | ||
"description": "Translate keys", | ||
"tag": "Basic", | ||
"tagColor": "grey", | ||
"tagInfo": "All users, regardless of their assigned roles and permissions, are granted entry-level access, such as: View glossary, View source content, Collaborate via comments, Limited access to editor, Generate API tokens", | ||
"doesEnableAllReadOnlyLanguages": false | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,5 +39,6 @@ | |
"members": [ | ||
49436, | ||
72007 | ||
] | ||
], | ||
"role_id": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
spec/lib/ruby_lokalise_api/rest/permission_templates_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RubyLokaliseApi::Rest::PermissionTemplates do | ||
let(:team_id) { 176_692 } | ||
|
||
specify '#permission_templates' do | ||
stub( | ||
uri: "teams/#{team_id}/roles", | ||
resp: { body: fixture('permission_templates/list') } | ||
) | ||
|
||
permission_templates = test_client.permission_templates team_id | ||
|
||
expect(permission_templates.collection.length).to eq(5) | ||
expect(permission_templates).to be_an_instance_of(RubyLokaliseApi::Collections::PermissionTemplates) | ||
|
||
template = permission_templates[0] | ||
|
||
expect(template.id).to eq(1) | ||
expect(template.role).to eq('Manager') | ||
expect(template.permissions).to include('branches_main_modify') | ||
expect(template.description).to include('Manage project settings') | ||
expect(template.tag).to eq('Full access') | ||
expect(template.tagColor).to eq('green') | ||
expect(template.tagInfo).to be_nil | ||
expect(template.doesEnableAllReadOnlyLanguages).to be true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters