Skip to content

Commit

Permalink
docs finished
Browse files Browse the repository at this point in the history
  • Loading branch information
bodrovis committed Mar 18, 2021
1 parent f1d0783 commit f4747d1
Show file tree
Hide file tree
Showing 21 changed files with 290 additions and 530 deletions.
84 changes: 33 additions & 51 deletions docs/api/languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,92 +7,74 @@
[Doc](https://app.lokalise.com/api2docs/curl/#transition-list-system-languages-get)

```elixir
@client.system_languages(params = {}) # Input:
## params (hash)
### :page and :limit
# Output:
## Collection of system languages supported by Lokalise
{:ok, languages} = ElixirLokaliseApi.SystemLanguages.all(page: 3, limit: 2)

language = hd(languages.items)
language.lang_iso
```

## Fetch project languages

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

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

language = languages.items |> hd
language.lang_iso
```

## Fetch a single project language

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

```elixir
@client.language(project_id, language_id) # Input:
## project_id (string, required)
## language_id (string, required)
# Output:
## A single language in the given project
{:ok, language} = ElixirLokaliseApi.ProjectLanguages.find(project_id, lang_id)

language.lang_id
```

## Create project languages

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

```elixir
@client.create_languages(project_id, params) # Input:
## project_id (string, required)
## params (array of hashes or hash, required) - contains parameter of newly created languages. Pass array of hashes to create multiple languages, or a hash to create a single language
### :lang_iso (string, required)
### :custom_iso (string)
### :custom_name (string)
### :custom_plural_forms (array) - can contain only plural forms initially supported by Lokalise
# Output:
## Collection of newly created languages
data = %{
languages: [
%{
lang_iso: "fr",
custom_iso: "samp"
},
%{
lang_iso: "de",
custom_name: "Sample"
}
]
}

{:ok, languages} = ElixirLokaliseApi.ProjectLanguages.create(project_id, data)
languages.items
```

## Update project language

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

```elixir
@client.update_language(project_id, language_id, params) # Input:
## project_id (string, required)
## language_id (string, required)
## params (hash, required)
### :lang_iso (string, required)
### :custom_name (string)
### :plural_forms (array) - can contain only plural forms initially supported by Lokalise
# Output:
## Updated language
```
data = %{
lang_name: "Updated"
}

Alternatively:
{:ok, language} = ElixirLokaliseApi.ProjectLanguages.update(project_id, lang_id, data)

```elixir
language = @client.language('project_id', 'lang_id')
language.update(params)
language.lang_name
```

## Delete project language

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

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

Alternatively:

```elixir
language = @client.language('project_id', 'lang_id')
language.destroy
{:ok, resp} = ElixirLokaliseApi.ProjectLanguages.delete(project_id, lang_id)
resp.language_deleted
```
47 changes: 20 additions & 27 deletions docs/api/orders.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,38 @@
[Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-orders-get)

```elixir
@client.orders(team_id, params = {}) # Input:
## team_id (integer, string, required)
## params (hash)
### :page and :limit
# Output:
## Collection of orders for the given team
{:ok, orders} = ElixirLokaliseApi.Orders.all(team_id, page: 3, limit: 2)

order = hd(orders.items)
order.order_id
```

## Fetch a single order

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

```elixir
@client.order(team_id, order_id) # Input:
## team_id (string, integer, required)
## order_id (string, required)
# Output:
## A single order
{:ok, order} = ElixirLokaliseApi.Orders.find(team_id, order_id)
order.order_id
```

## Create an order

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

```elixir
@client.create_order(team_id, params) # Input:
## team_id (string, integer, required)
## params (hash, required)
### project_id (string, required)
### card_id (integer, string, required) - card to process payment
### briefing (string, required)
### source_language_iso (string, required)
### target_language_isos (array of strings, required)
### keys (array of integers, required) - keys to include in the order
### provider_slug (string, required)
### translation_tier (integer, required)
### dry_run (boolean) - return the response without actually placing an order. Useful for price estimation. Default is `false`
### translation_style (string) - only for gengo provider. Available values are `formal`, `informal`, `business`, `friendly`. Defaults to `friendly`.
# Output:
## A newly created order

data = %{
project_id: "572560965f984614d567a4.18006942",
card_id: 1111,
briefing: "Sample",
source_language_iso: "en",
target_language_isos: ["fr"],
keys: [7921],
provider_slug: "google",
translation_tier: 1
}

{:ok, order} = ElixirLokaliseApi.Orders.create(team_id, data)

order.keys
```
46 changes: 18 additions & 28 deletions docs/api/payment-cards.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,44 @@
[Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-cards-get)

```elixir
@client.payment_cards(params = {}) # Input:
## params (hash)
### :page and :limit
# Output:
## Collection of payment cards under the `payment_cards` attribute
{:ok, cards} = ElixirLokaliseApi.PaymentCards.all(page: 2, limit: 2)

card = hd(cards.items)
card.card_id
```

## Fetch a single payment card

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

```elixir
@client.payment_card(card_id) # Input:
## card_id (string, required)
# Output:
## A single payment card
{:ok, card} = ElixirLokaliseApi.PaymentCards.find(card_id)

card.card_id
```

## Create a payment card

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

```elixir
@client.create_payment_card(params) # Input:
## params (hash, required)
### number (integer, string, required) - card number
### cvc (integer, required) - 3-digit card CVV (CVC)
### exp_month (integer, required) - card expiration month (1 - 12)
### exp_year (integer, required) - card expiration year (for example, 2019)
# Output:
## A newly created payment card
data = %{
number: "1212121212121212",
cvc: 123,
exp_month: 3,
exp_year: 2030
}

{:ok, card} = ElixirLokaliseApi.PaymentCards.create(data)

card.card_id
```

## Delete a payment card

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

```elixir
@client.destroy_payment_card(card_id) # Input:
## card_id (integer, string, required)
# Output:
## Hash containing card id and `card_deleted => true` attribute
```

Alternatively:

```elixir
card = @client.payment_card('card_id')
card.destroy
{:ok, resp} = ElixirLokaliseApi.PaymentCards.delete(card_id)
resp.card_deleted
```
71 changes: 17 additions & 54 deletions docs/api/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,40 @@
[Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-projects-get)

```elixir
@client.projects(params = {}) # Input:
## params (hash)
### :filter_team_id (string) - load projects only for the given team
### :page and :limit
# Output:
## Collection of projects under the `projects` attribute
{:ok, projects} = ElixirLokaliseApi.Projects.all(page: 3, limit: 2)
project = projects.items |> hd
project.name
```

## Fetch a single project

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

```elixir
@client.project(project_id) # Input:
## project_id (string, required)
# Output:
## A single project
{:ok, project} = ElixirLokaliseApi.Projects.find(project_id)

project.project_id
```

## Create a project

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

```elixir
@client.create_project(params) # Input:
## params (hash, required)
### name (string, required)
### description (string)
### team_id (integer) - you must be an admin of the chosen team. When omitted, defaults to the current team of the token's owner
# Output:
## A newly created project

project_data = %{name: "Elixir SDK", description: "Created via API"}
{:ok, project} = ElixirLokaliseApi.Projects.create(project_data)
project.name
```

## Update a project

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

```elixir
@client.update_project(project_id, params) # Input:
## project_id (string, required)
## params (hash, required)
### name (string, required)
### description (string)
# Output:
## An updated project
```

Alternatively:
project_data = %{name: "Updated SDK", description: "Updated via API"}

```elixir
project = @client.project('project_id')
project.update(params)
{:ok, project} = ElixirLokaliseApi.Projects.update(project_id, project_data)
project.project_id
```

## Empty a project
Expand All @@ -69,33 +50,15 @@ project.update(params)
Deletes *all* keys and translations from the project.

```elixir
@client.empty_project(project_id) # Input:
## project_id (string, required)
# Output:
## A project containing its id and a `keys_deleted => true` attribute
```

Alternatively:

```elixir
project = @client.project('project_id')
project.empty
{:ok, resp} = ElixirLokaliseApi.Projects.empty(project_id)
resp.keys_deleted
```

## Delete a project

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

```elixir
@client.destroy_project(project_id) # Input:
## project_id (string, required)
# Output:
## A project containing its id and a `project_deleted => true` attribute
```

Alternatively:

```elixir
project = @client.project('project_id')
project.destroy
```
{:ok, resp} = ElixirLokaliseApi.Projects.delete(project_id)
resp.project_deleted
```
Loading

0 comments on commit f4747d1

Please sign in to comment.