bugsnag-api 1.0.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -3
  3. data/CHANGELOG.md +32 -0
  4. data/CONTRIBUTING.md +40 -0
  5. data/README.md +126 -111
  6. data/bugsnag-api.gemspec +4 -3
  7. data/lib/bugsnag/api/client.rb +18 -9
  8. data/lib/bugsnag/api/client/collaborators.rb +87 -0
  9. data/lib/bugsnag/api/client/comments.rb +31 -40
  10. data/lib/bugsnag/api/client/currentuser.rb +33 -0
  11. data/lib/bugsnag/api/client/errors.rb +45 -51
  12. data/lib/bugsnag/api/client/eventfields.rb +50 -0
  13. data/lib/bugsnag/api/client/events.rb +38 -32
  14. data/lib/bugsnag/api/client/organizations.rb +46 -0
  15. data/lib/bugsnag/api/client/pivots.rb +43 -0
  16. data/lib/bugsnag/api/client/projects.rb +37 -63
  17. data/lib/bugsnag/api/client/trends.rb +38 -0
  18. data/lib/bugsnag/api/error.rb +4 -0
  19. data/lib/bugsnag/api/version.rb +1 -1
  20. data/spec/bugsnag/api/client/collaborators_spec.rb +101 -0
  21. data/spec/bugsnag/api/client/comments_spec.rb +42 -30
  22. data/spec/bugsnag/api/client/currentuser_spec.rb +57 -0
  23. data/spec/bugsnag/api/client/errors_spec.rb +44 -41
  24. data/spec/bugsnag/api/client/eventfields_spec.rb +56 -0
  25. data/spec/bugsnag/api/client/events_spec.rb +41 -29
  26. data/spec/bugsnag/api/client/organizations_spec.rb +53 -0
  27. data/spec/bugsnag/api/client/pivots_spec.rb +49 -0
  28. data/spec/bugsnag/api/client/projects_spec.rb +35 -59
  29. data/spec/bugsnag/api/client/trends_spec.rb +44 -0
  30. data/spec/bugsnag/api/client_spec.rb +8 -3
  31. data/spec/cassettes/Bugsnag_Api_Client/_get/handles_query_params.yml +45 -27
  32. data/spec/cassettes/Bugsnag_Api_Client/_last_response/caches_the_last_agent_response.yml +45 -27
  33. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/_invitecollaborator/creates_and_returns_a_collaborator.yml +80 -0
  34. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/_invitecollaborator/invites_multiple_collaborators.yml +80 -0
  35. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborator/returns_a_collaborator.yml +157 -0
  36. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborators/returns_a_list_of_all_organization_collaborators.yml +160 -0
  37. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborators/returns_a_list_of_all_project_collaborators.yml +160 -0
  38. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_collaborators/throws_an_argument_error_if_neither_org_id_or_project_id_are_provided.yml +80 -0
  39. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_delete_collaborator/deletes_a_collaborator.yml +80 -0
  40. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_update_collaborator_permissions/updates_and_returns_the_collaborator.yml +157 -0
  41. data/spec/cassettes/Bugsnag_Api_Client_Collaborators/given_a_collaborator_exists/_view_collaborator_projects/returns_a_list_of_projects_belonging_to_the_collaborator.yml +159 -0
  42. data/spec/cassettes/Bugsnag_Api_Client_Comments/_create_comment/creates_a_comment_on_the_error.yml +82 -0
  43. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_comment/retrieves_the_comment_specified.yml +159 -0
  44. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_comments/retrieves_all_comments_on_an_error.yml +161 -0
  45. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_delete_comment/deletes_the_comment_and_returns_true.yml +82 -0
  46. data/spec/cassettes/Bugsnag_Api_Client_Comments/given_a_comment_has_been_created/_update_comment/updates_the_message_on_a_comment.yml +159 -0
  47. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_organizations/when_using_auth_token/returns_the_organization_the_auth_token_belongs_to.yml +81 -0
  48. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_organizations/when_using_user_credentials/returns_users_organizations.yml +85 -0
  49. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_projects/when_using_auth_token/lists_current_user_s_projects_in_the_organization.yml +82 -0
  50. data/spec/cassettes/Bugsnag_Api_Client_CurrentUser/_list_projects/when_using_user_credentials/lists_current_user_s_projects_in_the_organization.yml +86 -0
  51. data/spec/cassettes/Bugsnag_Api_Client_Errors/_error/returns_a_single_error.yml +82 -0
  52. data/spec/cassettes/Bugsnag_Api_Client_Errors/_errors/returns_errors_on_the_project.yml +84 -0
  53. data/spec/cassettes/Bugsnag_Api_Client_Errors/_update_errors/updates_and_returns_the_updated_errors.yml +80 -0
  54. data/spec/cassettes/Bugsnag_Api_Client_Events/_error_events/lists_all_error_events.yml +84 -0
  55. data/spec/cassettes/Bugsnag_Api_Client_Events/_event/returns_the_specified_event.yml +253 -0
  56. data/spec/cassettes/Bugsnag_Api_Client_Events/_events/returns_the_a_list_of_project_errors.yml +84 -0
  57. data/spec/cassettes/Bugsnag_Api_Client_Events/_latest_event/returns_the_last_event_on_an_error.yml +253 -0
  58. data/spec/cassettes/Bugsnag_Api_Client_Organizations/_create_organization/creates_a_new_organization.yml +84 -0
  59. data/spec/cassettes/Bugsnag_Api_Client_Organizations/with_organization/_delete_organization/deletes_the_organization.yml +159 -0
  60. data/spec/cassettes/Bugsnag_Api_Client_Organizations/with_organization/_organization/returns_the_requested_organization.yml +165 -0
  61. data/spec/cassettes/Bugsnag_Api_Client_Organizations/with_organization/_update_organization/updates_and_returns_the_organization.yml +165 -0
  62. data/spec/cassettes/Bugsnag_Api_Client_Projects/_create_project/creates_a_new_project.yml +80 -0
  63. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_delete_project/deletes_the_project.yml +151 -0
  64. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_project/returns_the_requested_project.yml +157 -0
  65. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_regenerate_api_key/removes_the_current_api_key_and_replaces_it_with_a_new_api_key.yml +157 -0
  66. data/spec/cassettes/Bugsnag_Api_Client_Projects/given_a_project/_update_project/updates_and_returns_the_project.yml +157 -0
  67. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_buckets/returns_a_list_of_error_trends_in_bucket_form.yml +80 -0
  68. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_buckets/returns_a_list_of_project_trends_in_bucket_form.yml +80 -0
  69. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_resolution/returns_a_list_of_project_trends_in_resolution_form.yml +80 -0
  70. data/spec/cassettes/Bugsnag_Api_Client_Trends/_trends_resolution/returns_a_list_of_trends_in_resolution_form.yml +80 -0
  71. data/spec/spec_helper.rb +29 -27
  72. metadata +124 -83
  73. data/lib/bugsnag/api/client/accounts.rb +0 -44
  74. data/lib/bugsnag/api/client/users.rb +0 -99
  75. data/spec/bugsnag/api/client/accounts_spec.rb +0 -45
  76. data/spec/bugsnag/api/client/users_spec.rb +0 -105
  77. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_account/returns_the_requested_account.yml +0 -49
  78. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_account/when_using_account_credentials/returns_the_account.yml +0 -51
  79. data/spec/cassettes/Bugsnag_Api_Client_Accounts/_accounts/returns_all_accounts.yml +0 -49
  80. data/spec/cassettes/Bugsnag_Api_Client_Comments/_comments/returns_all_comments_on_an_error.yml +0 -107
  81. data/spec/cassettes/Bugsnag_Api_Client_Comments/_create_comment/created_a_comment.yml +0 -51
  82. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_comment/returns_a_comment.yml +0 -97
  83. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_delete_comment/deletes_an_existing_comment.yml +0 -92
  84. data/spec/cassettes/Bugsnag_Api_Client_Comments/with_comment/_update_comment/updates_an_existing_comment.yml +0 -97
  85. data/spec/cassettes/Bugsnag_Api_Client_Errors/_errors/returns_all_errors_on_an_project.yml +0 -48
  86. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_error/returns_an_error.yml +0 -48
  87. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_reopen_error/reopens_the_error.yml +0 -48
  88. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_resolve_error/resolves_the_error.yml +0 -48
  89. data/spec/cassettes/Bugsnag_Api_Client_Errors/with_error/_update_error/updates_the_error.yml +0 -48
  90. data/spec/cassettes/Bugsnag_Api_Client_Events/_error_events/returns_all_events_on_an_error.yml +0 -64
  91. data/spec/cassettes/Bugsnag_Api_Client_Events/_project_events/returns_all_events_on_a_project.yml +0 -64
  92. data/spec/cassettes/Bugsnag_Api_Client_Events/with_event/_event/returns_an_event.yml +0 -56
  93. data/spec/cassettes/Bugsnag_Api_Client_Projects/_account_projects/returns_all_projects_on_an_account.yml +0 -61
  94. data/spec/cassettes/Bugsnag_Api_Client_Projects/_account_projects/when_using_account_credentials/returns_all_projects.yml +0 -63
  95. data/spec/cassettes/Bugsnag_Api_Client_Projects/_create_project/creates_a_project_on_an_account.yml +0 -50
  96. data/spec/cassettes/Bugsnag_Api_Client_Projects/_user_projects/returns_all_projects_for_a_user.yml +0 -61
  97. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_delete_project/deletes_an_existing_project.yml +0 -91
  98. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_project/returns_a_project.yml +0 -95
  99. data/spec/cassettes/Bugsnag_Api_Client_Projects/with_project/_update_project/updates_an_existing_project.yml +0 -95
  100. data/spec/cassettes/Bugsnag_Api_Client_Users/_account_users/returns_all_users_on_an_account.yml +0 -49
  101. data/spec/cassettes/Bugsnag_Api_Client_Users/_account_users/when_using_account_credentials/returns_all_users.yml +0 -51
  102. data/spec/cassettes/Bugsnag_Api_Client_Users/_invite_user/invites_a_user_to_an_account.yml +0 -48
  103. data/spec/cassettes/Bugsnag_Api_Client_Users/_project_users/returns_all_users_for_a_project.yml +0 -49
  104. data/spec/cassettes/Bugsnag_Api_Client_Users/_user/returns_a_user.yml +0 -48
  105. data/spec/cassettes/Bugsnag_Api_Client_Users/_user/when_using_user_credentials/returns_the_authed_user.yml +0 -48
  106. data/spec/cassettes/Bugsnag_Api_Client_Users/with_user/_remove_user/removes_a_user_from_an_account.yml +0 -89
  107. data/spec/cassettes/Bugsnag_Api_Client_Users/with_user/_update_user_permissions/updates_a_users_permissions.yml +0 -93
