Sha256: b033eaba5079511794ed2f0eab8d9192f059f28594293884f7d7f4ca56fb7af1

Contents?: true

Size: 853 Bytes

Versions: 4

Compression:

Stored size: 853 Bytes

Contents

# frozen_string_literal: true
module Zendesk2::HelpCenter::SubscriptionRequest
  def self.included(klass)
    super
    klass.extend(ClassMethods)
  end

  module ClassMethods
    def accepted_attributes(type)
      case type
      when 'topic'
        %w(include_comments user_id)
      when 'post'
        %w(user_id)
      else
        %w(locale user_id)
      end
    end
  end

  def route_prefix
    case content_type
    when 'topic', 'post'
      'community'
    else
      'help_center'
    end
  end

  def plural_content_type
    pluralize(content_type)
  end

  def content_type
    subscription.fetch('content_type')
  end

  def content_id
    subscription.fetch('content_id').to_i
  end

  def subscription_id
    subscription.fetch('id')
  end

  def subscription
    Cistern::Hash.stringify_keys(params.fetch('subscription'))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zendesk2-1.15.0 lib/zendesk2/help_center/subscription_request.rb
zendesk2-1.13.1 lib/zendesk2/help_center/subscription_request.rb
zendesk2-1.13.0 lib/zendesk2/help_center/subscription_request.rb
zendesk2-1.12.0 lib/zendesk2/help_center/subscription_request.rb