diff --git a/docs/api/languages.md b/docs/api/languages.md index 4e54a52..7abb3a9 100644 --- a/docs/api/languages.md +++ b/docs/api/languages.md @@ -7,11 +7,10 @@ [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 @@ -19,12 +18,10 @@ [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 @@ -32,11 +29,9 @@ [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 @@ -44,15 +39,21 @@ [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 @@ -60,22 +61,13 @@ [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 @@ -83,16 +75,6 @@ language.update(params) [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 ``` diff --git a/docs/api/orders.md b/docs/api/orders.md index 70aa728..082dcdc 100644 --- a/docs/api/orders.md +++ b/docs/api/orders.md @@ -7,12 +7,10 @@ [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 @@ -20,11 +18,8 @@ [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 @@ -32,20 +27,18 @@ [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 ``` diff --git a/docs/api/payment-cards.md b/docs/api/payment-cards.md index 3a9e217..cb75ef0 100644 --- a/docs/api/payment-cards.md +++ b/docs/api/payment-cards.md @@ -7,11 +7,10 @@ [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 @@ -19,10 +18,9 @@ [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 @@ -30,15 +28,16 @@ [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 @@ -46,15 +45,6 @@ [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 ``` diff --git a/docs/api/projects.md b/docs/api/projects.md index 28dd400..0f67dca 100644 --- a/docs/api/projects.md +++ b/docs/api/projects.md @@ -7,12 +7,9 @@ [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 @@ -20,10 +17,9 @@ [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 @@ -31,14 +27,9 @@ [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 @@ -46,20 +37,10 @@ [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 @@ -69,17 +50,8 @@ 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 @@ -87,15 +59,6 @@ project.empty [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 +``` \ No newline at end of file diff --git a/docs/api/queued-processes.md b/docs/api/queued-processes.md index 942799c..9dd85e7 100644 --- a/docs/api/queued-processes.md +++ b/docs/api/queued-processes.md @@ -7,10 +7,7 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-processes-get) ```elixir -@client.queued_processes(project_id) # Input: - ## project_id (string, required) - # Output: - ## Collection of queued processes +{:ok, processes} = ElixirLokaliseApi.QueuedProcesses.all(project_id, page: 2, limit: 1) ``` ## Fetch a single queued process @@ -18,9 +15,7 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-process-get) ```elixir -@client.queued_process(project_id, process_id) # Input: - ## project_id (string, required) - ## process_id (string, required) - # Output: - ## Queued process resource +{:ok, process} = ElixirLokaliseApi.QueuedProcesses.find(project_id, process_id) + +process.type ``` diff --git a/docs/api/screenshots.md b/docs/api/screenshots.md index 795f6a3..238cc7d 100644 --- a/docs/api/screenshots.md +++ b/docs/api/screenshots.md @@ -7,12 +7,10 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-screenshots-get) ```elixir -@client.screenshots(project_id, params = {}) # Input: - ## project_id (string, required) - ## params (hash) - ### :page and :limit - # Output: - ## Collection of project screenshots +{:ok, screenshots} = ElixirLokaliseApi.Screenshots.all(project_id, page: 2, limit: 1) + +screenshot = hd(screenshots.items) +screenshot.screenshot_id ``` ## Fetch a single screenshot @@ -20,11 +18,9 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-screenshot-get) ```elixir -@client.screeshot(project_id, screeshot_id) # Input: - ## project_id (string, required) - ## screeshot_id (string, required) - # Output: - ## A single screenshot +{:ok, screenshot} = ElixirLokaliseApi.Screenshots.find(project_id, screenshot_id) + +screenshot.screenshot_id ``` ## Create screenshots @@ -32,17 +28,19 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-create-screenshots-post) ```elixir -@client.create_screenshots(project_id, params) # Input: - ## project_id (string, required) - ## params (hash or array of hashes, required) - ### :data (string, required) - the actual screenshot, base64-encoded (with leading image type "data:image/jpeg;base64,"). JPG and PNG formats are supported. - ### :title (string) - ### :description (string) - ### :ocr (boolean) - recognize translations on the image and attach screenshot to all possible keys - ### :key_ids (array) - attach the screenshot to key IDs specified - ### :tags (array) - # Output: - ## Collection of created screenshots +data = %{ + screenshots: [ + %{ + data: base64_data, + title: "Elixir screen" + } + ] +} + +{:ok, screenshots} = ElixirLokaliseApi.Screenshots.create(project_id, data) + +screenshot = hd(screenshots.items) +screenshot.title ``` ## Update screenshot @@ -50,23 +48,14 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-update-a-screenshot-put) ```elixir -@client.update_screenshot(project_id, screenshot_id, params = {}) # Input: - ## project_id (string, required) - ## screenshot_id (string, required) - ## params (hash) - ### :title (string) - ### :description (string) - ### :key_ids (array) - attach the screenshot to key IDs specified - ### :tags (array) - # Output: - ## Updated screenshot -``` +data = %{ + title: "Elixir updated", + description: "Mix test" +} -Alternatively: +{:ok, screenshot} = ElixirLokaliseApi.Screenshots.update(project_id, screenshot_id, data) -```elixir -screenshot = @client.screenshot('project_id', 'screen_id') -screenshot.update(params) +screenshot.title ``` ## Delete screenshot @@ -74,16 +63,7 @@ screenshot.update(params) [Doc](https://app.lokalise.com/api2docs/curl/#transition-delete-a-screenshot-delete) ```elixir -@client.destroy_screenshot(project_id, screenshot_id) # Input: - ## project_id (string, required) - ## screenshot_id (string, required) - # Output: - ## Hash with the project id and "screenshot_deleted" set to "true" -``` - -Alternatively: +{:ok, resp} = ElixirLokaliseApi.Screenshots.delete(project_id, screenshot_id) -```elixir -screenshot = @client.screenshot('project_id', 'screen_id') -screenshot.destroy +resp.screenshot_deleted ``` diff --git a/docs/api/snapshots.md b/docs/api/snapshots.md index 01bc367..3eb81fe 100644 --- a/docs/api/snapshots.md +++ b/docs/api/snapshots.md @@ -7,13 +7,10 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-snapshots-get) ```elixir -@client.snapshots(project_id, params = {}) # Input: - ## project_id (string, required) - ## params (hash) - ### :filter_title (string) - set title filter for the list - ### :page and :limit - # Output: - ## Collection of project snapshots +{:ok, snapshots} = ElixirLokaliseApi.Snapshots.all(project_id, page: 2, limit: 1) + +snapshot = hd(snapshots.items) +snapshot.snapshot_id ``` ## Create snapshot @@ -21,12 +18,12 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-create-a-snapshot-post) ```elixir -@client.create_snapshot(project_id, params = {}) # Input: - ## project_id (string, required) - ## params (hash) - ### :title (string) - # Output: - ## Created snapshot +data = %{ + title: "Elixir snap" +} + +{:ok, snapshot} = ElixirLokaliseApi.Snapshots.create(project_id, data) +snapshot.title ``` ## Restore snapshot @@ -34,18 +31,9 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-restore-a-snapshot-post) ```elixir -@client.restore_snapshot(project_id, snapshot_id) # Input: - ## project_id (string, required) - ## snapshot_id (string, required) - # Output: - ## Information about the restored project from the specified snapshot -``` - -Alternatively: +{:ok, project} = ElixirLokaliseApi.Snapshots.restore(project_id, snapshot_id) -```elixir -snapshot = @client.snapshots('project_id').first # you can't fetch a single snapshot -snapshot.restore +project.project_id ``` ## Delete snapshot @@ -53,16 +41,7 @@ snapshot.restore [Doc](https://app.lokalise.com/api2docs/curl/#transition-delete-a-snapshot-delete) ```elixir -@client.destroy_snapshot(project_id, snapshot_id) # Input: - ## project_id (string, required) - ## snapshot_id (string, required) - # Output: - ## Hash with the project id and "snapshot_deleted" set to "true" -``` +{:ok, resp} = ElixirLokaliseApi.Snapshots.delete(project_id, snapshot_id) -Alternatively: - -```elixir -snapshot = @client.snapshots('project_id').first # you can't fetch a single snapshot -snapshot.destroy +resp.snapshot_deleted ``` diff --git a/docs/api/tasks.md b/docs/api/tasks.md index 61a0e96..a0bc734 100644 --- a/docs/api/tasks.md +++ b/docs/api/tasks.md @@ -7,13 +7,10 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-tasks-get) ```elixir -@client.tasks(project_id, params = {}) # Input: - ## project_id (string, required) - ## params (hash) - ### :filter_title (string) - set title filter for the list - ### :page and :limit - # Output: - ## Collection of tasks for the project +{:ok, tasks} = ElixirLokaliseApi.Tasks.all(project_id, page: 2, limit: 1, filter_statuses: "completed") + +task = hd(tasks.items) +task.task_id ``` ## Fetch a single task @@ -21,11 +18,8 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-task-get) ```elixir -@client.task(project_id, task_id, params = {}) # Input: - ## project_id (string, required) - ## task_id (string, required) - # Output: - ## Single task for the project +{:ok, task} = ElixirLokaliseApi.Tasks.find(project_id, task_id) +task.task_id ``` ## Create task @@ -33,18 +27,20 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-create-a-task-post) ```elixir -@client.create_task(project_id, params) # Input: - ## project_id (string, required) - ## params (hash, required) - ### title (string, required) - ### keys (array) - translation key ids. Required if "parent_task_id" is not specified - ### languages (array of hashes, required) - #### language_iso (string) - #### users (array) - list of users identifiers, assigned to work on the language - ### Find other supported options at https://app.lokalise.com/api2docs/curl/#transition-create-a-task-post - # Output: - ## A newly created task - +data = %{ + title: "Elixir", + keys: [74_185, 74_187], + languages: [ + %{ + language_iso: "sq", + users: [2018] + } + ] +} + +{:ok, task} = ElixirLokaliseApi.Tasks.create(project_id, data) + +task.title ``` ## Update task @@ -52,21 +48,14 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-update-a-task-put) ```elixir -@client.update_task(project_id, task_id, params = {}) # Input: - ## project_id (string, required) - ## task_id (string or integer, required) - ## params (hash) - ### Find supported params at https://app.lokalise.com/api2docs/curl/#transition-update-a-task-put - # Output: - ## An updated task +data = %{ + title: "Elixir updated", + description: "sample" +} -``` +{:ok, task} = ElixirLokaliseApi.Tasks.update(project_id, task_id, data) -Alternatively: - -```elixir -task = @client.task('project_id', 'task_id') -task.update(params) +task.task_id ``` ## Delete task @@ -74,17 +63,7 @@ task.update(params) [Doc](https://app.lokalise.com/api2docs/curl/#transition-delete-a-task-delete) ```elixir -@client.destroy_task(project_id, task_id) # Input: - ## project_id (string, required) - ## task_id (string, required) - # Output: - ## Hash with the project id and "task_deleted" set to "true" +{:ok, resp} = ElixirLokaliseApi.Tasks.delete(project_id, task_id) -``` - -Alternatively: - -```elixir -task = @client.task('project_id', 'task_id') -task.destroy +resp.task_deleted ``` diff --git a/docs/api/team-user-groups.md b/docs/api/team-user-groups.md index eef014d..23a3c41 100644 --- a/docs/api/team-user-groups.md +++ b/docs/api/team-user-groups.md @@ -7,12 +7,10 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-groups-get) ```elixir -@client.team_user_groups(team_id, params = {}) # Input: - ## team_id (string, required) - ## params (hash) - ### :page and :limit - # Output: - ## Collection of team user groups +{:ok, groups} = ElixirLokaliseApi.TeamUserGroups.all(team_id, page: 3, limit: 2) + +group = hd(groups.items) +group.group_id ``` ## Fetch a single group @@ -20,11 +18,9 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-group-get) ```elixir -@client.team_user_group(team_id, group_id) # Input: - ## team_id (string, required) - ## group_id (string, required) - # Output: - ## Group +{:ok, group} = ElixirLokaliseApi.TeamUserGroups.find(team_id, group_id) + +group.group_id ``` ## Create group @@ -32,16 +28,19 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-create-a-group-post) ```elixir -@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 +data = %{ + name: "ExGroup", + is_reviewer: true, + is_admin: false, + languages: %{ + reference: [], + contributable: [640] + } +} + +{:ok, group} = ElixirLokaliseApi.TeamUserGroups.create(team_id, data) + +group.name ``` ## Update group @@ -49,24 +48,19 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-update-a-group-put) ```elixir -@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 -``` - -Alternatively: - -```elixir -group = @client.team_user_group('team_id', 'group_id') -group.update(params) +data = %{ + name: "ExGroup Updated", + is_reviewer: true, + is_admin: false, + languages: %{ + reference: [], + contributable: [640] + } +} + +{:ok, group} = ElixirLokaliseApi.TeamUserGroups.update(team_id, group_id, data) + +group.name ``` ## Add projects to group @@ -74,17 +68,13 @@ group.update(params) [Doc](https://app.lokalise.com/api2docs/curl/#transition-add-projects-to-group-put) ```elixir -@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 -``` +data = %{ + projects: [project_id] +} -Alternatively: +{:ok, group} = ElixirLokaliseApi.TeamUserGroups.add_projects(team_id, group_id, data) -```elixir -group = @client.team_user_group('team_id', 'group_id') -group.add_projects projects: [project_id1, project_id2] +assert group.group_id ``` ## Remove projects from group @@ -92,17 +82,13 @@ group.add_projects projects: [project_id1, project_id2] [Doc](https://app.lokalise.com/api2docs/curl/#transition-remove-projects-from-group-put) ```elixir -@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 -``` +data = %{ + projects: [project_id] +} -Alternatively: +{:ok, group} = ElixirLokaliseApi.TeamUserGroups.remove_projects(team_id, group_id, data) -```elixir -group = @client.team_user_group('team_id', 'group_id') -group.remove_projects projects: [project_id1, project_id2] +group.group_id ``` ## Add users to group @@ -110,17 +96,13 @@ group.remove_projects projects: [project_id1, project_id2] [Doc](https://app.lokalise.com/api2docs/curl/#transition-add-members-to-group-put) ```elixir -@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 -``` +data = %{ + users: [user_id] +} -Alternatively: +{:ok, group} = ElixirLokaliseApi.TeamUserGroups.add_members(team_id, group_id, data) -```elixir -group = @client.team_user_group('team_id', 'group_id') -group.add_users users: [user_id1, user_id2] +group.group_id ``` ## Remove users from group @@ -128,17 +110,13 @@ group.add_users users: [user_id1, user_id2] [Doc](https://app.lokalise.com/api2docs/curl/#transition-remove-members-from-group-put) ```elixir -@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 -``` +data = %{ + users: [user_id] +} -Alternatively: +{:ok, group} = ElixirLokaliseApi.TeamUserGroups.remove_members(team_id, group_id, data) -```elixir -group = @client.team_user_group('team_id', 'group_id') -group.remove_users users: [user_id1, user_id2] +group.group_id ``` ## Destroy group @@ -146,16 +124,7 @@ group.remove_users users: [user_id1, user_id2] [Doc](https://app.lokalise.com/api2docs/curl/#transition-delete-a-group-delete) ```elixir -@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" -``` +{:ok, resp} = ElixirLokaliseApi.TeamUserGroups.delete(team_id, group_id) -Alternatively: - -```elixir -group = @client.team_user_group('team_id', 'group_id') -group.destroy +resp.group_deleted ``` diff --git a/docs/api/team-users.md b/docs/api/team-users.md index ac61881..8089b05 100644 --- a/docs/api/team-users.md +++ b/docs/api/team-users.md @@ -7,12 +7,10 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-team-users-get) ```elixir -@client.team_users(team_id, params = {}) # Input: - ## team_id (string, required) - ## params (hash) - ### :page and :limit - # Output: - ## Collection of team users +{:ok, users} = ElixirLokaliseApi.TeamUsers.all(team_id, limit: 1, page: 2) + +user = hd(users.items) +user.user_id ``` ## Fetch a single team user @@ -20,11 +18,9 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-team-user-get) ```elixir -@client.team_user(team_id, user_id) # Input: - ## team_id (string, required) - ## user_id (string, required) - # Output: - ## Team user +{:ok, user} = ElixirLokaliseApi.TeamUsers.find(team_id, user_id) + +user.user_id ``` ## Update team user @@ -32,20 +28,13 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-update-a-team-user-put) ```elixir -@client.update_team_user(team_id, user_id, params) # Input: - ## team_id (string, required) - ## user_id (string, required) - ## params (hash, required): - ### :role (string, required) - :owner, :admin, or :member - # Output: - ## Updated team user -``` +data = %{ + role: "admin" +} -Alternatively: +{:ok, user} = ElixirLokaliseApi.TeamUsers.update(team_id, user_id, data) -```elixir -user = @client.team_user('team_id', 'user_id') -user.update(params) +user.user_id ``` ## Delete team user @@ -53,16 +42,7 @@ user.update(params) [Doc](https://app.lokalise.com/api2docs/curl/#transition-delete-a-team-user-delete) ```elixir -@client.destroy_team_user(team_id, user_id) # Input: - ## team_id (string, required) - ## user_id (string, required) - # Output: - ## Hash with "team_id" and "team_user_deleted" set to "true" -``` - -Alternatively: +{:ok, resp} = ElixirLokaliseApi.TeamUsers.delete(team_id, user_id) -```elixir -user = @client.team_user('team_id', 'user_id') -user.destroy +resp.team_user_deleted ``` diff --git a/docs/api/teams.md b/docs/api/teams.md index 9bc2012..b2ce70b 100644 --- a/docs/api/teams.md +++ b/docs/api/teams.md @@ -5,9 +5,8 @@ [Doc](https://app.lokalise.com/api2docs/curl/#resource-teams) ```elixir -@client.teams(params = {}) # Input: - ## params (hash) - ### :page and :limit - # Output: - ## Collection of teams +{:ok, teams} = ElixirLokaliseApi.Teams.all(page: 2, limit: 3) + +team = hd(teams.items) +team.team_id ``` diff --git a/docs/api/translation-providers.md b/docs/api/translation-providers.md index 4549064..2a3a56f 100644 --- a/docs/api/translation-providers.md +++ b/docs/api/translation-providers.md @@ -7,12 +7,10 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-providers-get) ```elixir -@client.translation_providers(team_id, params = {}) # Input: - ## team_id (string, required) - ## params (hash) - ### :page and :limit - # Output: - ## Collection of providers for the team +{:ok, translation_providers} = ElixirLokaliseApi.TranslationProviders.all(team_id, page: 2, limit: 1) + +provider = hd(translation_providers.items) +provider.provider_id ``` ## Fetch a single translation provider @@ -20,9 +18,7 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-provider-get) ```elixir -@client.translation_provider(team_id, provider_id) # Input: - ## team_id (string, required) - ## provider_id (string, required) - # Output: - ## Single provider for the team +{:ok, provider} = ElixirLokaliseApi.TranslationProviders.find(team_id, provider_id) + +provider.provider_id ``` diff --git a/docs/api/translations.md b/docs/api/translations.md index e23db04..44de0e5 100644 --- a/docs/api/translations.md +++ b/docs/api/translations.md @@ -7,13 +7,10 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-translations-get) ```elixir -@client.translations(project_id, params = {}) # Input: - ## project_id (string, required) - ## params (hash) - ### Find full list in the docs - ### :page and :limit - # Output: - ## Collection of translations for the project +{:ok, translations} = ElixirLokaliseApi.Translations.all(@project_id, filter_is_reviewed: 0, page: 2, limit: 1) + +translation = hd(translations.items) +translation.translation_id ``` ## Fetch a single translation @@ -21,13 +18,9 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-translation-get) ```elixir -@client.translation(project_id, translation_id, params = {}) # Input: - ## project_id (string, required) - ## translation_id (string, required) - ## params (hash) - ### :disable_references (string) - whether to disable key references. Supported values are 0 and 1 - # Output: - ## Single translation for the project +{:ok, translation} = ElixirLokaliseApi.Translations.find(project_id, translation_id, disable_references: 1) + +translation.translation_id ``` ## Update translation @@ -35,20 +28,12 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-update-a-translation-put) ```elixir -@client.update_translation(project_id, translation_id, params = {}) # Input: - ## project_id (string, required) - ## translation_id (string, required) - ## params (hash, required) - ### :translation (string or hash, required) - the actual translation. Provide hash for plural keys. - ### :is_fuzzy (boolean) - ### :is_reviewed (boolean) - # Output: - ## Updated translation -``` +data = %{ + translation: "Updated!", + is_reviewed: true +} -Alternatively: +{:ok, translation} = ElixirLokaliseApi.Translations.update(project_id, translation_id, data) -```elixir -translation = @client.translation('project_id', 'translation_id') -translation.update(params) +translation.translation_id ``` diff --git a/docs/api/webhooks.md b/docs/api/webhooks.md index bed6aa1..83fa1d5 100644 --- a/docs/api/webhooks.md +++ b/docs/api/webhooks.md @@ -7,12 +7,10 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-list-all-webhooks-get) ```elixir -@client.webhooks(project_id, params = {}) # Input: - ## project_id (string, required) - ## params (hash) - ### :page and :limit - # Output: - ## Collection of webhooks for the project +{:ok, webhooks} = ElixirLokaliseApi.Webhooks.all(project_id, page: 2, limit: 1) + +webhook = hd(webhooks.items) +webhook.webhook_id ``` ## Fetch a single webhook @@ -20,11 +18,9 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-webhook-get) ```elixir -@client.webhook(project_id, webhook_id) # Input: - ## project_id (string, required) - ## webhook_id (string, required) - # Output: - ## Webhook for the given project +{:ok, webhook} = ElixirLokaliseApi.Webhooks.find(project_id, webhook_id) + +webhook.webhook_id ``` ## Create webhook @@ -32,14 +28,14 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-create-a-webhook-post) ```elixir -@client.create_webhook(project_id, params) # Input: - ## project_id (string, required) - ## params (hash, required) - ### :url (string, required) - webhook URL - ### :events (array, required) - events to subscribe to. Check the API docs to find the list of supported events - ### :event_lang_map (array) - map the event with an array of languages iso codes - # Output: - ## Created webhook +data = %{ + url: "http://bodrovis.tech/lokalise", + events: ["project.imported"] +} + +{:ok, webhook} = ElixirLokaliseApi.Webhooks.create(project_id, data) + +webhook.url ``` ## Update webhook @@ -47,22 +43,13 @@ [Doc](https://app.lokalise.com/api2docs/curl/#transition-update-a-webhook-put) ```elixir -@client.update_webhook(project_id, webhook_id, params) # Input: - ## project_id (string, required) - ## webhook_id (string, required) - ## params (hash) - ### :url (string) - webhook URL - ### :events (array) - events to subscribe to. Check the API docs to find the list of supported events - ### :event_lang_map (array) - map the event with an array of languages iso codes - # Output: - ## Updated webhook -``` +data = %{ + events: ["project.exported"] +} -Alternatively: +{:ok, webhook} = ElixirLokaliseApi.Webhooks.update(project_id, webhook_id, data) -```elixir -webhook = @client.webhook(project_id, webhook_id) -webhook.update(params) +webhook.webhook_id ``` ## Delete webhook @@ -70,18 +57,9 @@ webhook.update(params) [Doc](https://app.lokalise.com/api2docs/curl/#transition-delete-a-webhook-delete) ```elixir -@client.destroy_webhook(project_id, webhook_id) # Input: - ## project_id (string, required) - ## webhook_id (string, required) - # Output: - ## Result of the delete operation -``` - -Alternatively: +{:ok, resp} = ElixirLokaliseApi.Webhooks.delete(project_id, webhook_id) -```elixir -webhook = @client.webhook(project_id, webhook_id) -webhook.destroy +resp.webhook_deleted ``` ## Regenerate webhook secret @@ -89,16 +67,8 @@ webhook.destroy [Doc](https://app.lokalise.com/api2docs/curl/#transition-regenerate-a-webhook-secret-patch) ```elixir -@client.regenerate_webhook_secret(project_id, webhook_id) # Input: - ## project_id (string, required) - ## webhook_id (string, required) - # Output: - ## Hash containing `project_id` and new `secret` -``` - -Alternatively: +{:ok, resp} = ElixirLokaliseApi.Webhooks.regenerate_secret(project_id, webhook_id) -```elixir -webhook = @client.webhook(project_id, webhook_id) -webhook.regenerate_secret +resp.project_id +resp.secret ``` diff --git a/test/elixir_lokalise_api/endpoints/branches_test.exs b/test/elixir_lokalise_api/endpoints/branches_test.exs index 2b47211..c79f9f8 100644 --- a/test/elixir_lokalise_api/endpoints/branches_test.exs +++ b/test/elixir_lokalise_api/endpoints/branches_test.exs @@ -44,7 +44,7 @@ defmodule ElixirLokaliseApi.BranchesTest do refute branches |> Pagination.next_page?() assert branches |> Pagination.prev_page?() - branch = hd branches.items + branch = hd(branches.items) assert branch.name == "master" end end diff --git a/test/elixir_lokalise_api/endpoints/contributors_test.exs b/test/elixir_lokalise_api/endpoints/contributors_test.exs index 3ea80df..9af4390 100644 --- a/test/elixir_lokalise_api/endpoints/contributors_test.exs +++ b/test/elixir_lokalise_api/endpoints/contributors_test.exs @@ -21,7 +21,7 @@ defmodule ElixirLokaliseApi.ContributorsTest do assert Enum.count(contributors.items) == 3 assert contributors.project_id == @project_id - contributor = hd contributors.items + contributor = hd(contributors.items) assert contributor.user_id == 20181 end end @@ -85,7 +85,7 @@ defmodule ElixirLokaliseApi.ContributorsTest do assert contributors.project_id == @project_id - contributor = hd contributors.items + contributor = hd(contributors.items) assert contributor.email == "elixir_test@example.com" assert contributor.fullname == "Elixir Rocks" diff --git a/test/elixir_lokalise_api/endpoints/files_test.exs b/test/elixir_lokalise_api/endpoints/files_test.exs index c50f4bc..7b7f330 100644 --- a/test/elixir_lokalise_api/endpoints/files_test.exs +++ b/test/elixir_lokalise_api/endpoints/files_test.exs @@ -62,7 +62,7 @@ defmodule ElixirLokaliseApi.FilesTest do refute files |> Pagination.next_page?() assert files |> Pagination.prev_page?() - file = hd files.items + file = hd(files.items) assert file.filename == "test_async.json" end end diff --git a/test/elixir_lokalise_api/endpoints/key_comments_test.exs b/test/elixir_lokalise_api/endpoints/key_comments_test.exs index ed1a6de..729e946 100644 --- a/test/elixir_lokalise_api/endpoints/key_comments_test.exs +++ b/test/elixir_lokalise_api/endpoints/key_comments_test.exs @@ -48,7 +48,7 @@ defmodule ElixirLokaliseApi.KeyCommentsTest do assert comments |> Pagination.next_page?() assert comments |> Pagination.prev_page?() - comment = hd comments.items + comment = hd(comments.items) assert comment.comment == "Image file key" end end @@ -81,7 +81,7 @@ defmodule ElixirLokaliseApi.KeyCommentsTest do assert Enum.count(comments.items) == 1 assert comments.project_id == @project_id - comment = hd comments.items + comment = hd(comments.items) assert comment.comment == "Elixir comment" assert comment.key_id == @key_id end diff --git a/test/elixir_lokalise_api/endpoints/keys_test.exs b/test/elixir_lokalise_api/endpoints/keys_test.exs index 5cee51e..d6d2e27 100644 --- a/test/elixir_lokalise_api/endpoints/keys_test.exs +++ b/test/elixir_lokalise_api/endpoints/keys_test.exs @@ -46,7 +46,7 @@ defmodule ElixirLokaliseApi.KeysTest do refute keys |> Pagination.next_page?() assert keys |> Pagination.prev_page?() - key = hd keys.items + key = hd(keys.items) assert key.key_id == 79_039_609 end end @@ -120,7 +120,7 @@ defmodule ElixirLokaliseApi.KeysTest do {:ok, %KeysCollection{} = keys} = Keys.create(@project_id, data) - key = hd keys.items + key = hd(keys.items) assert key.key_name.android == "elixir" assert key.description == "Via API" assert List.first(key.translations).translation == "Hi from Elixir" diff --git a/test/elixir_lokalise_api/endpoints/project_comments_test.exs b/test/elixir_lokalise_api/endpoints/project_comments_test.exs index cfd8c10..f5753ad 100644 --- a/test/elixir_lokalise_api/endpoints/project_comments_test.exs +++ b/test/elixir_lokalise_api/endpoints/project_comments_test.exs @@ -45,7 +45,7 @@ defmodule ElixirLokaliseApi.ProjectCommentsTest do assert comments |> Pagination.next_page?() assert comments |> Pagination.prev_page?() - comment = hd comments.items + comment = hd(comments.items) assert comment.comment == "my comment" end end diff --git a/test/elixir_lokalise_api/endpoints/projects_test.exs b/test/elixir_lokalise_api/endpoints/projects_test.exs index dccb498..d0616a5 100644 --- a/test/elixir_lokalise_api/endpoints/projects_test.exs +++ b/test/elixir_lokalise_api/endpoints/projects_test.exs @@ -36,7 +36,7 @@ defmodule ElixirLokaliseApi.ProjectsTest do test "lists paginated projects" do use_cassette "projects_all_paginated" do {:ok, %ProjectsCollection{} = projects} = Projects.all(page: 3, limit: 2) - project = projects.items |> List.first() + project = projects.items |> hd assert project.name == "Demo" assert Enum.count(projects.items) == 2