README.md in peddler-0.16.0 vs README.md in peddler-0.17.0
- old
+ new
@@ -1,6 +1,5 @@
-
# Peddler
[![Build Status](https://travis-ci.org/hakanensari/peddler.svg)](https://travis-ci.org/hakanensari/peddler)
[![Code Climate](https://codeclimate.com/github/hakanensari/peddler/badges/gpa.svg)](https://codeclimate.com/github/hakanensari/peddler)
[![Coverage Status](https://coveralls.io/repos/hakanensari/peddler/badge.svg?branch=master)](https://coveralls.io/r/hakanensari/peddler?branch=master)
@@ -37,33 +36,40 @@
primary_marketplace_id: "foo",
merchant_id: "bar",
aws_access_key_id: "baz",
aws_secret_access_key: "qux"
)
+```
-Alternatively, you can set these globally in the shell.
+Alternatively, set these globally in the shell.
-```sh
+```bash
export MWS_MARKETPLACE_ID=foo
export MWS_MERCHANT_ID=bar
export AWS_ACCESS_KEY_ID=baz
export AWS_SECRET_ACCESS_KEY=qux
```
+You can now instantiate a client without passing credentials.
+
+```ruby
+client = MWS::Orders::Client.new
+```
+
If you are creating a client for another seller, pass the latter's `MWSAuthToken` to the client.
```ruby
client.auth_token = "corge"
```
-Once you have a client with credentials, you can make requests to the API.
+Once you have a client with valid credentials, you should be able to make requests to the API.
-Peddler returns the response wrapped in a simple parser that handles both XML documents and flat files.
+Peddler returns the response wrapped in a parser that handles both XML documents and flat files.
```ruby
parser = client.get_service_status
-parser.parse # will return Hash or a CSV object
+parser.parse # will return a Hash or CSV object
```
You can swap the default parser with a purpose-built one.
```ruby
@@ -73,23 +79,24 @@
For a sample implementation, see my [MWS Orders](https://github.com/hakanensari/mws-orders) library.
Finally, you can handle network errors caused by throttling or other transient issues by defining an error handler.
```ruby
-MWS::Orders::Client.on_error do |request, response|
- if response.status == 503
- logger.info "I was throttled"
+MWS::Orders::Client.on_error do |e|
+ if e.response.status == 503
+ logger.warn e.response.message
end
end
```
-Alternatively, you can simply rescue.
+Alternatively, rescue.
```ruby
begin
client.some_method
-rescue Excon::Errors::ServiceUnavailable
- sleep 1 and retry
+rescue Excon::Errors::ServiceUnavailable => e
+ logger.warn e.response.message
+ retry
end
```
## The APIs