<?php

namespace MGModule\DNSManager2\mgLibs\custom\dns\submodules\SimpleDNSV8;


class Api
{

    private $curl;

    public function __construct(Curl $curl)
    {
        $this->curl = $curl;
    }

    public function getZone($zone)
    {
        return $this->curl->get("/zones/$zone");
    }

    public function getZoneRecords($zone)
    {
        return $this->curl->get("/zones/$zone/records");
    }

    public function getZones()
    {
        return $this->curl->get("/zones");
    }

    public function createZone($zone, $data)
    {
        return $this->curl->put("/zones/$zone", $data);
    }

    public function deleteZone($zone)
    {
        return $this->curl->delete("/zones/$zone");
    }

    public function addRecord($zone, $data)
    {
        return $this->curl->patch("/zones/$zone/records", [$data]);
    }

    public function removeRecord($zone, $data)
    {
        return $this->curl->patch("/zones/$zone/records", [array_merge(['Remove' => true], $data)]);
    }

    public function getDNSSecKeys($zone)
    {
        return $this->curl->get("/zones/$zone/dnsseckeys");
    }

    public function dnsSecSign($zone, $expire)
    {
        return $this->curl->post("/zones/$zone/dnssecsign?expire=$expire", ['asd' => 'qwe']);
    }

    public function createOrUpdateDNSSECkey($zone, $keyId, $data)
    {
        return $this->curl->put("/zones/$zone/dnsseckeys/$keyId", $data);
    }

    public function deleteDNSSECkey($zone, $keyId)
    {
        return $this->curl->delete("/zones/$zone/dnsseckeys/$keyId");
    }



}
