bugsnag-api 1.0.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38210f947fe7a802478a17d8d7bcab1983636e22
4
- data.tar.gz: eb5853d05a110c15c84b5ce8de7f12aa7dd9cd74
3
+ metadata.gz: e8fd0a95aa272468057d81984b0b20d40fccc01c
4
+ data.tar.gz: 6ecdee5fb39a7095d847dfb16f8a8485323a4c27
5
5
  SHA512:
6
- metadata.gz: b5f2ad8d39158f717c4581af07fb83b535fa17ef28806ad795fef987c5df022afa23b8e72494b3ab0ba3a54a1fb6652f404ae52174fb1a0cbf75ef6fee7256dd
7
- data.tar.gz: 674a6f9e8721547608a2a42d72474d5a06f4cca2a80d519fa8bac4077b3d56eebd4dad66e61306dd49f79a9a23691b0cd4d1b0356ec4e0c86db9b141882ccd7d
6
+ metadata.gz: 5504fb4a05af47894bf86c740b81707ae8d445e5ed73255312de352b8f90ffef51ac8750102928c0053831ba331d87f2b87cc99fe47c6935012f9176136e795e
7
+ data.tar.gz: cde5fdecf9c29ac4dcc8defaa781d3d8c682a4fc1a57537a4b1044e48e3b89bda6f04cece86b753b27dd83a6bfd087b975c4537c3d7107b62d1ee0dd2c3d126a
@@ -1,9 +1,20 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.4.1
4
+ - 2.2.2
3
5
  - 2.1.0
4
6
  - 2.0.0
5
7
  - 1.9.3
6
- - jruby-18mode
7
8
  - jruby-19mode
