Giter Site home page Giter Site logo

fusioncloud-sdk-java's Introduction

fusioncloud-sdk-java

How to include

implementation "com.datameshgroup.fusion:fusion-cloud:1.0.3"

Overview


This repository contains a websocket client and security components to make it easy for developers to connect and communicate with Unify - a platform created by DataMesh.

Getting Started


Usage

See the DataMesh Fusion API documentation for a full description of schema and workflows. The fusioncloud-sdk-java-demo application provides sample code for using this library.

Construct an instance of FusionClient using the configuration provided by DataMesh. See the Fusion Cloud API for instructions on how to manage settings.


FusionClient fusionClient;
fusionClient = new FusionClient(useTestEnvironment: true | false);
    saleID = "<<Provided by DataMesh>>";
    poiID = "<<Provided by DataMesh>>";
    kek = "<<Provided by DataMesh>>";
fusionClient.setSettings(saleID, poiID, kek); 

Other required settings:


String providerIdentification = "<<Provided by DataMesh>>";
String applicationName = "<<Provided by DataMesh>>";
String softwareVersion = "<<Your POS version>>";
String certificationCode = "<<Provided by DataMesh>>";

Socket connection is managed for every transaction request. To send a transaction request, call fusionClient.sendMessage(request, serviceID);

  • The serviceID of the transaction should be UUID, it can also be generated using MessageHeaderUtil.generateServiceID();.
  • The request is built using Java Fusion SDK.
  • Sample code:
// Declare serviceID
String serviceID = MessageHeaderUtil.generateServiceID();
// Build LoginRequest
SaleSoftware saleSoftware = new SaleSoftware.Builder()//
                .providerIdentification(providerIdentification)//
                .applicationName(applicationName)//
                .softwareVersion(softwareVersion)//
                .certificationCode(certificationCode)//
                .build();

        SaleTerminalData saleTerminalData = new SaleTerminalData.Builder()//
                .terminalEnvironment(TerminalEnvironment.SemiAttended)//
                .saleCapabilities(Arrays.asList(SaleCapability.CashierStatus, SaleCapability.CustomerAssistance,
                        SaleCapability.PrinterReceipt))//
                .build();

        LoginRequest loginRequest = new LoginRequest.Builder()//
                .dateTime(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date()))//
                .saleSoftware(saleSoftware)//
                .saleTerminalData(saleTerminalData)//
                .operatorLanguage("en")//
                .build();
                
//Send LoginRequest to host             
fusionClient.sendMessage(loginRequest, serviceID);

To listen for the transaction response or any other messages from the host, loop on fusionClient.readMessage();. This will return a SaleToPOI datatype that can then parsed. Sample code:

SaleToPOI saleToPOI = fusionClient.readMessage();

MessageCategory messageCategory;
        if (saleToPOI instanceof SaleToPOIResponse) {
            SaleToPOIResponse response = (SaleToPOIResponse) saleToPOI;
            response.getMessageHeader();
            messageCategory = response.getMessageHeader().getMessageCategory();
            Response responseBody = null;
            switch (messageCategory) {
                case Event:
                    EventNotification eventNotification = response.getEventNotification();
                    log("Event Details: " + eventNotification.getEventDetails());
                    break;
                case Login:
                    if(response.getLoginResponse() != null) {
                        response.getLoginResponse().getResponse();
                        responseBody = response.getLoginResponse().getResponse();
                        if (responseBody.getResult() != null) {
                            log(String.format("Login Result: %s ", responseBody.getResult()));

                            if (responseBody.getResult() != ResponseResult.Success) {
                                log(String.format("Error Condition: %s, Additional Response: %s",
                                        responseBody.getErrorCondition(), responseBody.getAdditionalResponse()));
                            }
                        }
                        waitingForResponse = false;
                    }
                    break;

                default:
                    log(messageCategory + " received during Payment response message handling.");
                    break;
            }
        } else
            log("Unexpected response message received.");

Dependencies


This project uses the following dependencies:

Minimum Required JDK


  • Java 1.8

Note: Other versions may work as well, but have not been tested.

For more details on how to use the methods, please refer to the sample app.

fusioncloud-sdk-java's People

Contributors

blacklabelsolutions avatar clintondean avatar i-grace avatar van-agustin avatar

Watchers

 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.