Model/Apiconnector/Client.php
public function postDataFields(
        $data,
        $type = 'String',
        $visibility = 'public',
        $defaultValue = false
    ) {
        $url = $this->getApiEndpoint() . self::REST_DATA_FILEDS;
        //set default value for the numeric datatype
        if ($type == 'numeric' && !$defaultValue) {
            $defaultValue = 0;
        }
        //set data for the string datatype
        if (is_string($data)) {
            $data = [
                'Name' => $data,
                'Type' => $type,
                'Visibility' => $visibility,
            ];
            //default value
            if ($defaultValue) {
                $data['DefaultValue'] = $defaultValue;
            }
        }
        $this->setUrl($url)
            ->buildPostBody($data)
            ->setVerb('POST');

        $response = $this->execute();

        if (isset($response->message)) {
            $message = 'POST CREATE DATAFIELDS ' . $response->message;
            $this->helper->debug('postDataFields', [$message]);
            $this->helper->debug('postDataFields', $data);
        }

        return $response;
    }
public function postDataFields(
        $data,
        $type = 'String',
        $visibility = 'public',
        $defaultValue = false
    ) {
        $url = $this->getApiEndpoint() . self::REST_DATA_FILEDS;
        //set default value for the numeric datatype
        if ($type == 'numeric' && !$defaultValue) {
            $defaultValue = 0;
        }
        //set data for the string datatype
        if (is_string($data)) {
            $data = [
                'Name' => $data,
                'Type' => $type,
                'Visibility' => $visibility,
            ];
            //default value
            if ($defaultValue) {
                $data['DefaultValue'] = $defaultValue;
            }
        }
        $this->setUrl($url)
            ->buildPostBody($data)
            ->setVerb('POST');

        $response = $this->execute();

        if (isset($response->message)) {
            $message = 'POST CREATE DATAFIELDS ' . $response->message;
            $this->helper->debug('postDataFields', [$message]);
            $this->helper->debug('postDataFields', $data);
        }

        return $response;
    }
public function postDataFields ( $ data , $ type = 'String' , $ visibility = 'public' , $ defaultValue = false ) { $ url = $ this -> getApiEndpoint ( ) . self :: REST_DATA_FILEDS ; //set default value for the numeric datatype if ( $ type == 'numeric' && ! $ defaultValue ) { $ defaultValue = 0 ; } //set data for the string datatype if ( is_string ( $ data ) ) { $ data = [ 'Name' => $ data , 'Type' => $ type , 'Visibility' => $ visibility , ] ; //default value if ( $ defaultValue ) { $ data [ 'DefaultValue' ] = $ defaultValue ; } } $ this -> setUrl ( $ url ) -> buildPostBody ( $ data ) -> setVerb ( 'POST' ) ; $ response = $ this -> execute ( ) ; if ( isset ( $ response -> message ) ) { $ message = 'POST CREATE DATAFIELDS ' . $ response -> message ; $ this -> helper -> debug ( 'postDataFields' , [ $ message ] ) ; $ this -> helper -> debug ( 'postDataFields' , $ data ) ; } return $ response ; }
Creates a data field within the account.

@param        $data         string/array
@param string $type string, numeric, date, boolean
@param string $visibility public, private
@param bool   $defaultValue

@return object
Creates a data field within the account .