Class: Merge::Filestorage::FileRequest
- Inherits:
-
Object
- Object
- Merge::Filestorage::FileRequest
- Defined in:
- lib/merge_ruby_client/filestorage/types/file_request.rb
Overview
# The File Object
### Description
The `File` object is used to represent a file in the workspace. The Object
typically exists under a folder or drive, if it exists.
### Usage Example
Fetch from the `GET /api/filestorage/v1/files` endpoint and view their files.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#description ⇒ String
readonly
The file’s description.
-
#drive ⇒ Merge::Filestorage::FileRequestDrive
readonly
The drive that the file belongs to.
-
#file_thumbnail_url ⇒ String
readonly
The URL that produces a thumbnail preview of the file.
-
#file_url ⇒ String
readonly
The URL to access the file.
-
#folder ⇒ Merge::Filestorage::FileRequestFolder
readonly
The folder that the file belongs to.
- #integration_params ⇒ Hash{String => Object} readonly
- #linked_account_params ⇒ Hash{String => Object} readonly
-
#mime_type ⇒ String
readonly
The file’s mime type.
-
#name ⇒ String
readonly
The file’s name.
-
#permissions ⇒ Merge::Filestorage::FileRequestPermissions
readonly
The Permission object is used to represent a user’s or group’s access to a File or Folder.
-
#size ⇒ Integer
readonly
The file’s size, in bytes.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Filestorage::FileRequest
Deserialize a JSON object to an instance of FileRequest.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(name: OMIT, file_url: OMIT, file_thumbnail_url: OMIT, size: OMIT, mime_type: OMIT, description: OMIT, folder: OMIT, permissions: OMIT, drive: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Filestorage::FileRequest constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of FileRequest to a JSON object.
Constructor Details
#initialize(name: OMIT, file_url: OMIT, file_thumbnail_url: OMIT, size: OMIT, mime_type: OMIT, description: OMIT, folder: OMIT, permissions: OMIT, drive: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Filestorage::FileRequest
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 65 def initialize(name: OMIT, file_url: OMIT, file_thumbnail_url: OMIT, size: OMIT, mime_type: OMIT, description: OMIT, folder: OMIT, permissions: OMIT, drive: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) @name = name if name != OMIT @file_url = file_url if file_url != OMIT @file_thumbnail_url = file_thumbnail_url if file_thumbnail_url != OMIT @size = size if size != OMIT @mime_type = mime_type if mime_type != OMIT @description = description if description != OMIT @folder = folder if folder != OMIT @permissions = if != OMIT @drive = drive if drive != OMIT @integration_params = integration_params if integration_params != OMIT @linked_account_params = linked_account_params if linked_account_params != OMIT @additional_properties = additional_properties @_field_set = { "name": name, "file_url": file_url, "file_thumbnail_url": file_thumbnail_url, "size": size, "mime_type": mime_type, "description": description, "folder": folder, "permissions": , "drive": drive, "integration_params": integration_params, "linked_account_params": linked_account_params }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
43 44 45 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 43 def additional_properties @additional_properties end |
#description ⇒ String (readonly)
Returns The file’s description.
29 30 31 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 29 def description @description end |
#drive ⇒ Merge::Filestorage::FileRequestDrive (readonly)
Returns The drive that the file belongs to.
37 38 39 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 37 def drive @drive end |
#file_thumbnail_url ⇒ String (readonly)
Returns The URL that produces a thumbnail preview of the file. Typically an image.
23 24 25 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 23 def file_thumbnail_url @file_thumbnail_url end |
#file_url ⇒ String (readonly)
Returns The URL to access the file.
21 22 23 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 21 def file_url @file_url end |
#folder ⇒ Merge::Filestorage::FileRequestFolder (readonly)
Returns The folder that the file belongs to.
31 32 33 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 31 def folder @folder end |
#integration_params ⇒ Hash{String => Object} (readonly)
39 40 41 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 39 def integration_params @integration_params end |
#linked_account_params ⇒ Hash{String => Object} (readonly)
41 42 43 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 41 def linked_account_params @linked_account_params end |
#mime_type ⇒ String (readonly)
Returns The file’s mime type.
27 28 29 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 27 def mime_type @mime_type end |
#name ⇒ String (readonly)
Returns The file’s name.
19 20 21 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 19 def name @name end |
#permissions ⇒ Merge::Filestorage::FileRequestPermissions (readonly)
Returns The Permission object is used to represent a user’s or group’s access to a File or Folder. Permissions are unexpanded by default. Use the query param ‘expand=permissions` to see more details under `GET /files`.
35 36 37 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 35 def @permissions end |
#size ⇒ Integer (readonly)
Returns The file’s size, in bytes.
25 26 27 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 25 def size @size end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Filestorage::FileRequest
Deserialize a JSON object to an instance of FileRequest
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 100 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) name = parsed_json["name"] file_url = parsed_json["file_url"] file_thumbnail_url = parsed_json["file_thumbnail_url"] size = parsed_json["size"] mime_type = parsed_json["mime_type"] description = parsed_json["description"] if parsed_json["folder"].nil? folder = nil else folder = parsed_json["folder"].to_json folder = Merge::Filestorage::FileRequestFolder.from_json(json_object: folder) end if parsed_json["permissions"].nil? = nil else = parsed_json["permissions"].to_json = Merge::Filestorage::FileRequestPermissions.from_json(json_object: ) end if parsed_json["drive"].nil? drive = nil else drive = parsed_json["drive"].to_json drive = Merge::Filestorage::FileRequestDrive.from_json(json_object: drive) end integration_params = parsed_json["integration_params"] linked_account_params = parsed_json["linked_account_params"] new( name: name, file_url: file_url, file_thumbnail_url: file_thumbnail_url, size: size, mime_type: mime_type, description: description, folder: folder, permissions: , drive: drive, integration_params: integration_params, linked_account_params: linked_account_params, additional_properties: struct ) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given
hash and check each fields type against the current object's property
definitions.
158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 158 def self.validate_raw(obj:) obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.file_url&.is_a?(String) != false || raise("Passed value for field obj.file_url is not the expected type, validation failed.") obj.file_thumbnail_url&.is_a?(String) != false || raise("Passed value for field obj.file_thumbnail_url is not the expected type, validation failed.") obj.size&.is_a?(Integer) != false || raise("Passed value for field obj.size is not the expected type, validation failed.") obj.mime_type&.is_a?(String) != false || raise("Passed value for field obj.mime_type is not the expected type, validation failed.") obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") obj.folder.nil? || Merge::Filestorage::FileRequestFolder.validate_raw(obj: obj.folder) obj..nil? || Merge::Filestorage::FileRequestPermissions.validate_raw(obj: obj.) obj.drive.nil? || Merge::Filestorage::FileRequestDrive.validate_raw(obj: obj.drive) obj.integration_params&.is_a?(Hash) != false || raise("Passed value for field obj.integration_params is not the expected type, validation failed.") obj.linked_account_params&.is_a?(Hash) != false || raise("Passed value for field obj.linked_account_params is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of FileRequest to a JSON object
148 149 150 |
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 148 def to_json(*_args) @_field_set&.to_json end |