class Zendesk2::CreateHelpCenterTranslation

Public Class Methods

accepted_attributes() click to toggle source
# File lib/zendesk2/help_center/create_help_center_translation.rb, line 10
def self.accepted_attributes
  %w(locale title body outdated draft)
end

Public Instance Methods

mock() click to toggle source
# File lib/zendesk2/help_center/create_help_center_translation.rb, line 18
def mock
  identity = cistern.serial_id

  record = {
    'id'                => identity,
    'url'               => url_for("/help_center/#{source_type_url}/#{source_id}/translation/#{locale}.json"),
    'html_url'          => html_url_for("/hc/#{locale}/#{source_type_url}/#{source_id}"),
    'created_at'        => timestamp,
    'updated_at'        => timestamp,
    'title'             => params.fetch('translation').fetch('title'),
    'body'              => (params.fetch('translation')['body'] || ''),
    'outdated'          => false,
    'draft'             => false,
    'locale'            => locale,
  }.merge(translation_params)

  cistern.data[:help_center_translations][mock_translation_key] = record

  mock_response('translation' => record)
end
translation_params() click to toggle source
# File lib/zendesk2/help_center/create_help_center_translation.rb, line 14
def translation_params
  Cistern::Hash.slice(params.fetch('translation'), *self.class.accepted_attributes)
end