'use strict';

const Token = require('./Token-8c5ba5d9.js');
const index = require('./index-c910887e.js');
const Item = require('./Item-00ce8c24.js');
require('./ok-97a5fd0b.js');
require('./index-9d95c045.js');
require('./index-cc85865d.js');
require('./TextDecoder-753156f3.js');
require('./_commonjsHelpers-537d719a.js');
require('./index-09251373.js');

class Merchant {
    constructor(connection) {
        this.connection = connection;
    }
    async create(request) {
        return await this.connection.post("merchant", request);
    }
    async list() {
        return this.connection.get("merchant");
    }
    async change(request, id) {
        return await this.connection.patch("merchant/" + (Token.Identifier.is(id) ? id : ""), request);
    }
    async load(id) {
        return !id
            ? await this.connection.get("merchant")
            : Token.Identifier.is(id)
                ? await this.connection.get("merchant/" + id)
                : (await Promise.all(id.map(i => this.connection.get("merchant/" + i)))).filter(index.Merchant.is);
    }
    static open(url, token) {
        const connection = Item.Connection.open(url, token);
        return connection && new Merchant(connection);
    }
}

exports.Merchant = Merchant;
