Giter Club home page Giter Club logo

cuba-component-xero's Introduction

Build Status Download license

CUBA Platform Component - Xero

This application component let's you easily integrate with the Xero API.

It mainly leverages the official Xero Java SDK. The configuration of the SDK is done via CUBA's application properties.

Installation

  1. xero is available in the CUBA marketplace
  2. Select a version of the add-on which is compatible with the platform version used in your project:
Platform Version Add-on Version
6.9.x 0.1.x

The latest version is: Download

Add custom application component to your project:

  • Artifact group: de.diedavids.cuba.xero
  • Artifact name: xero-global
  • Version: add-on version
dependencies {
  appComponent("de.diedavids.cuba.xero:xero-global:*addon-version*")
}

Add Xero API maven repository

In order to download all dependencies it is required to additionally add the following maven repositories to your build.gradle:


buildscript {
    
    //...
    
    repositories {

        maven { url "https://raw.github.com/XeroAPI/Xero-Java/mvn-repo" }
        maven { url "https://raw.github.com/XeroAPI/XeroAPI-Schemas/mvn-repo" }

        //...
        
    }
}

Usage

In order to interact with the Xero API it is reqiured to setup an account and create the corresponding credentials accordingly. After that the configuation settings can be setup in the CUBA application.

Configure the Xero SDK integration - Video Tutorial

In order to configure the connection to Xero correctly, this youtube video shows how to setup the integration: CUBA Xero Java SDK Integration - configuration

Create Xero API credentials

In order to interact with the Xero API, the following steps are required:

  1. create an account at Xero
  2. enable the Xero demo company
  3. create a application

Once all those steps are done, you will get credentials from Xero (Consumer Key, Consumer Secret etc.)

Additionally a public / private key pair has to be created. See details here: https://developer.xero.com/documentation/api-guides/create-publicprivate-key

Using OpenSSL it looks like this:

openssl genrsa -out privatekey.pem 1024
openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 1825
openssl pkcs12 -export -out public_privatekey.pfx -inkey privatekey.pem -in publickey.cer

Now you should have a file called public_privatekey.pfx and a password defined for it.

Configure the Xero API

In the CUBA application it is possible to configure all required and optional attributes through Administration > Application Properties > Xero.

Xero configuration

Using the private / public key file

The required file public_privatekey.pfx can be used in two ways:

The first option is to put the public_privatekey.pfx file into the conf directory of the CUBA application. In the configuration it has to be referenced via the application property xero.pathToPrivateKey where the filename should be inserted as a value.

The second option uses the external files feature of the CUBA application. You can just upload the file via Administration > External Files. Then in the configuration xero.privateKeyFileDescriptor has to point the FileDescriptor. This can be done via the following String sys$FileDescriptor-f0edbbb8-24c8-a179-a052-0e73f5eb88d1 where f0edbbb8-24c8-a179-a052-0e73f5eb88d1 is the UUID of the uploaded file. The ID of the file can be retrieved via the external files screen, when right click on the file and select System information.

Using the API in the application

In order to use the Xero API, you can use the default XeroClient from the official SDK. To get a reference to a XeroClient instance, you can use the following snippet:

@Inject
XeroClientFactory xeroClientFactory;

public List<Invoice> getInvoicesFromXero() {

    XeroClient client = xeroClientFactory.createClient();
    List<Invoice> xeroInvoiceList = client.getInvoices();

    return xeroInvoiceList;
}


Example usage

An example usage of this application component can be found here: cuba-example-using-xero

More information

More information on how to use Xero as well as using additional configurations, the following resources should be looked at:

cuba-component-xero's People

Contributors

mariodavid avatar

Stargazers

Egor Lavrenkov avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

smkdm

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.