All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.global.api.terminals.hpa.responses.InitializeResponse Maven / Gradle / Ivy

There is a newer version: 14.2.3
Show newest version
package com.global.api.terminals.hpa.responses;

import com.global.api.entities.exceptions.ApiException;
import com.global.api.terminals.abstractions.IInitializeResponse;
import com.global.api.utils.Element;
import com.global.api.utils.StringUtils;

import java.util.Dictionary;
import java.util.Hashtable;

public class InitializeResponse extends SipBaseResponse implements IInitializeResponse {
    private Dictionary> _params;
    private String serialNumber;
    private String lastCategory;

    public String getSerialNumber() {
        return serialNumber;
    }
    public void setSerialNumber(String serialNumber) {
        this.serialNumber = serialNumber;
    }

    public InitializeResponse(byte[] buffer, String... messageIds) throws ApiException {
        super(buffer, messageIds);
    }

    protected void mapResponse(Element response) {
        super.mapResponse(response);
        if (_params == null)
            _params = new Hashtable>();

        // set category
        String category = response.getString("TableCategory");
        if(StringUtils.isNullOrEmpty(category))
            category = lastCategory;
        else lastCategory = category;

        if(category != null) {
            if (_params.get(category) == null)
                _params.put(category, new Hashtable());

            for (Element field : response.getAll("Field")) {
                String key = field.getString("Key");
                String value = field.getString("Value");
                _params.get(category).put(key, value);
            }
        }
    }

    protected void finalizeResponse() {
        super.finalizeResponse();

        Dictionary terminalInformation = this._params.get("TERMINAL INFORMATION");
        if(terminalInformation != null)
            serialNumber = terminalInformation.get("SERIAL NUMBER");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy