phrase 4.25.0 → 4.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +26 -4
  4. data/docs/AutomationEvent.md +33 -0
  5. data/docs/AutomationEventProject.md +19 -0
  6. data/docs/AutomationEventsApi.md +168 -0
  7. data/docs/AutomationsCreateParameters.md +1 -1
  8. data/docs/AutomationsCreateParameters1.md +1 -1
  9. data/docs/CheckIssue.md +33 -0
  10. data/docs/ChecksApi.md +146 -0
  11. data/docs/DocumentsApi.md +4 -4
  12. data/docs/ICUApi.md +1 -1
  13. data/docs/IcuSkeletonError.md +17 -0
  14. data/docs/IcuSkeletonParameters.md +11 -11
  15. data/docs/JobCreateParameters.md +1 -1
  16. data/docs/JobsApi.md +2 -2
  17. data/docs/KeyCreateParameters.md +1 -1
  18. data/docs/KeyFormatAnnotationsApi.md +74 -0
  19. data/docs/KeyFormatAnnotationsList200ResponseInner.md +19 -0
  20. data/docs/KeyLinksBatchDestroyParameters.md +6 -4
  21. data/docs/KeyLinksCreateParameters.md +2 -2
  22. data/docs/KeyUpdateParameters.md +1 -1
  23. data/docs/LinkedKeysApi.md +14 -13
  24. data/docs/Locale.md +6 -0
  25. data/docs/LocaleCreateParameters.md +2 -0
  26. data/docs/LocaleDetails.md +6 -0
  27. data/docs/LocaleUpdateParameters.md +2 -0
  28. data/docs/MachineTranslationApi.md +263 -0
  29. data/docs/MachineTranslationLocaleProviderMapping.md +21 -0
  30. data/docs/MachineTranslationLocaleProviderMappingsCreateParameters.md +21 -0
  31. data/docs/MachineTranslationSettings.md +23 -0
  32. data/docs/MachineTranslationSettingsUpdateParameters.md +17 -0
  33. data/docs/PreTranslation.md +29 -0
  34. data/docs/PreTranslationCreateParameters.md +19 -0
  35. data/docs/PreTranslationsApi.md +210 -0
  36. data/docs/ProjectCreateParameters.md +8 -2
  37. data/docs/ProjectDetails.md +3 -1
  38. data/docs/ProjectUpdateParameters.md +8 -2
  39. data/docs/ScreenshotUpdateParameters.md +1 -1
  40. data/docs/ScreenshotsApi.md +2 -2
  41. data/docs/Upload.md +3 -1
  42. data/docs/UploadsApi.md +4 -4
  43. data/lib/phrase/api/automation_events_api.rb +215 -0
  44. data/lib/phrase/api/checks_api.rb +174 -0
  45. data/lib/phrase/api/documents_api.rb +6 -6
  46. data/lib/phrase/api/icu_api.rb +2 -6
  47. data/lib/phrase/api/key_format_annotations_api.rb +85 -0
  48. data/lib/phrase/api/linked_keys_api.rb +19 -23
  49. data/lib/phrase/api/machine_translation_api.rb +302 -0
  50. data/lib/phrase/api/pre_translations_api.rb +240 -0
  51. data/lib/phrase/api/screenshots_api.rb +4 -4
  52. data/lib/phrase/api/uploads_api.rb +6 -6
  53. data/lib/phrase/models/automation_event.rb +325 -0
  54. data/lib/phrase/models/automation_event_project.rb +208 -0
  55. data/lib/phrase/models/automations_create_parameters.rb +1 -1
  56. data/lib/phrase/models/automations_create_parameters1.rb +1 -1
  57. data/lib/phrase/models/check_issue.rb +319 -0
  58. data/lib/phrase/models/{key_links_index400_response.rb → icu_skeleton_error.rb} +11 -10
  59. data/lib/phrase/models/icu_skeleton_parameters.rb +6 -6
  60. data/lib/phrase/models/job_create_parameters.rb +1 -1
  61. data/lib/phrase/models/key_format_annotations_list200_response_inner.rb +207 -0
  62. data/lib/phrase/models/key_links_batch_destroy_parameters.rb +52 -6
  63. data/lib/phrase/models/key_links_create_parameters.rb +1 -1
  64. data/lib/phrase/models/locale.rb +31 -1
  65. data/lib/phrase/models/locale_create_parameters.rb +11 -1
  66. data/lib/phrase/models/locale_details.rb +31 -1
  67. data/lib/phrase/models/locale_update_parameters.rb +11 -1
  68. data/lib/phrase/models/machine_translation_locale_provider_mapping.rb +217 -0
  69. data/lib/phrase/models/machine_translation_locale_provider_mappings_create_parameters.rb +232 -0
  70. data/lib/phrase/models/machine_translation_settings.rb +230 -0
  71. data/lib/phrase/models/machine_translation_settings_update_parameters.rb +198 -0
  72. data/lib/phrase/models/pre_translation.rb +301 -0
  73. data/lib/phrase/models/pre_translation_create_parameters.rb +241 -0
  74. data/lib/phrase/models/project_create_parameters.rb +35 -1
  75. data/lib/phrase/models/project_details.rb +10 -1
  76. data/lib/phrase/models/project_update_parameters.rb +35 -1
  77. data/lib/phrase/models/upload.rb +13 -1
  78. data/lib/phrase/response.rb +2 -2
  79. data/lib/phrase/version.rb +1 -1
  80. data/lib/phrase.rb +16 -1
  81. data/phrase.gemspec +1 -1
  82. data/spec/api/automation_events_api_spec.rb +67 -0
  83. data/spec/api/checks_api_spec.rb +56 -0
  84. data/spec/api/documents_api_spec.rb +3 -3
  85. data/spec/api/icu_api_spec.rb +1 -1
  86. data/spec/api/key_format_annotations_api_spec.rb +38 -0
  87. data/spec/api/linked_keys_api_spec.rb +7 -7
  88. data/spec/api/machine_translation_api_spec.rb +79 -0
  89. data/spec/api/pre_translations_api_spec.rb +70 -0
  90. data/spec/api/screenshots_api_spec.rb +2 -2
  91. data/spec/models/automation_event_project_spec.rb +35 -0
  92. data/spec/models/automation_event_spec.rb +85 -0
  93. data/spec/models/check_issue_spec.rb +85 -0
  94. data/spec/models/{key_links_index400_response_spec.rb → icu_skeleton_error_spec.rb} +7 -7
  95. data/spec/models/key_format_annotations_list200_response_inner_spec.rb +35 -0
  96. data/spec/models/key_links_batch_destroy_parameters_spec.rb +10 -0
  97. data/spec/models/locale_create_parameters_spec.rb +6 -0
  98. data/spec/models/locale_details_spec.rb +18 -0
  99. data/spec/models/locale_spec.rb +18 -0
  100. data/spec/models/locale_update_parameters_spec.rb +6 -0
  101. data/spec/models/machine_translation_locale_provider_mapping_spec.rb +41 -0
  102. data/spec/models/machine_translation_locale_provider_mappings_create_parameters_spec.rb +41 -0
  103. data/spec/models/machine_translation_settings_spec.rb +47 -0
  104. data/spec/models/machine_translation_settings_update_parameters_spec.rb +29 -0
  105. data/spec/models/pre_translation_create_parameters_spec.rb +39 -0
  106. data/spec/models/pre_translation_spec.rb +73 -0
  107. data/spec/models/project_create_parameters_spec.rb +18 -0
  108. data/spec/models/project_details_spec.rb +6 -0
  109. data/spec/models/project_update_parameters_spec.rb +18 -0
  110. data/spec/models/upload_spec.rb +6 -0
  111. data/spec/response_spec.rb +53 -0
  112. metadata +313 -251
  113. data/docs/KeyLinksIndex400Response.md +0 -17
