Skip to content

Commit

Permalink
Added expand header
Browse files Browse the repository at this point in the history
Added documentation
  • Loading branch information
Tim committed Jun 13, 2023
1 parent f232c8a commit 07f131d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ func ValidateWebhook(httpRequest *http.Request) bool {
}
```

### Expanding responses
Many objects allow you to request additional information as an expanded response by using the expand header. This parameter is available on all API requests, and applies to the response of that request only. Checkout the [documentation](https://api.docs.ewarehousing-solutions.com/expanding-responses) for all possible options.
```go
ctx := context.Background()

order, res, err := client.Orders.Get(context.WithValue(ctx, "Expand", "order_lines"))
```

## Support

Expand Down
6 changes: 3 additions & 3 deletions ewhs/ewhs.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ func (c *Client) NewRequest(ctx context.Context, method string, uri string, body
req.Header.Set(CustomerCodeHeader, c.config.CustomerCode)
req.Header.Set(WmsCodeHeader, c.config.WmsCode)

// TODO: allow expand headers
//if ctx.Value("Expand") != nil {
//}
if expand := ctx.Value("Expand"); expand != nil {
req.Header.Set("Expand", expand.(string))
}

// if no auth token is found -> authorize first
if c.authToken == "" && uri != "wms/auth/login/" {
Expand Down

0 comments on commit 07f131d

Please sign in to comment.