Sha256: 5a4b98f962ebf2b29d51650c7aafe9d81d88d7c841707b12ba5e8b3b56b08374

Contents?: true

Size: 1.42 KB

Versions: 21

Compression:

Stored size: 1.42 KB

Contents

class Zendesk2::Client::Membership < Zendesk2::Client::Model
  extend Zendesk2::Attributes

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

  # @return [Time] The time the identity got created
  attribute :created_at, type: :time
  # @return [Boolean] Is membership the default
  attribute :default, type: :boolean
  # @return [Integer] The id of the organization
  attribute :organization_id, type: :integer
  # @return [Time] The time the identity got updated
  attribute :updated_at, type: :time
  # @return [Integer] The id of the user
  attribute :user_id, type: :integer
  # @return [String] The API url of this identity
  attribute :url, type: :string

  assoc_accessor :organization
  assoc_accessor :user

  def save!
    data = if new_record?
             requires :organization_id, :user_id

             service.create_membership("membership" => self.attributes).body["organization_membership"]
           else
             requires :identity

             raise ArgumentError, "update not implemented"
           end

    merge_attributes(data)
  end

  def destroy!
    requires :identity

    service.destroy_membership("membership" => { "id" => self.identity })
  end

  def default!
    requires :identity, :user_id

    self.service.mark_membership_default(
      "membership" => {
        "user_id" => self.user_id,
        "id"      => self.identity
      })

    self.default = true
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
zendesk2-1.7.5 lib/zendesk2/client/models/membership.rb
zendesk2-1.7.4 lib/zendesk2/client/models/membership.rb
zendesk2-1.7.2 lib/zendesk2/client/models/membership.rb
zendesk2-1.7.1 lib/zendesk2/client/models/membership.rb
zendesk2-1.7.0 lib/zendesk2/client/models/membership.rb
zendesk2-1.6.1 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.17 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.16 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.15 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.14 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.13 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.12 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.11 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.10 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.9 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.8 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.7 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.6 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.5 lib/zendesk2/client/models/membership.rb
zendesk2-1.5.4 lib/zendesk2/client/models/membership.rb