@@ -0,0 +1,240 @@
1
+ require 'cgi'
2
+
3
+ module Phrase
4
+ class PreTranslationsApi
5
+ attr_accessor :api_client
6
+
7
+ def initialize(api_client = ApiClient.default)
8
+ @api_client = api_client
9
+ end
10
+ # Create a pre-translation job
11
+ # Triggers a pre-translation job for a resource within a project, addressed by `translatable_type` (`locale`, `job`, `translation_key`, or `upload`) and `translatable_id` (its ID). Enqueues machine translation using the project's configured MT engine.
12
+ # @param project_id [String] Project ID
13
+ # @param pre_translation_create_parameters [PreTranslationCreateParameters]
14
+ # @param [Hash] opts the optional parameters
15
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
16
+ # @return [PreTranslation]
17
+ def pre_translation_create(project_id, pre_translation_create_parameters, opts = {})
18
+ data, _status_code, _headers = pre_translation_create_with_http_info(project_id, pre_translation_create_parameters, opts)
19
+ data
20
+ end
21
+
22
+ # Create a pre-translation job
23
+ # Triggers a pre-translation job for a resource within a project, addressed by `translatable_type` (`locale`, `job`, `translation_key`, or `upload`) and `translatable_id` (its ID). Enqueues machine translation using the project's configured MT engine.
24
+ # @param project_id [String] Project ID
25
+ # @param pre_translation_create_parameters [PreTranslationCreateParameters]
26
+ # @param [Hash] opts the optional parameters
27
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
28
+ # @return [Array<(Response<(PreTranslation)>, Integer, Hash)>] Response<(PreTranslation)> data, response status code and response headers
29
+ def pre_translation_create_with_http_info(project_id, pre_translation_create_parameters, opts = {})
30
+ if @api_client.config.debugging
31
+ @api_client.config.logger.debug 'Calling API: PreTranslationsApi.pre_translation_create ...'
32
+ end
33
+ # verify the required parameter 'project_id' is set
34
+ if @api_client.config.client_side_validation && project_id.nil?
35
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling PreTranslationsApi.pre_translation_create"
36
+ end
37
+ # verify the required parameter 'pre_translation_create_parameters' is set
38
+ if @api_client.config.client_side_validation && pre_translation_create_parameters.nil?
39
+ fail ArgumentError, "Missing the required parameter 'pre_translation_create_parameters' when calling PreTranslationsApi.pre_translation_create"
40
+ end
41
+ # resource path
42
+ local_var_path = '/projects/{project_id}/pre_translations'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))
43
+
44
+ # query parameters
45
+ query_params = opts[:query_params] || {}
46
+
47
+ # header parameters
48
+ header_params = opts[:header_params] || {}
49
+ # HTTP header 'Accept' (if needed)
50
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
51
+ # HTTP header 'Content-Type'
52
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
53
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
54
+
55
+ # form parameters
56
+ form_params = opts[:form_params] || {}
57
+
58
+ # http body (model)
59
+ post_body = opts[:body] || @api_client.object_to_http_body(pre_translation_create_parameters)
60
+
61
+ # return_type
62
+ return_type = opts[:return_type] || 'PreTranslation'
63
+
64
+ # auth_names
65
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
66
+
67
+ new_options = opts.merge(
68
+ :header_params => header_params,
69
+ :query_params => query_params,
70
+ :form_params => form_params,
71
+ :body => post_body,
72
+ :auth_names => auth_names,
73
+ :return_type => return_type
74
+ )
75
+
76
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
77
+ if @api_client.config.debugging
78
+ @api_client.config.logger.debug "API called: PreTranslationsApi#pre_translation_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
79
+ end
80
+ response = ::Phrase::Response.new(data, headers)
81
+ return response, status_code, headers
82
+ end
83
+
84
+ # Get a single pre-translation job
85
+ # Returns a single pre-translation job identified by its ID.
86
+ # @param project_id [String] Project ID
87
+ # @param id [String] ID
88
+ # @param [Hash] opts the optional parameters
89
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
90
+ # @option opts [String] :if_modified_since Last modified condition, see [Conditional GET requests / HTTP Caching](/en/api/strings/pagination#conditional-get-requests-%2F-http-caching) (optional)
91
+ # @option opts [String] :if_none_match ETag condition, see [Conditional GET requests / HTTP Caching](/en/api/strings/pagination#conditional-get-requests-%2F-http-caching) (optional)
92
+ # @return [PreTranslation]
93
+ def pre_translation_show(project_id, id, opts = {})
94
+ data, _status_code, _headers = pre_translation_show_with_http_info(project_id, id, opts)
95
+ data
96
+ end
97
+
98
+ # Get a single pre-translation job
99
+ # Returns a single pre-translation job identified by its ID.
100
+ # @param project_id [String] Project ID
101
+ # @param id [String] ID
102
+ # @param [Hash] opts the optional parameters
103
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
104
+ # @option opts [String] :if_modified_since Last modified condition, see [Conditional GET requests / HTTP Caching](/en/api/strings/pagination#conditional-get-requests-%2F-http-caching) (optional)
105
+ # @option opts [String] :if_none_match ETag condition, see [Conditional GET requests / HTTP Caching](/en/api/strings/pagination#conditional-get-requests-%2F-http-caching) (optional)
106
+ # @return [Array<(Response<(PreTranslation)>, Integer, Hash)>] Response<(PreTranslation)> data, response status code and response headers
107
+ def pre_translation_show_with_http_info(project_id, id, opts = {})
108
+ if @api_client.config.debugging
109
+ @api_client.config.logger.debug 'Calling API: PreTranslationsApi.pre_translation_show ...'
110
+ end
111
+ # verify the required parameter 'project_id' is set
112
+ if @api_client.config.client_side_validation && project_id.nil?
113
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling PreTranslationsApi.pre_translation_show"
114
+ end
115
+ # verify the required parameter 'id' is set
116
+ if @api_client.config.client_side_validation && id.nil?
117
+ fail ArgumentError, "Missing the required parameter 'id' when calling PreTranslationsApi.pre_translation_show"
118
+ end
119
+ # resource path
120
+ local_var_path = '/projects/{project_id}/pre_translations/{id}'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
121
+
122
+ # query parameters
123
+ query_params = opts[:query_params] || {}
124
+
125
+ # header parameters
126
+ header_params = opts[:header_params] || {}
127
+ # HTTP header 'Accept' (if needed)
128
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
129
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
130
+ header_params[:'If-Modified-Since'] = opts[:'if_modified_since'] if !opts[:'if_modified_since'].nil?
131
+ header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?
132
+
133
+ # form parameters
134
+ form_params = opts[:form_params] || {}
135
+
136
+ # http body (model)
137
+ post_body = opts[:body]
138
+
139
+ # return_type
140
+ return_type = opts[:return_type] || 'PreTranslation'
141
+
142
+ # auth_names
143
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
144
+
145
+ new_options = opts.merge(
146
+ :header_params => header_params,
147
+ :query_params => query_params,
148
+ :form_params => form_params,
149
+ :body => post_body,
150
+ :auth_names => auth_names,
151
+ :return_type => return_type
152
+ )
153
+
154
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
155
+ if @api_client.config.debugging
156
+ @api_client.config.logger.debug "API called: PreTranslationsApi#pre_translation_show\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
157
+ end
158
+ response = ::Phrase::Response.new(data, headers)
159
+ return response, status_code, headers
160
+ end
161
+
162
+ # List pre-translation jobs
163
+ # Returns all pre-translation jobs scoped to a project, ordered by creation date descending.
164
+ # @param project_id [String] Project ID
165
+ # @param [Hash] opts the optional parameters
166
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
167
+ # @option opts [String] :if_modified_since Last modified condition, see [Conditional GET requests / HTTP Caching](/en/api/strings/pagination#conditional-get-requests-%2F-http-caching) (optional)
168
+ # @option opts [String] :if_none_match ETag condition, see [Conditional GET requests / HTTP Caching](/en/api/strings/pagination#conditional-get-requests-%2F-http-caching) (optional)
169
+ # @option opts [Integer] :page Page number
170
+ # @option opts [Integer] :per_page Limit on the number of objects to be returned, between 1 and 100. 25 by default
171
+ # @return [Array<PreTranslation>]
172
+ def pre_translations_list(project_id, opts = {})
173
+ data, _status_code, _headers = pre_translations_list_with_http_info(project_id, opts)
174
+ data
175
+ end
176
+
177
+ # List pre-translation jobs
178
+ # Returns all pre-translation jobs scoped to a project, ordered by creation date descending.
179
+ # @param project_id [String] Project ID
180
+ # @param [Hash] opts the optional parameters
181
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
182
+ # @option opts [String] :if_modified_since Last modified condition, see [Conditional GET requests / HTTP Caching](/en/api/strings/pagination#conditional-get-requests-%2F-http-caching) (optional)
183
+ # @option opts [String] :if_none_match ETag condition, see [Conditional GET requests / HTTP Caching](/en/api/strings/pagination#conditional-get-requests-%2F-http-caching) (optional)
184
+ # @option opts [Integer] :page Page number
185
+ # @option opts [Integer] :per_page Limit on the number of objects to be returned, between 1 and 100. 25 by default
186
+ # @return [Array<(Response<(Array<PreTranslation>)>, Integer, Hash)>] Response<(Array<PreTranslation>)> data, response status code and response headers
187
+ def pre_translations_list_with_http_info(project_id, opts = {})
188
+ if @api_client.config.debugging
189
+ @api_client.config.logger.debug 'Calling API: PreTranslationsApi.pre_translations_list ...'
190
+ end
191
+ # verify the required parameter 'project_id' is set
192
+ if @api_client.config.client_side_validation && project_id.nil?
193
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling PreTranslationsApi.pre_translations_list"
194
+ end
195
+ # resource path
196
+ local_var_path = '/projects/{project_id}/pre_translations'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))
197
+
198
+ # query parameters
199
+ query_params = opts[:query_params] || {}
200
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
201
+ query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
202
+
203
+ # header parameters
204
+ header_params = opts[:header_params] || {}
205
+ # HTTP header 'Accept' (if needed)
206
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
207
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
208
+ header_params[:'If-Modified-Since'] = opts[:'if_modified_since'] if !opts[:'if_modified_since'].nil?
209
+ header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?
210
+
211
+ # form parameters
212
+ form_params = opts[:form_params] || {}
213
+
214
+ # http body (model)
215
+ post_body = opts[:body]
216
+
217
+ # return_type
218
+ return_type = opts[:return_type] || 'Array<PreTranslation>'
219
+
220
+ # auth_names
221
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
222
+
223
+ new_options = opts.merge(
224
+ :header_params => header_params,
225
+ :query_params => query_params,
226
+ :form_params => form_params,
227
+ :body => post_body,
228
+ :auth_names => auth_names,
229
+ :return_type => return_type
230
+ )
231
+
232
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
233
+ if @api_client.config.debugging
234
+ @api_client.config.logger.debug "API called: PreTranslationsApi#pre_translations_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
235
+ end
236
+ response = ::Phrase::Response.new(data, headers)
237
+ return response, status_code, headers
238
+ end
239
+ end
240
+ end
@@ -92,7 +92,7 @@ module Phrase
92
92
  end
