README.md in etsy-0.2.6 vs README.md in etsy-0.2.7
- old
+ new
@@ -43,11 +43,10 @@
### Console
For simple authentication from the console, configure the necessary parameters:
- require 'rubygems'
require 'etsy'
Etsy.api_key = 'key'
Etsy.api_secret = 'secret'
@@ -70,11 +69,10 @@
### Web Application
The process for authenticating via a web application is similar, but requires the configuration of a callback URL:
- require 'rubygems'
require 'etsy'
Etsy.api_key = 'key'
Etsy.api_secret = 'secret'
Etsy.callback_url = 'http://localhost:4567/authorize'
@@ -100,18 +98,25 @@
# access_token.token and access_token.secret can now be saved for future API calls
end
### Environment
-The Etsy API has both a sandbox environment and a production environment.
+The Etsy API previously had both a sandbox environment and a production environment. They have recently eliminated the sandbox environment, but the ability to set the environment has been preserved in case it is implemented in v3.
-If nothing is set, the default is :sandbox.
+If nothing is set, the default is :production.
You can set this using:
Etsy.environment = :production
+## Error handling
+
+For legacy reasons, this gem does *not* raise errors when requests are unsuccessful.
+However, you can force errors to be thrown by configuring the `silent_errors` flag.
+
+ >>> Etsy.silent_errors = false
+
## DSL
Use the Etsy::Request class to make flexible calls to the API.
To do so, find out which endpoint you wish to connect to and the parameters you wish to pass in.
@@ -221,11 +226,11 @@
>> association = {:resource => 'Images', :fields => ['red','green','blue'], :limit => 1, :offset => 0}
>> Listing.find(1, {:includes => [association]})
## Public mode vs authenticated calls
-This additional example should make clear the difference between issuing public versus authenticated requests:
+This additional example should make clear the difference between issuing public versus authenticated requests:
### Public workflow
>> Etsy.api_key = 'key'
>> user = Etsy.user('user_id_or_name')
@@ -236,51 +241,12 @@
>> Etsy.api_key = 'key'
>> Etsy.api_secret = 'secret'
>> user = Etsy.myself(token, secret)
>> access = { :access_token => user.token, :access_secret => user.secret }
>> Etsy::Listing.find_all_by_shop_id(user.shop.id, access.merge(:limit => 5))
-
-## Error handling
-Next versions of this gem will raise errors when requests are unsuccessful. The current version does not.
-Use either of following workarounds:
-### Low-level API
-
-Instead of doing this:
-
- >> Etsy::Request.get('/users/__SELF__', access).result
-
-Write this:
-
- >> Etsy::Request.get('/users/__SELF__', access).to_hash["results"]
-
-### Monkey patch
-
-This is Ruby, reopen the <code>Response</code> class anywhere in your codebase and redefine <code>result</code>:
-
- class Etsy::Response
- def result
- if success?
- results = to_hash['results'] || []
- count == 1 ? results.first : results
- else
- validate!
- end
- end
- end
-
-### Usage
-
-With the above in place, you can now rescue errors and act upon them:
-
- begin
- Etsy.myself(access.token, access.secret)
- rescue Etsy::OAuthTokenRevoked, Etsy::InvalidUserID, Etsy::MissingShopID, Etsy::EtsyJSONInvalid, Etsy::TemporaryIssue => e
- puts e.message
- end
-
## Contributing
I have a "commit bit" policy for contributions to this repository. Once I accept
your patch, I will give you full commit access. To submit patches:
@@ -319,9 +285,10 @@
* [Jake Boxer](https://github.com/jakeboxer)
* [Trae Robrock](https://github.com/trobrock)
* [Jimmy Tang](https://github.com/jimmytang)
* [Julio Santos](https://github.com/julio)
* [Roger Smith](https://github.com/rogsmith)
+* [Daniel Szmulewicz](https://github.com/danielsz)
### Github Flow
For those of you with commit access, please check out Scott Chacon's blog post about [github flow](http://scottchacon.com/2011/08/31/github-flow.html)