コード例 #1
0
 /**
  * @dataProvider apiClientOptionsProvider
  */
 public function testApiClientFactory($apiClientType, $apiClientClassName)
 {
     $apiClient = ApiClientFactory::getInstance()->getClient($this->username, $this->password, $apiClientType);
     $this->assertInstanceOf('\\Grow\\Client\\ApiClient\\ApiClientInterface', $apiClient);
     $this->assertInstanceOf($apiClientClassName, $apiClient);
 }
コード例 #2
0
 public function setUp()
 {
     parent::setUp();
     $this->apiClient = ApiClientFactory::getInstance()->getClient($this->username, $this->password, 'json');
 }
コード例 #3
0
<?php

include_once 'vendor/autoload.php';
include_once 'credentials.php';
use Grow\Client\ApiClient\ApiClientFactory;
use Grow\Client\Model\Baby;
use Grow\Client\Model\Chart;
use Grow\Client\Model\Centile;
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);