ruby-lokalise-api 2.9.0.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODE_OF_CONDUCT.md +1 -1
  3. data/.github/CONTRIBUTING.md +9 -2
  4. data/CHANGELOG.md +1 -80
  5. data/LICENSE +9 -18
  6. data/README.md +18 -1734
  7. data/lib/ruby-lokalise-api.rb +2 -0
  8. data/lib/ruby-lokalise-api/client.rb +17 -5
  9. data/lib/ruby-lokalise-api/collections/base.rb +5 -3
  10. data/lib/ruby-lokalise-api/collections/queued_process.rb +15 -0
  11. data/lib/ruby-lokalise-api/connection.rb +1 -1
  12. data/lib/ruby-lokalise-api/data/attributes.json +30 -12
  13. data/lib/ruby-lokalise-api/request.rb +8 -1
  14. data/lib/ruby-lokalise-api/resources/base.rb +55 -25
  15. data/lib/ruby-lokalise-api/resources/branch.rb +1 -1
  16. data/lib/ruby-lokalise-api/resources/contributor.rb +1 -1
  17. data/lib/ruby-lokalise-api/resources/custom_translation_status.rb +1 -1
  18. data/lib/ruby-lokalise-api/resources/file.rb +3 -1
  19. data/lib/ruby-lokalise-api/resources/key.rb +1 -1
  20. data/lib/ruby-lokalise-api/resources/key_comment.rb +1 -1
  21. data/lib/ruby-lokalise-api/resources/order.rb +2 -0
  22. data/lib/ruby-lokalise-api/resources/payment_card.rb +1 -1
  23. data/lib/ruby-lokalise-api/resources/project.rb +2 -2
  24. data/lib/ruby-lokalise-api/resources/project_language.rb +1 -1
  25. data/lib/ruby-lokalise-api/resources/queued_process.rb +18 -0
  26. data/lib/ruby-lokalise-api/resources/screenshot.rb +1 -1
  27. data/lib/ruby-lokalise-api/resources/snapshot.rb +3 -1
  28. data/lib/ruby-lokalise-api/resources/task.rb +1 -1
  29. data/lib/ruby-lokalise-api/resources/team_user.rb +1 -1
  30. data/lib/ruby-lokalise-api/resources/team_user_group.rb +2 -1
  31. data/lib/ruby-lokalise-api/resources/translation.rb +1 -1
  32. data/lib/ruby-lokalise-api/resources/translation_provider.rb +3 -0
  33. data/lib/ruby-lokalise-api/resources/webhook.rb +11 -3
  34. data/lib/ruby-lokalise-api/rest/comments.rb +5 -5
  35. data/lib/ruby-lokalise-api/rest/contributors.rb +5 -5
  36. data/lib/ruby-lokalise-api/rest/custom_translation_statuses.rb +6 -6
  37. data/lib/ruby-lokalise-api/rest/files.rb +3 -3
  38. data/lib/ruby-lokalise-api/rest/keys.rb +7 -7
  39. data/lib/ruby-lokalise-api/rest/languages.rb +6 -6
  40. data/lib/ruby-lokalise-api/rest/payment_cards.rb +3 -3
  41. data/lib/ruby-lokalise-api/rest/projects.rb +6 -6
  42. data/lib/ruby-lokalise-api/rest/queued_processes.rb +26 -0
  43. data/lib/ruby-lokalise-api/rest/screenshots.rb +5 -5
  44. data/lib/ruby-lokalise-api/rest/snapshots.rb +4 -4
  45. data/lib/ruby-lokalise-api/rest/tasks.rb +5 -5
  46. data/lib/ruby-lokalise-api/rest/team_user_group.rb +4 -4
  47. data/lib/ruby-lokalise-api/rest/team_users.rb +4 -4
  48. data/lib/ruby-lokalise-api/rest/teams.rb +1 -1
  49. data/lib/ruby-lokalise-api/rest/translation_providers.rb +2 -2
  50. data/lib/ruby-lokalise-api/rest/translations.rb +3 -3
  51. data/lib/ruby-lokalise-api/rest/webhooks.rb +16 -5
  52. data/lib/ruby-lokalise-api/utils/attribute_helpers.rb +11 -6
  53. data/lib/ruby-lokalise-api/version.rb +1 -1
  54. data/ruby-lokalise-api.gemspec +6 -6
  55. data/spec/lib/ruby-lokalise-api/custom_json_parser_spec.rb +4 -4
  56. data/spec/lib/ruby-lokalise-api/error_spec.rb +8 -0
  57. data/spec/lib/ruby-lokalise-api/rest/branches_spec.rb +12 -0
  58. data/spec/lib/ruby-lokalise-api/rest/comments_spec.rb +12 -0
  59. data/spec/lib/ruby-lokalise-api/rest/contributors_spec.rb +12 -0
  60. data/spec/lib/ruby-lokalise-api/rest/custom_translation_statuses_spec.rb +12 -0
  61. data/spec/lib/ruby-lokalise-api/rest/files_spec.rb +17 -9
  62. data/spec/lib/ruby-lokalise-api/rest/keys_spec.rb +38 -20
  63. data/spec/lib/ruby-lokalise-api/rest/languages_spec.rb +12 -0
  64. data/spec/lib/ruby-lokalise-api/rest/orders_spec.rb +38 -2
  65. data/spec/lib/ruby-lokalise-api/rest/payment_cards_spec.rb +19 -5
  66. data/spec/lib/ruby-lokalise-api/rest/projects_spec.rb +12 -0
  67. data/spec/lib/ruby-lokalise-api/rest/queued_processes_spec.rb +57 -0
  68. data/spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb +12 -0
  69. data/spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb +25 -0
  70. data/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb +20 -7
  71. data/spec/lib/ruby-lokalise-api/rest/team_user_groups_spec.rb +84 -0
  72. data/spec/lib/ruby-lokalise-api/rest/team_users_spec.rb +13 -0
  73. data/spec/lib/ruby-lokalise-api/rest/translation_providers_spec.rb +5 -0
  74. data/spec/lib/ruby-lokalise-api/rest/translations_spec.rb +12 -0
  75. data/spec/lib/ruby-lokalise-api/rest/webhooks_spec.rb +50 -0
  76. metadata +21 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8aa6e75e9dc1a1222dcd06066268fc71f9729086ed10ebc612e42a4d2d28bc1b
4
- data.tar.gz: 7ee797f27ce71c74623fe7d86a89eaf0d7eeda018ca43d0b302c6f2fd4eedd9a
3
+ metadata.gz: 61d306f7be49970786734ed94a006a6fd37d54e6919c19eb61390f78ad5acff8
4
+ data.tar.gz: ea3a5594f544a876386ffa1d50c1a7ff2a842966ca00811df33f54d9e304106e
5
5
  SHA512:
6
- metadata.gz: 4e0cd4ffcc6be509e79fd841adc3cb06cf4650cdb8589506cc1d4ce6dd628aec27736924c0ac0af7ca3a6138d5f7370dd8add6de71f569a5251e71641e1e56cc
7
- data.tar.gz: 7de2306a64022969b441d747fb9e3424d1ef8ad48928bbe2a34938bd19845b6a347538b483c9a3db556bb4f5b84b6dbc6c5331213072e1ca4dd934646a7259eb
6
+ metadata.gz: 356f32428e0732321e27bc47f2c63022bea36990fb69886fa2daff9d2016bee3f9b80795c326ef4c090f280e58de51d65e8b5e9c6711b3de2be6bb37ae2b2c01
7
+ data.tar.gz: 4d5eb8f4fac05abf181fe793d94b2ec5ca759c004d865bbbd085252e4ac49d5abded9056fe0535bb428e1a1308c858a760d4fedd3a05afa7aebb2c8ec1e8ff3f
@@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe
34
34
 
35
35
  ## Enforcement
36
36
 
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hello@lokalise.co. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hello@lokalise.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
38
 
39
39
  Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
40
 
@@ -10,5 +10,12 @@
10
10
  8. [Submit a pull request.][pr]
11
11
 
12
12
  [fork]: http://help.github.com/fork-a-repo/
13
- [branch]: http://learn.github.com/p/branching.html
14
- [pr]: http://help.github.com/send-pull-requests/
13
+ [branch]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-branches
14
+ [pr]: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests
15
+
16
+ ## Previewing the docs locally
17
+
18
+ 1. Clone the repo.
19
+ 2. `cd docs`
20
+ 3. `bundle exec jekyll serve --baseurl=''`.
21
+ 4. Navigate to `http://localhost:4000` and observe the docs.
data/CHANGELOG.md CHANGED
@@ -1,82 +1,3 @@
1
1
  # Changelog
2
2
 