93
93
 
94
94
  # Delete a screenshot
95
- # Delete an existing screenshot.
95
+ # Permanently removes a screenshot and all its associated markers from the project. Use this when you need to fully remove a screenshot that is no longer relevant — for example, after a UI redesign renders the captured screen obsolete. This is a hard delete: the screenshot record and every key-to-region marker linked to it are destroyed together and cannot be recovered.
96
96
  # @param project_id [String] Project ID
97
97
  # @param id [String] ID
98
98
  # @param [Hash] opts the optional parameters
@@ -105,7 +105,7 @@ module Phrase
105
105
  end
106
106
 
107
107
  # Delete a screenshot
108
- # Delete an existing screenshot.
108
+ # Permanently removes a screenshot and all its associated markers from the project. Use this when you need to fully remove a screenshot that is no longer relevant — for example, after a UI redesign renders the captured screen obsolete. This is a hard delete: the screenshot record and every key-to-region marker linked to it are destroyed together and cannot be recovered.
109
109
  # @param project_id [String] Project ID
110
110
  # @param id [String] ID
111
111
  # @param [Hash] opts the optional parameters
@@ -167,7 +167,7 @@ module Phrase
167
167
  end
168
168
 
169
169
  # Get a single screenshot
170
- # Get details on a single screenshot for a given project.
170
+ # Returns a single screenshot belonging to the specified project. Use this to retrieve the screenshot's name, description, hosted image URL, and marker count after uploading, or before creating, updating, or inspecting its markers. The response is a synchronous, idempotent read — repeated calls return the same record without side effects. The Attachable Screenshots feature must be enabled on the account.
171
171
  # @param project_id [String] Project ID
