Class: Files::Request
- Inherits:
-
Object
- Object
- Files::Request
- Defined in:
- lib/files.com/models/request.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: path (required) - string - Folder path on which to request the file.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.get_folder(path, params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
-
.list(params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
Instance Method Summary collapse
-
#automation_id ⇒ Object
string - ID of automation that created request.
- #automation_id=(value) ⇒ Object
- #delete(params = {}) ⇒ Object
-
#destination ⇒ Object
string - Destination filename.
- #destination=(value) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#group_ids ⇒ Object
string - A list of group IDs to request the file from.
- #group_ids=(value) ⇒ Object
-
#id ⇒ Object
int64 - Request ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Request
constructor
A new instance of Request.
-
#path ⇒ Object
string - Folder path This must be slash-delimited, but it must neither start nor end with a slash.
- #path=(value) ⇒ Object
- #save ⇒ Object
-
#source ⇒ Object
string - Source filename, if applicable.
- #source=(value) ⇒ Object
-
#user_display_name ⇒ Object
string - User making the request (if applicable).
- #user_display_name=(value) ⇒ Object
-
#user_ids ⇒ Object
string - A list of user IDs to request the file from.
- #user_ids=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Request
Returns a new instance of Request.
7 8 9 10 |
# File 'lib/files.com/models/request.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/request.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/request.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
131 132 133 |
# File 'lib/files.com/models/request.rb', line 131 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
path (required) - string - Folder path on which to request the file.
destination (required) - string - Destination filename (without extension) to request.
user_ids - string - A list of user IDs to request the file from. If sent as a string, it should be comma-delimited.
group_ids - string - A list of group IDs to request the file from. If sent as a string, it should be comma-delimited.
164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/files.com/models/request.rb', line 164 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise InvalidParameterError.new("Bad parameter: destination must be an String") if params[:destination] and !params[:destination].is_a?(String) raise InvalidParameterError.new("Bad parameter: user_ids must be an String") if params[:user_ids] and !params[:user_ids].is_a?(String) raise InvalidParameterError.new("Bad parameter: group_ids must be an String") if params[:group_ids] and !params[:group_ids].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] raise MissingParameterError.new("Parameter missing: destination") unless params[:destination] response, = Api.send_request("/requests", :post, params, ) Request.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
176 177 178 179 180 181 182 183 184 |
# File 'lib/files.com/models/request.rb', line 176 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 MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/requests/#{params[:id]}", :delete, params, ) nil end |
.destroy(id, params = {}, options = {}) ⇒ Object
186 187 188 189 |
# File 'lib/files.com/models/request.rb', line 186 def self.destroy(id, params = {}, = {}) delete(id, params, ) nil end |
.get_folder(path, params = {}, options = {}) ⇒ Object
Parameters:
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).
action - string
page - int64
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction (e.g. `sort_by[destination]=desc`). Valid fields are `destination`.
mine - boolean - Only show requests of the current user? (Defaults to true if current user is not a site admin.)
path (required) - string - Path to show requests for. If omitted, shows all paths. Send `/` to represent the root directory.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/files.com/models/request.rb', line 143 def self.get_folder(path, params = {}, = {}) params ||= {} params[:path] = path 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: action must be an String") if params[:action] and !params[:action].is_a?(String) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params[:page] and !params[:page].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) raise MissingParameterError.new("Parameter missing: path") unless params[:path] List.new(Request, params) do Api.send_request("/requests/folders/#{params[:path]}", :get, params, ) end end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
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).
action - string
page - int64
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction (e.g. `sort_by[destination]=desc`). Valid fields are `destination`.
mine - boolean - Only show requests of the current user? (Defaults to true if current user is not a site admin.)
path - string - Path to show requests for. If omitted, shows all paths. Send `/` to represent the root directory.
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/files.com/models/request.rb', line 118 def self.list(params = {}, = {}) 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: action must be an String") if params[:action] and !params[:action].is_a?(String) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params[:page] and !params[:page].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String) List.new(Request, params) do Api.send_request("/requests", :get, params, ) end end |
Instance Method Details
#automation_id ⇒ Object
string - ID of automation that created request
49 50 51 |
# File 'lib/files.com/models/request.rb', line 49 def automation_id @attributes[:automation_id] end |
#automation_id=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/request.rb', line 53 def automation_id=(value) @attributes[:automation_id] = value end |
#delete(params = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/files.com/models/request.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[:id] and !params[:id].is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/requests/#{@attributes[:id]}", :delete, params, @options) end |
#destination ⇒ Object
string - Destination filename
40 41 42 |
# File 'lib/files.com/models/request.rb', line 40 def destination @attributes[:destination] end |
#destination=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/request.rb', line 44 def destination=(value) @attributes[:destination] = value end |
#destroy(params = {}) ⇒ Object
94 95 96 97 |
# File 'lib/files.com/models/request.rb', line 94 def destroy(params = {}) delete(params) nil end |
#group_ids ⇒ Object
string - A list of group IDs to request the file from. If sent as a string, it should be comma-delimited.
76 77 78 |
# File 'lib/files.com/models/request.rb', line 76 def group_ids @attributes[:group_ids] end |
#group_ids=(value) ⇒ Object
80 81 82 |
# File 'lib/files.com/models/request.rb', line 80 def group_ids=(value) @attributes[:group_ids] = value end |
#id ⇒ Object
int64 - Request ID
13 14 15 |
# File 'lib/files.com/models/request.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/request.rb', line 17 def id=(value) @attributes[:id] = value end |
#path ⇒ Object
string - Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
22 23 24 |
# File 'lib/files.com/models/request.rb', line 22 def path @attributes[:path] end |
#path=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/request.rb', line 26 def path=(value) @attributes[:path] = value end |
#save ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/files.com/models/request.rb', line 99 def save if @attributes[:id] raise NotImplementedError.new("The Request object doesn't support updates.") else new_obj = Request.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#source ⇒ Object
string - Source filename, if applicable
31 32 33 |
# File 'lib/files.com/models/request.rb', line 31 def source @attributes[:source] end |
#source=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/request.rb', line 35 def source=(value) @attributes[:source] = value end |
#user_display_name ⇒ Object
string - User making the request (if applicable)
58 59 60 |
# File 'lib/files.com/models/request.rb', line 58 def user_display_name @attributes[:user_display_name] end |
#user_display_name=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/request.rb', line 62 def user_display_name=(value) @attributes[:user_display_name] = value end |
#user_ids ⇒ Object
string - A list of user IDs to request the file from. If sent as a string, it should be comma-delimited.
67 68 69 |
# File 'lib/files.com/models/request.rb', line 67 def user_ids @attributes[:user_ids] end |
#user_ids=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/request.rb', line 71 def user_ids=(value) @attributes[:user_ids] = value end |