Coder Social home page Coder Social logo

yonglehou / portablerest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cloudnimble/portablerest

0.0 1.0 0.0 2.84 MB

A library for consuming REST APIs from Portable Class Libraries. Designed to be partially drop-in compatible with RestSharp.

Home Page: https://nuget.org/packages/PortableRest

Batchfile 0.43% C# 99.57%

portablerest's Introduction

PortableRest is a Portable Class Library for implementing REST API clients in other Portable Class Libraries. It leverages JSON.NET for rapid, customizable serialization, as well as the Microsoft.Bcl.Async library for awaitable execution on any platform. It is designed to be largely drop-in compatible with RestSharp, though you will need to make some changes and recompile if you are upgrading from that solution.

Works on .NET 4.5, Silverlight 5, Windows Phone 8.x, and Windows 8.x, as well as iOS and Android through Xamarin.

Design Goals

  • Be able to write one REST client wrapper that can be used on all current-generation Microsoft platforms (without the techniques we have to use for XamlEssentials).
  • Have more control over serialization of property names (so you're not limited to the "remove all dashes" convention of RestSharp).
  • Be able to have objects be easily serializable to local storage using standard techniques, without jumping through a lot of hoops.

What's New?

Version 3.0

  • Added constructor overload that accepts a custom HttpMessageHandler for all requests the HttpClient makes.
  • Added support for using the AsyncOAuth NuGet package for leveraging OAuth in your requests.
  • Added support for specifying the JsonSerializerSettings on a client-wide or per-request basis, with request-specific settings taking precedence.
  • Enhanced the SendAsync method to pass exceptions thrown by the serializer into the RestResponse.
  • BREAKING: The regular package is no longer being signed. If you need the signed version, install PortableRest.Signed instead.

Version 2.5

  • Ability to control parameter encoding. Example: RestRequest.AddParameter("test", someStream, ParameterEncoding.Base64);.
  • Ability to add request-specific headers. This is useful in situations where the value might change between requests, for example with expiring OAuth tokens. Example: RestRequest.AddHeader("X-Authorization", yourTokenHere);
  • The RestClient will now set the UserAgent for you if you do not set the property yourself. The format will be "YourAssemblyTitleAttributeValue Major.Minor.Revision (PortableRest Major.Minor.Revision)"
  • In addition, you can call RestClient.SetUserAgent<SomeTypeFromYourRestLibrary>(someString), which in the above example would replace YourAssemblyTitleAttributeValue with the contents of someString.

Version 2.4

  • Ability to control parameter encoding. Example: RestRequest.AddParameter("test", someStream, ParameterEncoding.Base64);.
  • Ability to add request-specific headers. This is useful in situations where the value might change between requests, for example with expiring OAuth tokens. Example: RestRequest.AddHeader("X-Authorization", yourTokenHere);
  • The RestClient will now set the UserAgent for you if you do not set the property yourself. The format will be "YourAssemblyTitleAttributeValue Major.Minor.Revision (PortableRest Major.Minor.Revision)"
  • In addition, you can call RestClient.SetUserAgent<SomeTypeFromYourRestLibrary>(someString), which in the above example would replace YourAssemblyTitleAttributeValue with the contents of someString.

More Info

NOTE: Will have an updated post for v3 soon! Read more about PortableRest on our blog

Quick start

Install the NuGet package: Install-Package PortableRest, clone the repo, git clone git://github.com/advancedrei/portablerest.git, or download the latest release.

If you are planning on redistributing your own PortableRest-based client, such as our http://gaug.es Client, you need to make sure your Portable profile does not use .NET 4.0, Silverlight 4.0, or Windows Phone 7.X. Having those platforms available will cause this package to fail to install. If you need support for those platforms, create an issue and we'll investigate the possibility of adding support.

Please see the unit tests project, Bing.RestClient, or Xbox.Music for examples of how to leverage PortableRest in your REST client.

Bug tracker

Have a bug? Please create an issue here on GitHub that conforms with necolas's guidelines.

https://github.com/AdvancedREI/PortableRest/issues

Twitter account

Keep up to date on announcements and more by following AdvancedREI on Twitter, @AdvancedREI.

Blog

Read more detailed announcements, discussions, and more on The AdvancedREI Dev Blog.

Author

Robert McLaws

Copyright and license

Copyright 2013 AdvancedREI, LLC.

The MIT License (MIT)

Copyright (c) 2013 AdvancedREI, LLC. and Robert McLaws

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

  • The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

  • You may not use this software to sell apps in the Windows Phone Store or Windows Store that replicate functionality from apps distributed by AdvancedREI.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

portablerest's People

Contributors

chandu avatar matthewsannes avatar scottisafool avatar shmuelie avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.