Sha256: 2c63a321ca33619f37dcf8752edaa46e07c2e75d76d47fa643faa14d46e78af6

Contents?: true

Size: 1.56 KB

Versions: 7

Compression:

Stored size: 1.56 KB

Contents

# frozen_string_literal: true

require_relative "resource"
require_relative "../handler/api_operations"

module Nylas
  # Grants
  class Grants < Resource
    include ApiOperations::Get
    include ApiOperations::Put
    include ApiOperations::Delete
    include ApiOperations::Patch

    # Return all grants.
    #
    # @param query_params [Hash, nil] Query params to pass to the request.
    # @return [Array(Array(Hash), String)] The list of grants and API Request ID.
    def list(query_params: nil)
      get(
        path: "#{api_uri}/v3/grants",
        query_params: query_params
      )
    end

    # Return a grant.
    #
    # @param grant_id [String] The id of the grant to return.
    # @return [Array(Hash, String)] The grant and API request ID.
    def find(grant_id:)
      get(
        path: "#{api_uri}/v3/grants/#{grant_id}"
      )
    end

    # Update a grant.
    #
    # @param grant_id [String] The id of the grant to update.
    # @param request_body [Hash] The values to update the grant with
    # @return [Array(Hash, String)] The updated grant and API Request ID.
    def update(grant_id:, request_body:)
      patch(
        path: "#{api_uri}/v3/grants/#{grant_id}",
        request_body: request_body
      )
    end

    # Delete a grant.
    #
    # @param grant_id [String] The id of the grant to delete.
    # @return [Array(TrueClass, String)] True and the API Request ID for the delete operation.
    def destroy(grant_id:)
      _, request_id = delete(
        path: "#{api_uri}/v3/grants/#{grant_id}"
      )

      [true, request_id]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nylas-6.2.2 lib/nylas/resources/grants.rb
nylas-6.2.1 lib/nylas/resources/grants.rb
nylas-6.2.0 lib/nylas/resources/grants.rb
nylas-6.1.1 lib/nylas/resources/grants.rb
nylas-6.1.0 lib/nylas/resources/grants.rb
nylas-6.0.3 lib/nylas/resources/grants.rb
nylas-6.0.2 lib/nylas/resources/grants.rb