Sha256: 2f39b19dbc4269baeb09ac6f02097bd1b67c75271a1d8199f8ea4300a3b02180

Contents?: true

Size: 1.32 KB

Versions: 3

Compression:

Stored size: 1.32 KB

Contents

module Bugsnag
  module Api
    class Client

      # Methods for the Accounts API
      #
      # @see https://bugsnag.com/docs/api/accounts
      module Accounts
        # List your accounts
        #
        # @return [Array<Sawyer::Resource>] List of users
        # @see https://bugsnag.com/docs/api/accounts#list-your-accounts
        # @example
        #   Bugsnag::Api.accounts
        def accounts(options = {})
          paginate "accounts", options
        end

        # Get a single account
        #
        # @param account [String] Bugsnag account id
        # @return [Sawyer::Resource]
        # @see https://bugsnag.com/docs/api/accounts#get-the-authenticated-account
        # @see https://bugsnag.com/docs/api/accounts#get-account-details
        # @example
        #   Bugsnag::Api.account("515fb9337c1074f6fd000009")
        def account(account=nil, options = {})
          if account.nil? || account.is_a?(Hash)
            options = account || {}

            raise Bugsnag::Api::AccountCredentialsRequired.new(
              "Fetching account without an id is only possible when using "\
              "an account auth token."
            ) unless token_authenticated?

            get "account", options
          else
            get "accounts/#{account}", options
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bugsnag-api-1.0.3 lib/bugsnag/api/client/accounts.rb
bugsnag-api-1.0.2 lib/bugsnag/api/client/accounts.rb
bugsnag-api-1.0.1 lib/bugsnag/api/client/accounts.rb