Sha256: dff6592488c3924444f2989c1146b6f75fb34f7ea935a5ad150e809212c4ccff

Contents?: true

Size: 1.71 KB

Versions: 5

Compression:

Stored size: 1.71 KB

Contents

# frozen_string_literal: true
class Zendesk2::HelpCenter::Subscription
  include Zendesk2::Model

  extend Zendesk2::Attributes

  # @return [Integer] Automatically assigned when the subscription is created
  identity :id, type: :integer # ro: yes, required: no

  # @return [String] The API url of the subscription
  attribute :url # ro: yes, required: no
  # @return [Integer] The id of the user who has this subscription
  attribute :user_id, type: :integer # ro: yes, required: no
  # @return [Integer] The id of the subscribed item
  attribute :content_id, type: :integer # ro: yes, required: no
  # @return [String] The type of the subscribed item
  attribute :content_type # ro: yes, required: no
  # @return [String] The locale of the subscribed item
  attribute :locale # ro: yes, required: yes
  # @return [Boolean] Subscribe also to article comments. Only for section subscriptions.
  attribute :include_comments, type: :boolean # ro: yes, required: no
  # @return [Time] The time at which the subscription was created
  attribute :created_at, type: :time # ro: yes, required: no
  # @return [Time] The time at which the subscription was last updated
  attribute :updated_at, type: :time # ro: yes, required: no

  def destroy!
    requires :identity

    cistern.destroy_help_center_subscription('subscription' => attributes)
  end

  def save!
    response = if new_record?
                 requires :content_id, :content_type

                 cistern.create_help_center_subscription('subscription' => attributes)
               else
                 requires :identity

                 cistern.update_help_center_subscription('subscription' => attributes)
               end

    merge_attributes(response.body['subscription'])
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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