172
172
  # @param id [String] ID
173
173
  # @param [Hash] opts the optional parameters
@@ -180,7 +180,7 @@ module Phrase
180
180
  end
181
181
 
182
182
  # Get a single screenshot
183
- # Get details on a single screenshot for a given project.
183
+ # Returns a single screenshot belonging to the specified project. Use this to retrieve the screenshot&#39;s name, description, hosted image URL, and marker count after uploading, or before creating, updating, or inspecting its markers. The response is a synchronous, idempotent read — repeated calls return the same record without side effects. The Attachable Screenshots feature must be enabled on the account.
184
184
  # @param project_id [String] Project ID
185
185
  # @param id [String] ID
186
186
  # @param [Hash] opts the optional parameters
@@ -8,10 +8,10 @@ module Phrase
8
8
  @api_client = api_client
9
9
  end
10
10
  # Upload a new file
11
- # Upload a new language file. Creates necessary resources in your project. Note: be aware of [upload limits](https://support.phrase.com/hc/en-us/articles/8548271212188-Phrase-Strings-Limits#file-size-upload-limits-0-0).
11
+ # Upload a new language file. Creates necessary resources in your project. The upload is processed asynchronously: this endpoint returns `201 Created` once the file has been accepted and enqueued, not once processing has finished. Poll `GET /projects/{project_id}/uploads/{id}` and check the `state` field — `error` means processing failed (for example, an unparseable file or a `file_format` that doesn't match the file's actual content). Note: be aware of [upload limits](https://support.phrase.com/hc/en-us/articles/8548271212188-Phrase-Strings-Limits#file-size-upload-limits-0-0).
12
12
  # @param project_id [String] Project ID
