README.md in bootic_client-0.0.7 vs README.md in bootic_client-0.0.8

- old
+ new

@@ -113,10 +113,24 @@ client = BooticClient.client(:client_credentials, scope: 'admin', access_token: some_store[:access_token]) do |new_token| some_store[:access_token] = new_token end ``` +### 3. Basic Auth + +This strategy uses a `username` and `password` against APIs supporting HTTP's Basic Authentication scheme. + +The official Bootic API only supports OAuth2 tokens, but this allows the client to be used against internal APIs or stub APIs on development. + +```ruby +client = BooticClient.client(:basic_auth, username: 'foo', password: 'bar') + +root = client.root # etc +``` + +NOTE: `username` and `password` have nothing to do with your Bootic administrative credentials, and will be up to API maintainers to define. + ## Non GET links Most resource links lead to `GET` resources, but some will expect `POST`, `PUT`, `DELETE` or others. The Bootic API encodes this information in its link metadata so the client will do the right thing. The following example creates a new product on your first shop: @@ -182,9 +196,26 @@ BooticClient.configure do |c| ... c.cache_store = CACHE_STORE end +``` + +## Pre-loaded or custom root resources + +This client is designed to always navigate APIs starting from the root endpoint (the Hypermedia approach), but it's also possible to skip the root and start from a locally defined resource definition. + +```ruby +messaging_api = client.from_hash( + "_links" => { + "send_message" => {"href" => 'https://some.api.com/messages', "method" => 'post'}, + "delete_message" => {"href" => 'https://some.api.com/messages/:id', "method" => 'delete', "templated" => true} + } +) + +new_message = messaging_api.send_message(title: 'This is a new message') + +messaging_api.delete_message(id: new_message.id) ``` ## Contributing 1. Fork it