ruby-lokalise-api 3.1.0 → 4.0.0

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