public function testParseDateTime() { $nr = new Response(); $date1 = $nr->parseDateTime('2013-09-21T18:54:39.718+02:00'); $date2 = new \DateTime('2013-09-21T18:54:39+02:00'); $date3 = new \DateTime('2013-09-21T19:54:39+02:00'); $this->assertInstanceOf('DateTime', $date1); $this->assertEquals($date1->getTimestamp(), $date2->getTimestamp()); $this->assertNotEquals($date1->getTimestamp(), $date3->getTimestamp()); }
/** * Create a new Ncip user response * * @param QuiteSimpleXMLElement $dom * @return void */ public function __construct(QuiteSimpleXMLElement $dom = null) { if (is_null($dom)) { return; } parent::__construct($dom->first('/ns1:NCIPMessage/ns1:RenewItemResponse')); if ($this->success) { $this->id = $this->dom->text('ns1:ItemId/ns1:ItemIdentifierValue'); $this->dateDue = $this->parseDateTime($this->dom->text('ns1:DateDue')); } }
/** * Create a new Ncip user response * * @param QuiteSimpleXMLElement $dom * @return void */ public function __construct(QuiteSimpleXMLElement $dom = null) { if (is_null($dom)) { return; } parent::__construct($dom->first('/ns1:NCIPMessage/ns1:CheckInItemResponse')); if ($this->success) { $this->id = $this->dom->text('ns1:ItemId/ns1:ItemIdentifierValue'); $this->agencyId = $this->dom->text('ns1:ItemId/ns1:AgencyId'); } }
/** * Create a new Ncip user response * * @param QuiteSimpleXMLElement $dom * @return void */ public function __construct(QuiteSimpleXMLElement $dom = null) { if (is_null($dom)) { return; } parent::__construct($dom->first('/ns1:NCIPMessage/ns1:LookupItemResponse')); if ($this->success) { $this->exists = true; // not really needed when we have 'success' $this->itemId = $this->dom->text('ns1:ItemId/ns1:ItemIdentifierValue'); $this->agencyId = $this->dom->text('ns1:ItemId/ns1:AgencyId'); $this->dateRecalled = $this->dom->text('ns1:DateRecalled') ? $this->parseDateTime($this->dom->text('ns1:DateRecalled')) : null; $nfo = $this->dom->first('ns1:ItemOptionalFields'); $this->circulationStatus = $nfo->text('ns1:CirculationStatus'); $this->onLoan = $this->circulationStatus === 'On Loan'; $this->bibliographic = $this->parseBibliographicDescription($nfo->first('ns1:BibliographicDescription')); //$this->callNumber = $nfo->text('ns1:ItemDescription/ns1:CallNumber'); //$this->location = $nfo->text('ns1:Location/ns1:LocationName/ns1:LocationNameInstance/ns1:LocationNameValue'); } }
/** * Create a new Ncip checkout response * * @param QuiteSimpleXMLElement $dom * @return void */ public function __construct(QuiteSimpleXMLElement $dom = null) { if (is_null($dom)) { return; } parent::__construct($dom->first('/ns1:NCIPMessage/ns1:CheckOutItemResponse')); if ($this->success) { $this->userId = $this->dom->text('ns1:UserId/ns1:UserIdentifierValue'); $this->itemId = $this->dom->text('ns1:ItemId/ns1:ItemIdentifierValue'); $this->userAgencyId = $this->dom->text('ns1:UserId/ns1:AgencyId'); $this->itemAgencyId = $this->dom->text('ns1:ItemId/ns1:AgencyId'); $this->dateDue = $this->parseDateTime($this->dom->text('ns1:DateDue')); $x = $this->dom->first('ns1:ItemOptionalFields/ns1:BibliographicDescription'); if ($x) { $this->bibliographic = $this->parseBibliographicDescription($x); } } }
/** * Create a new Ncip user response * * @param QuiteSimpleXMLElement $dom * @return void */ public function __construct(QuiteSimpleXMLElement $dom = null) { $this->loanedItems = array(); if (is_null($dom)) { return; } parent::__construct($dom->first('/ns1:NCIPMessage/ns1:LookupUserResponse')); if ($this->success) { $this->exists = true; // not really neccessary as we have 'success' $uinfo = $this->dom->first('ns1:UserOptionalFields'); $this->userId = $this->dom->text('ns1:UserId/ns1:UserIdentifierValue'); $this->agencyId = $this->dom->text('ns1:UserId/ns1:AgencyId'); $this->firstName = $uinfo->text('ns1:NameInformation/ns1:PersonalNameInformation/ns1:StructuredPersonalUserName/ns1:GivenName'); $this->lastName = $uinfo->text('ns1:NameInformation/ns1:PersonalNameInformation/ns1:StructuredPersonalUserName/ns1:Surname'); $this->postalAddress = $uinfo->text('ns1:UserAddressInformation/ns1:PhysicalAddress/ns1:UnstructuredAddress/ns1:UnstructuredAddressData'); $this->lang = $uinfo->text('ns1:UserLanguage'); $this->loanedItems = array(); foreach ($uinfo->xpath('ns1:UserAddressInformation') as $adrinfo) { if ($adrinfo->text('ns1:UserAddressRoleType') == 'mailto') { $this->email = $adrinfo->text('ns1:ElectronicAddress/ns1:ElectronicAddressData'); } else { if ($adrinfo->text('ns1:UserAddressRoleType') == 'sms') { $this->phone = $adrinfo->text('ns1:ElectronicAddress/ns1:ElectronicAddressData'); } } } foreach ($this->dom->xpath('ns1:LoanedItem') as $loanedItem) { $this->loanedItems[] = array('id' => $loanedItem->text('ns1:ItemId/ns1:ItemIdentifierValue'), 'reminderLevel' => $loanedItem->text('ns1:ReminderLevel'), 'dateDue' => $this->parseDateTime($loanedItem->text('ns1:DateDue')), 'title' => $loanedItem->text('ns1:Title')); // TODO: Add ns1:Ext/ns1:BibliographicDescription ? } } }