13
13
  # @param file [File] File to be imported
14
- # @param file_format [String] File format. Auto-detected when possible and not specified.
14
+ # @param file_format [String] File format of the uploaded file, given as a format&#39;s &#x60;api_name&#x60;. See our [Formats API Endpoint](/en/api/strings/formats/list-formats) for the full list of supported formats. Optional. When omitted, Phrase tries to auto-detect the format from the file&#39;s content. This is not always possible for JSON files, since several JSON-based formats (e.g. &#x60;json&#x60;, &#x60;simple_json&#x60;, &#x60;nested_json&#x60;) share the same structure.
15
15
  # @param locale_id [String] Locale of the file&#39;s content. Can be the name or id of the locale. Preferred is id.
16
16
  # @param [Hash] opts the optional parameters
17
17
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
@@ -42,10 +42,10 @@ module Phrase
42
42
  end
43
43
 
44
44
  # Upload a new file
45
- # Upload a new language file. Creates necessary resources in your project. Note: be aware of [upload limits](https://support.phrase.com/hc/en-us/articles/8548271212188-Phrase-Strings-Limits#file-size-upload-limits-0-0).
45
+ # Upload a new language file. Creates necessary resources in your project. The upload is processed asynchronously: this endpoint returns &#x60;201 Created&#x60; once the file has been accepted and enqueued, not once processing has finished. Poll &#x60;GET /projects/{project_id}/uploads/{id}&#x60; and check the &#x60;state&#x60; field — &#x60;error&#x60; means processing failed (for example, an unparseable file or a &#x60;file_format&#x60; that doesn&#39;t match the file&#39;s actual content). Note: be aware of [upload limits](https://support.phrase.com/hc/en-us/articles/8548271212188-Phrase-Strings-Limits#file-size-upload-limits-0-0).
46
46
  # @param project_id [String] Project ID
