Sha256: df221ff7e52c9df81aa1b95991f7dd39196156a77ca3aa7c9028cce13d5de259

Contents?: true

Size: 1.99 KB

Versions: 15

Compression:

Stored size: 1.99 KB

Contents

module Auth0
  module Api
    module V2
      module Grants
        attr_reader :grants_path

        # Retrieve the grants associated with your account.
        # @see https://auth0.com/docs/api/management/v2#!/Grants/get_grants
        # @param client_id [string] The client_id of the grants to retrieve.
        # @param user_id [string]  The user_id of the grants to retrieve.
        # @param audience [string] The audience of the grants to retrieve.
        # @param page [int] The page index of the results to return. First page is 0.
        # @param per_page [int] The number of results per page. Paging is disabled if parameter not sent.
        # @param include_totals [boolean] Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).
        # @return [json] Returns the grants.
        def grants(client_id: nil, user_id: nil, audience: nil, page: nil, per_page: nil, include_totals: nil)
          request_params = {
            client_id: client_id,
            user_id: user_id,
            audience: audience,
            page: page,
            per_page: per_page,
            include_totals: include_totals
          }
          get(grants_path, request_params)
        end
        alias get_all_grants grants

        # Delete a grant associated with your account.
        # @see https://auth0.com/docs/api/management/v2#!/Grants/delete_grants_by_id
        # @param id [string] The id of the grant to delete.
        # @param user_id [string] The user_id of the grant to delete.
        def delete_grant(id, user_id)
          raise Auth0::InvalidParameter, 'Must specify a grant id as id' if id.to_s.empty?
          raise Auth0::InvalidParameter, 'Must specify a user id' if user_id.to_s.empty?
          path = "#{grants_path}/#{id}"
          delete(path, user_id: user_id)
        end

        private

        # Grants API path
        def grants_path
          @grants_path ||= '/api/v2/grants'
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
auth0-5.18.0 lib/auth0/api/v2/grants.rb
auth0-5.16.0 lib/auth0/api/v2/grants.rb
auth0-5.15.0 lib/auth0/api/v2/grants.rb
auth0-5.14.2 lib/auth0/api/v2/grants.rb
auth0-5.14.1 lib/auth0/api/v2/grants.rb
auth0-5.14.0 lib/auth0/api/v2/grants.rb
auth0-5.13.0 lib/auth0/api/v2/grants.rb
auth0-5.12.0 lib/auth0/api/v2/grants.rb
auth0-5.11.0 lib/auth0/api/v2/grants.rb
auth0-5.10.0 lib/auth0/api/v2/grants.rb
auth0-5.9.0 lib/auth0/api/v2/grants.rb
auth0-5.8.1 lib/auth0/api/v2/grants.rb
auth0-5.8.0 lib/auth0/api/v2/grants.rb
auth0-5.7.0 lib/auth0/api/v2/grants.rb
auth0-5.6.1 lib/auth0/api/v2/grants.rb