Skip to content

littleearth/delphiXERO

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

delphiXERO

XERO accounting API for Delphi

http://developer.xero.com/

Supports Delphi Sydney 10.4.2

  • Older versions may work but this has not been tested
  • RIO: Testing in RIO so far has not worked, OAuth2 authentication would fail, possibly in CodeChallenge generation

This is a work in progress so design and requirements may change.

License

Use this source code in open source or commercial software. You do not need to provide any credit. However please provide any fixes or enhancements to keep the component alive and helpful to everyone

Thanks

ToDo


  • Access Token JWT decode (delphi-jose-jwt?)
  • Expand API modules for all areas of API
  • Option for URL to open in inbuilt Edge browser

#Components#

TXEROAppDetails

Store XERO App Details

XEROAppDetails.ClientID := '4D914DECC5F34C4D882F76F0....';

TXEROAuthenticatorPKCE

OAuth2 PKCE Authentication ([https://developer.xero.com/documentation/oauth2/pkce-flow])

This component will launch the authentication URL and will start a http:localhost:{port} server for authentication response

By default the HTTP Server attempts to start on port 58985, 58986 or 58987

The default scope is 'openid profile email accounting.transactions accounting.contacts accounting.settings'

Use OnXEROAuthenticationURL to launch default browser or show within a browser in your application (NOTE: TWebBrowser IE Mode does not work)

XEROAuthenticatorPKCE.OnXEROAuthenticationURL :=  { example OnXEROAuthenticationURL(ASender: TObject; AURL: string) }
XEROAuthenticatorPKCE.OnXEROAuthenticationComplete :=  { example OnXEROAuthenticationComplete(ASender: TObject; ASuccess: Boolean) }
XEROAuthenticatorPKCE.Scope := 'openid profile email accounting.transactions accounting.contacts accounting.settings';
XEROAuthenticatorPKCE.Login;

Upon login FXEROAuthenticatorPKCE.AuthToken and XEROAuthenticatorPKCE.Tenants will be populated

TXEROApiJSON

Provide a simple interface for calling the XERO API

Get

var
 LAPI: TXEROApiJSON;
begin
  LAPI := TXEROApiJSON.Create(nil);
  try
	LAPI.XEROAppDetails := FXEROAppDetails;
	LAPI.TenantID := '06c6ccf8-bd57-4d2f-a36e-396b2af59f24';
	LJSON := LAPI.Get('Contacts','page=1');
  finally
	FreeAndNil(LAPI);
  end;
end;

Post

var
 LAPI: TXEROApiJSON;
begin
  LAPI := TXEROApiJSON.Create(nil);
  try
	LAPI.XEROAppDetails := FXEROAppDetails;
	LAPI.TenantID := '06c6ccf8-bd57-4d2f-a36e-396b2af59f24';
	LJSON := LAPI.Post('Contacts','[JSON data]');
  finally
	FreeAndNil(LAPI);
  end;
end;

About

XERO accounting API for Delphi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published