'use strict';

const apiBase = require('./apiBase-e4ebaf8b.js');

class DamgaApi {
  constructor(endpoint, defaultHeaders = {}, defaultQueryParams = {}) {
    // region domains
    this.createDomain = (data) => this.api.post(`domains`, data);
    this.getDomains = () => this.api.get(`domains`);
    this.updateDomain = (id, data) => this.api.put(`domains/${id}`, data);
    this.deleteDomain = (id) => this.api.delete(`domains/${id}`);
    // endregion
    // region load-balancers
    this.createLoadBalancer = (data) => this.api.post(`load-balancers`, data);
    this.getLoadBalancers = () => this.api.get(`load-balancers`);
    this.updateLoadBalancer = (id, data) => this.api.put(`load-balancers/${id}`, data);
    this.deleteLoadBalancer = (id) => this.api.delete(`load-balancers/${id}`);
    // endregion
    // region target-groups
    this.createTargetGroup = (data) => this.api.post(`target-groups`, data);
    this.getTargetGroups = () => this.api.get(`target-groups`);
    this.updateTargetGroup = (id, data) => this.api.put(`target-groups/${id}`, data);
    this.deleteTargetGroup = (id) => this.api.delete(`target-groups/${id}`);
    // endregion
    this.getDnsRecord = (domain) => this.api.post(`tools/dns-lookup`, { domain });
    this.api = new apiBase.APIBase(endpoint, defaultHeaders);
    this.api.axios.defaults.params = defaultQueryParams;
  }
}

exports.DamgaApi = DamgaApi;
