From 4df937f767fb46cac7bd22917ac592b74df8e243 Mon Sep 17 00:00:00 2001 From: Fabio Giacomoni Date: Tue, 2 Nov 2021 15:46:49 +0100 Subject: [PATCH] Modifiche ad aggiunta record DNS --- src/Endpoints/DNS.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Endpoints/DNS.php b/src/Endpoints/DNS.php index 48145a7..3b2a6e5 100644 --- a/src/Endpoints/DNS.php +++ b/src/Endpoints/DNS.php @@ -67,8 +67,23 @@ class DNS implements API $user = $this->adapter->post('zones/' . $zoneID . '/dns_records', $options); $this->body = json_decode($user->getBody()); + + $result = $this->body->result; + + if( !( $result instanceof \stdClass ) ) { + $errorMessage = ''; + + if( is_array( $result ) ) { + $errorMessage.= implode( $result ); + + } elseif( is_string( $result ) ) { + $errorMessage.= $result; + } + + throw new EndpointException( sprintf( 'Unexpected add record result. %s', $errorMessage ) ); + } - return $this->body->result; + return $result; } public function listRecords(