Sha256: 4eef02f9ad366bb6b8740d7cd6bf9a83766e8812793b4f802ec8080f96d0fc68

Contents?: true

Size: 1.26 KB

Versions: 21

Compression:

Stored size: 1.26 KB

Contents

class Zendesk2::Client::Category < Zendesk2::Client::Model

  # @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 :identity

    service.destroy_category("category" => {"id" => self.identity})
  end

  def save!
    data = if new_record?
             requires :name

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

             service.update_category(params).body["category"]
           end

    merge_attributes(data)
  end

  protected

  def params
    {"category" => Cistern::Hash.slice(Zendesk2.stringify_keys(attributes), *Zendesk2::Client::CreateCategory.accepted_attributes)}
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
zendesk2-1.5.3 lib/zendesk2/client/models/category.rb