Skip to content

Commit

Permalink
v9.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bodrovis committed Oct 15, 2024
1 parent 4681ad5 commit 6dbaf7f
Show file tree
Hide file tree
Showing 17 changed files with 253 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/_data/api_items.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@
path: fetch-a-single-payment-card
- title: Delete a payment card
path: delete-a-payment-card
- title: Permission templates
path: permission-templates
sub_paths:
- title: Fetch permission templates
path: fetch-permission-templates
- title: Projects
path: projects
sub_paths:
Expand Down
33 changes: 33 additions & 0 deletions docs/additional_info/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## 9.2.0 (15-Oct-2024)

* Added support for a new [`PermissionTemplates` endpoint](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
```

* Added `role_id` attribute to the user group object. For example:

```ruby
group = test_client.team_user_group team_id, group_id
group.role_id # => 5
```

* Added `role_id` attribute to the contributor object. For example:

```ruby
contributor = test_client.contributor project_id, user_id
contributor.role_id # => 5
```

## 9.1.0 (15-May-2024)

* Add support for [cursor pagination](https://lokalise.github.io/ruby-lokalise-api/api/getting-started#cursor-pagination) for List keys and List translation endpoints:
Expand Down
22 changes: 22 additions & 0 deletions docs/api/permission-templates.md
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
```
11 changes: 11 additions & 0 deletions lib/ruby_lokalise_api/collections/permission_templates.rb
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
11 changes: 11 additions & 0 deletions lib/ruby_lokalise_api/data/resource_attributes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contributor:
- is_reviewer
- languages
- admin_rights
- role_id
custom_translation_status:
- project_id
- branch
Expand Down Expand Up @@ -142,6 +143,15 @@ queued_process:
- created_at
- created_at_timestamp
- details
permission_template:
- id
- role
- permissions
- description
- tag
- tagColor
- tagInfo
- doesEnableAllReadOnlyLanguages
screenshot:
- project_id
- branch
Expand Down Expand Up @@ -256,6 +266,7 @@ team_user_group:
- team_id
- projects
- members
- role_id
translation:
- project_id
- branch
Expand Down
15 changes: 15 additions & 0 deletions lib/ruby_lokalise_api/endpoints/permission_templates_endpoint.rb
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
10 changes: 10 additions & 0 deletions lib/ruby_lokalise_api/resources/permission_template.rb
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
1 change: 1 addition & 0 deletions lib/ruby_lokalise_api/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Rest
include Rest::Languages
include Rest::Orders
include Rest::PaymentCards
include Rest::PermissionTemplates
include Rest::Projects
include Rest::QueuedProcesses
include Rest::Segments
Expand Down
21 changes: 21 additions & 0 deletions lib/ruby_lokalise_api/rest/permission_templates.rb
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
2 changes: 1 addition & 1 deletion lib/ruby_lokalise_api/version.rb
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
3 changes: 2 additions & 1 deletion spec/fixtures/contributors/contributor.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"create_branches",
"activity",
"statistics"
]
],
"role_id": 5
}
}
86 changes: 86 additions & 0 deletions spec/fixtures/permission_templates/list.json
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
}
]
}
3 changes: 2 additions & 1 deletion spec/fixtures/team_user_groups/team_user_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
"members": [
49436,
72007
]
],
"role_id": 5
}
2 changes: 2 additions & 0 deletions spec/lib/ruby_lokalise_api/rest/contributors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
'is_writable' => true
)
expect(contributor.admin_rights).to include('upload')
expect(contributor.user_id).to eq(user_id)
expect(contributor.role_id).to eq(5)
end

specify '#contributors' do
Expand Down
28 changes: 28 additions & 0 deletions spec/lib/ruby_lokalise_api/rest/permission_templates_spec.rb
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
1 change: 1 addition & 0 deletions spec/lib/ruby_lokalise_api/rest/team_user_groups_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
expect(group.created_at_timestamp).to eq(1_595_503_264)
expect(group.projects).to eq([])
expect(group.members).to include(49_436)
expect(group.role_id).to eq(5)
end

specify '#create_team_user_group' do
Expand Down
3 changes: 2 additions & 1 deletion spec/support/expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def proper_collection(collection_obj, collection)
def proper_endpoint(collection_obj)
res, ep = first_collection_endpoint(collection_from(collection_obj))

params = res.class.const_get(:MAIN_PARAMS).to_array.map do |p|
main_params = res.class.const_get(:MAIN_PARAMS).to_array
params = main_params.map do |p|
res.send(p).to_s
end

Expand Down

0 comments on commit 6dbaf7f

Please sign in to comment.