@@ -18,13 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "sawyer", '>= 0.5.3'
21
+ spec.add_dependency "sawyer", '~> 0.8.1'
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "webmock"
27
- spec.add_development_dependency "faker"
26
+ spec.add_development_dependency "webmock", RUBY_VERSION <= '2.0.0' ? '2.3.2': '>2.3.2'
27
+ spec.add_development_dependency "addressable", RUBY_VERSION <= '2.0.0' ? '2.3.6': '>2.3.6'
28
+ spec.add_development_dependency "faker", RUBY_VERSION <= '2.0.0' ? '1.3.0' : '>1.7.3'
28
29
  spec.add_development_dependency "vcr", "~> 2.9"
29
30
  spec.add_development_dependency "json"
30
31
  end
@@ -1,25 +1,33 @@
1
1
  require "sawyer"
2
2
 
3
- require "bugsnag/api/client/accounts"
4
- require "bugsnag/api/client/comments"
3
+ require "bugsnag/api/client/organizations"
4
+ require "bugsnag/api/client/collaborators"
5
+ require "bugsnag/api/client/projects"
6
+ require "bugsnag/api/client/eventfields"
7
+ require "bugsnag/api/client/currentuser"
5
8
  require "bugsnag/api/client/errors"
6
9
  require "bugsnag/api/client/events"
