public function call(string $method, RequestInterface $request, $responseClass)
    {
        $serializer = $this->getSerializer();

        $req = $res = null;

        try {
            $req = $serializer->normalize($request, 'json');

            $res = $this->request('POST', $method, [
                'json' => $req,
            ]);

            $parts = $this->parseResponse($res->getBody()->getContents());

            /** @var ResponseInterface $response */
            $response = null;
            foreach ($parts as $part) {
                if ($part['headers']['Content-ID'] === '<jsonInfos>') {
                    $response = $this->serializer->deserialize($part['body'], $responseClass, 'json');
                } elseif ($response) {
                    $response->addAttachment(
                        new Attachment(trim($part['headers']['Content-ID'], '<>'), $part['body'])
                    );
                }
            }

            return $response->setSuccess(true);
        } catch (\GuzzleHttp\Exception\ClientException $exception) {
            $response = new $responseClass;
            if (null !== $res = $exception->getResponse()) {
                $data = json_decode($res->getBody()->getContents(), true);
                if (isset($data['messages']) && !empty($data['messages'])) {
                    foreach ($data['messages'] as $m) {
                        $response->addMessage(new Message(intval($m['id']), $m['type'], $m['messageContent']));
                    }
                }
                return $response;
            }

            throw $exception;
        } catch (\Exception $exception) {
            $exception = new ClientException('REST call failed', 0, $exception);

            if ($this->debug && $req) {
                $exception->request = $req;
            }
            if ($this->debug && $res) {
                $exception->response = $res;
            }

            throw $exception;
        }
    }
public function call(string $method, RequestInterface $request, $responseClass)
    {
        $serializer = $this->getSerializer();

        $req = $res = null;

        try {
            $req = $serializer->normalize($request, 'json');

            $res = $this->request('POST', $method, [
                'json' => $req,
            ]);

            $parts = $this->parseResponse($res->getBody()->getContents());

            /** @var ResponseInterface $response */
            $response = null;
            foreach ($parts as $part) {
                if ($part['headers']['Content-ID'] === '<jsonInfos>') {
                    $response = $this->serializer->deserialize($part['body'], $responseClass, 'json');
                } elseif ($response) {
                    $response->addAttachment(
                        new Attachment(trim($part['headers']['Content-ID'], '<>'), $part['body'])
                    );
                }
            }

            return $response->setSuccess(true);
        } catch (\GuzzleHttp\Exception\ClientException $exception) {
            $response = new $responseClass;
            if (null !== $res = $exception->getResponse()) {
                $data = json_decode($res->getBody()->getContents(), true);
                if (isset($data['messages']) && !empty($data['messages'])) {
                    foreach ($data['messages'] as $m) {
                        $response->addMessage(new Message(intval($m['id']), $m['type'], $m['messageContent']));
                    }
                }
                return $response;
            }

            throw $exception;
        } catch (\Exception $exception) {
            $exception = new ClientException('REST call failed', 0, $exception);

            if ($this->debug && $req) {
                $exception->request = $req;
            }
            if ($this->debug && $res) {
                $exception->response = $res;
            }

            throw $exception;
        }
    }
public function call ( string $ method , RequestInterface $ request , $ responseClass ) { $ serializer = $ this -> getSerializer ( ) ; $ req = $ res = null ; try { $ req = $ serializer -> normalize ( $ request , 'json' ) ; $ res = $ this -> request ( 'POST' , $ method , [ 'json' => $ req , ] ) ; $ parts = $ this -> parseResponse ( $ res -> getBody ( ) -> getContents ( ) ) ; /** @var ResponseInterface $response */ $ response = null ; foreach ( $ parts as $ part ) { if ( $ part [ 'headers' ] [ 'Content-ID' ] === '<jsonInfos>' ) { $ response = $ this -> serializer -> deserialize ( $ part [ 'body' ] , $ responseClass , 'json' ) ; } elseif ( $ response ) { $ response -> addAttachment ( new Attachment ( trim ( $ part [ 'headers' ] [ 'Content-ID' ] , '<>' ) , $ part [ 'body' ] ) ) ; } } return $ response -> setSuccess ( true ) ; } catch ( \ GuzzleHttp \ Exception \ ClientException $ exception ) { $ response = new $ responseClass ; if ( null !== $ res = $ exception -> getResponse ( ) ) { $ data = json_decode ( $ res -> getBody ( ) -> getContents ( ) , true ) ; if ( isset ( $ data [ 'messages' ] ) && ! empty ( $ data [ 'messages' ] ) ) { foreach ( $ data [ 'messages' ] as $ m ) { $ response -> addMessage ( new Message ( intval ( $ m [ 'id' ] ) , $ m [ 'type' ] , $ m [ 'messageContent' ] ) ) ; } } return $ response ; } throw $ exception ; } catch ( \ Exception $ exception ) { $ exception = new ClientException ( 'REST call failed' , 0 , $ exception ) ; if ( $ this -> debug && $ req ) { $ exception -> request = $ req ; } if ( $ this -> debug && $ res ) { $ exception -> response = $ res ; } throw $ exception ; } }
Call the web service.

@param string           $method
@param RequestInterface $request
@param string           $responseClass

@return ResponseInterface

@throws ClientException
Call the web service .