47
47
  # @param file [File] File to be imported
48
- # @param file_format [String] File format. Auto-detected when possible and not specified.
48
+ # @param file_format [String] File format of the uploaded file, given as a format&#39;s &#x60;api_name&#x60;. See our [Formats API Endpoint](/en/api/strings/formats/list-formats) for the full list of supported formats. Optional. When omitted, Phrase tries to auto-detect the format from the file&#39;s content. This is not always possible for JSON files, since several JSON-based formats (e.g. &#x60;json&#x60;, &#x60;simple_json&#x60;, &#x60;nested_json&#x60;) share the same structure.
49
49
  # @param locale_id [String] Locale of the file&#39;s content. Can be the name or id of the locale. Preferred is id.
50
50
  # @param [Hash] opts the optional parameters
51
51
  # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
@@ -157,7 +157,7 @@ module Phrase
157
157
  end
158
158
 
159
159
  # Get a single upload
160
- # View details and summary for a single upload.
160
+ # View details and summary for a single upload. Use this endpoint to poll for the outcome of an upload created via `POST /projects/{project_id}/uploads` — check the `state` field.
161
161
  # @param project_id [String] Project ID
162
162
  # @param id [String] ID
163
163
  # @param [Hash] opts the optional parameters
@@ -170,7 +170,7 @@ module Phrase
170
170
  end
171
171
 
172
172
  # Get a single upload
173
- # View details and summary for a single upload.
173
+ # View details and summary for a single upload. Use this endpoint to poll for the outcome of an upload created via &#x60;POST /projects/{project_id}/uploads&#x60; — check the &#x60;state&#x60; field.
174
174
  # @param project_id [String] Project ID
175
175
  # @param id [String] ID
176
176
  # @param [Hash] opts the optional parameters
