Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bodrovis committed Mar 18, 2021
1 parent e654e88 commit f1d0783
Show file tree
Hide file tree
Showing 16 changed files with 192 additions and 308 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changelog

Please find changelog at [bodrovis.github.io/elixir-lokalise-api/additional_info/changelog](https://bodrovis.github.io/elixir-lokalise-api/additional_info/changelog)
6 changes: 2 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
`mix test`
# Contributing

`mix coveralls.html`

`mix format`
Please find contributing guide at [bodrovis.github.io/elixir-lokalise-api/additional_info/contribution_guide](https://bodrovis.github.io/elixir-lokalise-api/additional_info/contribution_guide).
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ translation_data = %{
process.status |> IO.puts # => "finished"
```

## Documentation

All documentation and usage examples can be found at [bodrovis.github.io/elixir-lokalise-api](https://bodrovis.github.io/elixir-lokalise-api/)

## License

Licensed under the [BSD 3 Clause license](https://github.com/bodrovis/elixir-lokalise-api/blob/master/LICENSE).
Expand Down
17 changes: 0 additions & 17 deletions docs/_data/additional_items.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
- title: Customization
path: customization
sub_paths:
- title: Choosing Network Adapter
path: choosing-network-adapter
- title: Setting Timeouts
path: setting-timeouts
- title: Customizing JSON parser
path: customizing-json-parser
- title: Exception handling
path: exception_handling
sub_paths:
- title: Error codes
path: error-codes
- title: API Rate Limits
path: api-rate-limits
- title: Contributing
path: contribution_guide
sub_paths:
- title: Running tests
path: running-tests
- title: Previewing the docs locally
path: previewing-the-docs-locally
- title: Changelog
path: changelog
- title: License
Expand Down
58 changes: 20 additions & 38 deletions docs/api/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,53 @@
[Doc](https://app.lokalise.com/api2docs/curl/#transition-list-project-comments-get)

```elixir
@client.project_comments(project_id, params = {}) # Input:
## project_id (string, required)
## params (hash)
### :page and :limit
# Output:
## Collection of comments available in the given project
{:ok, comments} = ElixirLokaliseApi.ProjectComments.all(project_id, page: 2, limit: 1)

single_comment = hd comments.items
single_comment.comment
```

## Fetch key comments

[Doc](https://app.lokalise.com/api2docs/curl/#transition-list-key-comments-get)

```elixir
@client.comments(project_id, key_id, params = {}) # Input:
## project_id (string, required)
## key_id (string, required)
## params (hash)
### :page and :limit
# Output:
## Collection of comments available for the specified key in the given project
{:ok, comments} = ElixirLokaliseApi.KeyComments.all(project_id, key_id, limit: 1, page: 2)
```

## Create key comments

[Doc](https://app.lokalise.com/api2docs/curl/#transition-create-comments-post)

```elixir
@client.create_comments(project_id, key_id, params) # Input:
## project_id (string, required)
## key_id (string, required)
## params (array or hash, required) - contains parameter of newly created comments. Pass array of hashes to create multiple comments, or a hash to create a single comment
### :comment (string, required)
# Output:
## Newly created comment
data = %{
comments: [
%{comment: "Elixir comment"}
]
}

{:ok, comments} = ElixirLokaliseApi.KeyComments.create(project_id, key_id, data)
comment = hd comments.items
comment.comment
```

## Fetch key comment

[Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-comment-get)

```elixir
@client.comment(project_id, key_id, comment_id) # Input:
## project_id (string, required)
## key_id (string, required)
## comment_id (string, required)
# Output:
## Comment for the key in the given project
{:ok, comment} = ElixirLokaliseApi.KeyComments.find(project_id, key_id, comment_id)

comment.comment
comment.comment_id
```

## Delete key comment

[Doc](https://app.lokalise.com/api2docs/curl/#transition-delete-a-comment-delete)

```elixir
@client.destroy_comment(project_id, key_id, comment_id) # Input:
## project_id (string, required)
## key_id (string, required)
## comment_id (string, required)
# Output:
## Hash with the project's id and "comment_deleted"=>true
```
{:ok, resp} = ElixirLokaliseApi.KeyComments.delete(project_id, key_id, comment_id)

Alternatively:

```elixir
comment = @client.comment('project_id', 'comment_id')
comment.destroy
assert resp.comment_deleted
```
85 changes: 33 additions & 52 deletions docs/api/contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,87 +5,68 @@
[Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-contributors-get)

```elixir
@client.contributors(project_id, params = {}) # Input:
## project_id (string, required)
## params (hash)
### :page and :limit
# Output:
## Collection of contributors in the given project
{:ok, contributors} = ElixirLokaliseApi.Contributors.all(project_id, page: 2, limit: 1)

contributor = hd contributors.items
contributor.user_id
```

## Fetch a single contributor

[Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-contributor-get)

```elixir
@client.contributor(project_id, contributor_id) # Input:
## project_id (string, required)
## contributor_id (string, required) - named as "user_id" in the response
# Output:
## Contributor in the given project
{:ok, contributor} = ElixirLokaliseApi.Contributors.find(project_id, contributor_id)

contributor.user_id
```

## Create contributors

[Doc](https://app.lokalise.com/api2docs/curl/#transition-create-contributors-post)

```elixir
@client.create_contributors(project_id, params) # Input:
## project_id (string, required)
## params (array of hashes or hash, required) - parameters for the newly created contributors. Pass array of hashes to create multiple contributors, or a hash to create a single contributor
### :email (string, required)
### :fullname (string)
### :is_admin (boolean)
### :is_reviewer (boolean)
### :languages (array of hashes, required if "is_admin" set to false) - possible languages attributes:
#### :lang_iso (string, required)
#### :is_writable (boolean)
### :admin_rights (array)
# Output:
## Collection of newly created contributors
data = %{
contributors: [
%{
email: "[email protected]",
fullname: "Elixir Rocks",
languages: [
%{
lang_iso: "en",
is_writable: false
}
]
}
]
}

{:ok, contributors} = ElixirLokaliseApi.Contributors.create(project_id, data)

contributor = hd contributors.items
contributor.email
```

## Update contributor

[Doc](https://app.lokalise.com/api2docs/curl/#transition-update-a-contributor-put)

```elixir
@client.update_contributor(project_id, contributor_id, params) # Input:
## project_id (string, required)
## contributor_id (string, required)
## params (hash, required)
### :is_admin (boolean)
### :is_reviewer (boolean)
### :languages (array of hashes) - possible languages attributes:
#### :lang_iso (string, required)
#### :is_writable (boolean)
### :admin_rights (array)
# Output:
## Updated contributor
```
data = %{
is_reviewer: true
}

Alternatively:
{:ok, contributor} = ElixirLokaliseApi.Contributors.update(project_id, contributor_id, data)

```elixir
contributor = @client.contributor('project_id', 'contributor_id')
contributor.update(params)
contributor.user_id
```

## Delete contributor

[Doc](https://app.lokalise.com/api2docs/curl/#transition-delete-a-contributor-delete)

```elixir
@client.destroy_contributor(project_id, contributor_id) # Input:
## project_id (string, required)
## contributor_id (string, required)
# Output:
## Hash with the project's id and "contributor_deleted"=>true
```

Alternatively:
{:ok, resp} = ElixirLokaliseApi.Contributors.delete(project_id, contributor_id)

```elixir
contributor = @client.contributor('project_id', 'id')
contributor.destroy
resp.contributor_deleted
```
71 changes: 25 additions & 46 deletions docs/api/custom-translation-statuses.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,79 +9,59 @@
[Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-custom-translation-statuses-get)

```elixir
@client.translation_statuses(project_id, params = {}) # Input:
## project_id (string, required)
## params (hash)
### :page and :limit
# Output:
## Collection of translation statuses for the project
{:ok, statuses} = ElixirLokaliseApi.TranslationStatuses.all(project_id, page: 2, limit: 1)

status = hd(statuses.items)
status.status_id
```

## Fetch a single translation status

[Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-custom-translation-status-get)

```elixir
@client.translation_status(project_id, status_id) # Input:
## project_id (string, required)
## status_id (string or integer, required)
# Output:
## Translation status inside the given project
{:ok, status} = ElixirLokaliseApi.TranslationStatuses.find(project_id, status_id)

status.status_id
```

## Create translation status

[Doc](https://app.lokalise.com/api2docs/curl/#transition-create-a-custom-translation-status-post)

```elixir
@client.create_translation_status(project_id, params) # Input:
## project_id (string, required)
## params (hash, required)
### :title (string, required) - title of the new status
### :color (string, required) - HEX color code of the new status. Lokalise allows a very limited number of color codes to set. Check the official docs or use `#translation_status_colors` method listed below to find the list of supported colors
# Output:
## Created translation status
data = %{
title: "elixir",
color: "#344563"
}

{:ok, status} = ElixirLokaliseApi.TranslationStatuses.create(project_id, data)

status.title
```

## Update translation status

[Doc](https://app.lokalise.com/api2docs/curl/#transition-update-a-custom-translation-status-put)

```elixir
@client.update_translation_status(project_id, status_id, params) # Input:
## project_id (string, required)
## status_id (string or integer, required)
## params (hash, required)
### :title (string, required) - title of the new status
### :color (string, required) - HEX color code of the new status
# Output:
## Updated translation status
```
data = %{
title: "elixir-upd"
}

Alternatively:
{:ok, status} = ElixirLokaliseApi.TranslationStatuses.update(project_id, status_id, data)

```elixir
status = @client.translation_status(project_id, status_id)
status.update(params)
status.title
```

## Delete translation status

[Doc](https://app.lokalise.com/api2docs/curl/#transition-delete-a-custom-translation-status-delete)

```elixir
@client.destroy_translation_status(project_id, status_id) # Input:
## project_id (string, required)
## status_id (string or integer, required)
# Output:
## Result of the delete operation
```

Alternatively:
{:ok, resp} = ElixirLokaliseApi.TranslationStatuses.delete(project_id, status_id)

```elixir
status = @client.translation_status(project_id, status_id)
status.destroy
resp.custom_translation_status_deleted
```

## Supported color codes for translation statuses
Expand All @@ -91,8 +71,7 @@ status.destroy
As long as Lokalise supports only very limited array of color hexadecimal codes for custom translation statuses, this method can be used to fetch all permitted values.

```elixir
@client.translation_status_colors(project_id) # Input:
## project_id (string, required)
# Output:
## Array of color codes in HEX format
{:ok, resp} = ElixirLokaliseApi.TranslationStatuses.available_colors(project_id)

resp.colors
```
Loading

0 comments on commit f1d0783

Please sign in to comment.