Class: Merge::Filestorage::PermissionRequest

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

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • remote_id (String) (defaults to: OMIT)

    The third-party API ID of the matching object.

  • user (Merge::Filestorage::PermissionRequestUser) (defaults to: OMIT)

    The user that is granted this permission.

  • group (Merge::Filestorage::PermissionRequestGroup) (defaults to: OMIT)

    The group that is granted this permission.

  • type (Merge::Filestorage::TypeEnum) (defaults to: OMIT)

    Denotes what type of people have access to the file.

    • ‘USER` - USER

    • ‘GROUP` - GROUP

    • ‘COMPANY` - COMPANY

    • ‘ANYONE` - ANYONE

  • roles (Array<Merge::Filestorage::RolesEnum>) (defaults to: OMIT)

    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.

  • 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
# 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 =  if  != 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": 
  }.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



42
43
44
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 42

def additional_properties
  @additional_properties
end

#groupMerge::Filestorage::PermissionRequestGroup (readonly)

Returns The group that is granted this permission.

Returns:



25
26
27
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 25

def group
  @group
end

#integration_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


38
39
40
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 38

def integration_params
  @integration_params
end

#linked_account_paramsHash{String => Object} (readonly)

Returns:

  • (Hash{String => Object})


40
41
42
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 40

def 
  @linked_account_params
end

#remote_idString (readonly)

Returns The third-party API ID of the matching object.

Returns:

  • (String)

    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

#rolesArray<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.

Returns:

  • (Array<Merge::Filestorage::RolesEnum>)

    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

#typeMerge::Filestorage::TypeEnum (readonly)

Returns Denotes what type of people have access to the file.

  • ‘USER` - USER

  • ‘GROUP` - GROUP

  • ‘COMPANY` - COMPANY

  • ‘ANYONE` - ANYONE.

Returns:

  • (Merge::Filestorage::TypeEnum)

    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

#userMerge::Filestorage::PermissionRequestUser (readonly)

Returns The user that is granted this permission.

Returns:



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

Parameters:

  • json_object (String)

Returns:



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"]
   = 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: ,
    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)


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

Returns:

  • (String)


127
128
129
# File 'lib/merge_ruby_client/filestorage/types/permission_request.rb', line 127

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