protected function build()
    {
        if ($this->beforeExecute) {
            call_user_func($this->beforeExecute, $this);
        }
        if ($this->bodyEntity !== null) {
            if ($this->pendingRequest instanceof EntityEnclosingRequestInterface) {
                $this->pendingRequest->setBody(
                    $this->serializer->serialize($this->bodyEntity, $this->requestFormat),
                    $this->requestContentType
                );
            } else {
                throw new \LogicException(
                    'Request must implement EntityEnclosingRequestInterface when command has body'
                );
            }
        }
        if ($this->accessToken !== null) {
            $this->pendingRequest->getParams()->set('oauth_commerce.token', $this->accessToken);
        }
        $this->request = $this->pendingRequest;
    }