Exemplo n.º 1
0
 /**
  * @param  null $data
  * @return Message
  */
 public function contacts($data = null)
 {
     $message = new Message();
     $result = $this->ontime->contacts($data);
     if (!isset($result['error'])) {
         $result = Contact::fromApiToEntity($result);
         $message->setSuccess(true);
         $message->setResult($result);
     } else {
         $message->setErrors($result['error']);
     }
     return $message;
 }
Exemplo n.º 2
0
 /**
  * @param  array          $datas
  * @param  EntityAbstract $element
  * @return mixed|void
  */
 protected function fromApiToEntitySingle($datas = [], &$element = null)
 {
     $datas = parent::prepareData($datas);
     $entity = $element instanceof ItemAbstract ? $element : self::instanciateItemType($this->get($datas, 'item_type'));
     $entity->setId($this->get($datas, 'id'));
     $entity->setNumber($this->get($datas, 'number'));
     $entity->setName($this->get($datas, 'name'));
     $entity->setDescription($this->get($datas, 'description'));
     $entity->setNotes($this->get($datas, 'notes'));
     $entity->setHasWorkLogs($this->get($datas, 'has_work_logs'));
     $entity->setHasAttachments($this->get($datas, 'has_attachments'));
     $entity->setHasNotifications($this->get($datas, 'has_notifications'));
     $entity->setHasRelatedItems($this->get($datas, 'has_related_items'));
     $entity->setHasEmails($this->get($datas, 'has_emails'));
     $entity->setHasCommits($this->get($datas, 'has_commits'));
     $entity->setHasZendeskTickets($this->get($datas, 'has_zendesk_tickets'));
     $entity->setIsRanked($this->get($datas, 'is_ranked'));
     $entity->setArchived($this->get($datas, 'archived'));
     $entity->setPubliclyViewable($this->get($datas, 'publicly_viewable'));
     $entity->setRank($this->get($datas, 'rank'));
     $entity->setItemType($this->get($datas, 'item_type'));
     $entity->setHasNotifications($this->get($datas, 'has_notifications'));
     $entity->setSubitemType($this->get($datas, 'subitem_type'));
     $entity->setResolution($this->get($datas, 'resolution'));
     $entity->setPercentComplete($this->get($datas, 'percent_complete'));
     $entity->setBuildNumber($this->get($datas, 'build_number'));
     $entity->setBuildNumberOfFix($this->get($datas, 'build_number_of_fix'));
     $entity->setVote(isset($datas['vote']) ? self::voteFromApiToEntitySingle($datas['vote']) : null);
     if (isset($datas['parent'])) {
         $parent = self::instanciateItemType($this->get($datas, 'item_type'));
         $entity->setParent(self::fromApiToEntity($datas['parent'], $parent));
     }
     $entity->setCustomFields(isset($datas['custom_fields']) ? CustomField::fromApiToEntity($datas['custom_fields']) : null);
     $entity->setReplicationProcedures($this->get($datas, 'replication_procedures'));
     // Dates
     $entity->setReportedDate(isset($datas['reported_date']) && null !== $datas['reported_date'] ? new \DateTime($datas['reported_date']) : null);
     $entity->setCompletionDate(isset($datas['completion_date']) && null !== $datas['completion_date'] ? new \DateTime($datas['completion_date']) : null);
     $entity->setCreatedDateTime(isset($datas['created_date_time']) && null !== $datas['created_date_time'] ? new \DateTime($datas['created_date_time']) : null);
     $entity->setLastUpdatedDateTime(isset($datas['last_updated_date_time']) && null !== $datas['last_updated_date_time'] ? new \DateTime($datas['last_updated_date_time']) : null);
     $entity->setDueDate(isset($datas['due_date']) && null !== $datas['due_date'] ? new \DateTime($datas['due_date']) : null);
     // Subitems
     if (isset($datas['subitems'])) {
         if (isset($datas['subitems']['count']) && $datas['subitems']['count'] > 0) {
         }
     }
     // Project
     $entity->setProject(isset($datas['project']) ? Project::fromApiToEntity($datas['project']) : null);
     $entity->setParentProject(isset($datas['project_parent']) ? Project::fromApiToEntity($datas['project_parent']) : null);
     // Release
     $entity->setRelease(isset($datas['release']) ? Release::fromApiToEntity($datas['release']) : null);
     // Durations
     $entity->setRemainingDuration(isset($datas['remaining_duration']) ? self::durationFromApiToEntitySingle($datas['remaining_duration']) : null);
     $entity->setActualDuration(isset($datas['actual_duration']) ? self::durationFromApiToEntitySingle($datas['actual_duration']) : null);
     $entity->setEstimatedDuration(isset($datas['estimated_duration']) ? self::durationFromApiToEntitySingle($datas['estimated_duration']) : null);
     // User, contacts and customer
     $entity->setReportedBy(isset($datas['reported_by']) ? User::fromApiToEntity($datas['reported_by']) : null);
     $entity->setCreatedBy(isset($datas['created_by']) ? User::fromApiToEntity($datas['created_by']) : null);
     $entity->setLastUpdatedBy(isset($datas['last_updated_by']) ? User::fromApiToEntity($datas['last_updated_by']) : null);
     if (isset($datas['assigned_to']) && $datas['assigned_to']['type']) {
         $assignedTo = PeopleAbstract::instanciatePeopleType($datas['assigned_to']['type']);
         $entity->setCreatedBy($assignedTo->getHelper()->fromApiToEntity($datas['assigned_to']));
     }
     $entity->setReportedByCustomerContact(isset($datas['reported_by_customer_contact']) ? Contact::fromApiToEntity($datas['reported_by_customer_contact']) : null);
     $entity->setCustomer(isset($datas['customer']) ? Customer::fromApiToEntity($datas['customer']) : null);
     // Item options type
     $entity->setPriority(isset($datas['priority']) ? self::priorityFromApiToEntitySingle($datas['priority']) : null);
     $entity->setStatus(isset($datas['status']) ? self::statusFromApiToEntitySingle($datas['status']) : null);
     $entity->setSeverity(isset($datas['severity']) ? self::severityFromApiToEntitySingle($datas['severity']) : null);
     $entity->setWorkflowStep(isset($datas['workflow_step']) ? self::workflowStepFromApiToEntitySingle($datas['workflow_step']) : null);
     return $entity;
 }