7
- require "bugsnag/api/client/projects"
8
- require "bugsnag/api/client/users"
10
+ require "bugsnag/api/client/pivots"
11
+ require "bugsnag/api/client/trends"
12
+ require "bugsnag/api/client/comments"
9
13
 
10
14
  module Bugsnag
11
15
  module Api
12
16
 
13
17
  # Client for the Bugsnag API
14
18
  #
15
- # @see https://bugsnag.com/docs/api
19
+ # @see http://docs.bugsnagapiv2.apiary.io/
16
20
  class Client
17
- include Bugsnag::Api::Client::Accounts
18
- include Bugsnag::Api::Client::Comments
21
+ include Bugsnag::Api::Client::Organizations
22
+ include Bugsnag::Api::Client::Collaborators
23
+ include Bugsnag::Api::Client::Projects
24
+ include Bugsnag::Api::Client::EventFields
25
+ include Bugsnag::Api::Client::CurrentUser
19
26
  include Bugsnag::Api::Client::Errors
20
27
  include Bugsnag::Api::Client::Events
21
- include Bugsnag::Api::Client::Projects
22
- include Bugsnag::Api::Client::Users
28
+ include Bugsnag::Api::Client::Pivots
29
+ include Bugsnag::Api::Client::Trends
30
+ include Bugsnag::Api::Client::Comments
23
31
 
