Class: Zendesk2::Organization

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/zendesk2/organization.rb

Instance Attribute Summary

Attributes included from Model

#errors

Instance Method Summary collapse

Methods included from Model

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

Instance Method Details

#created_atDate



9
# File 'lib/zendesk2/organization.rb', line 9

attribute :created_at, type: :time

#destroy!Object



35
36
37
38
39
# File 'lib/zendesk2/organization.rb', line 35

def destroy!
  requires :identity

  cistern.destroy_organization('organization' => { 'id' => identity })
end

#detailsString



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

attribute :details, type: :string

#domain_namesArray



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

attribute :domain_names, type: :array

#external_idString



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

attribute :external_id, type: :string

#group_idInteger



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

attribute :group_id, type: :integer

#idinteger



6
# File 'lib/zendesk2/organization.rb', line 6

identity :id, type: :integer

#membershipsZendesk2::Memberships



65
66
67
68
69
# File 'lib/zendesk2/organization.rb', line 65

def memberships
  requires :identity

  cistern.memberships(organization: self)
end

#nameString



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

attribute :name, type: :string

#notesString



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

attribute :notes, type: :string

#organization_fieldsHash



23
# File 'lib/zendesk2/organization.rb', line 23

attribute :organization_fields, type: :hash

#save!Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/zendesk2/organization.rb', line 41

def save!
  data = if new_record?
           requires :name

           cistern.create_organization('organization' => attributes)
         else
           requires :identity

           cistern.update_organization('organization' => attributes)
         end.body['organization']

  merge_attributes(data)
end

#shared_commentsBoolean



25
# File 'lib/zendesk2/organization.rb', line 25

attribute :shared_comments, type: :boolean

#shared_ticketsBoolean



27
# File 'lib/zendesk2/organization.rb', line 27

attribute :shared_tickets, type: :boolean

#tagsArray



29
# File 'lib/zendesk2/organization.rb', line 29

attribute :tags, type: :array

#ticketsZendesk2::Tickets



72
73
74
75
76
77
78
# File 'lib/zendesk2/organization.rb', line 72

def tickets
  requires :identity

  cistern.tickets.load(
    cistern.get_organization_tickets('organization_id' => identity).body['tickets']
  )
end

#updated_atDate



31
# File 'lib/zendesk2/organization.rb', line 31

attribute :updated_at, type: :time

#urlString



33
# File 'lib/zendesk2/organization.rb', line 33

attribute :url, type: :string

#usersZendesk2::Users



56
57
58
59
60
61
62
# File 'lib/zendesk2/organization.rb', line 56

def users
  requires :identity

  cistern.users.load(
    cistern.get_organization_users('organization' => { 'id' => identity }).body['users']
  )
end