Git Product home page Git Product logo

xero-netstandard's Introduction

Xero-NetStandard

Build Status Nuget Version Software License

A skinny wrapper of the Xero API. All third party libraries are included as source code.

What is supported?

  • Accounts - Find and Create
  • Bank Transactions - Create, Find and Update
  • Bank Transfers - Create, Find and Update
  • Branding Themes - Find
  • Contacts - Create, Find and Update
  • Credit Notes - Create, Find, Update and as PDF
  • Currencies - Find
  • Employees - Create, Find and Update
  • Expense Claims - Create, Find and Update
  • Invoices - Create, Find, Update and as PDF
  • Journals - Find
  • Manual Journals - Create, Find and Update
  • Organisation - Find
  • Payments - Create and Find
  • Receipts - Create, Find and Update
  • Repeating Invoices - Find
  • Tax Rates - Create, Find and Update
  • Users - Find

Things to note

  • You will need an instance of the API per user. The user is stored as part of the API instance.
  • The library tries to do as little as possible and provides a basis to be extended. There are examples of TokenStores, Authenticators and Application types. These examples provide enough to get you going, but are not a complete solution to all your needs. You will need to adapt them for your own use and situation. Private application will work out of the box, as they do not have to deal with tokens and OAuth.
  • The HTTP verbs are not used in the public part of the API. Create, Update and Find are used instead. This seperates the implementation from the the intent.
  • Invoices and Contacts support pagination. Unlike the RESTful API, paging is on and defaulted to page 1. See the Counts or Creation code examples for how to use the Page method to get all items.
  • Four decimal places are supported for Bank Transactions, Credit Notes, Invoices, Payments, Repeating Invoices and Receipts. Unlike the RESTful API, it is on by default.
  • Contacts support including archived contacts. Like the RESTful API, this is off by default. Use IncluceArchived(true) to include them.

Samples

There are samples for each of the API endpoints. These have been done as console applications and also a collection of NUnit tests. See the README for each of the executable and test assemblies.

Querying

There are simple filters on different endpoints.

  • ModifiedSince
  • Where
  • Or
  • And
  • OrderBy
  • OrderByDescending
  • Page
  • Offset

They are used in a Fluent way, but are not LINQ. They simply create a query for the URL passed to the API. Nested queries are not handled using the syntax. Or and And need to come after a Where statement. OrderBy, OrderByDescending and Page can come anywhere.

var invoices = await xeroApi.Invoices  
	.ModifiedSince(new DateTime(2014, 1, 31))  
	.Where("Total > 3500.0")  
	.And("Total < 10000.0")  
	.Page(2)  
	.OrderByDescending("DueDate")  
	.FindAsync();

The following gives the same query string to the API as the example above.

var invoices = await xeroApi.Invoices  
	.Page(2)  
	.OrderByDescending("DueDate")  
	.Where("Total > 3500.0")   
	.And("Total < 10000.0")  
	.ModifiedSince(new DateTime(2014, 1, 31))  
	.FindAsync();

Authenticators

The application classes all use implementations of IAuthenticator. See Xero.Api.Infrastructure.OAuth.Authenticator namespace for the implementations. The authenticators are used by the base infrastructure to do the heavy lifting of the Xero API authentication.

PrivateAuthenticator

Uses RSA-SHA1 and a public/private certificate. There are no tokens and each request has to be signed.

PublicAuthenticator

Uses HMAC-SHA1 and the standard 3-legged OAuth process. Tokens last for 30 minutes and cannot be renewed.

PartnerAuthenticator

Uses RSA-SHA1 and a Xero provider certificate and then the standard 3-legged OAuth process with an additional signing certificate. Tokens last for 30 minutes and be renewed. Token renewal is not currently handled by this provider, but will be done soon.

OAuth signing

All the signing is done by a slightly modified version of the Dust library provided by Ben Biddington. Source is included.

Token Stores

The token store implementations are separate and optional. (It is recommended that you do have a store.)

The interface ITokenStore has three methods.

public interface ITokenStore
{
	IConsumer Find(string user);
	void Add(IToken token);
	void Delete(IToken token);
}

You can provide your own implementation to suit the database you are using for your product. Ensure the dates on the token are stored in UTC.

Serialization

All communication with the Xero API is compressed at source. Writing to the API is done with XML. The data model classes have be attributed to give a small XML payload. All communication back from the API is JSON. These details are transparent to the user of the class library.

License

The MIT License (MIT)

xero-netstandard's People

Contributors

mjmortimer avatar philals avatar richard-rowley avatar matthewsteeples avatar pariesz avatar jamescolemanxero avatar justabearoz avatar rileyjamesxero avatar mrrrk avatar mjava1 avatar kiwidave72 avatar fnakashima avatar ezescan-rhys avatar orthros avatar ian-hook avatar tamaw avatar chappoo avatar ronanq avatar cbs-greg avatar xmixalis avatar rahmanyzm avatar mneelakanta avatar ksasha avatar ronnyek avatar corientdev avatar theregan avatar sidneyallen avatar paulblamire avatar luk355 avatar justinlatimer avatar

Stargazers

Steven Borrie avatar Chad Tolkien avatar  avatar

Watchers

Sam Jones avatar James Cloos avatar  avatar  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.