public function publishPact($providerName, $consumerName, $version, $contract)
    {
        $request = null;
        if ($contract instanceof \JsonSerializable) {
            $request = $this->requestBuilder->createPublishPactRequestFromObject($this->baseUrl, $consumerName, $providerName, $version, $contract);
        }else if (is_string($contract)) {
            $request = $this->requestBuilder->createPublishPactRequestFromFile($this->baseUrl, $consumerName, $providerName, $version, $contract);
        }

        if (!$request) {
            throw new PactBrokerException("Can't publish contract file. Contract in wrong type.");
        }

        $response = $this->client->sendRequest($request);
        $this->checkIfResponseIsCorrect($response);

        return $response;
    }