24
32
  # Header keys that can be passed in options hash to {#get},{#head}
25
33
  CONVENIENCE_HEADERS = Set.new([:accept, :content_type])
@@ -140,6 +148,7 @@ module Bugsnag
140
148
  def agent
141
149
  @agent ||= Sawyer::Agent.new(configuration.endpoint, sawyer_options) do |http|
142
150
  http.headers[:content_type] = "application/json"
151
+ http.headers[:'X-Version'] = "2"
143
152
  http.headers[:user_agent] = configuration.user_agent
144
153
 
145
154
  if basic_authenticated?
@@ -0,0 +1,87 @@
1
+ module Bugsnag
2
+ module Api
3
+ class Client
4
+
5
+ # Methods for the Organizations Collaborators API
6
+ #
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/collaborators
8
+ module Collaborators
9
+ # View a Collaborator
10
+ #
11
+ # @return [Sawyer::Resource] Collaborator
12
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/collaborators/view-a-collaborator
13
+ def collaborator(org_id, collaborator_id, options = {})
14
+ get "organizations/#{org_id}/collaborators/#{collaborator_id}", options
15
+ end
16
+
17
+ # List Collaborators
18
+ #
19
+ # @argument project_id [String] ID of project to get collaborators from (conflicts with org_id)
20
+ # @argument org_id [String] ID of organization to get collaborators from (conflicts with project_id)
21
+ #
22
+ # @option per_page [Number] Amount of results per-page
23
+ # @return [Array<Sawyer::Resource>] List of Collaborators
24
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/collaborators/list-collaborators
25
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/collaborators/list-collaborators-on-a-project
26
+ def collaborators(org_id = nil, project_id = nil, options = {})
27
+ if !org_id.nil?
28
+ paginate "organizations/#{org_id}/collaborators", options
29
+ elsif !project_id.nil?
30
+ paginate "projects/#{project_id}/collaborators", options
31
+ else
32
+ raise ArgumentError, "Must supply either an org_id or a project_id"
33
+ end
34
+ end
35
+
36
+ # Invite Collaborators
37
+ #
38
+ # @argument emails [(Array<String>/String)] A (list of emails/singular email) to invite
39
+ #
40
+ # @option project_ids [Array<String>] The ids in the organization the user(s) should have access to
41
+ # @option admin [Boolean] Whether to give admin permissions. Admins have access to all projects
42
+ # @return [Array<Sawyer::Resource>] Collaborator details
43
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/collaborators/bulk-invite-collaborators
44
+ def invite_collaborators(org_id, emails, options = {})
45
+ case emails
46
+ when String
47
+ post "organizations/#{org_id}/collaborators", options.merge({:email => emails})
48
+ when Array
49
+ post "organizations/#{org_id}/collaborators/bulk_invite", options.merge({:emails => emails})
50
+ else
51
+ raise ArgumentError, "Emails must be a String or an Array"
52
+ end
53
+ end
54
+
55
+ # Update a Collaborator's permissions
56
+ #
57
+ # @option project_ids [Array<String>] Ids in the organziation the user should have access to
58
+ # @option admin [Boolean] Whether to give admin permissions. Admins have access to all projects
59
+ # @return [Sawyer::Resource] Collaborator details
60
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/collaborators/update-a-collaborator's-permissions
61
+ def update_collaborator_permissions(org_id, id, options = {})
62
+ patch "organizations/#{org_id}/collaborators/#{id}", options
63
+ end
64
+
65
+ # Delete a Collaborator
66
+ #
67
+ # @return
68
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/collaborators/delete-a-collaborator
69
+ def delete_collaborator(org_id, id, options = {})
70
+ boolean_from_response :delete, "organizations/#{org_id}/collaborators/#{id}", options
71
+ end
72
+
73
+ # View Projects a Collaborator has access to
74
+ #
75
+ # @option sort [String] Which field to sort the results by. Possible values: created_at
76
+ # @option direction [String] Which direction to sort the results by. Possible values: asc, desc
77
+ # @option per_page [Number] Number of results per page
78
+ # @return [Array<Sawyer::Resource>] A list of projects the collaborator belongs to
79
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/organizations/collaborators/view-projects-a-collaborator-has-access-to
80
+ def view_collaborator_projects(org_id, id, options = {})
81
+ paginate "organizations/#{org_id}/collaborators/#{id}/projects", options
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+
@@ -2,61 +2,52 @@ module Bugsnag
2
2
  module Api
