Lokalise APIv2 Ruby SDK

Ruby interface for the Lokalise APIv2 that represents returned data as Ruby objects.

View the Project on GitHub lokalise/ruby-lokalise-api




Team user groups

Fetch team user groups

Doc

@client.team_user_groups(team_id, params = {})  # Input:
                                                ## team_id (string, required)
                                                ## params (hash)
                                                ### :page and :limit
                                                # Output:
                                                ## Collection of team user groups

For example:

team_id = '1234'
params = {
  limit: 1,
  page: 2
}

groups = @client.team_user_groups team_id, params

groups[0].group_id # => '5678'

Fetch a single group

Doc

@client.team_user_group(team_id, group_id)  # Input:
                                            ## team_id (string, required)
                                            ## group_id (string, required)
                                            # Output:
                                            ## Group

For example:

team_id = '1234'
group_id = '5678'

group = test_client.team_user_group team_id, group_id

group.name # => 'Demo'

Create group

Doc

@client.create_team_user_group(team_id, params) # Input:
                                                ## team_id (string, required)
                                                ## params (hash, required):
                                                ### :name (string, required)
                                                ### :is_reviewer (boolean, required)
                                                ### :is_admin (boolean, required)
                                                ### :admin_rights (array) - required only if is_admin is true
                                                ### :languages (array of hashes) - required if is_admin is false
                                                # Output:
                                                ## Updated group

For example:

params = {
  name: 'SDK',
  is_reviewer: true,
  is_admin: false,
  languages: {
    reference: [],
    contributable: [640]
  }
}

group = @client.create_team_user_group team_id, params

group.name # => 'SDK'
group.permissions['is_admin'] # => false

Update group

Doc

@client.update_team_user_group(team_id, group_id, params) # Input:
                                                          ## team_id (string, required)
                                                          ## group_id (string, required)
                                                          ## params (hash, required):
                                                          ### :name (string, required)
                                                          ### :is_reviewer (boolean, required)
                                                          ### :is_admin (boolean, required)
                                                          ### :admin_rights (array) - required only if is_admin is true
                                                          ### :languages (array of hashes) - required if is_admin is false
                                                          # Output:
                                                          ## Updated group

For example:

params = {
  name: 'Updated SDK',
  is_reviewer: true,
  is_admin: false,
  languages: {
    reference: [],
    contributable: [640]
  }
}

group = @client.update_team_user_group team_id, group_id, params

group.name # => 'Updated SDK'

Alternatively:

group = @client.team_user_group team_id, group_id
updated_group = group.update params

Add projects to group

Doc

@client.add_projects_to_group(team_id, group_id, project_ids) # Input:
                                                              ## team_id (string, required)
                                                              ## group_id (string, required)
                                                              ## project_ids (string or array, required) - project ids that you would like to add to this group

For example:

project_ids = %w[123.abc 567.def]

group = client.add_projects_to_group team_id, group_id, project_ids

group.projects # => ['123.abc', '567.def']

Alternatively:

group = @client.team_user_group team_id, group_id
updated_group = group.add_projects project_ids

Remove projects from group

Doc

@client.remove_projects_from_group(team_id, group_id, project_ids)  # Input:
                                                                    ## team_id (string, required)
                                                                    ## group_id (string, required)
                                                                    ## project_ids (string or array, required) - project ids that you would like to remove from this group

For example:

project_ids = %w[123.abc 567.def]

group = @client.remove_projects_from_group team_id, group_id, project_ids

group.projects # => []

Alternatively:

group = @client.team_user_group team_id, group_id
updated_group = group.remove_projects project_ids

Add users to group

Doc

@client.add_users_to_group(team_id, group_id, user_ids) # Input:
                                                        ## team_id (string, required)
                                                        ## group_id (string, required)
                                                        ## user_ids (string or array, required) - user ids that you would like to add to this group

For example:

user_ids = %w[1234 6789]
group = @client.add_members_to_group team_id, group_id, user_ids

group.members # => ['1234', '6789']

Alternatively:

group = @client.team_user_group team_id, group_id

updated_group = group.add_users user_ids

Remove users from group

Doc

@client.remove_users_from_group(team_id, group_id, user_ids)  # Input:
                                                              ## team_id (string, required)
                                                              ## group_id (string, required)
                                                              ## user_ids (string or array, required) - user ids that you would like to add to this group

For example:

user_ids = %w[1234 6789]

group = @client.remove_members_from_group team_id, group_id, user_ids

group.members # => []

Alternatively:

group = @client.team_user_group team_id, group_id
updated_group = group.remove_users user_ids

Destroy group

Doc

@client.destroy_team_user_group(team_id, group_id)  # Input:
                                                    ## team_id (string, required)
                                                    ## group_id (string, required)
                                                    # Output:
                                                    ## Hash with "team_id" and "group_deleted" set to "true"

For example:

response = @client.destroy_team_user_group team_id, group_id

response.group_deleted # => true

Alternatively:

group = @client.team_user_group team_id, group_id
response = group.destroy