3
- ## 2.9.0.1 (21-Jan-20)
4
-
5
- * Make JSON dependency version less strict
6
- * Test against Ruby 2.7.0
7
-
8
- ## 2.9.0 (05-Jan-20)
9
-
10
- * Fixed a couple of bugs
11
- * Updated Faraday to version 1
12
-
13
- ## 2.8.0 (13-Nov-19)
14
-
15
- * Added methods to [merge branches](https://lokalise.com/api2docs/curl/#transition-merge-a-branch-post):
16
- + `branch.merge params`
17
- + `client.merge_branch project_id, branch_id, params`
18
-
19
- ## 2.7.0 (30-Oct-19)
20
-
21
- * Added [`Branch` endpoint](https://lokalise.co/api2docs/curl/#resource-branches)
22
-
23
- ## 2.6.1 (27-Sep-19)
24
-
25
- * Update dependencies
26
- * Update tests for the latest Faraday (0.16)
27
-
28
- ## 2.6.0 (21-Aug-19)
29
-
30
- * Added [`Webhook` endpoint](https://lokalise.co/api2docs/curl/#resource-webhooks) (thanks to [@snkashis](https://github.com/snkashis) for help!)
31
-
32
- ## 2.5.0 (01-Aug-19)
33
-
34
- * Added `:timeout` and `:open_timeout` options for the client [to customize request timeouts](https://github.com/lokalise/ruby-lokalise-api#setting-timeouts)
35
- * [Added explanations](https://github.com/lokalise/ruby-lokalise-api#choosing-adapter) on how to change a default adapter
36
-
37
- ## 2.4.0 (31-Jul-19)
38
-
39
- * Remove MultiJson dependency and allow to use a [custom JSON parser](https://github.com/lokalise/ruby-lokalise-api#customizing-json-parser)
40
-
41
- ## 2.3.0 (17-Jul-19)
42
-
43
- * Incorporated latest API changes
44
- * Added support for [`TranslationStatus` endpoint](https://lokalise.co/api2docs/curl/#resource-translation-statuses)
45
-
46
- ## 2.2.0 (19-May-19)
47
-
48
- * Added support for [`TeamUserGroup` endpoint](https://lokalise.co/api2docs/curl/#resource-team-user-groups)
49
- * Enhancements to method chaining
50
-
51
- ## 2.1.1 (17-May-19)
52
-
53
- * Incorporate API updates (new attributes, mostly creation and update timestamps)
54
- * Remove trailing slash from request URLs
55
- * Updated cassettes and target Rubies (for Travis)
56
-
57
- ## 2.1.0 (19-Mar-19)
58
-
59
- * Add support for `Order`, `TranslationProvider`, and `PaymentCard` endpoints
60
-
61
- ## 2.0.1 (21-Feb-19)
62
-
63
- * Bump dependencies
64
- * Use more direct approach to sending `DELETE` requests with bodies. It seems like Faraday team [decided to abandon the idea of writing delete request one-liners](https://github.com/lostisland/faraday/issues/693#issuecomment-466086832), so we'll stick with another approach
65
-
66
- ## 2.0.0 (14-Dec-18)
67
-
68
- * Major re-write of internal stuff
69
- * Introduce method chaining
70
- * Rename all `#delete` interface methods to `#destroy`
71
-
72
- ## 1.1.0 (11-Dec-18)
73
-
74
- * Added methods to work with pagination (`next_page?`, `last_page?`, `prev_page?`, `first_page?`, `next_page`, `prev_page`)
75
-
76
- ## 1.0.1 (10-Dec-18)
77
-
78
- * Fixed incorrect build
79
-
80
- ## 1.0.0 (10-Dec-18)
81
-
82
- * Initial release
3
+ Find changelog at [lokalise.github.io/ruby-lokalise-api/additional_info/changelog](https://lokalise.github.io/ruby-lokalise-api/additional_info/changelog).
data/LICENSE CHANGED
@@ -1,22 +1,13 @@
1
- MIT License
1
+ BSD 3 Clause
2
2
 
3
- Copyright (c) 2018 Lokalise team, Ilya Bodrov, Roman Kutanov
3
+ Copyright 2021 Lokalise Group, Ilya Bodrov
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
5
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
12
6
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
7
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
15
8
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
+
11
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -1,63 +1,23 @@
1
1
  # Lokalise API v2 official Ruby interface
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/ruby-lokalise-api.svg)](https://badge.fury.io/rb/ruby-lokalise-api)
4
- [![Build Status](https://travis-ci.org/lokalise/ruby-lokalise-api.svg?branch=master)](https://travis-ci.org/lokalise/ruby-lokalise-api)
3
+ ![Gem](https://img.shields.io/gem/v/ruby-lokalise-api)
4
+ [![Build Status](https://travis-ci.com/lokalise/ruby-lokalise-api.svg?branch=master)](https://travis-ci.com/github/lokalise/ruby-lokalise-api)
5
5
  [![Test Coverage](https://codecov.io/gh/lokalise/ruby-lokalise-api/graph/badge.svg)](https://codecov.io/gh/lokalise/ruby-lokalise-api)
6
+ ![Downloads total](https://img.shields.io/gem/dt/ruby-lokalise-api)
6
7
 
7
- Official opinionated Ruby interface for the [Lokalise API](https://lokalise.com/api2docs/curl/) that represents returned data as Ruby objects.
8
+ Official opinionated Ruby interface for the [Lokalise API](https://app.lokalise.com/api2docs/curl/) that represents returned data as Ruby objects.
8
9
 
9
- ## Index
10
+ Looking for a Rails integration? Try the new [lokalise_rails gem](https://github.com/bodrovis/lokalise_rails).
10
11
 
11
- * [Getting started](#getting-started)
12
- + [Installation and Requirements](#installation-and-requirements)
13
- + [Initializing the Client](#initializing-the-client)
14
- + [Objects and models](#objects-and-models)
15
- + [Collections of resources and pagination](#collections-of-resources-and-pagination)
16
- + [Branching](#branching)
17
- * [Available Resources](#available-resources)
18
- + [Branches](#branches)
19
- + [Comments](#comments)
20
- + [Contributors](#contributors)
21
- + [Files](#files)
22
- + [Keys](#keys)
23
- + [Languages](#languages)
24
- + [Orders](#orders)
25
- + [Payment cards](#payment-cards)
26
- + [Projects](#projects)
27
- + [Screenshots](#screenshots)
28
- + [Snapshots](#snapshots)
29
- + [Tasks](#tasks)
30
- + [Teams](#teams)
31
- + [Team users](#team-users)
32
- + [Team user groups](#team-user-groups)
33
- + [Translations](#translations)
34
- + [Translation Providers](#translation-providers)
35
- + [Translation Statuses](#translation-statuses)
36
- + [Webhooks](#webhooks)
37
- * [Additional Info](#additional-info)
38
- + [Customizing request](#customizing-request)
39
- + [Customizing JSON parser](#customizing-json-parser)
40
- + [Error handling](#error-handling)
41
- + [API Rate Limits](#api-rate-limits)
42
- * [Running Tests](#running-tests)
12
+ ## Quickstart
43
13
 
44
- ## Getting Started
45
-
46
- ### Installation and Requirements
47
-
48
- This gem requires [Ruby 2.4+](https://www.ruby-lang.org/en/) and [RubyGems package manager](https://rubygems.org/pages/download).
49
-
50
- Install it by running:
14
+ Install the gem by running:
51
15
 
52
16
  ```bash
53
17
  $ gem install ruby-lokalise-api
54
18
  ```
55
19
 
56
- ### Initializing the Client
57
-
58
- In order to perform API requests, you require a special token that can be obtained in your [personal profile](https://lokalise.com/profile#apitokens) (*API tokens* section). Note that the owner of the token must have admin access rights.
59
-
60
- After you've obtained the token, initialize the client:
20
+ Obtain an API token in your [personal profile](https://lokalise.com/profile#apitokens) (*API tokens* section) and initialize the client:
61
21
 
62
22
  ```ruby
63
23
  require 'ruby-lokalise-api'
@@ -65,1702 +25,26 @@ require 'ruby-lokalise-api'
65
25
  @client = Lokalise.client 'YOUR_TOKEN_HERE'
66
26
  ```
67
27
 
68
- Now the `@client` can be used to perform API requests! Learn more about additional options in the [Customizing request section](#customizing-request).
69
-
70
- ### Objects and models
71
-
72
- Individual objects are represented as instances of Ruby classes which are called *models*. Each model responds to the methods that are named after the API object's attributes. [This file](https://github.com/lokalise/ruby-lokalise-api/blob/master/lib/ruby-lokalise-api/data/attributes.json) lists all objects and their methods.
73
-
74
- Here is an example:
75
-
76
- ```ruby
77
- project = client.project '123'
78
- project.name
79
- project.description
80
- project.created_by
81
- ```
82
-
83
- To get access to raw data returned by the API, use `#raw_data`:
84
-
85
- ```ruby
86
- project.raw_data
87
- ```
88
-
89
- Models support method chaining, meaning you can fetch a resource, update and delete it in one line:
90
-
91
- ```ruby
92
- @client.project('123').update(name: 'New name').destroy
93
- ```
94
-
95
- ### Collections of resources and pagination
96
-
97
- Fetching (or creating/updating) multiple objects will return a *collection* of objects. To get access to the actual data, use `#collection` method:
28
+ Now the `@client` can be used to perform API requests:
98
29
 
99
30
  ```ruby
100
- project = @client.projects.collection.first # => Get the first project
31
+ project = @client.project '123.abc'
101
32
  project.name
102
- ```
103
-
104
- Bulk fetches support [pagination](https://lokalise.com/api2docs/curl/#resource-pagination). There are two common parameters available:
105
-
106
- * `:limit` (defaults to `100`, maximum is `5000`) - number of records to display per page
107
- * `:page` (defaults to `1`) - page to fetch
108
-
109
- ```ruby
110
- projects = @client.projects limit: 10, page: 3 #=> Paginate by 10 records and fetch the third page
111
- ```
112
-
113
- Collections respond to the following methods:
114
-
115
- * `#total_pages`
116
- * `#total_results`
117
- * `#results_per_page`
118
- * `#current_page`
119
- * `#next_page?`
120
- * `#last_page?`
121
- * `#prev_page?`
122
- * `#first_page?`
123
-
124
- For example:
125
-
126
- ```ruby
127
- projects.current_page #=> 3
128
- projects.last_page? #=> true, this is the last page and there are no more projects available
129
- ```
130
-
131
- On top of that, you may easily fetch the next or the previous page of the collection by using:
132
-
133
- * `#next_page`
134
- * `#prev_page`
135
-
136
- These methods return instances of the same collection class or `nil` if the next/previous page is unavailable. Methods respect the parameters you've initially passed:
137
-
138
- ```ruby
139
- translations = @client.translations 'project_id', limit: 4, page: 2, disable_references: 0 # => we passed three parameters here
140
-
141
- translations.prev_page # => will load the previous page while preserving the `limit` and `disable_references` params
142
- ```
143
-
144
- ### Branching
145
-
146
- If you are using [project branching feature](https://docs.lokalise.com/en/articles/3391861-project-branching), simply add branch name separated by semicolon to your project ID in any endpoint to access the branch. For example, in order to access `new-feature` branch for the project with an id `123abcdef.01`:
147
-
148
- ```ruby
149
- @client.files '123abcdef.01:new-feature'
150
- ```
151
-
152
- ## Available Resources
153
-
154
- ### Branches
155
-
156
- [Branches attributes](https://lokalise.com/api2docs/curl/#resource-branches)
157
-
158
- #### Fetch branches
159
-
160
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-branches-get)
161
-
162
- ```ruby
163
- @client.branches(project_id, params = {}) # Input:
164
- ## project_id (string, required)
165
- ## params (hash)
166
- ### :page and :limit
167
- # Output:
168
- ## Collection of comments available in the branches project
169
- ```
170
-
171
- #### Fetch branch
172
-
173
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-branch-get)
174
-
175
- ```ruby
176
- @client.branch(project_id, branch_id) # Input:
177
- ## project_id (string, required)
178
- ## branch_id (string or integer, required)
179
- # Output:
180
- ## Branch inside the given project
181
- ```
182
-
183
- #### Create branch
184
-
185
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-branch-get)
186
-
187
- ```ruby
188
- @client.create_branch(project_id, params) # Input:
189
- ## project_id (string, required)
190
- ## params (hash, required):
191
- ### :name (string) - name of the branch
192
- # Output:
193
- ## Created branch
194
- ```
195
-
196
- #### Update branch
197
-
198
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-branch-put)
199
-
200
- ```ruby
201
- @client.update_branch(project_id, branch_id, params) # Input:
202
- ## project_id (string, required)
203
- ## branch_id (string or integer, required)
204
- ## params (hash, required):
205
- ### :name (string) - name of the branch
206
- # Output:
207
- ## Updated branch
208
- ```
209
-
210
- Alternatively:
211
-
212
- ```ruby
213
- branch = @client.branch('project_id', 'branch_id')
214
- branch.update params
215
- ```
216
-
217
- #### Delete branch
218
-
219
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-branch-delete)
220
-
221
- ```ruby
222
- @client.destroy_branch(project_id, branch_id) # Input:
223
- ## project_id (string, required)
224
- ## branch_id (string or integer, required)
225
- # Output:
226
- ## Hash with the project's id and "branch_deleted"=>true
227
- ```
228
-
229
- Alternatively:
230
-
231
- ```ruby
232
- branch = @client.branch('project_id', 'branch_id')
233
- branch.destroy
234
- ```
235
-
236
- #### Merge branch
237
-
238
- [Doc](https://lokalise.com/api2docs/curl/#transition-merge-a-branch-post)
239
-
240
- ```ruby
241
- @client.merge_branch(project_id, branch_id, params) # Input:
242
- ## project_id (string, required)
243
- ## branch_id (string or integer, required)
244
- ## params (hash)
245
- # Output:
246
- ## Hash with the project's id, "branch_merged"=>true, and branch attributes
247
- ```
248
-
249
- Alternatively:
250
-
251
- ```ruby
252
- branch = @client.branch('project_id', 'branch_id')
253
- branch.merge params
254
- ```
255
-
256
- ### Comments
257
-
258
- [Comments attributes](https://lokalise.com/api2docs/curl/#resource-comments)
259
-
260
- #### Fetch project comments
261
-
262
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-project-comments-get)
263
-
264
- ```ruby
265
- @client.project_comments(project_id, params = {}) # Input:
266
- ## project_id (string, required)
267
- ## params (hash)
268
- ### :page and :limit
269
- # Output:
270
- ## Collection of comments available in the given project
271
- ```
272
-
273
- #### Fetch key comments
274
-
275
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-key-comments-get)
276
-
277
- ```ruby
278
- @client.comments(project_id, key_id, params = {}) # Input:
279
- ## project_id (string, required)
280
- ## key_id (string, required)
281
- ## params (hash)
282
- ### :page and :limit
283
- # Output:
284
- ## Collection of comments available for the specified key in the given project
285
- ```
286
-
287
- #### Create key comments
288
-
289
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-comments-post)
290
-
291
- ```ruby
292
- @client.create_comments(project_id, key_id, params) # Input:
293
- ## project_id (string, required)
294
- ## key_id (string, required)
295
- ## 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
296
- ### :comment (string, required)
297
- # Output:
298
- ## Newly created comment
299
- ```
300
-
301
- #### Fetch key comment
302
-
303
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-comment-get)
304
-
305
- ```ruby
306
- @client.comment(project_id, key_id, comment_id) # Input:
307
- ## project_id (string, required)
308
- ## key_id (string, required)
309
- ## comment_id (string, required)
310
- # Output:
311
- ## Comment for the key in the given project
312
- ```
313
-
314
- #### Delete key comment
315
-
316
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-comment-delete)
317
-
318
- ```ruby
319
- @client.destroy_comment(project_id, key_id, comment_id) # Input:
320
- ## project_id (string, required)
321
- ## key_id (string, required)
322
- ## comment_id (string, required)
323
- # Output:
324
- ## Hash with the project's id and "comment_deleted"=>true
325
- ```
326
-
327
- Alternatively:
328
-
329
- ```ruby
330
- comment = @client.comment('project_id', 'comment_id')
331
- comment.destroy
332
- ```
333
-
334
- ### Contributors
335
-
336
- #### Fetch contributors
337
-
338
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-contributors-get)
339
-
340
- ```ruby
341
- @client.contributors(project_id, params = {}) # Input:
342
- ## project_id (string, required)
343
- ## params (hash)
344
- ### :page and :limit
345
- # Output:
346
- ## Collection of contributors in the given project
347
- ```
348
33
 
349
- #### Fetch a single contributor
34
+ process = @client.upload_file project_id,
35
+ data: 'Base-64 encoded data... ZnI6DQogI...',
36
+ filename: 'my_file.yml',
37
+ lang_iso: 'en'
350
38
 
351
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-contributor-get)
352
-
353
- ```ruby
354
- @client.contributor(project_id, contributor_id) # Input:
355
- ## project_id (string, required)
356
- ## contributor_id (string, required) - named as "user_id" in the response
357
- # Output:
358
- ## Contributor in the given project
359
- ```
360
-
361
- #### Create contributors
362
-
363
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-contributors-post)
364
-
365
- ```ruby
366
- @client.create_contributors(project_id, params) # Input:
367
- ## project_id (string, required)
368
- ## 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
369
- ### :email (string, required)
370
- ### :fullname (string)
371
- ### :is_admin (boolean)
372
- ### :is_reviewer (boolean)
373
- ### :languages (array of hashes, required if "is_admin" set to false) - possible languages attributes:
374
- #### :lang_iso (string, required)
375
- #### :is_writable (boolean)
376
- ### :admin_rights (array)
377
- # Output:
378
- ## Collection of newly created contributors
379
- ```
380
-
381
- #### Update contributor
382
-
383
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-contributor-put)
384
-
385
- ```ruby
386
- @client.update_contributor(project_id, contributor_id, params) # Input:
387
- ## project_id (string, required)
388
- ## contributor_id (string, required)
389
- ## params (hash, required)
390
- ### :is_admin (boolean)
391
- ### :is_reviewer (boolean)
392
- ### :languages (array of hashes) - possible languages attributes:
393
- #### :lang_iso (string, required)
394
- #### :is_writable (boolean)
395
- ### :admin_rights (array)
396
- # Output:
397
- ## Updated contributor
398
- ```
399
-
400
- Alternatively:
401
-
402
- ```ruby
403
- contributor = @client.contributor('project_id', 'contributor_id')
404
- contributor.update(params)
405
- ```
406
-
407
- #### Delete contributor
408
-
409
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-contributor-delete)
410
-
411
- ```ruby
412
- @client.destroy_contributor(project_id, contributor_id) # Input:
413
- ## project_id (string, required)
414
- ## contributor_id (string, required)
415
- # Output:
416
- ## Hash with the project's id and "contributor_deleted"=>true
417
- ```
418
-
419
- Alternatively:
420
-
421
- ```ruby
422
- contributor = @client.contributor('project_id', 'id')
423
- contributor.destroy
424
- ```
425
-
426
- ### Files
427
-
428
- [File attributes](https://lokalise.com/api2docs/curl/#object-files)
429
-
430
- #### Fetch translation files
431
-
432
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-files-get)
433
-
434
- ```ruby
435
- @client.files(project_id, params = {}) # Input:
436
- ## project_id (string, required)
437
- ## params (hash)
438
- ### :page and :limit
439
- # Output:
440
- ## Collection of translation files available in the given project
441
- ```
442
-
443
- #### Download translation files
444
-
445
- [Doc](https://lokalise.com/api2docs/curl/#transition-download-files-post)
446
-
447
- Exports project files as a `.zip` bundle and makes them available to download (the link is valid for 12 months).
448
-
449
- ```ruby
450
- @client.download_files(project_id, params) # Input:
451
- ## project_id (string, required)
452
- ## params (hash, required)
453
- ### :format (string, required) - one of the file formats supported by Lokalise (json, xml, po etc).
454
- ### Find the list of other supported params at https://lokalise.com/api2docs/curl/#transition-download-files-post
455
- # Output:
456
- ## Hash with the project id and a "bundle_url" link
457
- ```
458
-
459
- #### Upload translation file
460
-
461
- [Doc](https://lokalise.com/api2docs/curl/#transition-upload-a-file-post)
462
-
463
- ```ruby
464
- @client.upload_file(project_id, params) # Input:
465
- ## project_id (string, required)
466
- ## params (hash, required)
467
- ### :data (string, required) - base64-encoded data (the format must be supported by Lokalise)
468
- ### :filename (string, required)
469
- ### :lang_iso (string, required)
470
- ### Find the list of other supported params at https://lokalise.com/api2docs/curl/#transition-upload-a-file-post
471
- # Output:
472
- ## Hash with information about the upload
473
- ```
474
-
475
- ### Keys
476
-
477
- [Key attributes](https://lokalise.com/api2docs/curl/#object-keys)
478
-
479
- #### Fetch project keys
480
-
481
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-keys-get)
482
-
483
- ```ruby
484
- @client.keys(project_id, params = {}) # Input:
485
- ## project_id (string, required)
486
- ## params (hash)
487
- ### :page and :limit
488
- # Output:
489
- ## Collection of keys available in the given project
490
- ```
491
-
492
- #### Fetch a single project key
493
-
494
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-key-get)
495
-
496
- ```ruby
497
- @client.key(project_id, key_id, params = {}) # Input:
498
- ## project_id (string, required)
499
- ## key_id (string, required)
500
- ## params (hash)
501
- ### :disable_references (string) - possible values are "1" and "0".
502
- # Output:
503
- ## Project key
504
- ```
505
-
506
- #### Create project keys
507
-
508
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-keys-post)
509
-
510
- ```ruby
511
- @client.create_keys(project_id, params) # Input:
512
- ## project_id (string, required)
513
- ## params (array of hashes or hash, required)
514
- ### :key_name (string or hash, required) - for projects with enabled per-platform key names, pass hash with "ios", "android", "web" and "other" params.
515
- ### :platforms (array) - supported values are "ios", "android", "web" and "other"
516
- ### Find all other supported attributes at https://lokalise.com/api2docs/curl/#transition-create-keys-post
517
- # Output:
518
- ## Collection of newly created keys
519
- ```
520
-
521
- #### Update project key
522
-
523
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-key-put)
524
-
525
- ```ruby
526
- @client.update_key(project_id, key_id, params = {}) # Input:
527
- ## project_id (string, required)
528
- ## key_id (string, required)
529
- ## params (hash)
530
- ### Find a list of supported attributes at https://lokalise.com/api2docs/curl/#transition-update-a-key-put
531
- # Output:
532
- ## Updated key
533
- ```
534
-
535
- Alternatively:
536
-
537
- ```ruby
538
- key = @client.key('project_id', 'key_id')
539
- key.update(params)
540
- ```
541
-
542
- #### Bulk update project keys
543
-
544
- [Doc](https://lokalise.com/api2docs/curl/#transition-bulk-update-put)
545
-
546
- ```ruby
547
- @client.update_keys(project_id, params) # Input:
548
- ## project_id (string, required)
549
- ## params (hash or array of hashes, required)
550
- ### :key_id (string, required)
551
- ### Find all other supported attributes at https://lokalise.com/api2docs/curl/#transition-bulk-update-put
552
- # Output:
553
- ## Collection of updated keys
554
- ```
555
-
556
- #### Delete project key
557
-
558
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-key-delete)
559
-
560
- ```ruby
561
- @client.destroy_key(project_id, key_id) # Input:
562
- ## project_id (string, required)
563
- ## key_id (string, required)
564
- # Output:
565
- ## Hash with project_id and "key_removed" set to "true"
566
- ```
567
-
568
- Alternatively:
569
-
570
- ```ruby
571
- key = @client.key('project_id', 'key_id')
572
- key.destroy
573
- ```
574
-
575
- #### Bulk delete project keys
576
-
577
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-multiple-keys-delete)
578
-
579
- ```ruby
580
- @client.destroy_keys(project_id, key_ids) # Input:
581
- ## project_id (string, required)
582
- ## key_ids (array, required)
583
- # Output:
584
- ## Hash with project_id and "keys_removed" set to "true"
585
- ```
586
-
587
- Alternatively:
588
-
589
- ```ruby
590
- keys = @client.keys('project_id')
591
- keys.destroy_all # => will effectively destroy all keys in the project
592
- ```
593
-
594
- ### Languages
595
-
596
- [Language attributes](https://lokalise.com/api2docs/curl/#object-languages)
597
-
598
- #### Fetch system languages
599
-
600
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-system-languages-get)
601
-
602
- ```ruby
603
- @client.system_languages(params = {}) # Input:
604
- ## params (hash)
605
- ### :page and :limit
606
- # Output:
607
- ## Collection of system languages supported by Lokalise
608
- ```
609
-
610
- #### Fetch project languages
611
-
612
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-project-languages-get)
613
-
614
- ```ruby
615
- @client.project_languages(project_id, params = {}) # Input:
616
- ## project_id (string, required)
617
- ## params (hash)
618
- ### :page and :limit
619
- # Output:
620
- ## Collection of languages available in the given project
621
- ```
622
-
623
- #### Fetch a single project language
624
-
625
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-language-get)
626
-
627
- ```ruby
628
- @client.language(project_id, language_id) # Input:
629
- ## project_id (string, required)
630
- ## language_id (string, required)
631
- # Output:
632
- ## A single language in the given project
633
- ```
634
-
635
- #### Create project languages
636
-
637
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-languages-post)
638
-
639
- ```ruby
640
- @client.create_languages(project_id, params) # Input:
641
- ## project_id (string, required)
642
- ## 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
643
- ### :lang_iso (string, required)
644
- ### :custom_iso (string)
645
- ### :custom_name (string)
646
- ### :custom_plural_forms (array) - can contain only plural forms initially supported by Lokalise
647
- # Output:
648
- ## Collection of newly created languages
649
- ```
650
-
651
- #### Update project language
652
-
653
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-language-put)
654
-
655
- ```ruby
656
- @client.update_language(project_id, language_id, params) # Input:
657
- ## project_id (string, required)
658
- ## language_id (string, required)
659
- ## params (hash, required)
660
- ### :lang_iso (string, required)
661
- ### :custom_name (string)
662
- ### :plural_forms (array) - can contain only plural forms initially supported by Lokalise
663
- # Output:
664
- ## Updated language
665
- ```
666
-
667
- Alternatively:
668
-
669
- ```ruby
670
- language = @client.language('project_id', 'lang_id')
671
- language.update(params)
672
- ```
673
-
674
- #### Delete project language
675
-
676
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-language-delete)
677
-
678
- ```ruby
679
- @client.destroy_language(project_id, language_id) # Input:
680
- ## project_id (string, required)
681
- ## language_id (string, required)
682
- # Output:
683
- ## Hash with the project's id and "language_deleted"=>true
39
+ process.status
684
40
  ```
685
41
 
686
- Alternatively:
687
-
688
- ```ruby
689
- language = @client.language('project_id', 'lang_id')
690
- language.destroy
691
- ```
692
-
693
- ### Orders
694
-
695
- [Order attributes](https://lokalise.com/api2docs/curl/#object-orders)
696
-
697
- #### Fetch order collection
698
-
699
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-orders-get)
700
-
701
- ```ruby
702
- @client.orders(team_id, params = {}) # Input:
703
- ## team_id (integer, string, required)
704
- ## params (hash)
705
- ### :page and :limit
706
- # Output:
707
- ## Collection of orders for the given team
708
- ```
709
-
710
- #### Fetch a single order
711
-
712
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-an-order-get)
713
-
714
- ```ruby
715
- @client.order(team_id, order_id) # Input:
716
- ## team_id (string, integer, required)
717
- ## order_id (string, required)
718
- # Output:
719
- ## A single order
720
- ```
721
-
722
- #### Create an order
723
-
724
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-an-order-post)
725
-
726
- ```ruby
727
- @client.create_order(team_id, params) # Input:
728
- ## team_id (string, integer, required)
729
- ## params (hash, required)
730
- ### project_id (string, required)
731
- ### card_id (integer, string, required) - card to process payment
732
- ### briefing (string, required)
733
- ### source_language_iso (string, required)
734
- ### target_language_isos (array of strings, required)
735
- ### keys (array of integers, required) - keys to include in the order
736
- ### provider_slug (string, required)
737
- ### translation_tier (integer, required)
738
- ### dry_run (boolean) - return the response without actually placing an order. Useful for price estimation. Default is `false`
739
- ### translation_style (string) - only for gengo provider. Available values are `formal`, `informal`, `business`, `friendly`. Defaults to `friendly`.
740
- # Output:
741
- ## A newly created order
742
-
743
- ```
744
-
745
- ### Payment cards
746
-
747
- [Payment card attributes](https://lokalise.com/api2docs/curl/#object-payment-cards)
748
-
749
- #### Fetch payment card collection
750
-
751
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-cards-get)
752
-
753
- ```ruby
754
- @client.payment_cards(params = {}) # Input:
755
- ## params (hash)
756
- ### :page and :limit
757
- # Output:
758
- ## Collection of payment cards under the `payment_cards` attribute
759
- ```
760
-
761
- #### Fetch a single payment card
762
-
763
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-card-get)
764
-
765
- ```ruby
766
- @client.payment_card(card_id) # Input:
767
- ## card_id (string, required)
768
- # Output:
769
- ## A single payment card
770
- ```
771
-
772
- #### Create a payment card
773
-
774
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-a-card-post)
775
-
776
- ```ruby
777
- @client.create_payment_card(params) # Input:
778
- ## params (hash, required)
779
- ### number (integer, string, required) - card number
780
- ### cvc (integer, required) - 3-digit card CVV (CVC)
781
- ### exp_month (integer, required) - card expiration month (1 - 12)
782
- ### exp_year (integer, required) - card expiration year (for example, 2019)
783
- # Output:
784
- ## A newly created payment card
785
-
786
- ```
787
-
788
- #### Delete a payment card
789
-
790
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-card-delete)
791
-
792
- ```ruby
793
- @client.destroy_payment_card(card_id) # Input:
794
- ## card_id (integer, string, required)
795
- # Output:
796
- ## Hash containing card id and `card_deleted => true` attribute
797
- ```
798
-
799
- Alternatively:
800
-
801
- ```ruby
802
- card = @client.payment_card('card_id')
803
- card.destroy
804
- ```
805
-
806
- ### Projects
807
-
808
- [Project attributes](https://lokalise.com/api2docs/curl/#object-projects)
809
-
810
- #### Fetch projects collection
811
-
812
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-projects-get)
813
-
814
- ```ruby
815
- @client.projects(params = {}) # Input:
816
- ## params (hash)
817
- ### :filter_team_id (string) - load projects only for the given team
818
- ### :page and :limit
819
- # Output:
820
- ## Collection of projects under the `projects` attribute
821
- ```
822
-
823
- #### Fetch a single project
824
-
825
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-project-get)
826
-
827
- ```ruby
828
- @client.project(project_id) # Input:
829
- ## project_id (string, required)
830
- # Output:
831
- ## A single project
832
- ```
833
-
834
- #### Create a project
835
-
836
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-a-project-post)
837
-
838
- ```ruby
839
- @client.create_project(params) # Input:
840
- ## params (hash, required)
841
- ### name (string, required)
842
- ### description (string)
843
- ### team_id (integer) - you must be an admin of the chosen team. When omitted, defaults to the current team of the token's owner
844
- # Output:
845
- ## A newly created project
846
-
847
- ```
848
-
849
- #### Update a project
850
-
851
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-project-put)
852
-
853
- ```ruby
854
- @client.update_project(project_id, params) # Input:
855
- ## project_id (string, required)
856
- ## params (hash, required)
857
- ### name (string, required)
858
- ### description (string)
859
- # Output:
860
- ## An updated project
861
- ```
862
-
863
- Alternatively:
864
-
865
- ```ruby
866
- project = @client.project('project_id')
867
- project.update(params)
868
- ```
869
-
870
- #### Empty a project
871
-
872
- [Doc](https://lokalise.com/api2docs/curl/#transition-empty-a-project-put)
873
-
874
- Deletes *all* keys and translations from the project.
875
-
876
- ```ruby
877
- @client.empty_project(project_id) # Input:
878
- ## project_id (string, required)
879
- # Output:
880
- ## A project containing its id and a `keys_deleted => true` attribute
881
- ```
882
-
883
- Alternatively:
884
-
885
- ```ruby
886
- project = @client.project('project_id')
887
- project.empty
888
- ```
889
-
890
- #### Delete a project
891
-
892
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-project-delete)
893
-
894
- ```ruby
895
- @client.destroy_project(project_id) # Input:
896
- ## project_id (string, required)
897
- # Output:
898
- ## A project containing its id and a `project_deleted => true` attribute
899
- ```
900
-
901
- Alternatively:
902
-
903
- ```ruby
904
- project = @client.project('project_id')
905
- project.destroy
906
- ```
907
-
908
- ### Screenshots
909
-
910
- [Screenshot attributes](https://lokalise.com/api2docs/curl/#resource-screenshots)
911
-
912
- #### Fetch screenshots
913
-
914
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-screenshots-get)
915
-
916
- ```ruby
917
- @client.screenshots(project_id, params = {}) # Input:
918
- ## project_id (string, required)
919
- ## params (hash)
920
- ### :page and :limit
921
- # Output:
922
- ## Collection of project screenshots
923
- ```
924
-
925
- #### Fetch a single screenshot
926
-
927
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-screenshot-get)
928
-
929
- ```ruby
930
- @client.screeshot(project_id, screeshot_id) # Input:
931
- ## project_id (string, required)
932
- ## screeshot_id (string, required)
933
- # Output:
934
- ## A single screenshot
935
- ```
936
-
937
- #### Create screenshots
938
-
939
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-screenshots-post)
940
-
941
- ```ruby
942
- @client.create_screenshots(project_id, params) # Input:
943
- ## project_id (string, required)
944
- ## params (hash or array of hashes, required)
945
- ### :data (string, required) - the actual screenshot, base64-encoded (with leading image type "data:image/jpeg;base64,"). JPG and PNG formats are supported.
946
- ### :title (string)
947
- ### :description (string)
948
- ### :ocr (boolean) - recognize translations on the image and attach screenshot to all possible keys
949
- ### :key_ids (array) - attach the screenshot to key IDs specified
950
- ### :tags (array)
951
- # Output:
952
- ## Collection of created screenshots
953
- ```
954
-
955
- #### Update screenshot
956
-
957
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-screenshot-put)
958
-
959
- ```ruby
960
- @client.update_screenshot(project_id, screenshot_id, params = {}) # Input:
961
- ## project_id (string, required)
962
- ## screenshot_id (string, required)
963
- ## params (hash)
964
- ### :title (string)
965
- ### :description (string)
966
- ### :key_ids (array) - attach the screenshot to key IDs specified
967
- ### :tags (array)
968
- # Output:
969
- ## Updated screenshot
970
- ```
971
-
972
- Alternatively:
973
-
974
- ```ruby
975
- screenshot = @client.screenshot('project_id', 'screen_id')
976
- screenshot.update(params)
977
- ```
978
-
979
- #### Delete screenshot
980
-
981
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-screenshot-delete)
982
-
983
- ```ruby
984
- @client.destroy_screenshot(project_id, screenshot_id) # Input:
985
- ## project_id (string, required)
986
- ## screenshot_id (string, required)
987
- # Output:
988
- ## Hash with the project id and "screenshot_deleted" set to "true"
989
- ```
990
-
991
- Alternatively:
992
-
993
- ```ruby
994
- screenshot = @client.screenshot('project_id', 'screen_id')
995
- screenshot.destroy
996
- ```
997
-
998
- ### Snapshots
999
-
1000
- [Snapshot attributes](https://lokalise.com/api2docs/curl/#object-snapshots)
1001
-
1002
- #### Fetch snapshots
1003
-
1004
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-snapshots-get)
1005
-
1006
- ```ruby
1007
- @client.snapshots(project_id, params = {}) # Input:
1008
- ## project_id (string, required)
1009
- ## params (hash)
1010
- ### :filter_title (string) - set title filter for the list
1011
- ### :page and :limit
1012
- # Output:
1013
- ## Collection of project snapshots
1014
- ```
1015
-
1016
- #### Create snapshot
1017
-
1018
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-a-snapshot-post)
1019
-
1020
- ```ruby
1021
- @client.create_snapshot(project_id, params = {}) # Input:
1022
- ## project_id (string, required)
1023
- ## params (hash)
1024
- ### :title (string)
1025
- # Output:
1026
- ## Created snapshot
1027
- ```
1028
-
1029
- #### Restore snapshot
1030
-
1031
- [Doc](https://lokalise.com/api2docs/curl/#transition-restore-a-snapshot-post)
1032
-
1033
- ```ruby
1034
- @client.restore_snapshot(project_id, snapshot_id) # Input:
1035
- ## project_id (string, required)
1036
- ## snapshot_id (string, required)
1037
- # Output:
1038
- ## Information about the restored project from the specified snapshot
1039
- ```
1040
-
1041
- Alternatively:
1042
-
1043
- ```ruby
1044
- snapshot = @client.snapshots('project_id').first # you can't fetch a single snapshot
1045
- snapshot.restore
1046
- ```
1047
-
1048
- #### Delete snapshot
1049
-
1050
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-snapshot-delete)
1051
-
1052
- ```ruby
1053
- @client.destroy_snapshot(project_id, snapshot_id) # Input:
1054
- ## project_id (string, required)
1055
- ## snapshot_id (string, required)
1056
- # Output:
1057
- ## Hash with the project id and "snapshot_deleted" set to "true"
1058
- ```
1059
-
1060
- Alternatively:
1061
-
1062
- ```ruby
1063
- snapshot = @client.snapshots('project_id').first # you can't fetch a single snapshot
1064
- snapshot.destroy
1065
- ```
1066
-
1067
- ### Tasks
1068
-
1069
- [Task attributes](https://lokalise.com/api2docs/curl/#resource-tasks)
1070
-
1071
- #### Fetch tasks
1072
-
1073
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-tasks-get)
1074
-
1075
- ```ruby
1076
- @client.tasks(project_id, params = {}) # Input:
1077
- ## project_id (string, required)
1078
- ## params (hash)
1079
- ### :filter_title (string) - set title filter for the list
1080
- ### :page and :limit
1081
- # Output:
1082
- ## Collection of tasks for the project
1083
- ```
1084
-
1085
- #### Fetch a single task
1086
-
1087
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-task-get)
1088
-
1089
- ```ruby
1090
- @client.task(project_id, task_id, params = {}) # Input:
1091
- ## project_id (string, required)
1092
- ## task_id (string, required)
1093
- # Output:
1094
- ## Single task for the project
1095
- ```
1096
-
1097
- #### Create task
1098
-
1099
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-a-task-post)
1100
-
1101
- ```ruby
1102
- @client.create_task(project_id, params) # Input:
1103
- ## project_id (string, required)
1104
- ## params (hash, required)
1105
- ### title (string, required)
1106
- ### keys (array) - translation key ids. Required if "parent_task_id" is not specified
1107
- ### languages (array of hashes, required)
1108
- #### language_iso (string)
1109
- #### users (array) - list of users identifiers, assigned to work on the language
1110
- ### Find other supported options at https://lokalise.com/api2docs/curl/#transition-create-a-task-post
1111
- # Output:
1112
- ## A newly created task
1113
-
1114
- ```
1115
-
1116
- #### Update task
1117
-
1118
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-task-put)
1119
-
1120
- ```ruby
1121
- @client.update_task(project_id, task_id, params = {}) # Input:
1122
- ## project_id (string, required)
1123
- ## task_id (string or integer, required)
1124
- ## params (hash)
1125
- ### Find supported params at https://lokalise.com/api2docs/curl/#transition-update-a-task-put
1126
- # Output:
1127
- ## An updated task
1128
-
1129
- ```
1130
-
1131
- Alternatively:
1132
-
1133
- ```ruby
1134
- task = @client.task('project_id', 'task_id')
1135
- task.update(params)
1136
- ```
1137
-
1138
- #### Delete task
1139
-
1140
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-task-delete)
1141
-
1142
- ```ruby
1143
- @client.destroy_task(project_id, task_id) # Input:
1144
- ## project_id (string, required)
1145
- ## task_id (string, required)
1146
- # Output:
1147
- ## Hash with the project id and "task_deleted" set to "true"
1148
-
1149
- ```
1150
-
1151
- Alternatively:
1152
-
1153
- ```ruby
1154
- task = @client.task('project_id', 'task_id')
1155
- task.destroy
1156
- ```
1157
-
1158
- ### Teams
1159
-
1160
- #### Fetch teams
1161
-
1162
- [Doc](https://lokalise.com/api2docs/curl/#resource-teams)
1163
-
1164
- ```ruby
1165
- @client.teams(params = {}) # Input:
1166
- ## params (hash)
1167
- ### :page and :limit
1168
- # Output:
1169
- ## Collection of teams
1170
- ```
1171
-
1172
- ### Team users
1173
-
1174
- [Team user attributes](https://lokalise.com/api2docs/curl/#object-team-users)
1175
-
1176
- #### Fetch team users
1177
-
1178
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-team-users-get)
1179
-
1180
- ```ruby
1181
- @client.team_users(team_id, params = {}) # Input:
1182
- ## team_id (string, required)
1183
- ## params (hash)
1184
- ### :page and :limit
1185
- # Output:
1186
- ## Collection of team users
1187
- ```
1188
-
1189
- #### Fetch a single team user
1190
-
1191
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-team-user-get)
1192
-
1193
- ```ruby
1194
- @client.team_user(team_id, user_id) # Input:
1195
- ## team_id (string, required)
1196
- ## user_id (string, required)
1197
- # Output:
1198
- ## Team user
1199
- ```
1200
-
1201
- #### Update team user
1202
-
1203
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-team-user-put)
1204
-
1205
- ```ruby
1206
- @client.update_team_user(team_id, user_id, params) # Input:
1207
- ## team_id (string, required)
1208
- ## user_id (string, required)
1209
- ## params (hash, required):
1210
- ### :role (string, required) - :owner, :admin, or :member
1211
- # Output:
1212
- ## Updated team user
1213
- ```
1214
-
1215
- Alternatively:
1216
-
1217
- ```ruby
1218
- user = @client.team_user('team_id', 'user_id')
1219
- user.update(params)
1220
- ```
1221
-
1222
- #### Delete team user
1223
-
1224
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-team-user-delete)
1225
-
1226
- ```ruby
1227
- @client.destroy_team_user(team_id, user_id) # Input:
1228
- ## team_id (string, required)
1229
- ## user_id (string, required)
1230
- # Output:
1231
- ## Hash with "team_id" and "team_user_deleted" set to "true"
1232
- ```
1233
-
1234
- Alternatively:
1235
-
1236
- ```ruby
1237
- user = @client.team_user('team_id', 'user_id')
1238
- user.destroy
1239
- ```
1240
-
1241
- ### Team user groups
1242
-
1243
- [Team user group attributes](https://lokalise.com/api2docs/curl/#object-team-user-groups)
1244
-
1245
- #### Fetch team user groups
1246
-
1247
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-groups-get)
1248
-
1249
- ```ruby
1250
- @client.team_user_groups(team_id, params = {}) # Input:
1251
- ## team_id (string, required)
1252
- ## params (hash)
1253
- ### :page and :limit
1254
- # Output:
1255
- ## Collection of team user groups
1256
- ```
1257
-
1258
- #### Fetch a single group
1259
-
1260
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-group-get)
1261
-
1262
- ```ruby
1263
- @client.team_user_group(team_id, group_id) # Input:
1264
- ## team_id (string, required)
1265
- ## group_id (string, required)
1266
- # Output:
1267
- ## Group
1268
- ```
1269
-
1270
- #### Create group
1271
-
1272
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-a-group-post)
1273
-
1274
- ```ruby
1275
- @client.create_team_user_group(team_id, params) # Input:
1276
- ## team_id (string, required)
1277
- ## params (hash, required):
1278
- ### :name (string, required)
1279
- ### :is_reviewer (boolean, required)
1280
- ### :is_admin (boolean, required)
1281
- ### :admin_rights (array) - required only if is_admin is true
1282
- ### :languages (array of hashes) - required if is_admin is false
1283
- # Output:
1284
- ## Updated group
1285
- ```
1286
-
1287
- #### Update group
1288
-
1289
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-group-put)
1290
-
1291
- ```ruby
1292
- @client.update_team_user_group(team_id, group_id, params) # Input:
1293
- ## team_id (string, required)
1294
- ## group_id (string, required)
1295
- ## params (hash, required):
1296
- ### :name (string, required)
1297
- ### :is_reviewer (boolean, required)
1298
- ### :is_admin (boolean, required)
1299
- ### :admin_rights (array) - required only if is_admin is true
1300
- ### :languages (array of hashes) - required if is_admin is false
1301
- # Output:
1302
- ## Updated group
1303
- ```
1304
-
1305
- Alternatively:
1306
-
1307
- ```ruby
1308
- group = @client.team_user_group('team_id', 'group_id')
1309
- group.update(params)
1310
- ```
1311
-
1312
- #### Add projects to group
1313
-
1314
- [Doc](https://lokalise.com/api2docs/curl/#transition-add-projects-to-group-put)
1315
-
1316
- ```ruby
1317
- @client.add_projects_to_group(team_id, group_id, project_ids) # Input:
1318
- ## team_id (string, required)
1319
- ## group_id (string, required)
1320
- ## project_ids (string or array, required) - project ids that you would like to add to this group
1321
- ```
1322
-
1323
- Alternatively:
1324
-
1325
- ```ruby
1326
- group = @client.team_user_group('team_id', 'group_id')
1327
- group.add_projects projects: [project_id1, project_id2]
1328
- ```
1329
-
1330
- #### Remove projects from group
1331
-
1332
- [Doc](https://lokalise.com/api2docs/curl/#transition-remove-projects-from-group-put)
1333
-
1334
- ```ruby
1335
- @client.remove_projects_from_group(team_id, group_id, project_ids) # Input:
1336
- ## team_id (string, required)
1337
- ## group_id (string, required)
1338
- ## project_ids (string or array, required) - project ids that you would like to remove from this group
1339
- ```
1340
-
1341
- Alternatively:
1342
-
1343
- ```ruby
1344
- group = @client.team_user_group('team_id', 'group_id')
1345
- group.remove_projects projects: [project_id1, project_id2]
1346
- ```
1347
-
1348
- #### Add users (members) to group
1349
-
1350
- [Doc](https://lokalise.com/api2docs/curl/#transition-add-members-to-group-put)
1351
-
1352
- ```ruby
1353
- @client.add_users_to_group(team_id, group_id, user_ids) # Input:
1354
- ## team_id (string, required)
1355
- ## group_id (string, required)
1356
- ## user_ids (string or array, required) - user ids that you would like to add to this group
1357
- ```
1358
-
1359
- Alternatively:
1360
-
1361
- ```ruby
1362
- group = @client.team_user_group('team_id', 'group_id')
1363
- group.add_users users: [user_id1, user_id2]
1364
- ```
1365
-
1366
- #### Remove users (members) from group
1367
-
1368
- [Doc](https://lokalise.com/api2docs/curl/#transition-remove-members-from-group-put)
1369
-
1370
- ```ruby
1371
- @client.remove_users_from_group(team_id, group_id, user_ids) # Input:
1372
- ## team_id (string, required)
1373
- ## group_id (string, required)
1374
- ## user_ids (string or array, required) - user ids that you would like to add to this group
1375
- ```
1376
-
1377
- Alternatively:
1378
-
1379
- ```ruby
1380
- group = @client.team_user_group('team_id', 'group_id')
1381
- group.remove_users users: [user_id1, user_id2]
1382
- ```
1383
-
1384
- #### Destroy group
1385
-
1386
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-group-delete)
1387
-
1388
- ```ruby
1389
- @client.destroy_team_user_group(team_id, group_id) # Input:
1390
- ## team_id (string, required)
1391
- ## group_id (string, required)
1392
- # Output:
1393
- ## Hash with "team_id" and "group_deleted" set to "true"
1394
- ```
1395
-
1396
- Alternatively:
1397
-
1398
- ```ruby
1399
- group = @client.team_user_group('team_id', 'group_id')
1400
- group.destroy
1401
- ```
1402
-
1403
- ### Translations
1404
-
1405
- [Translation attributes](https://lokalise.com/api2docs/curl/#resource-translations)
1406
-
1407
- #### Fetch translations
1408
-
1409
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-translations-get)
1410
-
1411
- ```ruby
1412
- @client.translations(project_id, params = {}) # Input:
1413
- ## project_id (string, required)
1414
- ## params (hash)
1415
- ### Find full list in the docs
1416
- ### :page and :limit
1417
- # Output:
1418
- ## Collection of translations for the project
1419
- ```
1420
-
1421
- #### Fetch a single translation
1422
-
1423
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-translation-get)
1424
-
1425
- ```ruby
1426
- @client.translation(project_id, translation_id, params = {}) # Input:
1427
- ## project_id (string, required)
1428
- ## translation_id (string, required)
1429
- ## params (hash)
1430
- ### :disable_references (string) - whether to disable key references. Supported values are 0 and 1
1431
- # Output:
1432
- ## Single translation for the project
1433
- ```
1434
-
1435
- #### Update translation
1436
-
1437
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-translation-put)
1438
-
1439
- ```ruby
1440
- @client.update_translation(project_id, translation_id, params = {}) # Input:
1441
- ## project_id (string, required)
1442
- ## translation_id (string, required)
1443
- ## params (hash, required)
1444
- ### :translation (string or hash, required) - the actual translation. Provide hash for plural keys.
1445
- ### :is_fuzzy (boolean)
1446
- ### :is_reviewed (boolean)
1447
- # Output:
1448
- ## Updated translation
1449
- ```
1450
-
1451
- Alternatively:
1452
-
1453
- ```ruby
1454
- translation = @client.translation('project_id', 'translation_id')
1455
- translation.update(params)
1456
- ```
1457
-
1458
- ### Translation Providers
1459
-
1460
- [Translation provider attributes](https://lokalise.com/api2docs/curl/#object-translation-providers)
1461
-
1462
- #### Fetch translation providers
1463
-
1464
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-providers-get)
1465
-
1466
- ```ruby
1467
- @client.translation_providers(team_id, params = {}) # Input:
1468
- ## team_id (string, required)
1469
- ## params (hash)
1470
- ### :page and :limit
1471
- # Output:
1472
- ## Collection of providers for the team
1473
- ```
1474
-
1475
- #### Fetch a single translation provider
1476
-
1477
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-provider-get)
1478
-
1479
- ```ruby
1480
- @client.translation_provider(team_id, provider_id) # Input:
1481
- ## team_id (string, required)
1482
- ## provider_id (string, required)
1483
- # Output:
1484
- ## Single provider for the team
1485
- ```
1486
-
1487
- ### Translation Statuses
1488
-
1489
- [Translation Status attributes](https://lokalise.com/api2docs/curl/#object-translation-statuses)
1490
-
1491
- *Custom translation statuses must be enabled for the project before using this endpoint!* It can be done in the project settings.
1492
-
1493
- #### Fetch translation statuses
1494
-
1495
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-custom-translation-statuses-get)
1496
-
1497
- ```ruby
1498
- @client.translation_statuses(project_id, params = {}) # Input:
1499
- ## project_id (string, required)
1500
- ## params (hash)
1501
- ### :page and :limit
1502
- # Output:
1503
- ## Collection of translation statuses for the project
1504
- ```
1505
-
1506
- #### Fetch a single translation status
1507
-
1508
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-custom-translation-status-get)
1509
-
1510
- ```ruby
1511
- @client.translation_status(project_id, status_id) # Input:
1512
- ## project_id (string, required)
1513
- ## status_id (string or integer, required)
1514
- # Output:
1515
- ## Translation status inside the given project
1516
- ```
1517
-
1518
- #### Create translation status
1519
-
1520
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-a-custom-translation-status-post)
1521
-
1522
- ```ruby
1523
- @client.create_translation_status(project_id, params) # Input:
1524
- ## project_id (string, required)
1525
- ## params (hash, required)
1526
- ### :title (string, required) - title of the new status
1527
- ### :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
1528
- # Output:
1529
- ## Created translation status
1530
- ```
1531
-
1532
- #### Update translation status
1533
-
1534
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-custom-translation-status-put)
1535
-
1536
- ```ruby
1537
- @client.update_translation_status(project_id, status_id, params) # Input:
1538
- ## project_id (string, required)
1539
- ## status_id (string or integer, required)
1540
- ## params (hash, required)
1541
- ### :title (string, required) - title of the new status
1542
- ### :color (string, required) - HEX color code of the new status
1543
- # Output:
1544
- ## Updated translation status
1545
- ```
1546
-
1547
- Alternatively:
1548
-
1549
- ```ruby
1550
- status = @client.translation_status(project_id, status_id)
1551
- status.update(params)
1552
- ```
1553
-
1554
- #### Delete translation status
1555
-
1556
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-custom-translation-status-delete)
1557
-
1558
- ```ruby
1559
- @client.destroy_translation_status(project_id, status_id) # Input:
1560
- ## project_id (string, required)
1561
- ## status_id (string or integer, required)
1562
- # Output:
1563
- ## Result of the delete operation
1564
- ```
1565
-
1566
- Alternatively:
1567
-
1568
- ```ruby
1569
- status = @client.translation_status(project_id, status_id)
1570
- status.destroy
1571
- ```
1572
-
1573
- #### Supported color codes for translation statuses
1574
-
1575
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-available-colors-for-custom-translation-statuses-get)
1576
-
1577
- 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.
1578
-
1579
- ```ruby
1580
- @client.translation_status_colors(project_id) # Input:
1581
- ## project_id (string, required)
1582
- # Output:
1583
- ## Array of color codes in HEX format
1584
- ```
1585
-
1586
- ### Webhooks
1587
-
1588
- [Webhook attributes](https://lokalise.com/api2docs/curl/#object-webhooks)
1589
-
1590
- #### Fetch webhooks
1591
-
1592
- [Doc](https://lokalise.com/api2docs/curl/#transition-list-all-webhooks-get)
1593
-
1594
- ```ruby
1595
- @client.webhooks(project_id, params = {}) # Input:
1596
- ## project_id (string, required)
1597
- ## params (hash)
1598
- ### :page and :limit
1599
- # Output:
1600
- ## Collection of webhooks for the project
1601
- ```
1602
-
1603
- #### Fetch a single webhook
1604
-
1605
- [Doc](https://lokalise.com/api2docs/curl/#transition-retrieve-a-webhook-get)
1606
-
1607
- ```ruby
1608
- @client.webhook(project_id, webhook_id) # Input:
1609
- ## project_id (string, required)
1610
- ## webhook_id (string or integer, required)
1611
- # Output:
1612
- ## Webhook for the given project
1613
- ```
1614
-
1615
- #### Create webhook
1616
-
1617
- [Doc](https://lokalise.com/api2docs/curl/#transition-create-a-webhook-post)
1618
-
1619
- ```ruby
1620
- @client.create_webhook(project_id, params) # Input:
1621
- ## project_id (string, required)
1622
- ## params (hash, required)
1623
- ### :url (string, required) - webhook URL
1624
- ### :events (array, required) - events to subscribe to. Check the API docs to find the list of supported events
1625
- ### :event_lang_map (array) - map the event with an array of languages iso codes
1626
- # Output:
1627
- ## Created webhook
1628
- ```
1629
-
1630
- #### Update webhook
1631
-
1632
- [Doc](https://lokalise.com/api2docs/curl/#transition-update-a-webhook-put)
1633
-
1634
- ```ruby
1635
- @client.update_webhook(project_id, webhook_id, params) # Input:
1636
- ## project_id (string, required)
1637
- ## webhook_id (string or integer, required)
1638
- ## params (hash)
1639
- ### :url (string) - webhook URL
1640
- ### :events (array) - events to subscribe to. Check the API docs to find the list of supported events
1641
- ### :event_lang_map (array) - map the event with an array of languages iso codes
1642
- # Output:
1643
- ## Updated webhook
1644
- ```
1645
-
1646
- Alternatively:
1647
-
1648
- ```ruby
1649
- webhook = @client.webhook(project_id, webhook_id)
1650
- webhook.update(params)
1651
- ```
1652
-
1653
- #### Delete webhook
1654
-
1655
- [Doc](https://lokalise.com/api2docs/curl/#transition-delete-a-webhook-delete)
1656
-
1657
- ```ruby
1658
- @client.destroy_webhook(project_id, webhook_id) # Input:
1659
- ## project_id (string, required)
1660
- ## webhook_id (string or integer, required)
1661
- # Output:
1662
- ## Result of the delete operation
1663
- ```
1664
-
1665
- Alternatively:
1666
-
1667
- ```ruby
1668
- webhook = @client.webhook(project_id, webhook_id)
1669
- webhook.destroy
1670
- ```
1671
-
1672
- ## Additional Info
1673
-
1674
- ### Customizing Request
1675
-
1676
- #### Choosing Adapter
1677
-
1678
- This library utilizes [Faraday](https://lostisland.github.io/faraday) to perform requests. The default adapter is built-in [Net::HTTP](https://ruby-doc.org/stdlib-2.6.3/libdoc/net/http/rdoc/Net/HTTP.html) but you may customize it as needed.
1679
-
1680
- For example, to use [Excon](https://github.com/excon/excon):
1681
-
1682
- ```ruby
1683
- require 'excon' # somewhere in your code
1684
-
1685
- Faraday.default_adapter = :excon
1686
- ```
1687
-
1688
- All supported adapters are listed [on Faraday official website](https://lostisland.github.io/faraday/adapters/).
1689
-
1690
- #### Setting Timeouts
1691
-
1692
- Request timeouts may be adjusted during client initialization:
1693
-
1694
- ```ruby
1695
- @client = Lokalise.client('YOUR_TOKEN', open_timeout: 100, timeout: 500)
1696
- @client.open_timeout # => 100
1697
- @client.timeout # => 500
1698
- ```
1699
-
1700
- Both values are in *seconds*. They can be adjusted later with simple accessors:
1701
-
1702
- ```ruby
1703
- @client.open_timeout = 200
1704
- @client.timeout = 600
1705
- @client.open_timeout # => 200
1706
- @client.timeout # => 600
1707
- ```
1708
-
1709
- ### Customizing JSON parser
1710
-
1711
- This gem used to rely on [MultiJson](https://github.com/intridea/multi_json) but it is not maintained anymore. By default we are using a [built-in JSON module](https://ruby-doc.org/stdlib-2.0.0/libdoc/json/rdoc/JSON.html) but you may utilize any other parser by overriding `#custom_dump` and `#custom_load` methods inside `Lokalise::JsonHandler` module.
1712
-
1713
- For example, to use [Oj](https://github.com/ohler55/oj) you would do the following:
1714
-
1715
- ```ruby
1716
- require 'oj'
1717
-
1718
- module Lokalise
1719
- module JsonHandler
1720
- # This method accepts a Ruby object and must return a JSON string
1721
- def custom_dump(obj)
1722
- Oj.dump obj
1723
- end
1724
-
1725
- # This method accepts JSON and must return Ruby object
1726
- def custom_load(obj)
1727
- Oj.load obj
1728
- end
1729
- end
1730
- end
1731
- ```
1732
-
1733
- ### Error handling
1734
-
1735
- [Error codes](https://lokalise.com/api2docs/curl/#resource-errors)
1736
-
1737
- The gem may raise the following custom exceptions:
1738
-
1739
- * `Lokalise::Error::BadRequest` (`400`) - the provided request incorrect
1740
- * `Lokalise::Error::Unauthorized` (`401`) - token is missing or incorrect
1741
- * `Lokalise::Error::Forbidden` (`403`) - authenticated user does not have sufficient rights to perform the desired action
1742
- * `Lokalise::Error::NotFound` (`404`) - the provided endpoint (resource) cannot be found
1743
- * `Lokalise::Error::MethodNowAllowed` (`405`) - HTTP request with the provided verb is not supported by the endpoint
1744
- * `Lokalise::Error::NotAcceptable` (`406`) - posted resource is malformed
1745
- * `Lokalise::Error::Conflict` (`409`) - request conflicts with another request
1746
- * `Lokalise::Error::Locked` (`423`) - your token is used simultaneously in multiple requests
1747
- * `Lokalise::Error::TooManyRequests` (`429`)
1748
- * `Lokalise::Error::ServerError` (`500`)
1749
- * `Lokalise::Error::BadGateway` (`502`)
1750
- * `Lokalise::Error::ServiceUnavailable` (`503`)
1751
- * `Lokalise::Error::GatewayTimeout` (`504`)
1752
-
1753
- ### API Rate Limits
1754
-
1755
- Lokalise does not [rate-limit API requests](https://lokalise.com/api2docs/curl/#resource-rate-limits), however retain a right to decline the service in case of excessive use. Only one concurrent request per token is allowed. To ensure data consistency, it is not recommended to access the same project simultaneously using multiple tokens.
1756
-
1757
- ## Running Tests
42
+ ## Usage
1758
43
 
1759
- 1. Copypaste `.env.example` file as `.env`. Put your API token inside. The `.env` file is excluded from version control so your token is safe. All in all, we use pre-recorded VCR cassettes, so the actual API requests won't be sent. However, providing at least some token is required.
1760
- 3. Run `rspec .`. Observe test results and code coverage.
44
+ Detailed documentation can be found at [lokalise.github.io/ruby-lokalise-api](https://lokalise.github.io/ruby-lokalise-api/).
1761
45
 
1762
46
  ## License
1763
47
 
1764
- This gem is licensed under the [MIT License](https://github.com/lokalise/ruby-lokalise-api/blob/master/LICENSE).
48
+ This gem is licensed under the [BSD 3 Clause license](https://github.com/lokalise/ruby-lokalise-api/blob/master/LICENSE). Prior to version 4 the license type was MIT.
1765
49
 
1766
50
  Copyright (c) [Lokalise team](http://lokalise.co), [Ilya Bodrov](http://bodrovis.tech)