/** * Converts a response from the Printfection API to the corresponding PHP object. * * @param array $resp The response from the Printfection API. * @param string $apiKey * @return Printfection_Object|array */ public static function convertToPrintfectionObject($resp, $apiKey) { $types = array('campaign' => 'Printfection_Campaign', 'image' => 'Printfection_Image', 'item' => 'Printfection_Item', 'lineitem' => 'Printfection_LineItem', 'list' => 'Printfection_List', 'order' => 'Printfection_Order', 'size' => 'Printfection_Size'); if (self::isList($resp)) { $mapped = array(); foreach ($resp as $i) { array_push($mapped, self::convertToPrintfectionObject($i, $apiKey)); } return $mapped; } else { if (is_array($resp)) { if (isset($resp['object']) && is_string($resp['object']) && isset($types[$resp['object']])) { $class = $types[$resp['object']]; } else { $class = 'Printfection_Object'; } return Printfection_Object::scopedConstructFrom($class, $resp, $apiKey); } else { return $resp; } } }
public static function init() { self::$permanentAttributes = new Printfection_Util_Set(array('_apiKey', 'id')); }