3
3
  class Client
4
4
 
5
- # Methods for the Comments API
5
+ # Methods for the Errors API
6
6
  #
7
- # @see https://bugsnag.com/docs/api/comments
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/comments
8
8
  module Comments
9
- # List an error's comments
9
+ # List Comments on an Error
10
10
  #
11
- # @param error [String] Bugsnag error for which to list comments
12
- # @return [Array<Sawyer::Resource>] List of comments
13
- # @see https://bugsnag.com/docs/api/comments#list-an-error-s-comments
14
- # @example
15
- # Bugsnag::Api.comments("515fb9337c1074f6fd000009")
16
- def comments(error, options = {})
17
- paginate "errors/#{error}/comments", options
11
+ # @option offset [Number] The pagination offset (not required for general use)
12
+ # @option sort [String] Comments are only sortable by creation time e.g. "created_at"
13
+ # @option direction [String] Which direction to sort the result by, one of: asc, desc
14
+ # @option per_page [Number] How many results to return per page
15
+ # @return [Array<Sawyer::Resource>] List of Error Comments
16
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/comments/list-comments-on-an-error
17
+ def comments(project_id, error_id, options = {})
18
+ paginate "projects/#{project_id}/errors/#{error_id}/comments", options
18
19
  end
19
20
 
20
- # Get a single comment
21
+ # View an Comment
21
22
  #