8
- - 1.8.7
9
- - rbx-2
9
+
10
+ before_install:
11
+ - gem install bundler -v 1.12
12
+ - gem update --system
13
+ - bundle --version
14
+ - gem --version
15
+
16
+ install:
17
+ - bundle _1.12.0_ install --with "$GEMSETS"
18
+
19
+ script:
20
+ - bundle _1.12.0_ exec rake
@@ -1,6 +1,38 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ ## 2.0.0 (10 Oct 2017)
5
+
6
+ This release changes the gem to access v2 of the [Bugsnag data-access API](https://docs.bugsnag.com/api/data-access/), with full API documentation found [here](http://docs.bugsnagapiv2.apiary.io/).
7
+
8
+ ### Enhancements
9
+
10
+ * Uses Bugsnag data-access API v2 endpoints with associated changes to endpoints and methods, namely:
11
+ - Removes:
12
+ * accounts
13
+ * users
14
+ - Adds:
15
+ * organizations
16
+ * collaborators
17
+ * event fields
18
+ * pivots
19
+ * trends
20
+ - Updates:
21
+ * comments
22
+ * errors
23
+ * events
24
+ * projects
25
+
26
+ | [#11](https://github.com/bugsnag/bugsnag-api-ruby/pull/11)
27
+
28
+ * Adds error response to hitting rate limit
29
+ | [#10](https://github.com/bugsnag/bugsnag-api-ruby/pull/10)
30
+
31
+ ### Known Issues
32
+
33
+ * per_page option not respected in paginated API calls
34
+ * issues with event_fields not being created correctly
35
+
4
36
  1.0.2
5
37
  -----
6
38
  - Fix load-order bug when requiring from certain environments
@@ -0,0 +1,40 @@
1
+ # How to contribute
2
+
3
+ 1. [Fork](https://help.github.com/articles/fork-a-repo) the [library on GitHub](https://github.com/bugsnag/bugsnag-api-ruby)
4
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
5
+ 3. Commit and push until you are happy with your contribution
6
+ 4. Push to the branch (`git push origin my-new-feature`)
7
+ 5. Run the tests and make sure they all pass:
8
+
9
+ ```
10
+ rake spec
11
+ ```
12
+
13
+ 6. Create a [Pull Request](https://help.github.com/articles/using-pull-requests)
14
+
15
+ Thank you!
16
+
17
+ ## How to release
18
+
19
+ If you're a member of the core team, follow these instructions for releasing bugsnag-api-ruby.
20
+
21
+ ### First time setup
22
+
23
+ * Create a Rubygems account
24
+ * Get a member of the platforms team to add you as contributor on bugsnag-ruby in Rubygems
25
+
26
+ ### Every time
27
+
28
+ * Update `CHANGELOG.md`
29
+ * Update the version number in `bugsnag-api.gemspec`
30
+ * Update `README.md` if necessary with changes to the interface or configuration
31
+ * Commit/push your changes
32
+ * Release to rubygems
33
+
34
+ ```
35
+ gem build bugsnag-api.gemspec
36
+ gem push bugsnag-api-[version].gem
37
+ ```
38
+ * Create a new GitHub release, copying the changes from the change log
39
+
40
+
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  Bugsnag API Toolkit for Ruby
2
2
  ============================
3
+ ![Build status](https://travis-ci.org/bugsnag/bugsnag-api-ruby.svg?branch=master)
4
+
5
+ The library allows for quick read/write access to the [Bugsnag Data Access API](https://docs.bugsnag.com/api/data-access/) from your Ruby applications. You can use this library to build your own applications which leverage data found in your Bugsnag dashboard.
3
6
 
4
- The library allows for quick read/write access to the [Bugsnag API](https://bugsnag.com/docs/api) from your Ruby applications. You can use this library to build your own applications which leverage data found in your Bugsnag dashboard.
7
+ Version 2.x (current) of this gem corresponds to v2 of the Data Access API, while [1.x](https://github.com/bugsnag/bugsnag-api-ruby/tree/v1.0.3) uses the (deprecated) v1 of the Data Access API.
5
8
 
6
- If you are looking to automatically detect crashes in your Ruby apps, you should take a look at the [Bugsnag Ruby Detection Library](https://bugsnag.com/docs/notifiers/ruby) instead.
9
+ If you are looking to automatically detect crashes in your Ruby apps, you should take a look at the [Bugsnag Ruby Detection Library](https://docs.bugsnag.com/platforms/ruby) instead.
7
10
 
8
11
  This library borrows heavily from the code and philosophies of the fantastic [Octokit](https://github.com/octokit/octokit.rb) library. A big thanks to [@pengwynn](https://github.com/pengwynn) and the rest of the Octokit team!
9
12
 
@@ -19,12 +22,15 @@ This library borrows heavily from the code and philosophies of the fantastic [Oc
19
22
  - [Pagination](#pagination)
20
23
  - [Accessing HTTP responses](#accessing-http-responses)
21
24
  - [API Methods](#api-methods)
22
- - [Accounts](#accounts)
25
+ - [Organizations](#organizations)
26
+ - [Collaborators](#collaborators)
23
27
  - [Comments](#comments)
24
28
  - [Errors](#errors)
25
29
  - [Events](#events)
30
+ - [Event Fields](#event-fields)
31
+ - [Pivots](#pivots)
26
32
  - [Projects](#projects)
27
- - [Users](#users)
33
+ - [Trends](#trends)
28
34
  - [Advanced Configuration](#advanced-configuration)
29
35
 
30
36
 
@@ -51,6 +57,12 @@ $ gem install bugsnag-api
51
57
 
52
58
  ## Usage
53
59
 
60
+ ### Require gem
61
+
62
+ ```ruby
63
+ require 'bugsnag/api'
64
+ ```
65
+
54
66
  ### Making Requests
55
67
 
56
68
  API methods are available as module methods or as client instance methods.
@@ -58,42 +70,44 @@ API methods are available as module methods or as client instance methods.
58
70
  ```ruby
59
71
  # Provide authentication credentials
60
72
  Bugsnag::Api.configure do |config|
61
- config.auth_token = "your-account-api-token"
73
+ config.auth_token = "your-personal-auth-token"
62
74
  end
63
75
 
64
- # Fetch the current account
65
- account = Bugsnag::Api.account
76
+ # Access API methods
77
+ organizations = Bugsnag::Api.organizations
66
78
  ```
67
79
 
68
80
  or...
69
81
 
70
82
  ```ruby
71
83
  # Create an non-static API client
72
- client = Bugsnag::Api::Client.new(auth_token: "your-account-api-token")
84
+ client = Bugsnag::Api::Client.new(auth_token: "your-personal-auth-token")
73
85
 
74
86
  # Access API methods on the client
75
- accounts = client.accounts
87
+ organizations = client.organizations
76
88
  ```
77
89
 
78
90
  ### Consuming Resources
79
91
 
80
- Most methods return a `Resource` object which provides dot notation and [] access for fields returned in the API response.
92
+ Most methods return a [`Resource`](http://www.rubydoc.info/gems/sawyer/Sawyer/Resource)
93
+ object which provides dot notation and [] access for fields returned in the API
94
+ response.
81
95
 
82
96
  ```ruby
83
- # Fetch the current account
84
- account = Bugsnag::Api.account
97
+ # Fetch an organization
98
+ org = Bugsnag::Api.organization("organization-id")
85
99
 
86
- puts account.name
100
+ puts org.name
87
101
  # => "Acme Co"
88
102
 
89
- puts account.fields
90
- # => #<Set: {:id, :name, :created_at, :updated_at, :url, :users_url, :projects_url, :account_creator, :billing_contact}>
103
+ puts org.fields
104
+ # => #<Set: {:id, :name, :slug, :creator, :created_at, :updated_at, :auto_upgrade, :upgrade_url, :billing_emails}>
91
105
 
92
- puts account[:id]
106
+ puts org.id
93
107
  # => "50baed0d9bf39c1431000003"
94
108
 
95
- account.rels[:users].href
96
- # => "https://api.bugsnag.com/accounts/50baed0d9bf39c1431000003/users"
109
+ account.rels[:upgrade].href
110
+ # => "https://api.bugsnag.com/organizations/50baed0d9bf39c1431000003/..."
97
111
  ```
98
112
 
99
113
  ### Accessing Related Resources
@@ -101,15 +115,15 @@ account.rels[:users].href
101
115
  Resources returned by Bugsnag API methods contain not only data but hypermedia link relations:
102
116
 
103
117
  ```ruby
104
- account = Bugsnag::Api.account
118
+ project = Bugsnag::Api.projects("organization-id")
105
119
 
106
120
  # Get the users rel, returned from the API as users_url in the resource
107
- account.rels[:users].href
108
- # => "https://api.bugsnag.com/accounts/50baed0d9bf39c1431000003/users"
121
+ project.rels[:errors].href
122
+ # => "https://api.bugsnag.com/projects/50baed0d9bf39c1431000003/errors"
109
123
 
110
- users = account.rels[:users].get.data
111
- users.last.name
112
- # => "James Smith"
124
+ errors = project.rels[:errors].get.data
125
+ errors.first.message
126
+ # => "Can't find method: getStrng()"
113
127
  ```
114
128
 
115
129
  When processing API responses, all `*_url` attributes are culled in to the link relations collection. Any `url` attribute becomes `.rels[:self]`.
@@ -118,16 +132,17 @@ When processing API responses, all `*_url` attributes are culled in to the link
118
132
  ### Authentication
119
133
 
120
134
  API usage requires authentication. You can authenticate using either your
121
- Bugsnag account's [auth token](https://bugsnag.com/docs/api#account-authentication)
122
- or with your Bugsnag [user credentials](https://bugsnag.com/docs/api#user-authentication).
135
+ Bugsnag account's [auth token](https://app.bugsnag.com/settings/my-account/)
136
+ or with your Bugsnag user credentials.
123
137
 
124
138
  ```ruby
125
139
  # Authenticate with your Bugsnag account's auth token
126
140
  Bugsnag::Api.configure do |config|
127
- config.auth_token = "your-account-api-token"
141
+ config.auth_token = "your-personal-auth-token"
128
142
  end
129
143
 
130
- # Authenticate using your Bugsnag email address and password
144
+ # Authenticate using your Bugsnag email address and password. Unavailable when
145
+ # using multi-factor authentication.
131
146
  Bugsnag::Api.configure do |config|
132
147
  config.email = "example@example.com"
133
148
  config.password = "password"
@@ -140,7 +155,11 @@ Many Bugsnag API resources are paginated. While you may be tempted to start addi
140
155
 
141
156
  ```ruby
142
157
  errors = Bugsnag::Api.errors("project-id", per_page: 100)
143
- errors.concat Bugsnag::Api.last_response.rels[:next].get.data
158
+ last_response = Bugsnag::Api.last_response
159
+ until last_response.rels[:next].nil?
160
+ last_response = last_response.rels[:next].get
161
+ errors.concat last_response.data
162
+ end
144
163
  ```
145
164
 
146
165
 
@@ -149,37 +168,62 @@ errors.concat Bugsnag::Api.last_response.rels[:next].get.data
149
168
  While most methods return a `Resource` object or a `Boolean`, sometimes you may need access to the raw HTTP response headers. You can access the last HTTP response with `Client#last_response`:
150
169
 
151
170
  ```ruby
152
- account = Bugsnag::Api.account
153
- response = Bugsnag::Api.last_response
154
- status = response.headers[:status]
171
+ organization = Bugsnag::Api.organizations.first
172
+ response = Bugsnag::Api.last_response
173
+ status = response.headers[:status]
155
174
  ```
156
175
 
157
176
  ## API Methods
158
177
 
159
- ### Accounts
178
+ The following methods are available via `Bugsnag::Api` and the Client interface.
179
+ For more information, consult the [API
180
+ documentation](http://www.rubydoc.info/gems/bugsnag-api/Bugsnag/Api/Client)
181
+
182
+ ### Organizations
160
183
 
161
184
  ```ruby
162
- # List your accounts
163
- accounts = Bugsnag::Api.accounts
185
+ # List your organizations
186
+ orgs = Bugsnag::Api.organizations
187
+
188
+ # Get a single organization
189
+ org = Bugsnag::Api.organizations("organization-id")
190
+ ```
191
+
192
+ ### Collaborators
193
+
194
+ ```ruby
195
+ # List organization collaborators
196
+ users = Bugsnag::Api.collaborators("organization-id")
197
+
198
+ # List project collaborators
199
+ users = Bugsnag::Api.collaborators(nil, "project-id")
164
200
 
165
- # Get a single account
166
- account = Bugsnag::Api.account("account-id")
201
+ # Invite a user to an account
202
+ user = Bugsnag::Api.invite_collaborators("org-id", "example@example.com", {
203
+ admin: true
204
+ })
205
+
206
+ # Update a user's account permissions
207
+ user = Bugsnag::Api.update_collaborator_permissions("org-id", "user-id", {
208
+ admin: false
209
+ })
167
210
 
168
- # Get authenticated account (requires account auth)
169
- account = Bugsnag::Api.account
211
+ # Remove a user from an account
212
+ Bugsnag::Api.delete_collaborator("org-id", "user-id")
170
213
  ```
171
214
 
215
+
172
216
  ### Comments
173
217
 
174
218
  ```ruby
175
219
  # List error comments
176
- comments = Bugsnag::Api.comments("error-id")
220
+ comments = Bugsnag::Api.comments("project-id", "error-id")
177
221
 
178
222
  # Get a single comment
179
- comment = Bugsnag::Api.comment("comment-id")
223
+ comment = Bugsnag::Api.comment("project-id", "comment-id")
180
224
 
181
225
  # Create a comment
182
- comment = Bugsnag::Api.create_comment("error-id", "comment message")
226
+ comment = Bugsnag::Api.create_comment("project-id", "error-id", "comment message")
183
227
 
184
228
  # Update a comment
185
229
  comment = Bugsnag::Api.update_comment("comment-id", "new comment message")
@@ -192,24 +236,20 @@ Bugsnag::Api.delete_comment("comment-id")
192
236
 
193
237
  ```ruby
194
238
  # List project errors
195
- errors = Bugsnag::Api.errors("project-id")
239
+ errors = Bugsnag::Api.errors("project-id", "project-id")
196
240
 
197
241
  # Get a single error
198
- error = Bugsnag::Api.error("error-id")
242
+ error = Bugsnag::Api.error("project-id", "error-id")
199
243
 
200
- # Resolve an error
201
- error = Bugsnag::Api.resolve_error("error-id")
244
+ # Update a single error
245
+ error = Bugsnag::Api.update_errors("project-id", "error-id")
202
246
 
203
- # Re-open an error
204
- error = Bugsnag::Api.reopen_error("error-id")
205
-
206
- # Update an error
207
- error = Bugsnag::Api.update_error("error-id", {
208
- resolved: true
209
- })
247
+ # Update bulk errors
248
+ error = Bugsnag::Api.update_errors("project-id",
249
+ ["error-id1", "error-id2"])
210
250
 
211
251
  # Delete an error
212
- error = Bugsnag::Api.delete_error("error-id")
252
+ error = Bugsnag::Api.delete_error("project-id", "error-id")
213
253
  ```
214
254
 
215
255
  ### Events
@@ -219,78 +259,68 @@ error = Bugsnag::Api.delete_error("error-id")
219
259
  events = Bugsnag::Api.events("project-id")
220
260
 
221
261
  # List error events
222
- events = Bugsnag::Api.error_events("error-id")
262
+ events = Bugsnag::Api.error_events("project-id", "error-id")
263
+
264
+ # Get the latest event
265
+ event = Bugsnag::Api.latest_event("project-id", "error-id")
223
266
 
224
267
  # Get a single event
225
- event = Bugsnag::Api.event("event-id")
268
+ event = Bugsnag::Api.event("project-id", "event-id")
226
269
 
227
270
  # Delete an event
228
- Bugsnag::Api.delete_event("event-id")
271
+ Bugsnag::Api.delete_event("project-id", "event-id")
229
272
  ```
230
273
 
231
- ### Projects
274
+ ### Event Fields
232
275
 
233
276
  ```ruby
234
- # List account projects
235
- projects = Bugsnag::Api.projects("account-id")
277
+ # list a project's event fields
278
+ Bugsnag::Api.event_fields("project-id")
279
+
280
+ # create an event field
281
+ Bugsnag::Api.create_event_field("project-id", "display id", "path.to.field", {})
236
282
 
237
- # List authenticated account's projects (requires account auth)
238
- projects = Bugsnag::Api.projects
283
+ # update an event field
284
+ Bugsnag::Api.update_event_field("project-id", "display id", "new.path.to.field")
239
285
 
240
- # List user projects
241
- projects = Bugsnag::Api.user_projects("user-id")
286
+ # delete an event field
287
+ Bugsnag::Api.delete_event_field("project-id", "display id")
288
+ ```
289
+
290
+ ### Projects
291
+
292
+ ```ruby
293
+ # List organization projects
294
+ projects = Bugsnag::Api.projects("organization-id")
242
295
 
243
296
  # Get a single project
244
297
  project = Bugsnag::Api.project("project-id")
245
298
 
246
299
  # Create a project
247
- project = Bugsnag::Api.create_project("account-id", {
248
- name: "Name",
249
- type: "rails"
250
- })
300
+ project = Bugsnag::Api.create_project("organization-id", "project name", "rails")
251
301
 
252
302
  # Update a project
253
303
  project = Bugsnag::Api.update_project("project-id", {
254
304
  name: "New Name"
255
305
  })
256
306
 
307
+ # Regenerate a project API key
308
+ Bugsnag::Api.regenerate_api_key("project-id")
309
+
257
310
  # Delete a project
258
311
  Bugsnag::Api.delete_project("project-id")
259
312
  ```
260
313
 
261
- ### Users
314
+ ### Pivots
262
315
 
263
316
  ```ruby
264
- # List account users
265
- users = Bugsnag::Api.users("account-id")
266
-
267
- # List authenticated account's users (requires account auth)
268
- users = Bugsnag::Api.users
269
-
270
- # List project users
271
- users = Bugsnag::Api.project_users("project-id")
272
-
273
- # Get a single user
274
- user = Bugsnag::Api.user("user-id")
275
-
276
- # Get authenticated user (requires user auth)
277
- user = Bugsnag::Api.user
278
-
279
- # Invite a user to an account
280
- user = Bugsnag::Api.invite_user("account-id", "example@example.com", {
281
- admin: true
282
- })
317
+ # list a project's pivots
318
+ Bugsnag::Api.pivots("project-id")
283
319
 
284
- # Update a user's account permissions
285
- user = Bugsnag::Api.update_user_permissions("account-id", "user-id", {
286
- admin: false
287
- })
288
-
289
- # Remove a user from an account
290
- Bugsnag::Api.remove_user("account-id", "user-id")
320
+ # list pivot values
321
+ Bugsnag::Api.pivot_values("project-id", "display id")
291
322
  ```
292
323
 
293
-
294
324
  ## Advanced Configuration
295
325
 
296
326
  ### Endpoint
@@ -319,21 +349,6 @@ end
319
349
  ```
320
350
 
321
351
 
322
- ## Build Status
323
-
324
- ![Build status](https://travis-ci.org/bugsnag/bugsnag-api-ruby.svg?branch=master)
325
-
326
-
327
- ## Contributing
328
-
329
- 1. [Fork](https://help.github.com/articles/fork-a-repo) the [library on GitHub](https://github.com/bugsnag/bugsnag-api-ruby)
330
- 2. Create your feature branch (`git checkout -b my-new-feature`)
331
- 3. Commit and push until you are happy with your contribution
332
- 4. Push to the branch (`git push origin my-new-feature`)
333
- 5. Run the tests with rake spec and make sure they all pass
334
- 6. Create a [Pull Request](https://help.github.com/articles/using-pull-requests)
335
-
336
-
337
352
  ## License
338
353
 
339
354
  The Bugsnag API Toolkit for Ruby is free software released under the MIT License. See [LICENSE.txt](LICENSE.txt) for details.