Class: Nylas::Grants

Inherits:
Resource show all
Includes:
ApiOperations::Delete, ApiOperations::Get, ApiOperations::Post, ApiOperations::Put
Defined in:
lib/nylas/resources/grants.rb

Overview

Grants

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Nylas::Resource

Instance Method Details

#create(request_body) ⇒ Array(Hash, String)

Create a Grant via Custom Authentication.

Parameters:

  • request_body (Hash)

    The values to create the Grant with.

Returns:

  • (Array(Hash, String))

    Created grant and API Request ID.



39
40
41
42
43
44
# File 'lib/nylas/resources/grants.rb', line 39

def create(request_body)
  post(
    path: "#{api_uri}/v3/#{resource_name}/custom",
    request_body: request_body
  )
end

#destroy(grant_id:) ⇒ Array(TrueClass, String)

Delete a grant.

Parameters:

  • grant_id (String)

    The id of the grant to delete.

Returns:

  • (Array(TrueClass, String))

    True and the API Request ID for the delete operation.



62
63
64
65
66
67
68
# File 'lib/nylas/resources/grants.rb', line 62

def destroy(grant_id:)
  _, request_id = delete(
    path: "#{api_uri}/v3/grant/#{grant_id}"
  )

  [true, request_id]
end

#find(grant_id:) ⇒ Array(Hash, String)

Return a grant.

Parameters:

  • grant_id (String)

    The id of the grant to return.

Returns:

  • (Array(Hash, String))

    The grant and API request ID.



29
30
31
32
33
# File 'lib/nylas/resources/grants.rb', line 29

def find(grant_id:)
  get(
    path: "#{api_uri}/v3/grant/#{grant_id}"
  )
end

#list(query_params: nil) ⇒ Array(Array(Hash), String)

Return all grants.

Parameters:

  • query_params (Hash, nil) (defaults to: nil)

    Query params to pass to the request.

Returns:

  • (Array(Array(Hash), String))

    The list of grants and API Request ID.



18
19
20
21
22
23
# File 'lib/nylas/resources/grants.rb', line 18

def list(query_params: nil)
  get(
    path: "#{api_uri}/v3/grant",
    query_params: query_params
  )
end

#update(grant_id:, request_body:) ⇒ Array(Hash, String)

Update a grant.

Parameters:

  • grant_id (String)

    The id of the grant to update.

  • request_body (Hash)

    The values to update the grant with

Returns:

  • (Array(Hash, String))

    The updated grant and API Request ID.



51
52
53
54
55
56
# File 'lib/nylas/resources/grants.rb', line 51

def update(grant_id:, request_body:)
  put(
    path: "#{api_uri}/v3/grant/#{grant_id}",
    request_body: request_body
  )
end