"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("../../../core");
var apdu_1 = require("../../../core/apdu");
var response_1 = require("../response");
/**
 * Created by Stephane on 02/02/2018.
 */
var DefaultResponseDecoder = /** @class */ (function () {
    function DefaultResponseDecoder() {
        this.apduDecoder = new core_1.APDU.Response.APDUResponseConverter();
    }
    DefaultResponseDecoder.prototype.decode = function (data) {
        var apduResponse = this.apduDecoder.decode(data);
        //        Log.d(TAG, "APDU status: " + Helper.ByteArrayToHexString(apduStatus));
        //        Log.d(TAG, "Expected: " + Helper.ByteArrayToHexString(APDUStatusCode.SUCCESSFUL));
        if (apduResponse.statusEquals(core_1.APDU.APDUStatusCode.SUCCESSFUL)) {
            var payload = apduResponse.getData();
            var response = new response_1.Response(payload);
            return response;
        }
        else {
            throw apdu_1.APDUError.responseCodeError(apduResponse.getStatus(), data);
        }
    };
    return DefaultResponseDecoder;
}());
exports.DefaultResponseDecoder = DefaultResponseDecoder;
