README.md in pager_duty-connection-0.2.0 vs README.md in pager_duty-connection-1.0.0
- old
+ new
@@ -23,10 +23,12 @@
* provide first class objects for Incidents, Services, etc (they can change, and have new methods)
* provide an a ActiveResource interface (ActiveResource libraries can be hard to build wrappers for. Also, it's not conducive to accessing multiple pagerduty accounts)
* have methods for individual API calls that are possible (ie `find_incident`, `list_users`, etc)
* provide [will_paginate](https://github.com/mislav/will_paginate) or [kaminari](https://github.com/amatsuda/kaminari) paginated arrays (They aren't super documented for building a library that works well with them, and have different APIs)
+**Note**: v1 of the Pager Duty REST API is no longer supported with this gem. Please either upgrade to v2 of the API [(v2 Migration Documentation)](https://v2.developer.pagerduty.com/docs/migrating-to-api-v2) or do not upgrade past version [0.2.0 of this gem](https://github.com/technicalpickles/pager_duty-connection/tree/v0.2.0).
+
## Installation
Add this line to your application's Gemfile:
gem 'pager_duty-connection'
@@ -44,26 +46,45 @@
Working code is worth a thousand words. The basics:
```ruby
# setup the connection
-pagerduty = PagerDuty::Connection.new(account, token)
+pagerduty = PagerDuty::Connection.new(token, version)
-# 4 main methods: get, post, put, and delete:
+# 4 main methods: `get`, `post`, `put`, and `delete`:
-response = pagerduty.get('some/relative/path', :some => 'request', :parameter => 'to pass')
-response = pagerduty.post('some/relative/path', :some => 'request', :parameter => 'to pass')
-response = pagerduty.delete('some/relative/path', :some => 'request', :parameter => 'to pass')
-response = pagerduty.put('some/relative/path', :some => 'request', :parameter => 'to pass')
+response = pagerduty.get('some/relative/path', params)
+response = pagerduty.post('some/relative/path', params)
+response = pagerduty.delete('some/relative/path', params)
+response = pagerduty.put('some/relative/path', params)
# use something like irb or pry to poke around the responses
# the contents will vary a bit between call, ie:
response = pagerduty.get('incidents')
response.incidents # an array of incidents
response = pagerduty.get('incidents/YYZ')
response # the hash/object that represents the array
+```
+
+`get`, `post`, `put`, and `delete` all take a common parameter `params`.
+This parameter contains the query parameters, body, and custom headers
+needed to perform the request. Params is structured as follows:
+
+```ruby
+params = {
+ query_params: {
+ param1: "ABCD",
+ ids: [ "id1", "id2", "id3" ] # Faraday takes care of encoding the arrays to be `?ids[]=id1&ids[]=id2&ids[]=id3..`
+ }, {
+ body: { ... }, # Whatever needs to be sent in a `PUT` or `POST` request body
+ }, {
+ headers: {
+ from: "testuser@test.com" # Some requests require a From header
+ }
+ }
+}
```
For more advanced and realistic examples, check out the examples directory:
* [shifts-with-incidents-and-log-entries](examples/shifts-with-incidents-and-log-entries.rb)