Class: Files::Request

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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 = {}, 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/request.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Class Method Details

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



126
127
128
# File 'lib/files.com/models/request.rb', line 126

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

.create(path, params = {}, options = {}) ⇒ Object

Create Request

Parameters:

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.


154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/files.com/models/request.rb', line 154

def self.create(path, params = {}, options = {})
  params ||= {}
  params[:path] = path
  raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: destination must be an String") if params.dig(:destination) and !params.dig(:destination).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: user_ids must be an String") if params.dig(:user_ids) and !params.dig(:user_ids).is_a?(String)
  raise InvalidParameterError.new("Bad parameter: group_ids must be an String") if params.dig(:group_ids) and !params.dig(:group_ids).is_a?(String)
  raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
  raise MissingParameterError.new("Parameter missing: destination") unless params.dig(:destination)

  response, options = Api.send_request("/requests", :post, params, options)
  Request.new(response.data, options)
end

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

Parameters:

id (required) - integer - Request ID.


170
171
172
173
174
175
176
177
178
# File 'lib/files.com/models/request.rb', line 170

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("/requests/#{params[:id]}", :delete, params, options)
  response.data
end

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



180
181
182
# File 'lib/files.com/models/request.rb', line 180

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

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

Parameters:

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.
mine - boolean - Only show requests of the current user?  (Defaults to true if current user is not a site admin.)


118
119
120
121
122
123
124
# File 'lib/files.com/models/request.rb', line 118

def self.list(params = {}, options = {})
  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)

  response, options = Api.send_request("/requests", :get, params, options)
end

.list_for(path, params = {}, options = {}) ⇒ Object

Parameters:

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.
path (required) - string - Path to operate on.
mine - boolean - Only show requests of the current user?  (Defaults to true if current user is not a site admin.)


136
137
138
139
140
141
142
143
144
145
146
# File 'lib/files.com/models/request.rb', line 136

def self.list_for(path, params = {}, options = {})
  params ||= {}
  params[:path] = path
  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: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
  raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)

  response, options = Api.send_request("/requests/folders/#{URI.encode_www_form_component(params[:path])}", :get, params, options)
end

Instance Method Details

#automation_idObject

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

#create(params = {}) ⇒ Object

Create Request

Parameters:

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.


90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/files.com/models/request.rb', line 90

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

  Api.send_request("/requests", :post, params, @options)
end

#destinationObject

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

#group_idsObject

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

#idObject

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

#pathObject

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

#saveObject



104
105
106
107
108
109
110
111
# File 'lib/files.com/models/request.rb', line 104

def save
  if @attributes[:path]
    raise NotImplementedError.new("The Request object doesn't support updates.")
  else
    new_obj = Request.create(@attributes, @options)
    @attributes = new_obj.attributes
  end
end

#sourceObject

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_nameObject

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_idsObject

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