Class: DyspatchClient::DraftsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/dyspatch_client/api/drafts_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ DraftsApi

Returns a new instance of DraftsApi.



19
20
21
# File 'lib/dyspatch_client/api/drafts_api.rb', line 19

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/dyspatch_client/api/drafts_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#delete_localization(draft_id, language_id, accept, opts = {}) ⇒ nil

Remove a localization Deletes the localization with the given language ID if it exists

Parameters:

  • draft_id (String)

    A draft ID

  • language_id (String)

    A language ID (eg: en-US)

  • accept (String)

    A version of the API that should be used for the request. For example, to use version "2020.04", set the value to "application/vnd.dyspatch.2020.04+json"

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

    the optional parameters

Returns:

  • (nil)


29
30
31
32
# File 'lib/dyspatch_client/api/drafts_api.rb', line 29

def delete_localization(draft_id, language_id, accept, opts = {})
  delete_localization_with_http_info(draft_id, language_id, accept, opts)
  nil
end

#delete_localization_with_http_info(draft_id, language_id, accept, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Remove a localization Deletes the localization with the given language ID if it exists

Parameters:

  • draft_id (String)

    A draft ID

  • language_id (String)

    A language ID (eg: en-US)

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



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
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/dyspatch_client/api/drafts_api.rb', line 41

