Class: Merge::Filestorage::FileRequest

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • name (String) (defaults to: OMIT)

    The file’s name.

  • file_url (String) (defaults to: OMIT)

    The URL to access the file.

  • file_thumbnail_url (String) (defaults to: OMIT)

    The URL that produces a thumbnail preview of the file. Typically an image.

  • size (Integer) (defaults to: OMIT)

    The file’s size, in bytes.

  • mime_type (String) (defaults to: OMIT)

    The file’s mime type.

  • description (String) (defaults to: OMIT)

    The file’s description.

  • folder (Merge::Filestorage::FileRequestFolder) (defaults to: OMIT)

    The folder that the file belongs to.

  • permissions (Merge::Filestorage::FileRequestPermissions) (defaults to: OMIT)

    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`.

  • drive (Merge::Filestorage::FileRequestDrive) (defaults to: OMIT)

    The drive that the file belongs to.

  • integration_params (Hash{String => Object}) (defaults to: OMIT)
  • linked_account_params (Hash{String => Object}) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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 = permissions if permissions != OMIT
  @drive = drive if drive != OMIT
  @integration_params = integration_params if integration_params != OMIT
  @linked_account_params =  if  != 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": permissions,
    "drive": drive,
    "integration_params": integration_params,
    "linked_account_params": 
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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

#descriptionString (readonly)

Returns The file’s description.

Returns:

  • (String)

    The file’s description.



29
30
31
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 29

def description
  @description
end

#driveMerge::Filestorage::FileRequestDrive (readonly)

Returns The drive that the file belongs to.

Returns:



37
38
39
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 37

def drive
  @drive
end

#file_thumbnail_urlString (readonly)

Returns The URL that produces a thumbnail preview of the file. Typically an image.

Returns:

  • (String)

    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_urlString (readonly)

Returns The URL to access the file.

Returns:

  • (String)

    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

#folderMerge::Filestorage::FileRequestFolder (readonly)

Returns The folder that the file belongs to.

Returns:



31
32
33
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 31

def folder
  @folder
end

#integration_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


39
40
41
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 39

def integration_params
  @integration_params
end

#linked_account_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


41
42
43
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 41

def 
  @linked_account_params
end

#mime_typeString (readonly)

Returns The file’s mime type.

Returns:

  • (String)

    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

#nameString (readonly)

Returns The file’s name.

Returns:

  • (String)

    The file’s name.



19
20
21
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 19

def name
  @name
end

#permissionsMerge::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`.

Returns:

  • (Merge::Filestorage::FileRequestPermissions)

    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
  @permissions
end

#sizeInteger (readonly)

Returns The file’s size, in bytes.

Returns:

  • (Integer)

    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

Parameters:

  • json_object (String)

Returns:



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?
    permissions = nil
  else
    permissions = parsed_json["permissions"].to_json
    permissions = Merge::Filestorage::FileRequestPermissions.from_json(json_object: permissions)
  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"]
   = 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: permissions,
    drive: drive,
    integration_params: integration_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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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.permissions.nil? || Merge::Filestorage::FileRequestPermissions.validate_raw(obj: obj.permissions)
  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.&.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

Returns:

  • (String)


148
149
150
# File 'lib/merge_ruby_client/filestorage/types/file_request.rb', line 148

def to_json(*_args)
  @_field_set&.to_json
end