Class: Files::GroupUser
- Inherits:
-
Object
- Object
- Files::GroupUser
- Defined in:
- lib/files.com/models/group_user.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .all(params = {}, options = {}) ⇒ Object
-
.create(params = {}, options = {}) ⇒ Object
Parameters: group_id (required) - int64 - Group ID to add user to.
-
.delete(id, params = {}, options = {}) ⇒ Object
Parameters: group_id (required) - int64 - Group ID from which to remove user.
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: user_id - int64 - User ID.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: group_id (required) - int64 - Group ID to add user to.
Instance Method Summary collapse
-
#admin ⇒ Object
boolean - Is this user an administrator of this group?.
- #admin=(value) ⇒ Object
-
#delete(params = {}) ⇒ Object
Parameters: group_id (required) - int64 - Group ID from which to remove user.
- #destroy(params = {}) ⇒ Object
-
#group_id ⇒ Object
int64 - Group ID.
- #group_id=(value) ⇒ Object
-
#group_name ⇒ Object
string - Group name.
- #group_name=(value) ⇒ Object
-
#id ⇒ Object
int64 - Group User ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ GroupUser
constructor
A new instance of GroupUser.
- #save ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: group_id (required) - int64 - Group ID to add user to.
-
#user_id ⇒ Object
int64 - User ID.
- #user_id=(value) ⇒ Object
-
#usernames ⇒ Object
array(string) - A list of usernames for users in this group.
- #usernames=(value) ⇒ Object
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 = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/group_user.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/group_user.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
133 134 135 |
# File 'lib/files.com/models/group_user.rb', line 133 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
group_id (required) - int64 - Group ID to add user to.
user_id (required) - int64 - User ID to add to group.
admin - boolean - Is the user a group administrator?
141 142 143 144 145 146 147 148 149 |
# File 'lib/files.com/models/group_user.rb', line 141 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params[:group_id] and !params[:group_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: group_id") unless params[:group_id] raise MissingParameterError.new("Parameter missing: user_id") unless params[:user_id] response, = Api.send_request("/group_users", :post, params, ) GroupUser.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
Parameters:
group_id (required) - int64 - Group ID from which to remove user.
user_id (required) - int64 - User ID to remove from group.
172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/files.com/models/group_user.rb', line 172 def self.delete(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params[:group_id] and !params[:group_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: group_id") unless params[:group_id] raise MissingParameterError.new("Parameter missing: user_id") unless params[:user_id] Api.send_request("/group_users/#{params[:id]}", :delete, params, ) nil end |
.destroy(id, params = {}, options = {}) ⇒ Object
186 187 188 189 |
# File 'lib/files.com/models/group_user.rb', line 186 def self.destroy(id, params = {}, = {}) delete(id, params, ) nil end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
user_id - int64 - User ID. If provided, will return group_users of this user.
cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
group_id - int64 - Group ID. If provided, will return group_users of this group.
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/files.com/models/group_user.rb', line 122 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params[:group_id] and !params[:group_id].is_a?(Integer) List.new(GroupUser, params) do Api.send_request("/group_users", :get, params, ) end end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
group_id (required) - int64 - Group ID to add user to.
user_id (required) - int64 - User ID to add to group.
admin - boolean - Is the user a group administrator?
155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/files.com/models/group_user.rb', line 155 def self.update(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params[:group_id] and !params[:group_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: group_id") unless params[:group_id] raise MissingParameterError.new("Parameter missing: user_id") unless params[:user_id] response, = Api.send_request("/group_users/#{params[:id]}", :patch, params, ) GroupUser.new(response.data, ) end |
Instance Method Details
#admin ⇒ Object
boolean - Is this user an administrator of this group?
40 41 42 |
# File 'lib/files.com/models/group_user.rb', line 40 def admin @attributes[:admin] end |
#admin=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/group_user.rb', line 44 def admin=(value) @attributes[:admin] = value end |
#delete(params = {}) ⇒ Object
Parameters:
group_id (required) - int64 - Group ID from which to remove user.
user_id (required) - int64 - User ID to remove from group.
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/files.com/models/group_user.rb', line 87 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[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params[:group_id] and !params[:group_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: group_id") unless params[:group_id] raise MissingParameterError.new("Parameter missing: user_id") unless params[:user_id] Api.send_request("/group_users/#{@attributes[:id]}", :delete, params, @options) end |
#destroy(params = {}) ⇒ Object
101 102 103 104 |
# File 'lib/files.com/models/group_user.rb', line 101 def destroy(params = {}) delete(params) nil end |
#group_id ⇒ Object
int64 - Group ID
22 23 24 |
# File 'lib/files.com/models/group_user.rb', line 22 def group_id @attributes[:group_id] end |
#group_id=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/group_user.rb', line 26 def group_id=(value) @attributes[:group_id] = value end |
#group_name ⇒ Object
string - Group name
13 14 15 |
# File 'lib/files.com/models/group_user.rb', line 13 def group_name @attributes[:group_name] end |
#group_name=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/group_user.rb', line 17 def group_name=(value) @attributes[:group_name] = value end |
#id ⇒ Object
int64 - Group User ID.
58 59 60 |
# File 'lib/files.com/models/group_user.rb', line 58 def id @attributes[:id] end |
#id=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/group_user.rb', line 62 def id=(value) @attributes[:id] = value end |
#save ⇒ Object
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/files.com/models/group_user.rb', line 106 def save if @attributes[:id] new_obj = update(@attributes) else new_obj = GroupUser.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#update(params = {}) ⇒ Object
Parameters:
group_id (required) - int64 - Group ID to add user to.
user_id (required) - int64 - 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[:id] and !params[:id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params[:group_id] and !params[:group_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] raise MissingParameterError.new("Parameter missing: group_id") unless params[:group_id] raise MissingParameterError.new("Parameter missing: user_id") unless params[:user_id] Api.send_request("/group_users/#{@attributes[:id]}", :patch, params, @options) end |
#user_id ⇒ Object
int64 - User ID
31 32 33 |
# File 'lib/files.com/models/group_user.rb', line 31 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/group_user.rb', line 35 def user_id=(value) @attributes[:user_id] = value end |
#usernames ⇒ Object
array(string) - A list of usernames for users in this group
49 50 51 |
# File 'lib/files.com/models/group_user.rb', line 49 def usernames @attributes[:usernames] end |
#usernames=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/group_user.rb', line 53 def usernames=(value) @attributes[:usernames] = value end |