Module: Zendesk2::HelpCenter::TranslationSource::Request
- Included in:
- CreateHelpCenterTranslation, DestroyHelpCenterTranslation, GetHelpCenterTranslation, GetHelpCenterTranslations, UpdateHelpCenterTranslation
- Defined in:
- lib/zendesk2/help_center/translation_source.rb
Overview
allow requests to read common pieces of information about the translation source
Instance Method Summary collapse
- #locale ⇒ Object
-
#mock_translation_key ⇒ Object
Since Zendesk2::Request#find! calls .to_i on hash keys, we need an integer key for this.
- #source_id ⇒ Object
- #source_type ⇒ Object
- #source_type_url ⇒ Object
Instance Method Details
#locale ⇒ Object
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_key ⇒ Object
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_id ⇒ Object
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_type ⇒ Object
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_url ⇒ Object
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 |