ruby-lokalise-api 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/.github/CODE_OF_CONDUCT.md +46 -0
  3. data/.github/CONTRIBUTING.md +14 -0
  4. data/.github/ISSUE_TEMPLATE.md +13 -0
  5. data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  6. data/CHANGELOG.md +5 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE +22 -0
  9. data/README.md +917 -0
  10. data/Rakefile +16 -0
  11. data/lib/ruby-lokalise-api.rb +60 -0
  12. data/lib/ruby-lokalise-api/client.rb +22 -0
  13. data/lib/ruby-lokalise-api/collections/base.rb +46 -0
  14. data/lib/ruby-lokalise-api/collections/contributor.rb +13 -0
  15. data/lib/ruby-lokalise-api/collections/file.rb +13 -0
  16. data/lib/ruby-lokalise-api/collections/key.rb +13 -0
  17. data/lib/ruby-lokalise-api/collections/key_comment.rb +13 -0
  18. data/lib/ruby-lokalise-api/collections/project.rb +13 -0
  19. data/lib/ruby-lokalise-api/collections/project_comment.rb +13 -0
  20. data/lib/ruby-lokalise-api/collections/project_language.rb +13 -0
  21. data/lib/ruby-lokalise-api/collections/screenshot.rb +13 -0
  22. data/lib/ruby-lokalise-api/collections/snapshot.rb +13 -0
  23. data/lib/ruby-lokalise-api/collections/system_language.rb +13 -0
  24. data/lib/ruby-lokalise-api/collections/task.rb +13 -0
  25. data/lib/ruby-lokalise-api/collections/team.rb +13 -0
  26. data/lib/ruby-lokalise-api/collections/team_user.rb +13 -0
  27. data/lib/ruby-lokalise-api/collections/translation.rb +13 -0
  28. data/lib/ruby-lokalise-api/connection.rb +17 -0
  29. data/lib/ruby-lokalise-api/data/attributes.json +127 -0
  30. data/lib/ruby-lokalise-api/error.rb +47 -0
  31. data/lib/ruby-lokalise-api/request.rb +60 -0
  32. data/lib/ruby-lokalise-api/resources/base.rb +117 -0
  33. data/lib/ruby-lokalise-api/resources/contributor.rb +13 -0
  34. data/lib/ruby-lokalise-api/resources/file.rb +25 -0
  35. data/lib/ruby-lokalise-api/resources/key.rb +13 -0
  36. data/lib/ruby-lokalise-api/resources/key_comment.rb +15 -0
  37. data/lib/ruby-lokalise-api/resources/project.rb +18 -0
  38. data/lib/ruby-lokalise-api/resources/project_comment.rb +7 -0
  39. data/lib/ruby-lokalise-api/resources/project_language.rb +15 -0
  40. data/lib/ruby-lokalise-api/resources/screenshot.rb +13 -0
  41. data/lib/ruby-lokalise-api/resources/snapshot.rb +17 -0
  42. data/lib/ruby-lokalise-api/resources/system_language.rb +7 -0
  43. data/lib/ruby-lokalise-api/resources/task.rb +13 -0
  44. data/lib/ruby-lokalise-api/resources/team.rb +6 -0
  45. data/lib/ruby-lokalise-api/resources/team_user.rb +13 -0
  46. data/lib/ruby-lokalise-api/resources/translation.rb +13 -0
  47. data/lib/ruby-lokalise-api/rest/comments.rb +57 -0
  48. data/lib/ruby-lokalise-api/rest/contributors.rb +54 -0
  49. data/lib/ruby-lokalise-api/rest/files.rb +33 -0
  50. data/lib/ruby-lokalise-api/rest/keys.rb +75 -0
  51. data/lib/ruby-lokalise-api/rest/languages.rb +63 -0
  52. data/lib/ruby-lokalise-api/rest/projects.rb +58 -0
  53. data/lib/ruby-lokalise-api/rest/screenshots.rb +54 -0
  54. data/lib/ruby-lokalise-api/rest/snapshots.rb +43 -0
  55. data/lib/ruby-lokalise-api/rest/tasks.rb +54 -0
  56. data/lib/ruby-lokalise-api/rest/team_users.rb +44 -0
  57. data/lib/ruby-lokalise-api/rest/teams.rb +12 -0
  58. data/lib/ruby-lokalise-api/rest/translations.rb +35 -0
  59. data/lib/ruby-lokalise-api/utils/attribute_helpers.rb +52 -0
  60. data/lib/ruby-lokalise-api/utils/string_utils.rb +21 -0
  61. data/lib/ruby-lokalise-api/version.rb +3 -0
  62. data/ruby-lokalise-api.gemspec +32 -0
  63. data/spec/lib/ruby-lokalise-api/error_spec.rb +23 -0
  64. data/spec/lib/ruby-lokalise-api/rest/comments_spec.rb +78 -0
  65. data/spec/lib/ruby-lokalise-api/rest/contributors_spec.rb +79 -0
  66. data/spec/lib/ruby-lokalise-api/rest/files_spec.rb +53 -0
  67. data/spec/lib/ruby-lokalise-api/rest/keys_spec.rb +119 -0
  68. data/spec/lib/ruby-lokalise-api/rest/languages_spec.rb +91 -0
  69. data/spec/lib/ruby-lokalise-api/rest/projects_spec.rb +79 -0
  70. data/spec/lib/ruby-lokalise-api/rest/screenshots_spec.rb +76 -0
  71. data/spec/lib/ruby-lokalise-api/rest/snapshots_spec.rb +61 -0
  72. data/spec/lib/ruby-lokalise-api/rest/tasks_spec.rb +89 -0
  73. data/spec/lib/ruby-lokalise-api/rest/team_users_spec.rb +56 -0
  74. data/spec/lib/ruby-lokalise-api/rest/teams_spec.rb +22 -0
  75. data/spec/lib/ruby-lokalise-api/rest/translations_spec.rb +54 -0
  76. data/spec/lib/ruby-lokalise-api/utils/snakecase_spec.rb +17 -0
  77. data/spec/lib/ruby-lokalise-api_spec.rb +13 -0
  78. data/spec/spec_helper.rb +15 -0
  79. data/spec/support/test_client.rb +5 -0
  80. data/spec/support/vcr.rb +8 -0
  81. metadata +255 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f2212a93b34d63ef5bec7884f3003088d74a2c616affdf9931ad9767ae8b1f5d
