public function postRequest($action, $type, $network, $object) { if (count($object['objects']) < 1) { throw new Exception("Object is empty"); } $_body = json_encode($object); $_bodyLength = mb_strlen($_body); if ($_bodyLength >= self::MAX_REQUEST_BODY) { throw new Exception("Body message is longer than maximum limit of " . self::MAX_REQUEST_BODY . ": {$_bodyLength}"); } if ($action != 'invalidate' && $action != 'delete') { throw new Exception("Invalid action {$action}"); } if ($type != 'url' && $type != 'cpcode') { throw new Exception("Invalid type {$type}"); } if ($network != 'production' && $network != 'staging') { throw new Exception("Invalid network {$network}"); } $_URL = self::BASE_URL . "/{$action}/{$type}/{$network}"; $response = $this->client->post($_URL, ['body' => $_body, 'headers' => ['Content-Type' => 'application/json']]); return $response; }