コード例 #1
0
ファイル: JoindinService.php プロジェクト: phpminds/website
 /**
  * Approved events should show in the upcoming list
  *
  * @param array $events
  * @return bool
  */
 public function areEventsApproved(array &$events)
 {
     $response = $this->httpClient->get($this->joindinEvent->getUrl('users/hosted?username='******''));
     // get the URI for the hosted events
     $usernameInfo = json_decode($response->getBody()->getContents(), true);
     $hostedEventsUri = '';
     if (!empty($usernameInfo['users'])) {
         if (!isset($usernameInfo['users'][0]['hosted_events_uri'])) {
             return false;
         }
         $hostedEventsUri = $usernameInfo['users'][0]['hosted_events_uri'];
     }
     $response = $this->httpClient->get($hostedEventsUri);
     $hostedEvents = json_decode($response->getBody()->getContents(), true)['events'];
     if (empty($hostedEvents)) {
         return false;
     }
     $events = array_reduce($events, function ($carry, $item) {
         $carry[$item->joindin_event_name] = $item;
         return $carry;
     });
     $found = false;
     foreach ($hostedEvents as $event) {
         if (array_key_exists($event['name'], $events)) {
             $found = true;
             $events[$event['name']]->uri = $event['uri'];
         }
     }
     return $found;
 }
コード例 #2
0
ファイル: JoindinEventTest.php プロジェクト: phpminds/website
 public function testCanCreateAnEventPayload()
 {
     $eventPayload = $this->joindinEvent->getCreateEventPayload($this->event, 'a name', 'a description');
     $expectedPayload = ['name' => 'PHPMinds December 2015', 'description' => 'Event description', 'start_date' => '2015-12-17 20:00:00', 'end_date' => '2015-12-17 22:00:00', 'tz_continent' => 'Europe', 'tz_place' => 'London', 'location' => 'a little venue'];
     $this->assertSame($expectedPayload, $eventPayload);
 }