@@ -0,0 +1,325 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class AutomationEvent
5
+ # Unique identifier of the automation event.
6
+ attr_accessor :id
7
+
8
+ # Identifier of the automation that produced this event.
9
+ attr_accessor :automation_id
10
+
11
+ # Outcome of the automation run.
12
+ attr_accessor :state
13
+
14
+ # What caused the automation to run.
15
+ attr_accessor :triggered_by
16
+
17
+ # Timestamp when the event was created.
18
+ attr_accessor :created_at
19
+
20
+ # Number of jobs created during this automation run.
21
+ attr_accessor :jobs_created
22
+
23
+ # Identifiers of the jobs created during this automation run.
24
+ attr_accessor :job_ids
25
+
26
+ attr_accessor :project
27
+
28
+ # Error message describing the failure when state is `failure`; null otherwise.
29
+ attr_accessor :details
30
+
31
+ class EnumAttributeValidator
32
+ attr_reader :datatype
33
+ attr_reader :allowable_values
34
+
35
+ def initialize(datatype, allowable_values)
36
+ @allowable_values = allowable_values.map do |value|
37
+ case datatype.to_s
38
+ when /Integer/i
39
+ value.to_i
40
+ when /Float/i
41
+ value.to_f
42
+ else
43
+ value
44
+ end
45
+ end
46
+ end
47
+
48
+ def valid?(value)
49
+ !value || allowable_values.include?(value)
50
+ end
51
+ end
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'id' => :'id',
57
+ :'automation_id' => :'automation_id',
58
+ :'state' => :'state',
59
+ :'triggered_by' => :'triggered_by',
60
+ :'created_at' => :'created_at',
61
+ :'jobs_created' => :'jobs_created',
62
+ :'job_ids' => :'job_ids',
63
+ :'project' => :'project',
64
+ :'details' => :'details'
65
+ }
66
+ end
67
+
68
+ # Attribute type mapping.
69
+ def self.openapi_types
70
+ {
71
+ :'id' => :'String',
72
+ :'automation_id' => :'String',
73
+ :'state' => :'String',
74
+ :'triggered_by' => :'String',
75
+ :'created_at' => :'DateTime',
76
+ :'jobs_created' => :'Integer',
77
+ :'job_ids' => :'Array<String>',
78
+ :'project' => :'AutomationEventProject',
79
+ :'details' => :'String'
80
+ }
81
+ end
82
+
83
+ # List of attributes with nullable: true
84
+ def self.openapi_nullable
85
+ Set.new([
86
+ :'details'
87
+ ])
88
+ end
89
+
90
+ # Initializes the object
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ def initialize(attributes = {})
93
+ if (!attributes.is_a?(Hash))
94
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::AutomationEvent` initialize method"
95
+ end
96
+
97
+ # check to see if the attribute exists and convert string to symbol for hash key
98
+ attributes = attributes.each_with_object({}) { |(k, v), h|
99
+ if (!self.class.attribute_map.key?(k.to_sym))
100
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::AutomationEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
101
+ end
102
+ h[k.to_sym] = v
103
+ }
104
+
105
+ if attributes.key?(:'id')
106
+ self.id = attributes[:'id']
107
+ end
108
+
109
+ if attributes.key?(:'automation_id')
110
+ self.automation_id = attributes[:'automation_id']
111
+ end
112
+
113
+ if attributes.key?(:'state')
114
+ self.state = attributes[:'state']
115
+ end
116
+
117
+ if attributes.key?(:'triggered_by')
118
+ self.triggered_by = attributes[:'triggered_by']
119
+ end
120
+
121
+ if attributes.key?(:'created_at')
122
+ self.created_at = attributes[:'created_at']
123
+ end
124
+
125
+ if attributes.key?(:'jobs_created')
126
+ self.jobs_created = attributes[:'jobs_created']
127
+ end
128
+
129
+ if attributes.key?(:'job_ids')
130
+ if (value = attributes[:'job_ids']).is_a?(Array)
131
+ self.job_ids = value
132
+ end
133
+ end
134
+
135
+ if attributes.key?(:'project')
136
+ self.project = attributes[:'project']
137
+ end
138
+
139
+ if attributes.key?(:'details')
140
+ self.details = attributes[:'details']
141
+ end
142
+ end
143
+
144
+ # Show invalid properties with the reasons. Usually used together with valid?
145
+ # @return Array for valid properties with the reasons
146
+ def list_invalid_properties
147
+ invalid_properties = Array.new
148
+ invalid_properties
149
+ end
150
+
151
+ # Check to see if the all the properties in the model are valid
152
+ # @return true if the model is valid
153
+ def valid?
154
+ state_validator = EnumAttributeValidator.new('String', ["success", "failure", "in_progress"])
155
+ return false unless state_validator.valid?(@state)
156
+ triggered_by_validator = EnumAttributeValidator.new('String', ["manual", "schedule", "upload", "upload_batch"])
157
+ return false unless triggered_by_validator.valid?(@triggered_by)
158
+ true
159
+ end
160
+
161
+ # Custom attribute writer method checking allowed values (enum).
162
+ # @param [Object] state Object to be assigned
163
+ def state=(state)
164
+ validator = EnumAttributeValidator.new('String', ["success", "failure", "in_progress"])
165
+ unless validator.valid?(state)
166
+ fail ArgumentError, "invalid value for \"state\", must be one of #{validator.allowable_values}."
167
+ end
168
+ @state = state
169
+ end
170
+
171
+ # Custom attribute writer method checking allowed values (enum).
172
+ # @param [Object] triggered_by Object to be assigned
173
+ def triggered_by=(triggered_by)
174
+ validator = EnumAttributeValidator.new('String', ["manual", "schedule", "upload", "upload_batch"])
175
+ unless validator.valid?(triggered_by)
176
+ fail ArgumentError, "invalid value for \"triggered_by\", must be one of #{validator.allowable_values}."
177
+ end
178
+ @triggered_by = triggered_by
179
+ end
180
+
181
+ # Checks equality by comparing each attribute.
182
+ # @param [Object] Object to be compared
183
+ def ==(o)
184
+ return true if self.equal?(o)
185
+ self.class == o.class &&
186
+ id == o.id &&
187
+ automation_id == o.automation_id &&
188
+ state == o.state &&
189
+ triggered_by == o.triggered_by &&
190
+ created_at == o.created_at &&
191
+ jobs_created == o.jobs_created &&
192
+ job_ids == o.job_ids &&
193
+ project == o.project &&
194
+ details == o.details
195
+ end
196
+
197
+ # @see the `==` method
198
+ # @param [Object] Object to be compared
199
+ def eql?(o)
200
+ self == o
201
+ end
202
+
203
+ # Calculates hash code according to all attributes.
204
+ # @return [Integer] Hash code
205
+ def hash
206
+ [id, automation_id, state, triggered_by, created_at, jobs_created, job_ids, project, details].hash
207
+ end
208
+
209
+ # Builds the object from hash
210
+ # @param [Hash] attributes Model attributes in the form of hash
211
+ # @return [Object] Returns the model itself
212
+ def self.build_from_hash(attributes)
213
+ new.build_from_hash(attributes)
214
+ end
215
+
216
+ # Builds the object from hash
217
+ # @param [Hash] attributes Model attributes in the form of hash
218
+ # @return [Object] Returns the model itself
219
+ def build_from_hash(attributes)
220
+ return nil unless attributes.is_a?(Hash)
221
+ self.class.openapi_types.each_pair do |key, type|
222
+ if type =~ /\AArray<(.*)>/i
223
+ # check to ensure the input is an array given that the attribute
224
+ # is documented as an array but the input is not
225
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
226
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
227
+ end
228
+ elsif !attributes[self.class.attribute_map[key]].nil?
229
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
230
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
231
+ end
232
+
233
+ self
234
+ end
235
+
236
+ # Deserializes the data based on type
237
+ # @param string type Data type
238
+ # @param string value Value to be deserialized
239
+ # @return [Object] Deserialized data
240
+ def _deserialize(type, value)
241
+ case type.to_sym
242
+ when :DateTime
243
+ DateTime.parse(value)
244
+ when :Date
245
+ Date.parse(value)
246
+ when :Time
247
+ Time.parse(value)
248
+ when :String
249
+ value.to_s
250
+ when :Integer
251
+ value.to_i
252
+ when :Float
253
+ value.to_f
254
+ when :Boolean
255
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
256
+ true
257
+ else
258
+ false
259
+ end
260
+ when :Object
261
+ # generic object (usually a Hash), return directly
262
+ value
263
+ when /\AArray<(?<inner_type>.+)>\z/
264
+ inner_type = Regexp.last_match[:inner_type]
265
+ value.map { |v| _deserialize(inner_type, v) }
266
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
267
+ k_type = Regexp.last_match[:k_type]
268
+ v_type = Regexp.last_match[:v_type]
269
+ {}.tap do |hash|
270
+ value.each do |k, v|
271
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
272
+ end
273
+ end
274
+ else # model
275
+ Phrase.const_get(type).build_from_hash(value)
276
+ end
277
+ end
278
+
279
+ # Returns the string representation of the object
280
+ # @return [String] String presentation of the object
281
+ def to_s
282
+ to_hash.to_s
283
+ end
284
+
285
+ # to_body is an alias to to_hash (backward compatibility)
286
+ # @return [Hash] Returns the object in the form of hash
287
+ def to_body
288
+ to_hash
289
+ end
290
+
291
+ # Returns the object in the form of hash
292
+ # @return [Hash] Returns the object in the form of hash
293
+ def to_hash
294
+ hash = {}
295
+ self.class.attribute_map.each_pair do |attr, param|
296
+ value = self.send(attr)
297
+ if value.nil?
298
+ is_nullable = self.class.openapi_nullable.include?(attr)
299
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
300
+ end
301
+
302
+ hash[param] = _to_hash(value)
303
+ end
304
+ hash
305
+ end
306
+
307
+ # Outputs non-array value in the form of hash
308
+ # For object, use to_hash. Otherwise, just return the value
309
+ # @param [Object] value Any valid value
310
+ # @return [Hash] Returns the value in the form of hash
311
+ def _to_hash(value)
312
+ if value.is_a?(Array)
313
+ value.compact.map { |v| _to_hash(v) }
314
+ elsif value.is_a?(Hash)
315
+ {}.tap do |hash|
316
+ value.each { |k, v| hash[k] = _to_hash(v) }
317
+ end
318
+ elsif value.respond_to? :to_hash
319
+ value.to_hash
320
+ else
321
+ value
322
+ end
323
+ end
324
+ end
325
+ end