Sha256: 7cea6fd452df4d099ee34b7905ef8b10638b1818ba6e99afa07308712d777326

Contents?: true

Size: 1.21 KB

Versions: 42

Compression:

Stored size: 1.21 KB

Contents

class Zendesk2::Client::Category < Zendesk2::Model
  PARAMS = %w[id name description position]

  # @return [Integer] Automatically assigned during creation
  identity :id, type: :integer

  # @return [Time] The time the category was created
  attribute :created_at, type: :time
  # @return [String] The description of the category
  attribute :description, type: :string
  # @return [String] The name of the category
  attribute :name, type: :string
  # @return [Integer] The position of this category relative to other categories
  attribute :position, type: :integer
  # @return [Time] The time of the last update of the category
  attribute :updated_at, type: :time
  # @return [String] The API url of this category
  attribute :url, type: :string

  def destroy!
    requires :id

    connection.destroy_category("id" => self.id)
  end

  def save!
    data = if new_record?
             requires :name

             connection.create_category(params).body["category"]
           else
             requires :identity

             connection.update_category(params).body["category"]
           end
    merge_attributes(data)
  end

  private

  def params
    Cistern::Hash.slice(Zendesk2.stringify_keys(attributes), *PARAMS)
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
zendesk2-1.4.2 lib/zendesk2/client/models/category.rb
zendesk2-1.4.1 lib/zendesk2/client/models/category.rb
zendesk2-1.4.0 lib/zendesk2/client/models/category.rb
zendesk2-1.3.3 lib/zendesk2/client/models/category.rb
zendesk2-1.3.2 lib/zendesk2/client/models/category.rb
zendesk2-1.3.1 lib/zendesk2/client/models/category.rb
zendesk2-1.3.0 lib/zendesk2/client/models/category.rb
zendesk2-1.2.10 lib/zendesk2/client/models/category.rb
zendesk2-1.2.9 lib/zendesk2/client/models/category.rb
zendesk2-1.2.7 lib/zendesk2/client/models/category.rb
zendesk2-1.2.6 lib/zendesk2/client/models/category.rb
zendesk2-1.2.5 lib/zendesk2/client/models/category.rb
zendesk2-1.2.4 lib/zendesk2/client/models/category.rb
zendesk2-1.2.3 lib/zendesk2/client/models/category.rb
zendesk2-1.2.2 lib/zendesk2/client/models/category.rb
zendesk2-1.2.1 lib/zendesk2/client/models/category.rb
zendesk2-1.2.0 lib/zendesk2/client/models/category.rb
zendesk2-1.1.3 lib/zendesk2/client/models/category.rb
zendesk2-1.1.2 lib/zendesk2/client/models/category.rb
zendesk2-1.0.0 lib/zendesk2/client/models/category.rb