Class: Files::GroupUser

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/group_user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ GroupUser

Returns a new instance of GroupUser.



7
8
9
10
# File 'lib/files.com/models/group_user.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/group_user.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/group_user.rb', line 5

def options
  @options
end

Class Method Details

.all(params = {}, options = {}) ⇒ Object



119
120
121
# File 'lib/files.com/models/group_user.rb', line 119

def self.all(params = {}, options = {})
  list(params, options)
end

.delete(id, params = {}, options = {}) ⇒ Object



141
142
143
144
145
146
147
148
149
# File 'lib/files.com/models/group_user.rb', line 141

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  response, _options = Api.send_request("/group_users/#{params[:id]}", :delete, params, options)
  response.data
end

.destroy(id, params = {}, options = {}) ⇒ Object



151
152
153
# File 'lib/files.com/models/group_user.rb', line 151

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

user_id - integer - User ID.  If provided, will return groups of which this user is a member.
page - integer - Current page number.
per_page - integer - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
group_id - integer - Group ID.  If provided, will return members of this group.


108
109
110
111
112
113
114
115
116
117
# File 'lib/files.com/models/group_user.rb', line 108

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params.dig(:group_id) and !params.dig(:group_id).is_a?(Integer)

  response, options = Api.send_request("/group_users", :get, params, options)
  response.data.map { |object| GroupUser.new(object, options) }
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

group_id (required) - integer - Group ID to add user to.
user_id (required) - integer - User ID to add to group.
admin - boolean - Is the user a group administrator?


127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/files.com/models/group_user.rb', line 127

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params.dig(:group_id) and !params.dig(:group_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
  raise MissingParameterError.new("Parameter missing: group_id") unless params.dig(:group_id)
  raise MissingParameterError.new("Parameter missing: user_id") unless params.dig(:user_id)

  response, options = Api.send_request("/group_users/#{params[:id]}", :patch, params, options)
  GroupUser.new(response.data, options)
end

Instance Method Details

#adminObject

boolean - Is this user an administrator of this group?



22
23
24
# File 'lib/files.com/models/group_user.rb', line 22

def admin
  @attributes[:admin]
end

#admin=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/group_user.rb', line 26

def admin=(value)
  @attributes[:admin] = value
end

#delete(params = {}) ⇒ Object



84
85
86
87
88
89
90
91
92
# File 'lib/files.com/models/group_user.rb', line 84

def delete(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)

  Api.send_request("/group_users/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



94
95
96
# File 'lib/files.com/models/group_user.rb', line 94

def destroy(params = {})
  delete(params)
end

#group_idObject

int64 - Group ID to add user to.



49
50
51
# File 'lib/files.com/models/group_user.rb', line 49

def group_id
  @attributes[:group_id]
end

#group_id=(value) ⇒ Object



53
54
55
# File 'lib/files.com/models/group_user.rb', line 53

def group_id=(value)
  @attributes[:group_id] = value
end

#idObject

int64 - Group ID



13
14
15
# File 'lib/files.com/models/group_user.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/group_user.rb', line 17

def id=(value)
  @attributes[:id] = value
end

#nameObject

string - Group name



31
32
33
# File 'lib/files.com/models/group_user.rb', line 31

def name
  @attributes[:name]
end

#name=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/group_user.rb', line 35

def name=(value)
  @attributes[:name] = value
end

#saveObject



98
99
100
# File 'lib/files.com/models/group_user.rb', line 98

def save
  update(@attributes)
end

#update(params = {}) ⇒ Object

Parameters:

group_id (required) - integer - Group ID to add user to.
user_id (required) - integer - User ID to add to group.
admin - boolean - Is the user a group administrator?


70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/files.com/models/group_user.rb', line 70

def update(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params.dig(:group_id) and !params.dig(:group_id).is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
  raise MissingParameterError.new("Parameter missing: group_id") unless params.dig(:group_id)
  raise MissingParameterError.new("Parameter missing: user_id") unless params.dig(:user_id)

  Api.send_request("/group_users/#{@attributes[:id]}", :patch, params, @options)
end

#user_idObject

int64 - User ID to add to group.



58
59
60
# File 'lib/files.com/models/group_user.rb', line 58

def user_id
  @attributes[:user_id]
end

#user_id=(value) ⇒ Object



62
63
64
# File 'lib/files.com/models/group_user.rb', line 62

def user_id=(value)
  @attributes[:user_id] = value
end

#usernamesObject

array - A list of usernames for users in this group



40
41
42
# File 'lib/files.com/models/group_user.rb', line 40

def usernames
  @attributes[:usernames]
end

#usernames=(value) ⇒ Object



44
45
46
# File 'lib/files.com/models/group_user.rb', line 44

def usernames=(value)
  @attributes[:usernames] = value
end