Class: Phrase::UploadsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/phrase/api/uploads_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ UploadsApi

Returns a new instance of UploadsApi.



7
8
9
# File 'lib/phrase/api/uploads_api.rb', line 7

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



5
6
7
# File 'lib/phrase/api/uploads_api.rb', line 5

def api_client
  @api_client
end

Instance Method Details

#upload_create(project_id, file, file_format, locale_id, opts = {}) ⇒ Upload

Upload a new file Upload a new language file. Creates necessary resources in your project.

Parameters:

  • project_id (String)

    Project ID

  • file (File)

    File to be imported

  • file_format (String)

    File format. Auto-detected when possible and not specified.

  • locale_id (String)

    Locale of the file's content. Can be the name or id of the locale. Preferred is id.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

  • :branch (String)

    specify the branch to use

  • :tags (String)

    List of tags separated by comma to be associated with the new keys contained in the upload.

  • :update_translations (Boolean)

    Indicates whether existing translations should be updated with the file content.

  • :update_translation_keys (Boolean)

    Pass `false` here to prevent new keys from being created and existing keys updated. (default to true)

  • :update_translations_on_source_match (Boolean)

    Update target translations only if the source translations of the uploaded multilingual file match the stored translations. (default to false)

  • :update_descriptions (Boolean)

    Existing key descriptions will be updated with the file content. Empty descriptions overwrite existing descriptions.

  • :convert_emoji (Boolean)

    This option is obsolete. Providing the option will cause a bad request error.

  • :skip_upload_tags (Boolean)

    Indicates whether the upload should not create upload tags.

  • :skip_unverification (Boolean)

    Indicates whether the upload should unverify updated translations.

  • :file_encoding (String)

    Enforces a specific encoding on the file contents. Valid options are \"UTF-8\", \"UTF-16\" and \"ISO-8859-1\".

  • :locale_mapping (Object)

    Mapping between locale names and translation columns. Required in some formats like CSV or XLSX.

  • :format_options (Object)

    Additional options available for specific formats. See our format guide for complete list.

  • :autotranslate (Boolean)

    If set, translations for the uploaded language will be fetched automatically.

  • :mark_reviewed (Boolean)

    Indicated whether the imported translations should be marked as reviewed. This setting is available if the review workflow is enabled for the project.

  • :tag_only_affected_keys (Boolean)

    Indicates whether only keys affected (created or updated) by the upload should be tagged. The default is `false` (default to false)

  • :translation_key_prefix (String)

    This prefix will be added to all uploaded translation key names to prevent collisions. Use a meaningful prefix related to your project or file to keep key names organized.

Returns:



35
36
37
38
# File 'lib/phrase/api/uploads_api.rb', line 35

def upload_create(project_id, file, file_format, locale_id, opts = {})
  data, _status_code, _headers = upload_create_with_http_info(project_id, file, file_format, locale_id, opts)
  data
end

#upload_create_with_http_info(project_id, file, file_format, locale_id, opts = {}) ⇒ Array<(Response<(Upload)>, Integer, Hash)>

Upload a new file Upload a new language file. Creates necessary resources in your project.

Parameters:

  • project_id (String)

    Project ID

  • file (File)

    File to be imported

  • file_format (String)

    File format. Auto-detected when possible and not specified.

  • locale_id (String)

    Locale of the file&#39;s content. Can be the name or id of the locale. Preferred is id.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

  • :branch (String)

    specify the branch to use

  • :tags (String)

    List of tags separated by comma to be associated with the new keys contained in the upload.

  • :update_translations (Boolean)

    Indicates whether existing translations should be updated with the file content.

  • :update_translation_keys (Boolean)

    Pass &#x60;false&#x60; here to prevent new keys from being created and existing keys updated.

  • :update_translations_on_source_match (Boolean)

    Update target translations only if the source translations of the uploaded multilingual file match the stored translations.

  • :update_descriptions (Boolean)

    Existing key descriptions will be updated with the file content. Empty descriptions overwrite existing descriptions.

  • :convert_emoji (Boolean)

    This option is obsolete. Providing the option will cause a bad request error.

  • :skip_upload_tags (Boolean)

    Indicates whether the upload should not create upload tags.

  • :skip_unverification (Boolean)

    Indicates whether the upload should unverify updated translations.

  • :file_encoding (String)

    Enforces a specific encoding on the file contents. Valid options are \&quot;UTF-8\&quot;, \&quot;UTF-16\&quot; and \&quot;ISO-8859-1\&quot;.

  • :locale_mapping (Object)

    Mapping between locale names and translation columns. Required in some formats like CSV or XLSX.

  • :format_options (Object)

    Additional options available for specific formats. See our format guide for complete list.

  • :autotranslate (Boolean)

    If set, translations for the uploaded language will be fetched automatically.

  • :mark_reviewed (Boolean)

    Indicated whether the imported translations should be marked as reviewed. This setting is available if the review workflow is enabled for the project.

  • :tag_only_affected_keys (Boolean)

    Indicates whether only keys affected (created or updated) by the upload should be tagged. The default is &#x60;false&#x60;

  • :translation_key_prefix (String)

    This prefix will be added to all uploaded translation key names to prevent collisions. Use a meaningful prefix related to your project or file to keep key names organized.

Returns:

  • (Array<(Response<(Upload)>, Integer, Hash)>)

    Response<(Upload)> data, response status code and response headers



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/phrase/api/uploads_api.rb', line 65

