lib/bugsnag/api/client/projects.rb in bugsnag-api-1.0.0 vs lib/bugsnag/api/client/projects.rb in bugsnag-api-1.0.1
- old
+ new
@@ -11,12 +11,23 @@
# @param account [String] Bugsnag account for which to list projects
# @return [Array<Sawyer::Resource>] List of projects
# @see https://bugsnag.com/docs/api/projects#list-an-account-s-projects
# @example
# Bugsnag::Api.projects("515fb9337c1074f6fd000009")
- def projects(account, options = {})
- paginate "accounts/#{account}/projects", options
+ def projects(account=nil, options = {})
+ if account.nil? || account.is_a?(Hash)
+ options = account || {}
+
+ raise Bugsnag::Api::AccountCredentialsRequired.new(
+ "Fetching projects without an account id is only possible when "\
+ "using an account auth token."
+ ) unless token_authenticated?
+
+ paginate "account/projects", options
+ else
+ paginate "accounts/#{account}/projects", options
+ end
end
alias :account_projects :projects
# List user projects
#
@@ -24,11 +35,11 @@
# @return [Array<Sawyer::Resource>] List of projects
# @see https://bugsnag.com/docs/api/projects#list-a-user-s-projects
# @example
# Bugsnag::Api.user_projects("515fb9337c1074f6fd000007")
def user_projects(user, options = {})
- paginate "user/#{user}/projects", options
+ paginate "users/#{user}/projects", options
end
# Get a single project
#
# @param project [String] A Bugsnag project
@@ -67,10 +78,10 @@
#
# @param project [String] A Bugsnag project
# @return [Boolean] `true` if project was deleted
# @see https://bugsnag.com/docs/api/projects#delete-a-project
def delete_project(project, options = {})
- delete "projects/#{project}", options
+ boolean_from_response :delete, "projects/#{project}", options
end
end
end
end
end