Class: Zendesk2::Membership

Inherits:
Object
  • Object
show all
Extended by:
Attributes
Includes:
Model
Defined in:
lib/zendesk2/membership.rb

Instance Attribute Summary

Attributes included from Model

#errors

Instance Method Summary collapse

Methods included from Attributes

assoc_accessor, assoc_reader, assoc_writer

Methods included from Model

#destroy, #destroyed?, #missing_attributes, #save, #update!

Instance Method Details

#created_atTime

Returns The time the identity got created.

Returns:

  • (Time)

    The time the identity got created



11
# File 'lib/zendesk2/membership.rb', line 11

attribute :created_at, type: :time

#defaultBoolean

Returns Is membership the default.

Returns:

  • (Boolean)

    Is membership the default



13
# File 'lib/zendesk2/membership.rb', line 13

attribute :default, type: :boolean

#default!Object



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/zendesk2/membership.rb', line 46

def default!
  requires :identity, :user_id

  cistern.mark_membership_default(
    'membership' => {
      'user_id' => user_id,
      'id'      => identity,
    }
  )

  self.default = true
end

#destroy!Object



40
41
42
43
44
# File 'lib/zendesk2/membership.rb', line 40

def destroy!
  requires :identity

  cistern.destroy_membership('membership' => { 'id' => identity })
end

#idInteger

Returns Automatically assigned upon creation.

Returns:

  • (Integer)

    Automatically assigned upon creation



8
# File 'lib/zendesk2/membership.rb', line 8

identity :id, type: :integer

#organization_idInteger

Returns The id of the organization.

Returns:

  • (Integer)

    The id of the organization



15
# File 'lib/zendesk2/membership.rb', line 15

attribute :organization_id, type: :integer

#save!Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/zendesk2/membership.rb', line 26

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

           cistern.create_membership('membership' => attributes).body['organization_membership']
         else
           requires :identity

           raise ArgumentError, 'update not implemented'
         end

  merge_attributes(data)
end

#updated_atTime

Returns The time the identity got updated.

Returns:

  • (Time)

    The time the identity got updated



17
# File 'lib/zendesk2/membership.rb', line 17

attribute :updated_at, type: :time

#urlString

Returns The API url of this identity.

Returns:

  • (String)

    The API url of this identity



21
# File 'lib/zendesk2/membership.rb', line 21

attribute :url, type: :string

#user_idInteger

Returns The id of the user.

Returns:

  • (Integer)

    The id of the user



19
# File 'lib/zendesk2/membership.rb', line 19

attribute :user_id, type: :integer