22
- # @param comment [String] A Bugsnag comment ID
23
- # @return [Sawyer::Resource] The comment you requested, if it exists
24
- # @see https://bugsnag.com/docs/api/comments#get-comment-details
25
- # @example
26
- # Bugsnag::Api.comment("50baed119bf39c1431000004")
27
- def comment(comment, options = {})
28
- get "comments/#{comment}", options
23
+ # @return [Sawyer::Resource] Requested Comment
24
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/comments/view-a-comment
25
+ def comment(id, options = {})
26
+ get "comments/#{id}", options
29
27
  end
30
28
 
31
- # Create a comment
29
+ # Create a Comment on an Error
32
30
  #
33
- # @param error [String] The Bugsnag error to create the comment on
34
- # @option message [String] The comment's message
35
- # @see https://bugsnag.com/docs/api/comments#create-a-comment
36
- # @example
37
- # Bugsnag::Api.create_comment("515fb9337c1074f6fd000009", message: "Oops!")
38
- def create_comment(error, message, options = {})
39
- post "errors/#{error}/comments", options.merge({:message => message})
31
+ # @return [Sawyer::Resource] The new Comment
32
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/comments/create-a-comment-on-an-error
33
+ def create_comment(project_id, error_id, message, options = {})
34
+ post "projects/#{project_id}/errors/#{error_id}/comments", options.merge({:message => message})
40
35
  end
41
36
 
42
- # Update a comment
37
+ # Update a Comment
43
38
  #
44
- # @param error [String] The Bugsnag comment to update
45
- # @return [Sawyer::Resource] The updated comment
46
- # @see https://bugsnag.com/docs/api/comments#update-a-comment
47
- # @example
48
- # Bugsnag::Api.update_comment("50baed119bf39c1431000004", message: "Fixed!")
49
- def update_comment(comment, message, options = {})
50
- patch "comments/#{comment}", options.merge({:message => message})
39
+ # @return [Sawyer::Resource] The updated Comment
40
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/comments/update-a-comment
41
+ def update_comment(id, message, options = {})
42
+ patch "comments/#{id}", options.merge({:message => message})
51
43
  end
52
44
 
53
- # Delete a comment
45
+ # Delete a Comment
54
46
  #
55
- # @param comment [String] The Bugsnag comment to delete
56
- # @return [Boolean] `true` if comment was deleted
57
- # @see https://bugsnag.com/docs/api/comments#delete-a-comment
58
- def delete_comment(comment, options = {})
59
- boolean_from_response :delete, "comments/#{comment}", options
47
+ # @return
48
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/comments/delete-a-comment
49
+ def delete_comment(id, options = {})
50
+ boolean_from_response :delete, "comments/#{id}", options
60
51
  end
61
52
  end
62
53
  end
@@ -0,0 +1,33 @@
1
+ module Bugsnag
2
+ module Api
3
+ class Client
4
+
5
+ # Methods for theCurrent User API
6
+ #
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/current-user
8
+ module CurrentUser
9
+ # List the Current User's Organizations
10
+ #
11
+ # @option admin [Boolean] If only Organizations the user is an admin of should be returned
12
+ # @option per_page [Number] Number of results to return per-page
13
+ # @return [Array<Sawyer::Resource>] List of Organizations
14
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/current-user/organizations/list-the-current-user's-organizations
15
+ def organizations(options = {})
16
+ paginate "user/organizations", options
17
+ end
18
+
19
+ # List the Current User's Projects
20
+ #
21
+ # @option sort [String] Which field to sort the results by, one of: created_at
22
+ # @option direction [String] Which direction to sort the results by, on of: asc, desc
23
+ # @option per_page [Number] Number of results to return per-page
24
+ # @return [Array<Sawyer::Resource>] List of Projects
25
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/current-user/organizations/list-the-current-user's-projects
26
+ def projects(org_id, options = {})
27
+ paginate "organizations/#{org_id}/projects", options
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
@@ -4,72 +4,66 @@ module Bugsnag
4
4
 
