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

com.global.api.entities.payroll.BasePayrollResponse Maven / Gradle / Ivy

There is a newer version: 14.2.3
Show newest version
package com.global.api.entities.payroll;

import com.global.api.entities.exceptions.ApiException;
import com.global.api.utils.JsonDoc;
import org.joda.time.DateTime;

import java.util.List;

public abstract class BasePayrollResponse {
    protected int totalRecords;
    protected List rawResults;
    protected DateTime timestamp;
    protected int statusCode;
    protected String responseMessage;

    int getTotalRecords() {
        return totalRecords;
    }

    List getRawResults() {
        return rawResults;
    }

    public DateTime getTimestamp() {
        return timestamp;
    }

    int getStatusCode() {
        return statusCode;
    }

    String getResponseMessage() {
        return responseMessage;
    }

    BasePayrollResponse(String rawResponse) throws ApiException {
        JsonDoc doc = JsonDoc.parse(rawResponse);
        MapResponseValues(doc);

        if (statusCode != 200) {
            throw new ApiException(responseMessage);
        }
    }

    protected void MapResponseValues(JsonDoc doc) {
        totalRecords = doc.getInt("TotalRecords");
        rawResults = doc.getEnumerator("Results");
//        timestamp = doc.getValue("Timestamp", (input) => {
//            if(input != null)
//                return DateTime.Parse(input.ToString());
//            return null;
//        });
        statusCode = doc.getInt("StatusCode");
        responseMessage = doc.getString("ResponseMessage");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy