7digital/SevenDigital.Api.Wrapper — pull request #51 by gregsochanik (2012-11-16 14:32:48+00:00)
Title: Simplify the Basket endpoints parameter call methods

This brings it more in-line with how the rest of the codebase behaves. Add/Remove item methods are replaced by a single `UseBasketId` method that takes a `basketId` in Guid format.

The `RemoveItemFromBasket` class now implements `HasBasketItemParameter` which hooks up the `BasketItemId` extension method to allow you to specify the `basketItemItem` you want to remove.

The `AddItemToBasket` `releaseId` and `trackId` parameters are now handled by the already existing `ForReleaseId(int releaseId)` and `ForTrackId(int trackId)` methods as `AddItemToBasket` implements `HasReleaseIdParameter` and `HasTrackIdParameter`.

There are 2 known issues with this set-up though that I will look at:

As `CreateBasket` inherits from Basket, it also inherits the `UseBasketId` method which is irrelevant. Not a dangerous problem as the api ignores it, but more a clean code issue.

There are unit tests based around the idea that if you specify a track / release id with one instance of the FLuentApi, and then you use that instance to just specify a `releaseId`; the `trackId` query string parameter should be removed. As a result of this, when you specify `UseBasketId` it fires `api.ClearParameters()`, which again from a clean code perspective is not ideal.

Example usage can be found in `SevenDigital.Api.Wrapper.Integration.Tests.EndpointTests.BasketEndpoint.BasketCreateTests`

Create
```c#
Basket basket = new FluentApi()
.WithParameter("country", "GB")
.Please();
```

Retrieve
```c#
Basket basket = new FluentApi()
.UseBasketId(new Guid(_basketId))
.Please();
```

AddItem
```c#
Basket basket = new FluentApi()
.UseBasketId(new Guid(_basketId))
.ForReleaseId(EXPECTED_RELEASE_ID)
.ForTrackId(EXPECTED_TRACK_ID)
.Please();
```
RemoveItem
```c#
Basket basket = new FluentApi()
.UseBasketId(new Guid(_basketId))
.BasketItemId(toRemove)
.Please();
```