Class: Merge::Filestorage::PermissionRequest
- Inherits:
-
Object
- Object
- Merge::Filestorage::PermissionRequest
- Defined in:
- lib/merge_ruby_client/filestorage/types/permission_request.rb
Overview
# The Permission Object
### Description
The Permission object is used to represent a user's or group's access to a File
or Folder. Permissions are unexpanded by default.
### Usage Example
Fetch from the `GET Files` or `GET Folders` endpoint. Permissions are unexpanded
by default. Use the query param `expand=permissions` to see more details.
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#group ⇒ Merge::Filestorage::PermissionRequestGroup
readonly
The group that is granted this permission.
- #integration_params ⇒ Hash{String => Object} readonly
- #linked_account_params ⇒ Hash{String => Object} readonly
-
#remote_id ⇒ String
readonly
The third-party API ID of the matching object.
-
#roles ⇒ Array<Merge::Filestorage::RolesEnum>
readonly
The permissions that the user or group has for the File or Folder.
-
#type ⇒ Merge::Filestorage::TypeEnum
readonly
Denotes what type of people have access to the file.
-
#user ⇒ Merge::Filestorage::PermissionRequestUser
readonly
The user that is granted this permission.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Merge::Filestorage::PermissionRequest
Deserialize a JSON object to an instance of PermissionRequest.
-
.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(remote_id: OMIT, user: OMIT, group: OMIT, type: OMIT, roles: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Filestorage::PermissionRequest constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of PermissionRequest to a JSON object.
Constructor Details
#initialize(remote_id: OMIT, user: OMIT, group: OMIT, type: OMIT, roles: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) ⇒ Merge::Filestorage::PermissionRequest
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 65 def initialize(remote_id: OMIT, user: OMIT, group: OMIT, type: OMIT, roles: OMIT, integration_params: OMIT, linked_account_params: OMIT, additional_properties: nil) @remote_id = remote_id if remote_id != OMIT @user = user if user != OMIT @group = group if group != OMIT @type = type if type != OMIT @roles = roles if roles != 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 = { "remote_id": remote_id, "user": user, "group": group, "type": type, "roles": roles, "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.
42 43 44 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 42 def additional_properties @additional_properties end |
#group ⇒ Merge::Filestorage::PermissionRequestGroup (readonly)
Returns The group that is granted this permission.
25 26 27 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 25 def group @group end |
#integration_params ⇒ Hash{String => Object} (readonly)
38 39 40 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 38 def integration_params @integration_params end |
#linked_account_params ⇒ Hash{String => Object} (readonly)
40 41 42 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 40 def linked_account_params @linked_account_params end |
#remote_id ⇒ String (readonly)
Returns The third-party API ID of the matching object.
21 22 23 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 21 def remote_id @remote_id end |
#roles ⇒ Array<Merge::Filestorage::RolesEnum> (readonly)
Returns The permissions that the user or group has for the File or Folder. It is possible for a user or group to have multiple roles, such as viewing & uploading. Possible values include: ‘READ`, `WRITE`, `OWNER`. In cases where there is no clear mapping, the original value passed through will be returned.
36 37 38 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 36 def roles @roles end |
#type ⇒ Merge::Filestorage::TypeEnum (readonly)
Returns Denotes what type of people have access to the file.
-
‘USER` - USER
-
‘GROUP` - GROUP
-
‘COMPANY` - COMPANY
-
‘ANYONE` - ANYONE.
31 32 33 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 31 def type @type end |
#user ⇒ Merge::Filestorage::PermissionRequestUser (readonly)
Returns The user that is granted this permission.
23 24 25 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 23 def user @user end |
Class Method Details
.from_json(json_object:) ⇒ Merge::Filestorage::PermissionRequest
Deserialize a JSON object to an instance of PermissionRequest
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 92 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) remote_id = parsed_json["remote_id"] if parsed_json["user"].nil? user = nil else user = parsed_json["user"].to_json user = Merge::Filestorage::PermissionRequestUser.from_json(json_object: user) end if parsed_json["group"].nil? group = nil else group = parsed_json["group"].to_json group = Merge::Filestorage::PermissionRequestGroup.from_json(json_object: group) end type = parsed_json["type"] roles = parsed_json["roles"] integration_params = parsed_json["integration_params"] linked_account_params = parsed_json["linked_account_params"] new( remote_id: remote_id, user: user, group: group, type: type, roles: roles, 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.
137 138 139 140 141 142 143 144 145 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 137 def self.validate_raw(obj:) obj.remote_id&.is_a?(String) != false || raise("Passed value for field obj.remote_id is not the expected type, validation failed.") obj.user.nil? || Merge::Filestorage::PermissionRequestUser.validate_raw(obj: obj.user) obj.group.nil? || Merge::Filestorage::PermissionRequestGroup.validate_raw(obj: obj.group) obj.type&.is_a?(Merge::Filestorage::TypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.roles&.is_a?(Array) != false || raise("Passed value for field obj.roles is not the expected type, validation failed.") 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 PermissionRequest to a JSON object
127 128 129 |
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 127 def to_json(*_args) @_field_set&.to_json end |