Skip to content

Commit

Permalink
add activateZoneService and deactivateZoneService endpoints (#88)
Browse files Browse the repository at this point in the history
* adds activateZoneService and deactivateZoneService to zones service
  • Loading branch information
AGS4NO authored Oct 19, 2023
1 parent 488f09f commit 5dd9dba
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).

- NEW: Added listRegistrantChanges, createRegistrantChange, getRegistrantChange, deleteRegistrantChange and checkRegistrantChange endpoints (dnsimple/dnsimple-php#83)
- NEW: Added getDomainTransferLock, enableDomainTransferLock and deleteDomainTransferLock endpoints (dnsimple/dnsimple-php#85)
- NEW: Added activateZoneService and deactivateZoneService endpoints (dnsimple/dnsimple-php#87)

## 1.1.0

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ cd dnsimple-php

[Install composer locally](https://getcomposer.org/doc/00-intro.md#locally).

Install the dependencies:
Install the dependencies using composer:

```shell
php composer.phar install
composer install
```

### 3. Testing
Expand Down
32 changes: 32 additions & 0 deletions src/Dnsimple/Service/Zones.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,36 @@ public function checkZoneRecordDistribution($account, $zone, $record): Response
$response = $this->get("/{$account}/zones/{$zone}/records/{$record}/distribution");
return new Response($response, ZoneDistribution::class);
}

/**
* Activates DNS services for the zone.
*
* @see https://developer.dnsimple.com/v2/zones/#activateZoneService
*
* @param int $account The account id
* @param string $zone The zone name
* @return Response The zone requested
* @throws DnsimpleException When something goes wrong
*/
public function activateZoneService($account, $zone): Response
{
$response = $this->put("/{$account}/zones/{$zone}/activation");
return new Response($response, Zone::class);
}

/**
* Deactivates DNS services for the zone.
*
* @see https://developer.dnsimple.com/v2/zones/#deactivateZoneService
*
* @param int $account The account id
* @param string $zone The zone name
* @return Response The zone requested
* @throws DnsimpleException When something goes wrong
*/
public function deactivateZoneService($account, $zone): Response
{
$response = $this->delete("/{$account}/zones/{$zone}/activation");
return new Response($response, Zone::class);
}
}
22 changes: 22 additions & 0 deletions tests/Dnsimple/Service/ZonesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,26 @@ public function testCheckZoneDistributionError()

$this->service->checkZoneDistribution(1010, "example.com");
}

public function testActivateZoneService()
{
$this->mockResponseWith("activateZoneService/success");

$zone = $this->service->activateZoneService(1010, "example-alpha.com")->getData();

self::assertEquals(1, $zone->id);
self::assertEquals(1010, $zone->accountId);
self::assertEquals("example-alpha.com", $zone->name);
}

public function testDeactivateZoneService()
{
$this->mockResponseWith("deactivateZoneService/success");

$zone = $this->service->deactivateZoneService(1010, "example-alpha.com")->getData();

self::assertEquals(1, $zone->id);
self::assertEquals(1010, $zone->accountId);
self::assertEquals("example-alpha.com", $zone->name);
}
}
16 changes: 16 additions & 0 deletions tests/fixtures/v2/api/activateZoneService/success.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 22 Jan 2016 16:54:14 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
X-RateLimit-Limit: 4000
X-RateLimit-Remaining: 3995
X-RateLimit-Reset: 1453484046
ETag: W/"2161245abd349a34cba32a970e6424ba"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 93182033-a215-484e-a107-5235fa48001c
X-Runtime: 0.177942
Strict-Transport-Security: max-age=31536000

{"data":{"id":1,"account_id":1010,"name":"example-alpha.com","reverse":false,"created_at":"2015-04-23T07:40:03Z","updated_at":"2015-04-23T07:40:03Z"}}
16 changes: 16 additions & 0 deletions tests/fixtures/v2/api/deactivateZoneService/success.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 22 Jan 2016 16:54:14 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
X-RateLimit-Limit: 4000
X-RateLimit-Remaining: 3995
X-RateLimit-Reset: 1453484046
ETag: W/"2161245abd349a34cba32a970e6424ba"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 93182033-a215-484e-a107-5235fa48001c
X-Runtime: 0.177942
Strict-Transport-Security: max-age=31536000

{"data":{"id":1,"account_id":1010,"name":"example-alpha.com","reverse":false,"created_at":"2015-04-23T07:40:03Z","updated_at":"2015-04-23T07:40:03Z"}}

0 comments on commit 5dd9dba

Please sign in to comment.