5
5
  # Methods for the Errors API
6
6
  #
7
- # @see https://bugsnag.com/docs/api/errors
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors
8
8
  module Errors
9
- # List a project's errors
9
+ # List the Errors on a Project
10
10
  #
11
- # @param project [String] Bugsnag project for which to list errors
12
- # @return [Array<Sawyer::Resource>] List of errors
13
- # @see https://bugsnag.com/docs/api/errors#list-a-project-s-errors
14
- # @example
15
- # Bugsnag::Api.errors("50baed119bf39c1431000004")
16
- def errors(project, options = {})
17
- paginate "projects/#{project}/errors", options
11
+ # @option base [String] Only Error Events occuring before this time will be returned
12
+ # @option sort [String] Which field to sort by, one of: last_seen, first_seen, users, events, unsorted
13
+ # @option direction [String] Which direction to sort the result by, one of: asc, desc
14
+ # @option filters [Filters] An optional filters object, see http://docs.bugsnagapiv2.apiary.io/#introduction/filtering
15
+ # @return [Array<Sawyer::Resource>] List of Project Errors
16
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/errors/list-the-errors-on-a-project
17
+ def errors(project_id, id=nil, options = {})
18
+ paginate "projects/#{project_id}/errors", options
18
19
  end
19
20
 
20
- # Get a single error
21
+ # View an Error
21
22
  #
22
- # @param error [String] A Bugsnag error
23
- # @return [Sawyer::Resource] The error you requested, if it exists
24
- # @see https://bugsnag.com/docs/api/errors#get-error-details
25
- # @example
26
- # Bugsnag::Api.error("518031bcd775355c48a1cd4e")
27
- def error(error, options = {})
28
- get "errors/#{error}", options
23
+ # @return [Sawyer::Resource] Requested Error
24
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/errors/view-an-error
25
+ def error(project_id, id, options = {})
26
+ get "projects/#{project_id}/errors/#{id}", options
29
27
  end
30
28
 
31
- # Resolve an error
29
+ # Update an Error
32
30
  #
33
- # @param error [String] A Bugsnag error
34
- # @return [Sawyer::Resource] The updated error
35
- # @see https://bugsnag.com/docs/api/errors#update-an-error-s-status
36
- # @example
37
- # Bugsnag::Api.resolve_error("518031bcd775355c48a1cd4e")
38
- def resolve_error(error, options = {})
39
- patch "errors/#{error}", options.merge({:resolved => true})
40
- end
41
-
42
- # Re-open an error
31
+ # @argument ids [(Array<String>/String)] An Id, or array of Ids to update
43
32
  #
44
- # @param error [String] A Bugsnag error
45
- # @return [Sawyer::Resource] The updated error
46
- # @see https://bugsnag.com/docs/api/errors#update-an-error-s-status
47
- # @example
48
- # Bugsnag::Api.reopen_error("518031bcd775355c48a1cd4e")
49
- def reopen_error(error, options = {})
50
- patch "errors/#{error}", options.merge({:resolved => false})
33
+ # @option severity [String] The Error's new severity. One of: info, warning, error
34
+ # @option assigned_collaborator_id [String] THe collaborator to assign to the Error
35
+ # @option issue_url [String] Updates to link to an existing 3rd party issue
36
+ # @option issue_title [String] Updates the issues title
37
+ # @option reopen_rules [Object] Snooze rules for automatically reopening the Error
38
+ # @return [Sawyer::Resource] Updated Error
39
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/errors/update-an-error
40
+ def update_errors(project_id, ids, operation, options = {})
41
+ case ids
42
+ when String
43
+ patch "projects/#{project_id}/errors/#{ids}", options.merge({:operation => operation})
44
+ when Array
45
+ patch "projects/#{project_id}/errors", options.merge({:operation => operation, :query => {:error_ids => ids.join(' ')}})
46
+ else
47
+ raise ArgumentError, "ids must be a String or an Array"
48
+ end
51
49
  end