def upload_create_with_http_info(project_id, file, file_format, locale_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UploadsApi.upload_create ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling UploadsApi.upload_create"
  end
  # verify the required parameter 'file' is set
  if @api_client.config.client_side_validation && file.nil?
    fail ArgumentError, "Missing the required parameter 'file' when calling UploadsApi.upload_create"
  end
  # verify the required parameter 'file_format' is set
  if @api_client.config.client_side_validation && file_format.nil?
    fail ArgumentError, "Missing the required parameter 'file_format' when calling UploadsApi.upload_create"
  end
  # verify the required parameter 'locale_id' is set
  if @api_client.config.client_side_validation && locale_id.nil?
    fail ArgumentError, "Missing the required parameter 'locale_id' when calling UploadsApi.upload_create"
  end
  # resource path
  local_var_path = '/projects/{project_id}/uploads'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])
  header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['file'] = file
  form_params['file_format'] = file_format
  form_params['locale_id'] = locale_id
  form_params['branch'] = opts[:'branch'] if !opts[:'branch'].nil?
  form_params['tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  form_params['update_translations'] = opts[:'update_translations'] if !opts[:'update_translations'].nil?
  form_params['update_translation_keys'] = opts[:'update_translation_keys'] if !opts[:'update_translation_keys'].nil?
  form_params['update_translations_on_source_match'] = opts[:'update_translations_on_source_match'] if !opts[:'update_translations_on_source_match'].nil?
  form_params['update_descriptions'] = opts[:'update_descriptions'] if !opts[:'update_descriptions'].nil?
  form_params['convert_emoji'] = opts[:'convert_emoji'] if !opts[:'convert_emoji'].nil?
  form_params['skip_upload_tags'] = opts[:'skip_upload_tags'] if !opts[:'skip_upload_tags'].nil?
  form_params['skip_unverification'] = opts[:'skip_unverification'] if !opts[:'skip_unverification'].nil?
  form_params['file_encoding'] = opts[:'file_encoding'] if !opts[:'file_encoding'].nil?
  form_params['locale_mapping'] = opts[:'locale_mapping'] if !opts[:'locale_mapping'].nil?
  form_params['format_options'] = opts[:'format_options'] if !opts[:'format_options'].nil?
  form_params['autotranslate'] = opts[:'autotranslate'] if !opts[:'autotranslate'].nil?
  form_params['mark_reviewed'] = opts[:'mark_reviewed'] if !opts[:'mark_reviewed'].nil?
  form_params['tag_only_affected_keys'] = opts[:'tag_only_affected_keys'] if !opts[:'tag_only_affected_keys'].nil?
  form_params['translation_key_prefix'] = opts[:'translation_key_prefix'] if !opts[:'translation_key_prefix'].nil?

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'Upload' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic', 'Token']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UploadsApi#upload_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end

#upload_show(project_id, id, opts = {}) ⇒ Upload

Get a single upload View details and summary for a single upload.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

  • :branch (String)

    specify the branch to use

Returns:



155
156
157
158
# File 'lib/phrase/api/uploads_api.rb', line 155

def upload_show(project_id, id, opts = {})
  data, _status_code, _headers = upload_show_with_http_info(project_id, id, opts)
  data
end

#upload_show_with_http_info(project_id, id, opts = {}) ⇒ Array<(Response<(Upload)>, Integer, Hash)>

Get a single upload View details and summary for a single upload.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

  • :branch (String)

    specify the branch to use

Returns:

  • (Array<(Response<(Upload)>, Integer, Hash)>)

    Response<(Upload)> data, response status code and response headers



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/phrase/api/uploads_api.rb', line 168

def upload_show_with_http_info(project_id, id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UploadsApi.upload_show ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling UploadsApi.upload_show"
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling UploadsApi.upload_show"
  end
  # resource path
  local_var_path = '/projects/{project_id}/uploads/{id}'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'branch'] = opts[:'branch'] if !opts[:'branch'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'Upload' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic', 'Token']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UploadsApi#upload_show\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end

#uploads_list(project_id, opts = {}) ⇒ Array<Upload>

List uploads List all uploads for the given project.

Parameters:

  • project_id (String)

    Project ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

  • :page (Integer)

    Page number

  • :per_page (Integer)

    Limit on the number of objects to be returned, between 1 and 100. 25 by default

  • :branch (String)

    specify the branch to use

Returns:



231
232
233
234
# File 'lib/phrase/api/uploads_api.rb', line 231

def uploads_list(project_id, opts = {})
  data, _status_code, _headers = uploads_list_with_http_info(project_id, opts)
  data
end

#uploads_list_with_http_info(project_id, opts = {}) ⇒ Array<(Response<(Array<Upload>)>, Integer, Hash)>

List uploads List all uploads for the given project.

Parameters:

  • project_id (String)

    Project ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

  • :page (Integer)

    Page number

  • :per_page (Integer)

    Limit on the number of objects to be returned, between 1 and 100. 25 by default

  • :branch (String)

    specify the branch to use

Returns:

  • (Array<(Response<(Array<Upload>)>, Integer, Hash)>)

    Response<(Array<Upload>)> data, response status code and response headers



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/phrase/api/uploads_api.rb', line 245

def uploads_list_with_http_info(project_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UploadsApi.uploads_list ...'
  end
  # verify the required parameter 'project_id' is set
  if @api_client.config.client_side_validation && project_id.nil?
    fail ArgumentError, "Missing the required parameter 'project_id' when calling UploadsApi.uploads_list"
  end
  # resource path
  local_var_path = '/projects/{project_id}/uploads'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
  query_params[:'branch'] = opts[:'branch'] if !opts[:'branch'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'Array<Upload>' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic', 'Token']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UploadsApi#uploads_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end