public function testSavePdf()
 {
     $expectedFileContent = 'pdf';
     $entity = Chart::createNew()->setChartImage(base64_encode($expectedFileContent));
     $filename = sprintf("%s/pdf.%s", sys_get_temp_dir(), rand(1, 9999999));
     $entity->saveImage($filename);
     $this->assertStringEqualsFile($filename, $expectedFileContent);
 }
 /**
  * {@inheritdoc}
  */
 public function getChart($chartIdentifier, DateTime $edd, ImageConfig $imageConfig)
 {
     $url = $this->buildQuery(sprintf('/api/Storage/Chart/%s/', $chartIdentifier), array('EDD' => $edd->format('Y-m-d'), 'ImageConfig' => array('Greyscale' => $imageConfig->getGreyscale() ? 'true' : 'false', 'ShowExtraCentiles' => $imageConfig->getShowExtraCentiles() ? 'true' : 'false', 'GridlinesByWeight' => $imageConfig->getGridlinesByWeight() ? 'true' : 'false', 'ScalePercent' => (int) $imageConfig->getScalePercent())));
     $data = $this->doRequest($url);
     return Chart::createFromJson($data)->setChartIdentifier($chartIdentifier);
 }
use Grow\Client\Model\Measurement;
use Grow\Client\Model\Config\ImageConfig;
use Grow\Client\Model\Config\PdfConfig;
use Grow\Client\Model\Option\GenderOption;
use Grow\Client\Model\Option\EthnicityOption;
$apiClient = ApiClientFactory::getInstance()->getClient(GROW_API_USERNAME, GROW_API_PASSWORD);
$edd = new DateTime("-1 day");
$ethnicities = $apiClient->getEthnicities();
$genders = $apiClient->getGenders();
$outcomes = $apiClient->getOutcomes();
$measurementTypes = $apiClient->getMeasurementTypes();
$hospitals = $apiClient->getHospitals();
$babies = array(Baby::createNew()->setBirthOrderNumber(0)->setBirthWeight(3550)->setGender($genders->current()->getIdentifier())->setGestation(275)->setName('Baby1')->setUnknown(false), Baby::createNew()->setBirthOrderNumber(1)->setUnknown(true));
$imageConfig = ImageConfig::createNew()->setGreyscale(false)->setGridlinesByWeight(false)->setScalePercent(200)->setShowExtraCentiles(false);
$pdfConfig = PdfConfig::createNew()->setGreyscale(false)->setGridlinesByWeight(false)->setShowExtraCentiles(false);
$chart = Chart::createNew()->setBabies($babies)->setDob(new DateTime("1990-01-01 01:01:01"))->setEdd($edd)->setEthnicity($ethnicities->current()->getIdentifier())->setFirstname("SampleFN")->setLastname("SampleLN")->setMotherRef("SampleMR")->setGetPdf(true)->setGetImage(true)->setHeight(163)->setImageConfig($imageConfig)->setPdfConfig($pdfConfig)->setWeight(45);
$chartResponse = $apiClient->addChart($chart);
$chartIdentifier = $chart->getChartIdentifier();
$chartIdentifierPrefix = $apiClient->getChartIdentifierPrefix($chartIdentifier);
$prefixedChartIdentifier = sprintf("%s%s", (string) $chartIdentifierPrefix, $chartIdentifier);
echo sprintf("Chart #%s added.\n", $chartIdentifier);
$imageFilename = sprintf("/tmp/%s.jpg", $chartIdentifier);
$chartResponse->saveImage($imageFilename);
echo sprintf("Chart's image saved as '%s'.\n", $imageFilename);
$pdfFilename = sprintf("/tmp/%s.pdf", $chartIdentifier);
$chartResponse->savePdf($pdfFilename);
echo sprintf("Chart's pdf saved as '%s'.\n", $pdfFilename);
// getChart($chartIdentifier, DateTime $edd, ImageConfig $imageConfig);
// Measurement - Add
$measurement = Measurement::createNew()->setDate(new DateTime())->setType($measurementTypes->current()->getIdentifier())->setValue(32)->setImageConfig($imageConfig);
$measurement = $apiClient->addMeasurement($prefixedChartIdentifier, $measurement);