lib/bugsnag/api/client/errors.rb in bugsnag-api-1.0.3 vs lib/bugsnag/api/client/errors.rb in bugsnag-api-2.0.0
- old
+ new
@@ -2,74 +2,68 @@
module Api
class Client
# Methods for the Errors API
#
- # @see https://bugsnag.com/docs/api/errors
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors
module Errors
- # List a project's errors
+ # List the Errors on a Project
#
- # @param project [String] Bugsnag project for which to list errors
- # @return [Array<Sawyer::Resource>] List of errors
- # @see https://bugsnag.com/docs/api/errors#list-a-project-s-errors
- # @example
- # Bugsnag::Api.errors("50baed119bf39c1431000004")
- def errors(project, options = {})
- paginate "projects/#{project}/errors", options
+ # @option base [String] Only Error Events occuring before this time will be returned
+ # @option sort [String] Which field to sort by, one of: last_seen, first_seen, users, events, unsorted
+ # @option direction [String] Which direction to sort the result by, one of: asc, desc
+ # @option filters [Filters] An optional filters object, see http://docs.bugsnagapiv2.apiary.io/#introduction/filtering
+ # @return [Array<Sawyer::Resource>] List of Project Errors
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/errors/list-the-errors-on-a-project
+ def errors(project_id, id=nil, options = {})
+ paginate "projects/#{project_id}/errors", options
end
- # Get a single error
+ # View an Error
#
- # @param error [String] A Bugsnag error
- # @return [Sawyer::Resource] The error you requested, if it exists
- # @see https://bugsnag.com/docs/api/errors#get-error-details
- # @example
- # Bugsnag::Api.error("518031bcd775355c48a1cd4e")
- def error(error, options = {})
- get "errors/#{error}", options
+ # @return [Sawyer::Resource] Requested Error
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/errors/view-an-error
+ def error(project_id, id, options = {})
+ get "projects/#{project_id}/errors/#{id}", options
end
- # Resolve an error
+ # Update an Error
#
- # @param error [String] A Bugsnag error
- # @return [Sawyer::Resource] The updated error
- # @see https://bugsnag.com/docs/api/errors#update-an-error-s-status
- # @example
- # Bugsnag::Api.resolve_error("518031bcd775355c48a1cd4e")
- def resolve_error(error, options = {})
- patch "errors/#{error}", options.merge({:resolved => true})
- end
-
- # Re-open an error
+ # @argument ids [(Array<String>/String)] An Id, or array of Ids to update
#
- # @param error [String] A Bugsnag error
- # @return [Sawyer::Resource] The updated error
- # @see https://bugsnag.com/docs/api/errors#update-an-error-s-status
- # @example
- # Bugsnag::Api.reopen_error("518031bcd775355c48a1cd4e")
- def reopen_error(error, options = {})
- patch "errors/#{error}", options.merge({:resolved => false})
+ # @option severity [String] The Error's new severity. One of: info, warning, error
+ # @option assigned_collaborator_id [String] THe collaborator to assign to the Error
+ # @option issue_url [String] Updates to link to an existing 3rd party issue
+ # @option issue_title [String] Updates the issues title
+ # @option reopen_rules [Object] Snooze rules for automatically reopening the Error
+ # @return [Sawyer::Resource] Updated Error
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/errors/update-an-error
+ def update_errors(project_id, ids, operation, options = {})
+ case ids
+ when String
+ patch "projects/#{project_id}/errors/#{ids}", options.merge({:operation => operation})
+ when Array
+ patch "projects/#{project_id}/errors", options.merge({:operation => operation, :query => {:error_ids => ids.join(' ')}})
+ else
+ raise ArgumentError, "ids must be a String or an Array"
+ end
end
- # Update an error
+ # Delete an Error
#
- # @param error [String] A Bugsnag error
- # @return [Sawyer::Resource] The updated error
- # @see https://bugsnag.com/docs/api/errors#update-an-error-s-status
- # @example
- # Bugsnag::Api.update_error("518031bcd775355c48a1cd4e")
- def update_error(error, options = {})
- patch "errors/#{error}", options
- end
-
- # Delete an error
+ # @argument error_id [String] ID of error to delete (conflicts with project_id)
+ # @argument project_id [String] Id of project to delete all errors from (conflicts with error_id)
#
- # @param error [String] A Bugsnag error
- # @return [Boolean] `true` if error was deleted
- # @see https://bugsnag.com/docs/api/errors#delete-an-error
- def delete_error(error, options = {})
- boolean_from_response :delete, "errors/#{error}", options
+ # @return
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/errors/delete-an-error
+ def delete_errors(project_id, error_id=nil, options = {})
+ if !error_id.nil?
+ boolean_from_response :delete, "projects/#{project_id}/errors/#{error_id}", options
+ else
+ boolean_from_response :delete, "projects/#{project_id}/errors", options
+ end
end
end
end
end
end
+
\ No newline at end of file