private function constructInsertEntityContext(
        $table,
        Entity $entity,
        TableServiceCreateOptions $options = null
    ) {
        Validate::canCastAsString($table, 'table');
        Validate::notNullOrEmpty($table, 'table');
        Validate::notNullOrEmpty($entity, 'entity');
        Validate::isTrue($entity->isValid($msg), $msg);

        $method      = Resources::HTTP_POST;
        $context     = new HttpCallContext();
        $headers     = array();
        $queryParams = array();
        $statusCode  = Resources::STATUS_CREATED;
        $path        = $table;
        $body        = $this->odataSerializer->getEntity($entity);

        if (is_null($options)) {
            $options = new TableServiceCreateOptions();
        }

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_TYPE,
            Resources::JSON_CONTENT_TYPE
        );
        $this->addOptionalHeader(
            $headers,
            Resources::ACCEPT_HEADER,
            $options->getAccept()
        );
        $this->addOptionalHeader(
            $headers,
            Resources::PREFER,
            $options->getDoesReturnContent() ? Resources::RETURN_CONTENT : null
        );

        $options->setLocationMode(LocationMode::PRIMARY_ONLY);
        $context->setBody($body);
        $context->setHeaders($headers);
        $context->setMethod($method);
        $context->setPath($path);
        $context->setQueryParameters($queryParams);
        $context->addStatusCode($statusCode);
        $context->setServiceOptions($options);

        return $context;
    }
private function constructInsertEntityContext(
        $table,
        Entity $entity,
        TableServiceCreateOptions $options = null
    ) {
        Validate::canCastAsString($table, 'table');
        Validate::notNullOrEmpty($table, 'table');
        Validate::notNullOrEmpty($entity, 'entity');
        Validate::isTrue($entity->isValid($msg), $msg);

        $method      = Resources::HTTP_POST;
        $context     = new HttpCallContext();
        $headers     = array();
        $queryParams = array();
        $statusCode  = Resources::STATUS_CREATED;
        $path        = $table;
        $body        = $this->odataSerializer->getEntity($entity);

        if (is_null($options)) {
            $options = new TableServiceCreateOptions();
        }

        $this->addOptionalHeader(
            $headers,
            Resources::CONTENT_TYPE,
            Resources::JSON_CONTENT_TYPE
        );
        $this->addOptionalHeader(
            $headers,
            Resources::ACCEPT_HEADER,
            $options->getAccept()
        );
        $this->addOptionalHeader(
            $headers,
            Resources::PREFER,
            $options->getDoesReturnContent() ? Resources::RETURN_CONTENT : null
        );

        $options->setLocationMode(LocationMode::PRIMARY_ONLY);
        $context->setBody($body);
        $context->setHeaders($headers);
        $context->setMethod($method);
        $context->setPath($path);
        $context->setQueryParameters($queryParams);
        $context->addStatusCode($statusCode);
        $context->setServiceOptions($options);

        return $context;
    }
private function constructInsertEntityContext ( $ table , Entity $ entity , TableServiceCreateOptions $ options = null ) { Validate :: canCastAsString ( $ table , 'table' ) ; Validate :: notNullOrEmpty ( $ table , 'table' ) ; Validate :: notNullOrEmpty ( $ entity , 'entity' ) ; Validate :: isTrue ( $ entity -> isValid ( $ msg ) , $ msg ) ; $ method = Resources :: HTTP_POST ; $ context = new HttpCallContext ( ) ; $ headers = array ( ) ; $ queryParams = array ( ) ; $ statusCode = Resources :: STATUS_CREATED ; $ path = $ table ; $ body = $ this -> odataSerializer -> getEntity ( $ entity ) ; if ( is_null ( $ options ) ) { $ options = new TableServiceCreateOptions ( ) ; } $ this -> addOptionalHeader ( $ headers , Resources :: CONTENT_TYPE , Resources :: JSON_CONTENT_TYPE ) ; $ this -> addOptionalHeader ( $ headers , Resources :: ACCEPT_HEADER , $ options -> getAccept ( ) ) ; $ this -> addOptionalHeader ( $ headers , Resources :: PREFER , $ options -> getDoesReturnContent ( ) ? Resources :: RETURN_CONTENT : null ) ; $ options -> setLocationMode ( LocationMode :: PRIMARY_ONLY ) ; $ context -> setBody ( $ body ) ; $ context -> setHeaders ( $ headers ) ; $ context -> setMethod ( $ method ) ; $ context -> setPath ( $ path ) ; $ context -> setQueryParameters ( $ queryParams ) ; $ context -> addStatusCode ( $ statusCode ) ; $ context -> setServiceOptions ( $ options ) ; return $ context ; }
Constructs HTTP call context for insertEntity API.

@param string                    $table   The name of the table.
@param Entity                    $entity  The table entity.
@param TableServiceCreateOptions $options The optional parameters.

@return HttpCallContext
Constructs HTTP call context for insertEntity API .