Class: Phrase::LocalesApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ LocalesApi

Returns a new instance of LocalesApi.



7
8
9
# File 'lib/phrase/api/locales_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/locales_api.rb', line 5

def api_client
  @api_client
end

Instance Method Details

#account_locales(id, opts = {}) ⇒ Array<LocalePreview1>

List locales used in account List all locales unique by locale code used across all projects within an account.

Parameters:

  • id (String)

    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

Returns:



18
19
20
21
# File 'lib/phrase/api/locales_api.rb', line 18

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

#account_locales_with_http_info(id, opts = {}) ⇒ Array<(Response<(Array<LocalePreview1>)>, Integer, Hash)>

List locales used in account List all locales unique by locale code used across all projects within an account.

Parameters:

  • id (String)

    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

Returns:

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

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



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/phrase/api/locales_api.rb', line 31

def (id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LocalesApi.account_locales ...'
  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 LocalesApi.account_locales"
  end
  # resource path
  local_var_path = '/accounts/{id}/locales'.sub('{' + 'id' + '}', CGI.escape(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?

  # 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<LocalePreview1>' 

  # 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: LocalesApi#account_locales\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end

#locale_create(project_id, locale_create_parameters, opts = {}) ⇒ LocaleDetails

Create a locale Create a new locale.

Parameters:

  • project_id (String)

    Project ID

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

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

Returns:



89
90
91
92
# File 'lib/phrase/api/locales_api.rb', line 89

def locale_create(project_id, locale_create_parameters, opts = {})
  data, _status_code, _headers = locale_create_with_http_info(project_id, locale_create_parameters, opts)
  data
end

#locale_create_with_http_info(project_id, locale_create_parameters, opts = {}) ⇒ Array<(Response<(LocaleDetails)>, Integer, Hash)>

Create a locale Create a new locale.

Parameters:

  • project_id (String)

    Project ID

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

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

Returns:

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

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



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
146
147
148
149
150
151
152
153
154
# File 'lib/phrase/api/locales_api.rb', line 101

def locale_create_with_http_info(project_id, locale_create_parameters, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LocalesApi.locale_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 LocalesApi.locale_create"
  end
  # verify the required parameter 'locale_create_parameters' is set
  if @api_client.config.client_side_validation && locale_create_parameters.nil?
    fail ArgumentError, "Missing the required parameter 'locale_create_parameters' when calling LocalesApi.locale_create"
  end
  # resource path
  local_var_path = '/projects/{project_id}/locales'.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(['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] || @api_client.object_to_http_body(locale_create_parameters) 

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

  # 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: LocalesApi#locale_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end

#locale_delete(project_id, id, opts = {}) ⇒ nil

Delete a locale Delete an existing locale.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    Locale ID or locale name

  • 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:

  • (nil)


164
165
166
167
# File 'lib/phrase/api/locales_api.rb', line 164

def locale_delete(project_id, id, opts = {})
  data, _status_code, _headers = locale_delete_with_http_info(project_id, id, opts)
  data
end

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

Delete a locale Delete an existing locale.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    Locale ID or locale name

  • 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, Integer, Hash)>)

    Response<(nil, response status code and response headers



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
221
222
223
224
225
226
227
# File 'lib/phrase/api/locales_api.rb', line 177

def locale_delete_with_http_info(project_id, id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LocalesApi.locale_delete ...'
  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 LocalesApi.locale_delete"
  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 LocalesApi.locale_delete"
  end
  # resource path
  local_var_path = '/projects/{project_id}/locales/{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] || {}
  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] 

  # 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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: LocalesApi#locale_delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end

#locale_download(project_id, id, opts = {}) ⇒ File

Download a locale Download a locale in a specific file format.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    Locale ID or locale name

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

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

  • :if_modified_since (String)

    Last modified condition, see &lt;a href&#x3D;&quot;#overview–conditional-get-requests–http-caching&quot;&gt;Conditional GET requests / HTTP Caching&lt;/a&gt; (optional)

  • :if_none_match (String)

    ETag condition, see &lt;a href&#x3D;&quot;#overview–conditional-get-requests–http-caching&quot;&gt;Conditional GET requests / HTTP Caching&lt;/a&gt; (optional)

  • :branch (String)

    specify the branch to use

  • :file_format (String)

    File format name. See the &lt;a href&#x3D;&quot;support.phrase.com/hc/en-us/sections/6111343326364&quot;&gt;format guide&lt;/a&gt; for all supported file formats.

  • :tags (String)

    Limit results to keys tagged with a list of comma separated tag names.

  • :tag (String)

    Limit download to tagged keys. This parameter is deprecated. Please use the &quot;tags&quot; parameter instead

  • :include_empty_translations (Boolean)

    Indicates whether keys without translations should be included in the output as well.

  • :exclude_empty_zero_forms (Boolean)

    Indicates whether zero forms should be included when empty in pluralized keys.

  • :include_translated_keys (Boolean)

    Include translated keys in the locale file. Use in combination with include_empty_translations to obtain only untranslated keys.

  • :keep_notranslate_tags (Boolean)

    Indicates whether [NOTRANSLATE] tags should be kept.

  • :convert_emoji (Boolean)

    This option is obsolete. Projects that were created on or after Nov 29th 2019 or that did not contain emoji by then will not require this flag any longer since emoji are now supported natively.

  • :format_options (Object)

    Additional formatting and render options. See the &lt;a href&#x3D;&quot;support.phrase.com/hc/en-us/sections/6111343326364&quot;&gt;format guide&lt;/a&gt; for a list of options available for each format. Specify format options like this: &lt;code&gt;…&amp;format_options&#x3D;bar&lt;/code&gt;

  • :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;.

  • :skip_unverified_translations (Boolean)

    Indicates whether the locale file should skip all unverified translations. This parameter is deprecated and should be replaced with &lt;code&gt;include_unverified_translations&lt;/code&gt;.

  • :include_unverified_translations (Boolean)

    if set to false unverified translations are excluded

  • :use_last_reviewed_version (Boolean)

    If set to true the last reviewed version of a translation is used. This is only available if the review workflow is enabled for the project.

  • :fallback_locale_id (String)

    If a key has no translation in the locale being downloaded the translation in the fallback locale will be used. Provide the ID of the locale that should be used as the fallback. Requires include_empty_translations to be set to &lt;code&gt;true&lt;/code&gt;.

  • :source_locale_id (String)

    Provides the source language of a corresponding job as the source language of the generated locale file. This parameter will be ignored unless used in combination with a &lt;code&gt;tag&lt;/code&gt; parameter indicating a specific job.

  • :translation_key_prefix (String)

    Download all translation keys, and remove the specified prefix where possible. Warning: this may create duplicate key names if other keys share the same name after the prefix is removed.

  • :filter_by_prefix (Boolean)

    Only download translation keys containing the specified prefix, and remove the prefix from the generated file.

  • :custom_metadata_filters (Object)

    Custom metadata filters. Provide the name of the metadata field and the value to filter by. Only keys with matching metadata will be included in the download.

Returns:

  • (File)


257
258
259
260
# File 'lib/phrase/api/locales_api.rb', line 257

def locale_download(project_id, id, opts = {})
  data, _status_code, _headers = locale_download_with_http_info(project_id, id, opts)
  data
end

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

Download a locale Download a locale in a specific file format.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    Locale ID or locale name

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

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

  • :if_modified_since (String)

    Last modified condition, see &lt;a href&#x3D;&quot;#overview–conditional-get-requests–http-caching&quot;&gt;Conditional GET requests / HTTP Caching&lt;/a&gt; (optional)

  • :if_none_match (String)

    ETag condition, see &lt;a href&#x3D;&quot;#overview–conditional-get-requests–http-caching&quot;&gt;Conditional GET requests / HTTP Caching&lt;/a&gt; (optional)

  • :branch (String)

    specify the branch to use

  • :file_format (String)

    File format name. See the &lt;a href&#x3D;&quot;support.phrase.com/hc/en-us/sections/6111343326364&quot;&gt;format guide&lt;/a&gt; for all supported file formats.

  • :tags (String)

    Limit results to keys tagged with a list of comma separated tag names.

  • :tag (String)

    Limit download to tagged keys. This parameter is deprecated. Please use the &quot;tags&quot; parameter instead

  • :include_empty_translations (Boolean)

    Indicates whether keys without translations should be included in the output as well.

  • :exclude_empty_zero_forms (Boolean)

    Indicates whether zero forms should be included when empty in pluralized keys.

  • :include_translated_keys (Boolean)

    Include translated keys in the locale file. Use in combination with include_empty_translations to obtain only untranslated keys.

  • :keep_notranslate_tags (Boolean)

    Indicates whether [NOTRANSLATE] tags should be kept.

  • :convert_emoji (Boolean)

    This option is obsolete. Projects that were created on or after Nov 29th 2019 or that did not contain emoji by then will not require this flag any longer since emoji are now supported natively.

  • :format_options (Object)

    Additional formatting and render options. See the &lt;a href&#x3D;&quot;support.phrase.com/hc/en-us/sections/6111343326364&quot;&gt;format guide&lt;/a&gt; for a list of options available for each format. Specify format options like this: &lt;code&gt;…&amp;format_options&#x3D;bar&lt;/code&gt;

  • :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;.

  • :skip_unverified_translations (Boolean)

    Indicates whether the locale file should skip all unverified translations. This parameter is deprecated and should be replaced with &lt;code&gt;include_unverified_translations&lt;/code&gt;.

  • :include_unverified_translations (Boolean)

    if set to false unverified translations are excluded

  • :use_last_reviewed_version (Boolean)

    If set to true the last reviewed version of a translation is used. This is only available if the review workflow is enabled for the project.

  • :fallback_locale_id (String)

    If a key has no translation in the locale being downloaded the translation in the fallback locale will be used. Provide the ID of the locale that should be used as the fallback. Requires include_empty_translations to be set to &lt;code&gt;true&lt;/code&gt;.

  • :source_locale_id (String)

    Provides the source language of a corresponding job as the source language of the generated locale file. This parameter will be ignored unless used in combination with a &lt;code&gt;tag&lt;/code&gt; parameter indicating a specific job.

  • :translation_key_prefix (String)

    Download all translation keys, and remove the specified prefix where possible. Warning: this may create duplicate key names if other keys share the same name after the prefix is removed.

  • :filter_by_prefix (Boolean)

    Only download translation keys containing the specified prefix, and remove the prefix from the generated file.

  • :custom_metadata_filters (Object)

    Custom metadata filters. Provide the name of the metadata field and the value to filter by. Only keys with matching metadata will be included in the download.

Returns:

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

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



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/phrase/api/locales_api.rb', line 290

def locale_download_with_http_info(project_id, id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LocalesApi.locale_download ...'
  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 LocalesApi.locale_download"
  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 LocalesApi.locale_download"
  end
  # resource path
  local_var_path = '/projects/{project_id}/locales/{id}/download'.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?
  query_params[:'file_format'] = opts[:'file_format'] if !opts[:'file_format'].nil?
  query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  query_params[:'tag'] = opts[:'tag'] if !opts[:'tag'].nil?
  query_params[:'include_empty_translations'] = opts[:'include_empty_translations'] if !opts[:'include_empty_translations'].nil?
  query_params[:'exclude_empty_zero_forms'] = opts[:'exclude_empty_zero_forms'] if !opts[:'exclude_empty_zero_forms'].nil?
  query_params[:'include_translated_keys'] = opts[:'include_translated_keys'] if !opts[:'include_translated_keys'].nil?
  query_params[:'keep_notranslate_tags'] = opts[:'keep_notranslate_tags'] if !opts[:'keep_notranslate_tags'].nil?
  query_params[:'convert_emoji'] = opts[:'convert_emoji'] if !opts[:'convert_emoji'].nil?
  query_params[:'format_options'] = opts[:'format_options'] if !opts[:'format_options'].nil?
  query_params[:'encoding'] = opts[:'encoding'] if !opts[:'encoding'].nil?
  query_params[:'skip_unverified_translations'] = opts[:'skip_unverified_translations'] if !opts[:'skip_unverified_translations'].nil?
  query_params[:'include_unverified_translations'] = opts[:'include_unverified_translations'] if !opts[:'include_unverified_translations'].nil?
  query_params[:'use_last_reviewed_version'] = opts[:'use_last_reviewed_version'] if !opts[:'use_last_reviewed_version'].nil?
  query_params[:'fallback_locale_id'] = opts[:'fallback_locale_id'] if !opts[:'fallback_locale_id'].nil?
  query_params[:'source_locale_id'] = opts[:'source_locale_id'] if !opts[:'source_locale_id'].nil?
  query_params[:'translation_key_prefix'] = opts[:'translation_key_prefix'] if !opts[:'translation_key_prefix'].nil?
  query_params[:'filter_by_prefix'] = opts[:'filter_by_prefix'] if !opts[:'filter_by_prefix'].nil?
  query_params[:'custom_metadata_filters'] = opts[:'custom_metadata_filters'] if !opts[:'custom_metadata_filters'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['*'])
  header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
  header_params[:'If-Modified-Since'] = opts[:'if_modified_since'] if !opts[:'if_modified_since'].nil?
  header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?

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

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

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

  # 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: LocalesApi#locale_download\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end

#locale_show(project_id, id, opts = {}) ⇒ LocaleDetails

Get a single locale Get details on a single locale for a given project.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    Locale ID or locale name

  • 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:



372
373
374
375
# File 'lib/phrase/api/locales_api.rb', line 372

def locale_show(project_id, id, opts = {})
  data, _status_code, _headers = locale_show_with_http_info(project_id, id, opts)
  data
end

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

Get a single locale Get details on a single locale for a given project.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    Locale ID or locale name

  • 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<(LocaleDetails)>, Integer, Hash)>)

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



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/phrase/api/locales_api.rb', line 385

def locale_show_with_http_info(project_id, id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LocalesApi.locale_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 LocalesApi.locale_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 LocalesApi.locale_show"
  end
  # resource path
  local_var_path = '/projects/{project_id}/locales/{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] || 'LocaleDetails' 

  # 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: LocalesApi#locale_show\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end

#locale_update(project_id, id, locale_update_parameters, opts = {}) ⇒ LocaleDetails

Update a locale Update an existing locale.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    Locale ID or locale name

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

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

Returns:



447
448
449
450
# File 'lib/phrase/api/locales_api.rb', line 447

def locale_update(project_id, id, locale_update_parameters, opts = {})
  data, _status_code, _headers = locale_update_with_http_info(project_id, id, locale_update_parameters, opts)
  data
end

#locale_update_with_http_info(project_id, id, locale_update_parameters, opts = {}) ⇒ Array<(Response<(LocaleDetails)>, Integer, Hash)>

Update a locale Update an existing locale.

Parameters:

  • project_id (String)

    Project ID

  • id (String)

    Locale ID or locale name

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

    the optional parameters

Options Hash (opts):

  • :x_phrase_app_otp (String)

    Two-Factor-Authentication token (optional)

Returns:

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

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



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'lib/phrase/api/locales_api.rb', line 460

def locale_update_with_http_info(project_id, id, locale_update_parameters, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LocalesApi.locale_update ...'
  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 LocalesApi.locale_update"
  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 LocalesApi.locale_update"
  end
  # verify the required parameter 'locale_update_parameters' is set
  if @api_client.config.client_side_validation && locale_update_parameters.nil?
    fail ArgumentError, "Missing the required parameter 'locale_update_parameters' when calling LocalesApi.locale_update"
  end
  # resource path
  local_var_path = '/projects/{project_id}/locales/{id}'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'id' + '}', CGI.escape(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(['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] || @api_client.object_to_http_body(locale_update_parameters) 

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

  # 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(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: LocalesApi#locale_update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end

#locales_list(project_id, opts = {}) ⇒ Array<Locale>

List locales List all locales 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

  • :sort_by (String)

    Sort locales. Valid options are &quot;name_asc&quot;, &quot;name_desc&quot;, &quot;default_asc&quot;, &quot;default_desc&quot;.

  • :branch (String)

    specify the branch to use

Returns:



529
530
531
532
# File 'lib/phrase/api/locales_api.rb', line 529

def locales_list(project_id, opts = {})
  data, _status_code, _headers = locales_list_with_http_info(project_id, opts)
  data
end

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

List locales List all locales 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

  • :sort_by (String)

    Sort locales. Valid options are &quot;name_asc&quot;, &quot;name_desc&quot;, &quot;default_asc&quot;, &quot;default_desc&quot;.

  • :branch (String)

    specify the branch to use

Returns:

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

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



544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
# File 'lib/phrase/api/locales_api.rb', line 544

def locales_list_with_http_info(project_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: LocalesApi.locales_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 LocalesApi.locales_list"
  end
  # resource path
  local_var_path = '/projects/{project_id}/locales'.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[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].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<Locale>' 

  # 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: LocalesApi#locales_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  response = ::Phrase::Response.new(data, headers)
  return response, status_code, headers
end