Skip to content

Commit

Permalink
[#21] - Updated the README.md to include details about resolving a re…
Browse files Browse the repository at this point in the history
…source's links.
  • Loading branch information
eoin55 committed Dec 11, 2017
1 parent b997502 commit ce9959d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ halClent.HttpClient.BaseAddress = new Uri("https://api.retail.com/");
#### (Optional) Custom serializer settings
HalClient uses the default JsonMediaTypeFormatter for handling deserialization of responses. If you need to change any of the settings (for handling null values, missing properties, custom date formats and so on), you can build a custom MediaTypeFormatter by subclassing JsonMediaTypeFormatter, and then passing it in to the HalClient constructor:
```cs
public class CustomMediaTypeFormatter : JsonMediaTypeFormatter
public class CustomMediaTypeFormatter : JsonMediaTypeFormatter
{
SerializerSettings.NullValueHandling = NullValueHandling.Ignore;

SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/hal+json"));
}

Expand Down Expand Up @@ -215,6 +215,21 @@ client
2. GET https://api.retail.com/v1/order/46AC5C29-B8EB-43E7-932E-19167DA9F5D3
3. DELETE https://api.retail.com/v1/order/46AC5C29-B8EB-43E7-932E-19167DA9F5D3

### 8) Retrieve a resource's links
```cs
IList<ILink> links =
client
.Root("/v1/version/1")
.Get("order", new {orderRef = "46AC5C29-B8EB-43E7-932E-19167DA9F5D3"}, "retail")
.Item<Order>()
.Links;
```

1. GET https://api.retail.com/v1/version/1
2. GET https://api.retail.com/v1/order/46AC5C29-B8EB-43E7-932E-19167DA9F5D3
3. Reads *Order* resource
4. Returns the *Order* resource's *links*, e.g. *self*, *retail:order-edit*, *retail:order-delete*.

## Dependency Injection

`HalClient` implements interface `IHalClient`. Registering it with [Autofac](http://autofac.org/) might look something like this:
Expand Down

0 comments on commit ce9959d

Please sign in to comment.