52
50
 
53
- # Update an error
51
+ # Delete an Error
54
52
  #
55
- # @param error [String] A Bugsnag error
56
- # @return [Sawyer::Resource] The updated error
57
- # @see https://bugsnag.com/docs/api/errors#update-an-error-s-status
58
- # @example
59
- # Bugsnag::Api.update_error("518031bcd775355c48a1cd4e")
60
- def update_error(error, options = {})
61
- patch "errors/#{error}", options
62
- end
63
-
64
- # Delete an error
53
+ # @argument error_id [String] ID of error to delete (conflicts with project_id)
54
+ # @argument project_id [String] Id of project to delete all errors from (conflicts with error_id)
65
55
  #
66
- # @param error [String] A Bugsnag error
67
- # @return [Boolean] `true` if error was deleted
68
- # @see https://bugsnag.com/docs/api/errors#delete-an-error
69
- def delete_error(error, options = {})
70
- boolean_from_response :delete, "errors/#{error}", options
56
+ # @return
57
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/errors/errors/delete-an-error
58
+ def delete_errors(project_id, error_id=nil, options = {})
59
+ if !error_id.nil?
60
+ boolean_from_response :delete, "projects/#{project_id}/errors/#{error_id}", options
61
+ else
62
+ boolean_from_response :delete, "projects/#{project_id}/errors", options
63
+ end
71
64
  end
72
65
  end
73
66
  end
74
67
  end
75
68
  end
69
+
@@ -0,0 +1,50 @@
1
+ module Bugsnag
2
+ module Api
3
+ class Client
4
+
5
+ # Methods for the Project Event Fields API
6
+ #
7
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields
8
+ module EventFields
9
+ # List the Event Fields for a Project
10
+ #
11
+ # @option per_page []Number] Number of results required per page
12
+ # @return [Array<Sawyer::Resource>] List of event fields
13
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields/list-the-event-fields-for-a-project
14
+ def event_fields(project_id, options = {})
15
+ paginate "projects/#{project_id}/event_fields", options
16
+ end
17
+
18
+ # Create a custom Event Field
19
+ #
20
+ # @option reindex [Boolean] Whether to reindex historical events
21
+ # @option pivot_options [Object] Configuration for how this field will appear in pivots
22
+ # @return [Sawyer::Resource] New Event Field
23
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields/create-a-custom-event-field
24
+ def create_event_field(project_id, display_id, path, filter_options, options = {})
25
+ post "projects/#{project_id}/event_fields", options.merge({:display_id => display_id, :path => path, :filter_options => filter_options})
26
+ end
27
+
28
+ # Update a custom Event Field
29
+ #
30
+ # @option reindex [Boolean] Whether to reindex historical events
31
+ # @option filter_options [Object] Configuration for how the field will appear in the Filter Bar
32
+ # @option pivot_options [Object] Configuration for how this field will appear in pivots
33
+ # @return [Sawyer::Resource] Updated Event Field
34
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields/update-a-custom-event-field
35
+ def update_event_field(project_id, display_id, path, options = {})
36
+ patch "projects/#{id}/event_fields/#{display_id}", options.merge({:display_id => display_id, :path => path})
37
+ end
38
+
39
+ # Delete a custom Event Field
40
+ #
41
+ # @return
42
+ # @see http://docs.bugsnagapiv2.apiary.io/#reference/projects/event-fields/delete-a-custom-event-field
43
+ def delete_event_field(project_id, display_id, options = {})
44
+ boolean_from_resposne :delete, "project/#{project_id}/event_fields/#{display_id}", options
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+