4
+ data.tar.gz: e56cee6b0d8bc2974591f215191a1543f2d1b9d28a774b46c7bec1fff96c5ccb
5
+ SHA512:
6
+ metadata.gz: ec48688594d2492bade883ac5dda7baa533d9f27a6c7cd59dc90cfd30e7be5e8517885f85ca3a43b3d8009bd8052945334a4c38dcee60a1a4720960289e4e338
7
+ data.tar.gz: 2c367579e4617dc4c89474afbd09b7b62b10a768ddaca01162934527e3211391f225ea39d3cc1a8fa1310c661d9eaab758c8239a887c2d7e091c0f4152211be0
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
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.
38
+
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
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,14 @@
1
+ # Contributing
2
+
3
+ 1. [Fork the repository.][fork]
4
+ 2. [Create a topic branch.][branch]
5
+ 3. Implement your feature or bug fix.
6
+ 4. Don't forget to add specs and make sure they pass by running `rspec .`.
7
+ 5. Make sure your code complies with the style guide by running `rubocop`. `rubocop -a` can automatically fix most issues for you.
8
+ 6. If necessary, add documentation for your feature or bug fix.
9
+ 7. Commit and push your changes.
10
+ 8. [Submit a pull request.][pr]
11
+
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/
@@ -0,0 +1,13 @@
1
+ ### Steps to reproduce
2
+
3
+ ### Expected behavior
4
+
5
+ Tell us what should happen
6
+
7
+ ### Actual behavior
8
+
9
+ Tell us what happens instead
10
+
11
+ ### System configuration
12
+
13
+ **Ruby version**:
@@ -0,0 +1,11 @@
1
+ ### Summary
2
+
3
+ Provide a general description of the code changes in your pull
4
+ request. Were there any bugs you had fixed? If so, mention them. If
5
+ these bugs have open GitHub issues, be sure to tag them here as well,
6
+ to keep the conversation linked together.
7
+
8
+ ### Other Information
9
+
10
+ If there's anything else that's important and relevant to your pull
11
+ request, mention that information here.
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 (10-Dec-18)
4
+
5
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Lokalise team, Ilya Bodrov, Roman Kutanov
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:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
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.
data/README.md ADDED
@@ -0,0 +1,917 @@
1
+ # Lokalise API 2.0 official Ruby interface
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)
5
+
6
+ Official opinionated Ruby interface for the [Lokalise API](https://lokalise.co/api2docs/ruby/) that represents returned data as Ruby objects.
7
+
8
+ ## Index
9
+
10
+ * [Getting started](#getting-started)
11
+ + [Installation and Requirements](#installation-and-requirements)
12
+ + [Initializing the Client](#initializing-the-client)
13
+ + [Objects and models](#objects-and-models)
14
+ + [Collections of resources and pagination](#collections-of-resources-and-pagination)
15
+ * [Available Resources](#available-resources)
16
+ + [Comments](#comments)
17
+ + [Contributors](#contributors)
18
+ + [Files](#files)
19
+ + [Keys](#keys)
20
+ + [Languages](#languages)
21
+ + [Projects](#projects)
22
+ + [Screenshots](#screenshots)
23
+ + [Snapshots](#snapshots)
24
+ + [Tasks](#tasks)
25
+ + [Teams](#teams)
26
+ + [Team users](#team-users)
27
+ + [Translations](#translations)
28
+ * [Additional Info](#additional-info)
29
+ + [Error handling](#error-handling)
30
+ + [API Rate Limits](#api-rate-limits)
31
+ * [Running Tests](#running-tests)
32
+
33
+ ## Getting Started
34
+
35
+ ### Installation and Requirements
36
+
37
+ This gem requires [Ruby 2.4+](https://www.ruby-lang.org/en/) and [RubyGems package manager](https://rubygems.org/pages/download).
38
+
39
+ Install it by running:
40
+
41
+ ```bash
42
+ $ gem install ruby-lokalise-api
43
+ ```
44
+
45
+ ### Initializing the Client
46
+
47
+ In order to perform API requests, you require a special token that can be obtained in your [personal profile](https://lokalise.co/profile#apitokens) (*API tokens* section). Note that the owner of the token must have admin access rights.
48
+
49
+ After you've obtained the token, initialize the client:
50
+
51
+ ```ruby
52
+ require 'ruby-lokalise-api'
53
+
54
+ @client = Lokalise.client 'YOUR_TOKEN_HERE'
55
+ ```
56
+
57
+ Now the `@client` can be used to perform API requests!
58
+
59
+ ### Objects and models
60
+
61
+ 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.
62
+
63
+ Here is an example:
64
+
65
+ ```ruby
66
+ project = client.project '123'
67
+ project.name
68
+ project.description
69
+ project.created_by
70
+ ```
71
+
72
+ To get access to raw data returned by the API, use `#raw_data`:
73
+
74
+ ```ruby
75
+ project.raw_data
76
+ ```
77
+
78
+ ### Collections of resources and pagination
79
+
80
+ Fetching (or creating/updating) multiple objects will return a *collection* of objects. To get access to the actual data, use `#collection` method:
81
+
82
+ ```ruby
83
+ project = @client.projects.collection.first # => Get the first project
84
+ project.name
85
+ ```
86
+
87
+ Bulk fetches support [pagination](https://lokalise.co/api2docs/php/#resource-pagination). There are two common parameters available:
88
+
89
+ * `:limit` (defaults to `100`, maximum is `5000`) - number of records to display per page
90
+ * `:page` (defaults to `1`) - page to fetch
91
+
92
+ ```ruby
93
+ projects = @client.projects limit: 10, page: 3 #=> Paginate by 10 records and fetch the third page
94
+ ```
95
+
96
+ Collections respond to the following methods:
97
+
98
+ * `#total_pages`
99
+ * `#total_results`
100
+ * `#results_per_page`
101
+ * `#current_page`
102
+
103
+ For example:
104
+
105
+ ```ruby
106
+ projects.current_page #=> 3
107
+ ```
108
+
109
+ ## Available Resources
110
+
111
+ ### Comments
112
+
113
+ [Comments attributes](https://lokalise.co/api2docs/ruby/#resource-comments)
114
+
115
+ #### Fetch project comments
116
+
117
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-project-comments-get)
118
+
119
+ ```ruby
120
+ @client.project_comments(project_id, params = {}) # Input:
121
+ ## project_id (string, required)
122
+ ## params (hash)
123
+ ### :page and :limit
124
+ # Output:
125
+ ## Collection of comments available in the given project
126
+ ```
127
+
128
+ #### Fetch key comments
129
+
130
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-key-comments-get)
131
+
132
+ ```ruby
133
+ @client.comments(project_id, key_id, params = {}) # Input:
134
+ ## project_id (string, required)
135
+ ## key_id (string, required)
136
+ ## params (hash)
137
+ ### :page and :limit
138
+ # Output:
139
+ ## Collection of comments available for the specified key in the given project
140
+ ```
141
+
142
+ #### Create key comments
143
+
144
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-create-comments-post)
145
+
146
+ ```ruby
147
+ @client.create_comments(project_id, key_id, params) # Input:
148
+ ## project_id (string, required)
149
+ ## key_id (string, required)
150
+ ## 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
151
+ ### :comment (string, required)
152
+ # Output:
153
+ ## Newly created comment
154
+ ```
155
+
156
+ #### Fetch key comment
157
+
158
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-comment-get)
159
+
160
+ ```ruby
161
+ @client.comment(project_id, key_id, comment_id) # Input:
162
+ ## project_id (string, required)
163
+ ## key_id (string, required)
164
+ ## comment_id (string, required)
165
+ # Output:
166
+ ## Comment for the key in the given project
167
+ ```
168
+
169
+ #### Delete key comment
170
+
171
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-delete-a-comment-delete)
172
+
173
+ ```ruby
174
+ @client.delete_comment(project_id, key_id, comment_id) # Input:
175
+ ## project_id (string, required)
176
+ ## key_id (string, required)
177
+ ## comment_id (string, required)
178
+ # Output:
179
+ ## Hash with the project's id and "comment_deleted"=>true
180
+ ```
181
+
182
+ ### Contributors
183
+
184
+ #### Fetch contributors
185
+
186
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-contributors-get)
187
+
188
+ ```ruby
189
+ @client.contributors(project_id, params = {}) # Input:
190
+ ## project_id (string, required)
191
+ ## params (hash)
192
+ ### :page and :limit
193
+ # Output:
194
+ ## Collection of contributors in the given project
195
+ ```
196
+
197
+ #### Fetch a single contributor
198
+
199
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-contributor-get)
200
+
201
+ ```ruby
202
+ @client.contributor(project_id, contributor_id) # Input:
203
+ ## project_id (string, required)
204
+ ## contributor_id (string, required) - named as "user_id" in the response
205
+ # Output:
206
+ ## Contributor in the given project
207
+ ```
208
+
209
+ #### Create contributors
210
+
211
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-create-contributors-post)
212
+
213
+ ```ruby
214
+ @client.create_contributors(project_id, params) # Input:
215
+ ## project_id (string, required)
216
+ ## 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
217
+ ### :email (string, required)
218
+ ### :fullname (string)
219
+ ### :is_admin (boolean)
220
+ ### :is_reviewer (boolean)
221
+ ### :languages (array of hashes, required if "is_admin" set to false) - possible languages attributes:
222
+ #### :lang_iso (string, required)
223
+ #### :is_writable (boolean)
224
+ ### :admin_rights (array)
225
+ # Output:
226
+ ## Collection of newly created contributors
227
+ ```
228
+
229
+ #### Update contributor
230
+
231
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-update-a-contributor-put)
232
+
233
+ ```ruby
234
+ @client.update_contributor(project_id, contributor_id, params) # Input:
235
+ ## project_id (string, required)
236
+ ## contributor_id (string, required)
237
+ ## params (hash, required)
238
+ ### :is_admin (boolean)
239
+ ### :is_reviewer (boolean)
240
+ ### :languages (array of hashes) - possible languages attributes:
241
+ #### :lang_iso (string, required)
242
+ #### :is_writable (boolean)
243
+ ### :admin_rights (array)
244
+ # Output:
245
+ ## Updated contributor
246
+ ```
247
+
248
+ #### Delete contributor
249
+
250
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-delete-a-contributor-delete)
251
+
252
+ ```ruby
253
+ @client.delete_contributor(project_id, contributor_id) # Input:
254
+ ## project_id (string, required)
255
+ ## contributor_id (string, required)
256
+ # Output:
257
+ ## Hash with the project's id and "contributor_deleted"=>true
258
+ ```
259
+
260
+ ### Files
261
+
262
+ [File attributes](https://lokalise.co/api2docs/ruby/#object-files)
263
+
264
+ #### Fetch translation files
265
+
266
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-files-get)
267
+
268
+ ```ruby
269
+ @client.files(project_id, params = {}) # Input:
270
+ ## project_id (string, required)
271
+ ## params (hash)
272
+ ### :page and :limit
273
+ # Output:
274
+ ## Collection of translation files available in the given project
275
+ ```
276
+
277
+ #### Download translation files
278
+
279
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-download-files-post)
280
+
281
+ Exports project files as a `.zip` bundle and makes them available to download (the link is valid for 12 months).
282
+
283
+ ```ruby
284
+ @client.download_files(project_id, params) # Input:
285
+ ## project_id (string, required)
286
+ ## params (hash, required)
287
+ ### :format (string, required) - one of the file formats supported by Lokalise (json, xml, po etc).
288
+ ### Find the list of other supported params at https://lokalise.co/api2docs/ruby/#transition-download-files-post
289
+ # Output:
290
+ ## Hash with the project id and a "bundle_url" link
291
+ ```
292
+
293
+ #### Upload translation file
294
+
295
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-upload-a-file-post)
296
+
297
+ ```ruby
298
+ @client.upload_file(project_id, params) # Input:
299
+ ## project_id (string, required)
300
+ ## params (hash, required)
301
+ ### :data (string, required) - base64-encoded data (the format must be supported by Lokalise)
302
+ ### :filename (string, required)
303
+ ### :lang_iso (string, required)
304
+ ### Find the list of other supported params at https://lokalise.co/api2docs/ruby/#transition-upload-a-file-post
305
+ # Output:
306
+ ## Hash with information about the upload
307
+ ```
308
+
309
+ ### Keys
310
+
311
+ [Key attributes](https://lokalise.co/api2docs/ruby/#object-keys)
312
+
313
+ #### Fetch project keys
314
+
315
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-keys-get)
316
+
317
+ ```ruby
318
+ @client.keys(project_id, params = {}) # Input:
319
+ ## project_id (string, required)
320
+ ## params (hash)
321
+ ### :page and :limit
322
+ # Output:
323
+ ## Collection of keys available in the given project
324
+ ```
325
+
326
+ #### Fetch a single project key
327
+
328
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-key-get)
329
+
330
+ ```ruby
331
+ @client.key(project_id, key_id, params = {}) # Input:
332
+ ## project_id (string, required)
333
+ ## key_id (string, required)
334
+ ## params (hash)
335
+ ### :disable_references (string) - possible values are "1" and "0".
336
+ # Output:
337
+ ## Project key
338
+ ```
339
+
340
+ #### Create project keys
341
+
342
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-create-keys-post)
343
+
344
+ ```ruby
345
+ @client.create_keys(project_id, params) # Input:
346
+ ## project_id (string, required)
347
+ ## params (array of hashes or hash, required)
348
+ ### :key_name (string or hash, required) - for projects with enabled per-platform key names, pass hash with "ios", "android", "web" and "other" params.
349
+ ### :platforms (array) - supported values are "ios", "android", "web" and "other"
350
+ ### Find all other supported attributes at https://lokalise.co/api2docs/ruby/#transition-create-keys-post
351
+ # Output:
352
+ ## Collection of newly created keys
353
+ ```
354
+
355
+ #### Update project key
356
+
357
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-update-a-key-put)
358
+
359
+ ```ruby
360
+ @client.update_key(project_id, key_id, params = {}) # Input:
361
+ ## project_id (string, required)
362
+ ## key_id (string, required)
363
+ ## params (hash)
364
+ ### Find a list of supported attributes at https://lokalise.co/api2docs/ruby/#transition-update-a-key-put
365
+ # Output:
366
+ ## Updated key
367
+ ```
368
+
369
+ #### Bulk update project keys
370
+
371
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-bulk-update-put)
372
+
373
+ ```ruby
374
+ @client.update_keys(project_id, params) # Input:
375
+ ## project_id (string, required)
376
+ ## params (hash or array of hashes, required)
377
+ ### :key_id (string, required)
378
+ ### Find all other supported attributes at https://lokalise.co/api2docs/ruby/#transition-bulk-update-put
379
+ # Output:
380
+ ## Collection of updated keys
381
+ ```
382
+
383
+ #### Delete project key
384
+
385
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-delete-a-key-delete)
386
+
387
+ ```ruby
388
+ @client.delete_key(project_id, key_id) # Input:
389
+ ## project_id (string, required)
390
+ ## key_id (string, required)
391
+ # Output:
392
+ ## Hash with project_id and "key_removed" set to "true"
393
+ ```
394
+
395
+ #### Bulk delete project keys
396
+
397
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-delete-multiple-keys-delete)
398
+
399
+ ```ruby
400
+ @client.delete_keys(project_id, key_ids) # Input:
401
+ ## project_id (string, required)
402
+ ## key_ids (array, required)
403
+ # Output:
404
+ ## Hash with project_id and "keys_removed" set to "true"
405
+ ```
406
+
407
+ ### Languages
408
+
409
+ [Language attributes](https://lokalise.co/api2docs/ruby/#object-languages)
410
+
411
+ #### Fetch system languages
412
+
413
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-system-languages-get)
414
+
415
+ ```ruby
416
+ @client.system_languages(params = {}) # Input:
417
+ ## params (hash)
418
+ ### :page and :limit
419
+ # Output:
420
+ ## Collection of system languages supported by Lokalise
421
+ ```
422
+
423
+ #### Fetch project languages
424
+
425
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-project-languages-get)
426
+
427
+ ```ruby
428
+ @client.project_languages(project_id, params = {}) # Input:
429
+ ## project_id (string, required)
430
+ ## params (hash)
431
+ ### :page and :limit
432
+ # Output:
433
+ ## Collection of languages available in the given project
434
+ ```
435
+
436
+ #### Fetch a single project language
437
+
438
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-language-get)
439
+
440
+ ```ruby
441
+ @client.language(project_id, language_id) # Input:
442
+ ## project_id (string, required)
443
+ ## language_id (string, required)
444
+ # Output:
445
+ ## A single language in the given project
446
+ ```
447
+
448
+ #### Create project languages
449
+
450
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-create-languages-post)
451
+
452
+ ```ruby
453
+ @client.create_languages(project_id, params) # Input:
454
+ ## project_id (string, required)
455
+ ## 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
456
+ ### :lang_iso (string, required)
457
+ ### :custom_iso (string)
458
+ ### :custom_name (string)
459
+ ### :custom_plural_forms (array) - can contain only plural forms initially supported by Lokalise
460
+ # Output:
461
+ ## Collection of newly created languages
462
+ ```
463
+
464
+ #### Update project language
465
+
466
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-update-a-language-put)
467
+
468
+ ```ruby
469
+ @client.update_language(project_id, language_id, params) # Input:
470
+ ## project_id (string, required)
471
+ ## language_id (string, required)
472
+ ## params (hash, required)
473
+ ### :lang_iso (string, required)
474
+ ### :custom_name (string)
475
+ ### :plural_forms (array) - can contain only plural forms initially supported by Lokalise
476
+ # Output:
477
+ ## Updated language
478
+ ```
479
+
480
+ #### Delete project language
481
+
482
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-delete-a-language-delete)
483
+
484
+ ```ruby
485
+ @client.delete_language(project_id, language_id) # Input:
486
+ ## project_id (string, required)
487
+ ## language_id (string, required)
488
+ # Output:
489
+ ## Hash with the project's id and "language_deleted"=>true
490
+ ```
491
+
492
+ ### Projects
493
+
494
+ [Project attributes](https://lokalise.co/api2docs/php/#object-projects)
495
+
496
+ #### Fetch projects collection
497
+
498
+ [Doc](https://lokalise.co/api2docs/php/#transition-list-all-projects-get)
499
+
500
+ ```ruby
501
+ @client.projects(params = {}) # Input:
502
+ ## params (hash)
503
+ ### :filter_team_id (string) - load projects only for the given team
504
+ ### :page and :limit
505
+ # Output:
506
+ ## Collection of projects under the `projects` attribute
507
+ ```
508
+
509
+ #### Fetch a single project
510
+
511
+ [Doc](https://lokalise.co/api2docs/php/#transition-retrieve-a-project-get)
512
+
513
+ ```ruby
514
+ @client.project(project_id) # Input:
515
+ ## project_id (string, required)
516
+ # Output:
517
+ ## A single project
518
+ ```
519
+
520
+ #### Create a project
521
+
522
+ [Doc](https://lokalise.co/api2docs/php/#transition-create-a-project-post)
523
+
524
+ ```ruby
525
+ @client.create_project(params) # Input:
526
+ ## params (hash, required)
527
+ ### name (string, required)
528
+ ### description (string)
529
+ ### team_id (integer) - you must be an admin of the chosen team. When omitted, defaults to the current team of the token's owner
530
+ # Output:
531
+ ## A newly created project
532
+
533
+ ```
534
+
535
+ #### Update a project
536
+
537
+ [Doc](https://lokalise.co/api2docs/php/#transition-update-a-project-put)
538
+
539
+ ```ruby
540
+ @client.update_project(project_id, params) # Input:
541
+ ## project_id (string, required)
542
+ ## params (hash, required)
543
+ ### name (string, required)
544
+ ### description (string)
545
+ # Output:
546
+ ## An updated project
547
+ ```
548
+
549
+ #### Empty a project
550
+
551
+ [Doc](https://lokalise.co/api2docs/php/#transition-empty-a-project-put)
552
+
553
+ Deletes *all* keys and translations from the project.
554
+
555
+ ```ruby
556
+ @client.empty_project(project_id) # Input:
557
+ ## project_id (string, required)
558
+ # Output:
559
+ ## A project containing its id and a `keys_deleted => true` attribute
560
+ ```
561
+
562
+ #### Delete a project
563
+
564
+ [Doc](https://lokalise.co/api2docs/php/#transition-delete-a-project-delete)
565
+
566
+ ```ruby
567
+ @client.delete_project(project_id) # Input:
568
+ ## project_id (string, required)
569
+ # Output:
570
+ ## A project containing its id and a `project_deleted => true` attribute
571
+ ```
572
+
573
+ ### Screenshots
574
+
575
+ [Screenshot attributes](https://lokalise.co/api2docs/ruby/#resource-screenshots)
576
+
577
+ #### Fetch screenshots
578
+
579
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-screenshots-get)
580
+
581
+ ```ruby
582
+ @client.screenshots(project_id, params = {}) # Input:
583
+ ## project_id (string, required)
584
+ ## params (hash)
585
+ ### :page and :limit
586
+ # Output:
587
+ ## Collection of project screenshots
588
+ ```
589
+
590
+ #### Fetch a single screenshot
591
+
592
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-screenshot-get)
593
+
594
+ ```ruby
595
+ @client.screeshot(project_id, screeshot_id) # Input:
596
+ ## project_id (string, required)
597
+ ## screeshot_id (string, required)
598
+ # Output:
599
+ ## A single screenshot
600
+ ```
601
+
602
+ #### Create screenshots
603
+
604
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-create-screenshots-post)
605
+
606
+ ```ruby
607
+ @client.create_screenshots(project_id, params) # Input:
608
+ ## project_id (string, required)
609
+ ## params (hash or array of hashes, required)
610
+ ### :data (string, required) - the actual screenshot, base64-encoded (with leading image type "data:image/jpeg;base64,"). JPG and PNG formats are supported.
611
+ ### :title (string)
612
+ ### :description (string)
613
+ ### :ocr (boolean) - recognize translations on the image and attach screenshot to all possible keys
614
+ ### :key_ids (array) - attach the screenshot to key IDs specified
615
+ ### :tags (array)
616
+ # Output:
617
+ ## Collection of created screenshots
618
+ ```
619
+
620
+ #### Update screenshot
621
+
622
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-update-a-screenshot-put)
623
+
624
+ ```ruby
625
+ @client.update_screenshot(project_id, screenshot_id, params = {}) # Input:
626
+ ## project_id (string, required)
627
+ ## screenshot_id (string, required)
628
+ ## params (hash)
629
+ ### :title (string)
630
+ ### :description (string)
631
+ ### :key_ids (array) - attach the screenshot to key IDs specified
632
+ ### :tags (array)
633
+ # Output:
634
+ ## Updated screenshot
635
+ ```
636
+
637
+ #### Delete screenshot
638
+
639
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-delete-a-screenshot-delete)
640
+
641
+ ```ruby
642
+ @client.delete_screenshot(project_id, screenshot_id) # Input:
643
+ ## project_id (string, required)
644
+ ## screenshot_id (string, required)
645
+ # Output:
646
+ ## Hash with the project id and "screenshot_deleted" set to "true"
647
+ ```
648
+
649
+ ### Snapshots
650
+
651
+ [Snapshot attributes](https://lokalise.co/api2docs/ruby/#object-snapshots)
652
+
653
+ #### Fetch snapshots
654
+
655
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-snapshots-get)
656
+
657
+ ```ruby
658
+ @client.snapshots(project_id, params = {}) # Input:
659
+ ## project_id (string, required)
660
+ ## params (hash)
661
+ ### :filter_title (string) - set title filter for the list
662
+ ### :page and :limit
663
+ # Output:
664
+ ## Collection of project snapshots
665
+ ```
666
+
667
+ #### Create snapshot
668
+
669
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-create-a-snapshot-post)
670
+
671
+ ```ruby
672
+ @client.create_snapshot(project_id, params = {}) # Input:
673
+ ## project_id (string, required)
674
+ ## params (hash)
675
+ ### :title (string)
676
+ # Output:
677
+ ## Created snapshot
678
+ ```
679
+
680
+ #### Restore snapshot
681
+
682
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-restore-a-snapshot-post)
683
+
684
+ ```ruby
685
+ @client.restore_snapshot(project_id, snapshot_id) # Input:
686
+ ## project_id (string, required)
687
+ ## snapshot_id (string, required)
688
+ # Output:
689
+ ## Information about the restored project from the specified snapshot
690
+ ```
691
+
692
+ #### Delete snapshot
693
+
694
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-delete-a-snapshot-delete)
695
+
696
+ ```ruby
697
+ @client.delete_snapshot(project_id, snapshot_id) # Input:
698
+ ## project_id (string, required)
699
+ ## snapshot_id (string, required)
700
+ # Output:
701
+ ## Hash with the project id and "snapshot_deleted" set to "true"
702
+ ```
703
+
704
+ ### Tasks
705
+
706
+ [Task attributes](https://lokalise.co/api2docs/ruby/#resource-tasks)
707
+
708
+ #### Fetch tasks
709
+
710
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-tasks-get)
711
+
712
+ ```ruby
713
+ @client.tasks(project_id, params = {}) # Input:
714
+ ## project_id (string, required)
715
+ ## params (hash)
716
+ ### :filter_title (string) - set title filter for the list
717
+ ### :page and :limit
718
+ # Output:
719
+ ## Collection of tasks for the project
720
+ ```
721
+
722
+ #### Fetch a single task
723
+
724
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-task-get)
725
+
726
+ ```ruby
727
+ @client.task(project_id, task_id, params = {}) # Input:
728
+ ## project_id (string, required)
729
+ ## task_id (string, required)
730
+ # Output:
731
+ ## Single task for the project
732
+ ```
733
+
734
+ #### Create task
735
+
736
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-create-a-task-post)
737
+
738
+ ```ruby
739
+ @client.create_task(project_id, params) # Input:
740
+ ## project_id (string, required)
741
+ ## params (hash, required)
742
+ ### title (string, required)
743
+ ### keys (array) - translation key ids. Required if "parent_task_id" is not specified
744
+ ### languages (array of hashes, required)
745
+ #### language_iso (string)
746
+ #### users (array) - list of users identifiers, assigned to work on the language
747
+ ### Find other supported options at https://lokalise.co/api2docs/ruby/#transition-create-a-task-post
748
+ # Output:
749
+ ## A newly created task
750
+
751
+ ```
752
+
753
+ #### Update task
754
+
755
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-update-a-task-put)
756
+
757
+ ```ruby
758
+ @client.delete_task(project_id, task_id) # Input:
759
+ ## project_id (string, required)
760
+ ## task_id (string, required)
761
+ # Output:
762
+ ## Hash with the project id and "task_deleted" set to "true"
763
+
764
+ ```
765
+
766
+ ### Teams
767
+
768
+ #### Fetch teams
769
+
770
+ [Doc](https://lokalise.co/api2docs/ruby/#resource-teams)
771
+
772
+ ```ruby
773
+ @client.teams(params = {}) # Input:
774
+ ## params (hash)
775
+ ### :page and :limit
776
+ # Output:
777
+ ## Collection of teams
778
+ ```
779
+
780
+ ### Team users
781
+
782
+ [Team user attributes](https://lokalise.co/api2docs/ruby/#object-team-users)
783
+
784
+ #### Fetch team users
785
+
786
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-team-users-get)
787
+
788
+ ```ruby
789
+ @client.team_users(team_id, params = {}) # Input:
790
+ ## team_id (string, required)
791
+ ## params (hash)
792
+ ### :page and :limit
793
+ # Output:
794
+ ## Collection of team users
795
+ ```
796
+
797
+ #### Fetch a single team user
798
+
799
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-team-user-get)
800
+
801
+ ```ruby
802
+ @client.team_user(team_id, user_id) # Input:
803
+ ## team_id (string, required)
804
+ ## user_id (string, required)
805
+ # Output:
806
+ ## Team user
807
+ ```
808
+
809
+ #### Update team user
810
+
811
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-update-a-team-user-put)
812
+
813
+ ```ruby
814
+ @client.update_team_user(team_id, user_id, params) # Input:
815
+ ## team_id (string, required)
816
+ ## user_id (string, required)
817
+ ## params (hash, required):
818
+ ### :role (string, required) - :owner, :admin, or :member
819
+ # Output:
820
+ ## Updated team user
821
+ ```
822
+
823
+ #### Delete team user
824
+
825
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-delete-a-team-user-delete)
826
+
827
+ ```ruby
828
+ @client.delete_team_user(team_id, user_id) # Input:
829
+ ## team_id (string, required)
830
+ ## user_id (string, required)
831
+ # Output:
832
+ ## Hash with "team_id" and "team_user_deleted" set to "true"
833
+ ```
834
+
835
+ ### Translations
836
+
837
+ [Translation attributes](https://lokalise.co/api2docs/ruby/#resource-translations)
838
+
839
+ #### Fetch translations
840
+
841
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-list-all-translations-get)
842
+
843
+ ```ruby
844
+ @client.translations(project_id, params = {}) # Input:
845
+ ## project_id (string, required)
846
+ ## params (hash)
847
+ ### :disable_references (string) - whether to disable key references. Supported values are 0 and 1
848
+ ### :page and :limit
849
+ # Output:
850
+ ## Collection of translations for the project
851
+ ```
852
+
853
+ #### Fetch a single translation
854
+
855
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-retrieve-a-translation-get)
856
+
857
+ ```ruby
858
+ @client.translation(project_id, translation_id, params = {}) # Input:
859
+ ## project_id (string, required)
860
+ ## translation_id (string, required)
861
+ ## params (hash)
862
+ ### :disable_references (string) - whether to disable key references. Supported values are 0 and 1
863
+ # Output:
864
+ ## Single translation for the project
865
+ ```
866
+
867
+ #### Update translation
868
+
869
+ [Doc](https://lokalise.co/api2docs/ruby/#transition-update-a-translation-put)
870
+
871
+ ```ruby
872
+ @client.update_translation(project_id, translation_id, params = {}) # Input:
873
+ ## project_id (string, required)
874
+ ## translation_id (string, required)
875
+ ## params (hash, required)
876
+ ### :translation (string or hash, required) - the actual translation. Provide hash for plural keys.
877
+ ### :is_fuzzy (boolean)
878
+ ### :is_reviewed (boolean)
879
+ # Output:
880
+ ## Updated translation
881
+ ```
882
+
883
+ ## Additional Info
884
+
885
+ ### Error handling
886
+
887
+ [Error codes](https://lokalise.co/api2docs/curl/#resource-errors)
888
+
889
+ The gem may raise the following custom exceptions:
890
+
891
+ * `Lokalise::Error::BadRequest` (`400`) - the provided request incorrect
892
+ * `Lokalise::Error::Unauthorized` (`401`) - token is missing or incorrect
893
+ * `Lokalise::Error::Forbidden` (`403`) - authenticated user does not have sufficient rights to perform the desired action
894
+ * `Lokalise::Error::NotFound` (`404`) - the provided endpoint (resource) cannot be found
895
+ * `Lokalise::Error::NotAcceptable` (`406`) - posted resource is malformed
896
+ * `Lokalise::Error::Conflict` (`409`) - request conflicts with another request
897
+ * `Lokalise::Error::Locked` (`423`) - your token is used simultaneously in multiple requests
898
+ * `Lokalise::Error::TooManyRequests` (`429`)
899
+ * `Lokalise::Error::ServerError` (`500`)
900
+ * `Lokalise::Error::BadGateway` (`502`)
901
+ * `Lokalise::Error::ServiceUnavailable` (`503`)
902
+ * `Lokalise::Error::GatewayTimeout` (`504`)
903
+
904
+ ### API Rate Limits
905
+
906
+ Lokalise does not [rate-limit API requests](https://lokalise.co/api2docs/ruby/#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.
907
+
908
+ ## Running Tests
909
+
910
+ 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.
911
+ 3. Run `rspec .`. Observe test results and code coverage.
912
+
913
+ ## License
914
+
915
+ This gem is licensed under the [MIT License](https://github.com/lokalise/ruby-lokalise-api/blob/master/LICENSE).
916
+
917
+ Copyright (c) [Lokalise team](http://lokalise.co), [Ilya Bodrov](http://bodrovis.tech)