public function createComponent($productFamilyId, $componentType)
    {
        $service = $this->getService();

        $rawDataKey = '';
        switch ($componentType) {
            case 'metered_components':
                $rawDataKey = 'metered_component';
                break;
            case 'quantity_based_components':
                $rawDataKey = 'quantity_based_component';
                break;
            case 'on_off_components':
                $rawDataKey = 'on_off_component';
                break;
            default:
                break;
        }
        $rawData  = $this->getRawData(array($rawDataKey => $this->_params));
        $response = $service->request('product_families/' . (int)$productFamilyId . '/' . $componentType, 'POST', $rawData);

        $responseArray = $this->getResponseArray($response);

        if (!$this->isError() && '201' == $response->getStatusCode()) {
            $this->_data = $responseArray['component'];
        } else {
            $this->_data = array();
        }

        return $this;
    }
public function createComponent($productFamilyId, $componentType)
    {
        $service = $this->getService();

        $rawDataKey = '';
        switch ($componentType) {
            case 'metered_components':
                $rawDataKey = 'metered_component';
                break;
            case 'quantity_based_components':
                $rawDataKey = 'quantity_based_component';
                break;
            case 'on_off_components':
                $rawDataKey = 'on_off_component';
                break;
            default:
                break;
        }
        $rawData  = $this->getRawData(array($rawDataKey => $this->_params));
        $response = $service->request('product_families/' . (int)$productFamilyId . '/' . $componentType, 'POST', $rawData);

        $responseArray = $this->getResponseArray($response);

        if (!$this->isError() && '201' == $response->getStatusCode()) {
            $this->_data = $responseArray['component'];
        } else {
            $this->_data = array();
        }

        return $this;
    }
public function createComponent ( $ productFamilyId , $ componentType ) { $ service = $ this -> getService ( ) ; $ rawDataKey = '' ; switch ( $ componentType ) { case 'metered_components' : $ rawDataKey = 'metered_component' ; break ; case 'quantity_based_components' : $ rawDataKey = 'quantity_based_component' ; break ; case 'on_off_components' : $ rawDataKey = 'on_off_component' ; break ; default : break ; } $ rawData = $ this -> getRawData ( array ( $ rawDataKey => $ this -> _params ) ) ; $ response = $ service -> request ( 'product_families/' . ( int ) $ productFamilyId . '/' . $ componentType , 'POST' , $ rawData ) ; $ responseArray = $ this -> getResponseArray ( $ response ) ; if ( ! $ this -> isError ( ) && '201' == $ response -> getStatusCode ( ) ) { $ this -> _data = $ responseArray [ 'component' ] ; } else { $ this -> _data = array ( ) ; } return $ this ; }
Create a component

@param int    $productFamilyId
@param string $componentType ; one of the following:
- metered_components
- quantity_based_components
- on_off_components

@return Component
@see Component::setName()
@see Component::setUnitName()
@see Component::setUnitPrice()
@see Component::setPricingScheme()
@see Component::setPrices()
Create a component