Module: Zendesk2::HelpCenter::TranslationSource::Request

Overview

allow requests to read common pieces of information about the translation source

Instance Method Summary collapse

Instance Method Details

#localeObject



38
39
40
# File 'lib/zendesk2/help_center/translation_source.rb', line 38

def locale
  (params['translation'] || params).fetch('locale') || 'en-us'
end

#mock_translation_keyObject

Since Zendesk2::Request#find! calls .to_i on hash keys, we need an integer key for this.



44
45
46
# File 'lib/zendesk2/help_center/translation_source.rb', line 44

def mock_translation_key
  [source_type, source_id, locale].join('-').each_byte.reduce(0) { |a, e| a + e }
end

#source_idObject



19
20
21
# File 'lib/zendesk2/help_center/translation_source.rb', line 19

def source_id
  Integer((params['translation'] || params).fetch('source_id'))
end

#source_typeObject



23
24
25
# File 'lib/zendesk2/help_center/translation_source.rb', line 23

def source_type
  (params['translation'] || params).fetch('source_type')
end

#source_type_urlObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/zendesk2/help_center/translation_source.rb', line 27

def source_type_url
  case source_type
  when 'Article'
    'articles'
  when 'Section'
    'sections'
  when 'Category'
    'categories'
  end
end