-
Notifications
You must be signed in to change notification settings - Fork 238
/
organization.rb
96 lines (88 loc) · 3.51 KB
/
organization.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
module Trello
# Organizations are useful for linking members together.
#
# @!attribute [r] id
# @return [String]
# @!attribute [r] name
# @return [String]
# @!attribute [r] display_name
# @return [String]
# @!attribute [r] description
# @return [String]
# @!attribute [r] url
# @return [String]
# @!attribute [r] team_type
# @return [String]
# @!attribute [r] desc_data
# @return [String]
# @!attribute [r] logo_hash
# @return [String]
# @!attribute [r] logo_url
# @return [String]
# @!attribute [r] power_ups
# @return [Array]
# @!attribute [r] website
# @return [String]
# @!attribute [w] google_app_domain
# @return [String]
# @!attribute [w] google_app_version
# @return [String]
# @!attribute [w] enable_add_external_members
# @return [Boolean]
# @!attribute [w] private_board_creation_permission_level
# @return [String]
# @!attribute [w] organization_visible_board_creation_permission_level
# @return [String]
# @!attribute [w] public_board_creation_permission_level
# @return [String]
# @!attribute [w] visibility_level
# @return [String]
class Organization < BasicData
schema do
# Readonly
attribute :id, readonly: true, primary_key: true
attribute :team_type, readonly: true, remote_key: 'teamType'
attribute :url, readonly: true
attribute :desc_data, readonly: true, remote_key: 'descData'
attribute :logo_hash, readonly: true, remote_key: 'logoHash'
attribute :logo_url, readonly: true, remote_key: 'logoUrl'
attribute :products, readonly: true
attribute :power_ups, readonly: true, remote_key: 'powerUps'
# Writable
attribute :name
attribute :display_name, remote_key: 'displayName'
attribute :description, remote_key: 'desc'
attribute :website
# Writable but update only
attribute :google_app_domain, update_only: true, remote_key: 'associatedDomain', class_name: 'BoardPref'
attribute :google_app_version, update_only: true, remote_key: 'googleAppsVersion ', class_name: 'BoardPref'
attribute :enable_add_external_members, update_only: true, remote_key: 'externalMembersDisabled', class_name: 'BoardPref'
attribute :private_board_creation_permission_level, update_only: true, remote_key: 'boardVisibilityRestrict/private', class_name: 'BoardPref'
attribute :organization_visible_board_creation_permission_level, update_only: true, remote_key: 'boardVisibilityRestrict/org', class_name: 'BoardPref'
attribute :public_board_creation_permission_level, update_only: true, remote_key: 'boardVisibilityRestrict/public', class_name: 'BoardPref'
attribute :visibility_level, update_only: true, remote_key: 'permissionLevel ', class_name: 'BoardPref'
end
validates_presence_of :id, :name
include HasActions
class << self
# Find an organization by its id.
def find(id, params = {})
client.find(:organization, id, params)
end
end
# Returns a list of boards under this organization.
def boards(params = {})
boards = Board.from_response client.get("/organizations/#{id}/boards", params)
MultiAssociation.new(self, boards).proxy
end
# Returns an array of members associated with the organization.
def members(params = {})
members = Member.from_response client.get("/organizations/#{id}/members/all", params)
MultiAssociation.new(self, members).proxy
end
# :nodoc:
def request_prefix
"/organizations/#{id}"
end
end
end