8,827

Downloads

241

Downloads of v 1.0.1

5

Average downloads per day

2013-02-28

Last published

Share on Social Networks

License details

provided by Sonatype

Apache-2.0

DocaLabs.Http.Client

1.0.1

The main goal of the library is to minimize plumbing code to bare minimum.

In order to use the library in most cases you would need to define:

* An interface for the remote service.

* A class for request data, properties of that class can be mapped into the HTTP query or to the request body.

* A class for response data, in some cases you won't need to define even that, for example if you want to get a string back.

That's it. The implemnatation is unit test friedly becuase the only thing you are working is against an interface.

For example for Google's street view you would need to define someting like:

public interface IStreetViewService

{

Image Fetch(StreetViewRequest request);

}

public class StreetViewRequest

{

public GeoLocation location { get; private set; }

public ImageSize size { get; set; }

public int? heading { get; set; }

public int fov { get; set; }

public int pitch { get; set; }

public bool sensor { get; set; }

}

public class ImageSize

{

public int width { get; set; }

public int height { get; set; }

public override string ToString()

{

return string.Format("{0}x{1}", width, height);

}

}

Then inject using the factory (instead of supplying the URL here you can use the app.config file):

HttpClientFactory.CreateInstance<IStreetViewService>(new Uri("http://maps.googleapis.com/maps/api/streetview"));

and finally the call:

var image = service.Fetch(new StreetViewRequest { location = GeoLocation(53.34462, -6.25958), size = new ImageSize { width = 640, height = 300 }, heading = 152, fov = 90 });

To install DocaLabs.Http.Client, run the following command in the Package Manager Console

Install-Package DocaLabs.Http.Client -Version 1.0.1

Owners

Authors

Alexey Kadyrov

Copyright

Copyright ©2013 Alexey Kadyrov

Tags

Dependencies

This package has no dependencies.

Version History

Version Downloads Last updated
DocaLabs.Http.Client 3.0.0 7,510 Monday, October 28, 2013
DocaLabs.Http.Client 2.0.1.2 282 Thursday, September 19, 2013
DocaLabs.Http.Client 2.0.0.1 150 Monday, September 16, 2013
DocaLabs.Http.Client 1.0.1.2 149 Friday, September 6, 2013
DocaLabs.Http.Client 1.0.1.1 310 Tuesday, April 2, 2013
DocaLabs.Http.Client 1.0.1 (this version) 241 Thursday, February 28, 2013
DocaLabs.Http.Client 1.0.0 185 Saturday, February 23, 2013