"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const base_1 = require("./base");
class Transaction {
    constructor(connection) {
        this.base = new base_1.Base(connection);
    }
    getCount(countQuery) {
        return __awaiter(this, void 0, void 0, function* () {
            // const params = {
            //   senderId: typeof countQuery === "undefined" ? undefined : countQuery.senderId,
            //   senderPublicKey: typeof countQuery === "undefined" ? undefined : countQuery.senderPublicKey,
            // };
            const res = yield this.base.get('/api/transactions/count', countQuery);
            const result = res.data;
            return result;
        });
    }
    newestFirst(newestFirstQuery) {
        return __awaiter(this, void 0, void 0, function* () {
            const params = {
                count: newestFirstQuery.count,
                offset: newestFirstQuery.offset,
                limit: newestFirstQuery.limit,
                senderId: newestFirstQuery.senderId,
                senderPublicKey: newestFirstQuery.senderPublicKey,
            };
            const res = yield this.base.get('/api/transactions/newestFirst', params);
            const result = res.data;
            return result;
        });
    }
    getTransactions(query) {
        return __awaiter(this, void 0, void 0, function* () {
            const params = {
                limit: query.limit,
                offset: query.offset,
                id: query.id,
                senderId: query.senderId,
                senderPublicKey: query.senderPublicKey,
                blockId: query.blockId,
                type: query.type,
                height: query.height,
                message: query.message,
            };
            const res = yield this.base.get('/api/transactions/', params);
            const result = res.data;
            return result;
        });
    }
    getUnconfirmedTransaction(id) {
        return __awaiter(this, void 0, void 0, function* () {
            const params = {
                id: id,
            };
            const res = yield this.base.get('/api/transactions/unconfirmed/get', params);
            const result = res.data;
            return result;
        });
    }
    getUnconfirmedTransactions(senderPublicKey, address) {
        return __awaiter(this, void 0, void 0, function* () {
            const params = {
                senderPublicKey: senderPublicKey,
                address: address,
            };
            const res = yield this.base.get('/api/transactions/unconfirmed', params);
            const result = res.data;
            return result;
        });
    }
    addTransactions(transactions) {
        return __awaiter(this, void 0, void 0, function* () {
            const params = {
                transactions: transactions,
            };
            const res = yield this.base.put('/api/transactions/batch', params);
            const result = res.data;
            return result;
        });
    }
}
exports.Transaction = Transaction;
//# sourceMappingURL=transaction.js.map