Class: Files::Preview
- Inherits:
-
Object
- Object
- Files::Preview
- Defined in:
- lib/files.com/models/preview.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
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - integer - Preview ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: page - integer - Current page number.
Instance Method Summary collapse
-
#download_uri ⇒ Object
string - Link to download preview.
-
#id ⇒ Object
int64 - Preview ID.
-
#initialize(attributes = {}, options = {}) ⇒ Preview
constructor
A new instance of Preview.
-
#size ⇒ Object
int64 - Preview size.
-
#status ⇒ Object
string - Preview status.
-
#type ⇒ Object
string - Preview status.
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ Preview
Returns a new instance of Preview.
7 8 9 10 |
# File 'lib/files.com/models/preview.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/preview.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/preview.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
55 56 57 |
# File 'lib/files.com/models/preview.rb', line 55 def self.all(params = {}, = {}) list(params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - integer - Preview ID.
size - string - Preview Size
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/files.com/models/preview.rb', line 62 def self.find(id, params = {}, = {}) 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: size must be an String") if params.dig(:size) and !params.dig(:size).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/previews/#{params[:id]}", :get, params, ) Preview.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
73 74 75 |
# File 'lib/files.com/models/preview.rb', line 73 def self.get(id, params = {}, = {}) find(id, params, ) 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.
ids (required) - string - Preview IDs. Comma delimited.
size - string - Preview Size
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/files.com/models/preview.rb', line 43 def self.list(params = {}, = {}) 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: ids must be an String") if params.dig(:ids) and !params.dig(:ids).is_a?(String) raise InvalidParameterError.new("Bad parameter: size must be an String") if params.dig(:size) and !params.dig(:size).is_a?(String) raise MissingParameterError.new("Parameter missing: ids") unless params.dig(:ids) response, = Api.send_request("/previews", :get, params, ) response.data.map { |object| Preview.new(object, ) } end |
Instance Method Details
#download_uri ⇒ Object
string - Link to download preview
18 19 20 |
# File 'lib/files.com/models/preview.rb', line 18 def download_uri @attributes[:download_uri] end |
#id ⇒ Object
int64 - Preview ID
23 24 25 |
# File 'lib/files.com/models/preview.rb', line 23 def id @attributes[:id] end |
#size ⇒ Object
int64 - Preview size
33 34 35 |
# File 'lib/files.com/models/preview.rb', line 33 def size @attributes[:size] end |
#status ⇒ Object
string - Preview status. Can be invalid, not_generated, generating, complete, or file_too_large
13 14 15 |
# File 'lib/files.com/models/preview.rb', line 13 def status @attributes[:status] end |
#type ⇒ Object
string - Preview status. Can be invalid, not_generated, generating, complete, or file_too_large
28 29 30 |
# File 'lib/files.com/models/preview.rb', line 28 def type @attributes[:type] end |