Explorar o código

Add support for dealing with webhooks. mydnshost/mydnshost-api#9

Shane Mc Cormack %!s(int64=7) %!d(string=hai) anos
pai
achega
0f755ac9bd
Modificáronse 1 ficheiros con 53 adicións e 0 borrados
  1. 53 0
      src/MyDNSHostAPI.php

+ 53 - 0
src/MyDNSHostAPI.php

@@ -846,6 +846,59 @@
 			return $this->api(($this->domainAdmin ? '/admin' : '') . '/domains/' . $domain . '/keys/' . $key, 'DELETE');
 		}
 
+		/**
+		 * Get Domain Hooks for the given domain
+		 *
+		 * @param $domain Domain to get hooks for
+		 * @return Array of domain hooks.
+		 */
+		public function getDomainHooks($domain) {
+			if ($this->auth === FALSE) { return NULL; }
+
+			$result = $this->api(($this->domainAdmin ? '/admin' : '') . '/domains/' . $domain . '/hooks');
+			return isset($result['response']) ? $result['response'] : (isset($result['error']) ? NULL : []);
+		}
+
+		/**
+		 * Create a new Domain Hook.
+		 *
+		 * @param $domain Domain to create hook for
+		 * @param $data Data to use for the create
+		 * @return Result of create operation.
+		 */
+		public function createDomainHook($domain, $data) {
+			if ($this->auth === FALSE) { return []; }
+
+			return $this->api(($this->domainAdmin ? '/admin' : '') . '/domains/' . $domain . '/hooks', 'POST', $data);
+		}
+
+		/**
+		 * Update a Domain Hook.
+		 *
+		 * @param $domain Domain to update hook for
+		 * @param $hookid Hook ID to update
+		 * @param $data Data to use for the update
+		 * @return Result of update operation.
+		 */
+		public function updateDomainHook($domain, $hookid, $data) {
+			if ($this->auth === FALSE) { return []; }
+
+			return $this->api(($this->domainAdmin ? '/admin' : '') . '/domains/' . $domain . '/hooks/' . $hookid, 'POST', $data);
+		}
+
+		/**
+		 * Delete a Domain Hook.
+		 *
+		 * @param $domain Domain to delete hook for
+		 * @param $hookid hookid to delete
+		 * @return Result of delete operation.
+		 */
+		public function deleteDomainHook($domain, $hookid) {
+			if ($this->auth === FALSE) { return []; }
+
+			return $this->api(($this->domainAdmin ? '/admin' : '') . '/domains/' . $domain . '/hooks/' . $hookid, 'DELETE');
+		}
+
 		/**
 		 * Get the last response from the API
 		 *