def delete_localization_with_http_info(draft_id, language_id, accept, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DraftsApi.delete_localization ...'
  end
  # verify the required parameter 'draft_id' is set
  if @api_client.config.client_side_validation && draft_id.nil?
    fail ArgumentError, "Missing the required parameter 'draft_id' when calling DraftsApi.delete_localization"
  end
  # verify the required parameter 'language_id' is set
  if @api_client.config.client_side_validation && language_id.nil?
    fail ArgumentError, "Missing the required parameter 'language_id' when calling DraftsApi.delete_localization"
  end
  # verify the required parameter 'accept' is set
  if @api_client.config.client_side_validation && accept.nil?
    fail ArgumentError, "Missing the required parameter 'accept' when calling DraftsApi.delete_localization"
  end
  # resource path
  local_var_path = '/drafts/{draftId}/localizations/{languageId}'.sub('{' + 'draftId' + '}', CGI.escape(draft_id.to_s)).sub('{' + 'languageId' + '}', CGI.escape(language_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  header_params[:'Accept'] = accept

  # 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] || ['Bearer']

  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: DraftsApi#delete_localization\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_draft_by_id(draft_id, target_language, accept, opts = {}) ⇒ DraftRead

Get Draft by ID Gets a draft object with the matching ID. The "compiled" field will contain the template in the default, unlocalized form.

Parameters:

  • draft_id (String)

    A draft ID

  • target_language (String)

    The type of templating language to compile as. Should only be used for visual templates.

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:



102
103
104
105
# File 'lib/dyspatch_client/api/drafts_api.rb', line 102

def get_draft_by_id(draft_id, target_language, accept, opts = {})
  data, _status_code, _headers = get_draft_by_id_with_http_info(draft_id, target_language, accept, opts)
  data
end

#get_draft_by_id_with_http_info(draft_id, target_language, accept, opts = {}) ⇒ Array<(DraftRead, Integer, Hash)>

Get Draft by ID Gets a draft object with the matching ID. The &quot;compiled&quot; field will contain the template in the default, unlocalized form.

Parameters:

  • draft_id (String)

    A draft ID

  • target_language (String)

    The type of templating language to compile as. Should only be used for visual templates.

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:

  • (Array<(DraftRead, Integer, Hash)>)

    DraftRead data, response status code and response headers



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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/dyspatch_client/api/drafts_api.rb', line 114

def get_draft_by_id_with_http_info(draft_id, target_language, accept, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DraftsApi.get_draft_by_id ...'
  end
  # verify the required parameter 'draft_id' is set
  if @api_client.config.client_side_validation && draft_id.nil?
    fail ArgumentError, "Missing the required parameter 'draft_id' when calling DraftsApi.get_draft_by_id"
  end
  # verify the required parameter 'target_language' is set
  if @api_client.config.client_side_validation && target_language.nil?
    fail ArgumentError, "Missing the required parameter 'target_language' when calling DraftsApi.get_draft_by_id"
  end
  # verify enum value
  allowable_values = ["html", "handlebars", "ampscript", "freemarker", "cheetah", "jinja"]
  if @api_client.config.client_side_validation && !allowable_values.include?(target_language)
    fail ArgumentError, "invalid value for \"target_language\", must be one of #{allowable_values}"
  end
  # verify the required parameter 'accept' is set
  if @api_client.config.client_side_validation && accept.nil?
    fail ArgumentError, "Missing the required parameter 'accept' when calling DraftsApi.get_draft_by_id"
  end
  # resource path
  local_var_path = '/drafts/{draftId}'.sub('{' + 'draftId' + '}', CGI.escape(draft_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.dyspatch.2020.04+json', '*/*'])
  header_params[:'Accept'] = accept

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

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

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

  # auth_names
  auth_names = opts[:auth_names] || ['Bearer']

  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: DraftsApi#get_draft_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_draft_localization_keys(draft_id, accept, opts = {}) ⇒ Array<LocalizationKeyRead>

Get localization keys Returns the list of values that need to be translated for the draft. Set the Accept header to ‘application/vnd.dyspatch.2020.04+json` to get a JSON object, or `text/vnd.dyspatch.2020.04+x-gettext-translation` to get the POT file.

Parameters:

  • draft_id (String)

    A draft ID

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:



182
183
184
185
# File 'lib/dyspatch_client/api/drafts_api.rb', line 182

def get_draft_localization_keys(draft_id, accept, opts = {})
  data, _status_code, _headers = get_draft_localization_keys_with_http_info(draft_id, accept, opts)
  data
end

#get_draft_localization_keys_with_http_info(draft_id, accept, opts = {}) ⇒ Array<(Array<LocalizationKeyRead>, Integer, Hash)>

Get localization keys Returns the list of values that need to be translated for the draft. Set the &#x60;Accept&#x60; header to &#x60;application/vnd.dyspatch.2020.04+json&#x60; to get a JSON object, or &#x60;text/vnd.dyspatch.2020.04+x-gettext-translation&#x60; to get the POT file.

Parameters:

  • draft_id (String)

    A draft ID

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:

  • (Array<(Array<LocalizationKeyRead>, Integer, Hash)>)

    Array<LocalizationKeyRead> data, response status code and response headers



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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/dyspatch_client/api/drafts_api.rb', line 193

def get_draft_localization_keys_with_http_info(draft_id, accept, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DraftsApi.get_draft_localization_keys ...'
  end
  # verify the required parameter 'draft_id' is set
  if @api_client.config.client_side_validation && draft_id.nil?
    fail ArgumentError, "Missing the required parameter 'draft_id' when calling DraftsApi.get_draft_localization_keys"
  end
  # verify the required parameter 'accept' is set
  if @api_client.config.client_side_validation && accept.nil?
    fail ArgumentError, "Missing the required parameter 'accept' when calling DraftsApi.get_draft_localization_keys"
  end
  # resource path
  local_var_path = '/drafts/{draftId}/localizationKeys'.sub('{' + 'draftId' + '}', CGI.escape(draft_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/vnd.dyspatch.2020.04+json', 'text/vnd.dyspatch.2020.04+x-gettext-translation'])
  header_params[:'Accept'] = accept

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

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

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

  # auth_names
  auth_names = opts[:auth_names] || ['Bearer']

  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: DraftsApi#get_draft_localization_keys\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_drafts(accept, opts = {}) ⇒ DraftsRead

List Drafts Returns all drafts for your organization.

Parameters:

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Options Hash (opts):

  • :cursor (String)

    A cursor value used to retrieve a specific page from a paginated result set.

  • :status (String)

    Filter the list of drafts by a particular status

Returns:



252
253
254
255
# File 'lib/dyspatch_client/api/drafts_api.rb', line 252

def get_drafts(accept, opts = {})
  data, _status_code, _headers = get_drafts_with_http_info(accept, opts)
  data
end

#get_drafts_with_http_info(accept, opts = {}) ⇒ Array<(DraftsRead, Integer, Hash)>

List Drafts Returns all drafts for your organization.

Parameters:

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Options Hash (opts):

  • :cursor (String)

    A cursor value used to retrieve a specific page from a paginated result set.

  • :status (String)

    Filter the list of drafts by a particular status

Returns:

  • (Array<(DraftsRead, Integer, Hash)>)

    DraftsRead data, response status code and response headers



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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'lib/dyspatch_client/api/drafts_api.rb', line 264

def get_drafts_with_http_info(accept, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DraftsApi.get_drafts ...'
  end
  # verify the required parameter 'accept' is set
  if @api_client.config.client_side_validation && accept.nil?
    fail ArgumentError, "Missing the required parameter 'accept' when calling DraftsApi.get_drafts"
  end
  allowable_values = ["awaitingTranslation"]
  if @api_client.config.client_side_validation && opts[:'status'] && !allowable_values.include?(opts[:'status'])
    fail ArgumentError, "invalid value for \"status\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/drafts'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.dyspatch.2020.04+json', '*/*'])
  header_params[:'Accept'] = accept

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

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

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

  # auth_names
  auth_names = opts[:auth_names] || ['Bearer']

  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: DraftsApi#get_drafts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_localization_for_draft(draft_id, accept, opts = {}) ⇒ Array<LocalizationMetaRead>

Get localizations on a draft Returns localization metadata for the draft

Parameters:

  • draft_id (String)

    A draft ID

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:



324
325
326
327
# File 'lib/dyspatch_client/api/drafts_api.rb', line 324

def get_localization_for_draft(draft_id, accept, opts = {})
  data, _status_code, _headers = get_localization_for_draft_with_http_info(draft_id, accept, opts)
  data
end

#get_localization_for_draft_with_http_info(draft_id, accept, opts = {}) ⇒ Array<(Array<LocalizationMetaRead>, Integer, Hash)>

Get localizations on a draft Returns localization metadata for the draft

Parameters:

  • draft_id (String)

    A draft ID

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:

  • (Array<(Array<LocalizationMetaRead>, Integer, Hash)>)

    Array<LocalizationMetaRead> data, response status code and response headers



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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/dyspatch_client/api/drafts_api.rb', line 335

def get_localization_for_draft_with_http_info(draft_id, accept, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DraftsApi.get_localization_for_draft ...'
  end
  # verify the required parameter 'draft_id' is set
  if @api_client.config.client_side_validation && draft_id.nil?
    fail ArgumentError, "Missing the required parameter 'draft_id' when calling DraftsApi.get_localization_for_draft"
  end
  # verify the required parameter 'accept' is set
  if @api_client.config.client_side_validation && accept.nil?
    fail ArgumentError, "Missing the required parameter 'accept' when calling DraftsApi.get_localization_for_draft"
  end
  # resource path
  local_var_path = '/drafts/{draftId}/localizations'.sub('{' + 'draftId' + '}', CGI.escape(draft_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/vnd.dyspatch.2020.04+json'])
  header_params[:'Accept'] = accept

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

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

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

  # auth_names
  auth_names = opts[:auth_names] || ['Bearer']

  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: DraftsApi#get_localization_for_draft\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#save_localization(draft_id, language_id, accept, inline_object, opts = {}) ⇒ nil

Create or update a localization Inserts a localization or sets the name on an existing localization that already uses the languageId

Parameters:

  • draft_id (String)

    A draft ID

  • language_id (String)

    A language ID (eg: en-US)

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:

  • (nil)


395
396
397
398
# File 'lib/dyspatch_client/api/drafts_api.rb', line 395

def save_localization(draft_id, language_id, accept, inline_object, opts = {})
  save_localization_with_http_info(draft_id, language_id, accept, inline_object, opts)
  nil
end

#save_localization_with_http_info(draft_id, language_id, accept, inline_object, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Create or update a localization Inserts a localization or sets the name on an existing localization that already uses the languageId

Parameters:

  • draft_id (String)

    A draft ID

  • language_id (String)

    A language ID (eg: en-US)

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/dyspatch_client/api/drafts_api.rb', line 408

def save_localization_with_http_info(draft_id, language_id, accept, inline_object, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DraftsApi.save_localization ...'
  end
  # verify the required parameter 'draft_id' is set
  if @api_client.config.client_side_validation && draft_id.nil?
    fail ArgumentError, "Missing the required parameter 'draft_id' when calling DraftsApi.save_localization"
  end
  # verify the required parameter 'language_id' is set
  if @api_client.config.client_side_validation && language_id.nil?
    fail ArgumentError, "Missing the required parameter 'language_id' when calling DraftsApi.save_localization"
  end
  # verify the required parameter 'accept' is set
  if @api_client.config.client_side_validation && accept.nil?
    fail ArgumentError, "Missing the required parameter 'accept' when calling DraftsApi.save_localization"
  end
  # verify the required parameter 'inline_object' is set
  if @api_client.config.client_side_validation && inline_object.nil?
    fail ArgumentError, "Missing the required parameter 'inline_object' when calling DraftsApi.save_localization"
  end
  # resource path
  local_var_path = '/drafts/{draftId}/localizations/{languageId}'.sub('{' + 'draftId' + '}', CGI.escape(draft_id.to_s)).sub('{' + 'languageId' + '}', CGI.escape(language_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
  header_params[:'Accept'] = accept

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

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(inline_object) 

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['Bearer']

  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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DraftsApi#save_localization\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#set_translation(draft_id, language_id, accept, request_body, opts = {}) ⇒ nil

Set translations for language Completely replaces any existing translations for the given language with those provided in request body. Variables embedded in keys or values are expected to be in the format ‘%(my_variable)s` and will automatically convert to the correct Dyspatch format depending on the type of template. Accepts key/value pairs in JSON format or in gettext PO file format. For JSON set Content-Type header to application/json. For gettext PO format set Content-Type header to text/x-gettext-translation.

Parameters:

  • draft_id (String)

    A draft ID

  • language_id (String)

    A language ID (eg: en-US)

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

  • request_body (Hash<String, String>)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


476
477
478
479
# File 'lib/dyspatch_client/api/drafts_api.rb', line 476

def set_translation(draft_id, language_id, accept, request_body, opts = {})
  set_translation_with_http_info(draft_id, language_id, accept, request_body, opts)
  nil
end

#set_translation_with_http_info(draft_id, language_id, accept, request_body, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Set translations for language Completely replaces any existing translations for the given language with those provided in request body. Variables embedded in keys or values are expected to be in the format &#x60;%(my_variable)s&#x60; and will automatically convert to the correct Dyspatch format depending on the type of template. Accepts key/value pairs in JSON format or in gettext PO file format. For JSON set &#x60;Content-Type&#x60; header to &#x60;application/json&#x60;. For gettext PO format set &#x60;Content-Type&#x60; header to &#x60;text/x-gettext-translation&#x60;.

Parameters:

  • draft_id (String)

    A draft ID

  • language_id (String)

    A language ID (eg: en-US)

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

  • request_body (Hash<String, String>)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# File 'lib/dyspatch_client/api/drafts_api.rb', line 489

def set_translation_with_http_info(draft_id, language_id, accept, request_body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DraftsApi.set_translation ...'
  end
  # verify the required parameter 'draft_id' is set
  if @api_client.config.client_side_validation && draft_id.nil?
    fail ArgumentError, "Missing the required parameter 'draft_id' when calling DraftsApi.set_translation"
  end
  # verify the required parameter 'language_id' is set
  if @api_client.config.client_side_validation && language_id.nil?
    fail ArgumentError, "Missing the required parameter 'language_id' when calling DraftsApi.set_translation"
  end
  # verify the required parameter 'accept' is set
  if @api_client.config.client_side_validation && accept.nil?
    fail ArgumentError, "Missing the required parameter 'accept' when calling DraftsApi.set_translation"
  end
  # verify the required parameter 'request_body' is set
  if @api_client.config.client_side_validation && request_body.nil?
    fail ArgumentError, "Missing the required parameter 'request_body' when calling DraftsApi.set_translation"
  end
  # resource path
  local_var_path = '/drafts/{draftId}/localizations/{languageId}/translations'.sub('{' + 'draftId' + '}', CGI.escape(draft_id.to_s)).sub('{' + 'languageId' + '}', CGI.escape(language_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(['*/*'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
  header_params[:'Accept'] = accept

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

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(request_body) 

  # return_type
  return_type = opts[:return_type] 

  # auth_names
  auth_names = opts[:auth_names] || ['Bearer']

  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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: DraftsApi#set_translation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#submit_draft_for_approval(draft_id, accept, opts = {}) ⇒ nil

Submit the draft for approval Moves the draft into submitted state.

Parameters:

  • draft_id (String)

    A draft ID

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:

  • (nil)


557
558
559
560
# File 'lib/dyspatch_client/api/drafts_api.rb', line 557

def submit_draft_for_approval(draft_id, accept, opts = {})
  submit_draft_for_approval_with_http_info(draft_id, accept, opts)
  nil
end

#submit_draft_for_approval_with_http_info(draft_id, accept, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Submit the draft for approval Moves the draft into submitted state.

Parameters:

  • draft_id (String)

    A draft ID

  • accept (String)

    A version of the API that should be used for the request. For example, to use version &quot;2020.04&quot;, set the value to &quot;application/vnd.dyspatch.2020.04+json&quot;

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

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



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
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# File 'lib/dyspatch_client/api/drafts_api.rb', line 568

def submit_draft_for_approval_with_http_info(draft_id, accept, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: DraftsApi.submit_draft_for_approval ...'
  end
  # verify the required parameter 'draft_id' is set
  if @api_client.config.client_side_validation && draft_id.nil?
    fail ArgumentError, "Missing the required parameter 'draft_id' when calling DraftsApi.submit_draft_for_approval"
  end
  # verify the required parameter 'accept' is set
  if @api_client.config.client_side_validation && accept.nil?
    fail ArgumentError, "Missing the required parameter 'accept' when calling DraftsApi.submit_draft_for_approval"
  end
  # resource path
  local_var_path = '/drafts/{draftId}/publishRequest'.sub('{' + 'draftId' + '}', CGI.escape(draft_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(['*/*'])
  header_params[:'Accept'] = accept

  # 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] || ['Bearer']

  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: DraftsApi#submit_draft_for_approval\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end