<?php

include_once dirname(__FILE__) . "/../common/common.php";
include_once dirname(__FILE__) . '/../business/AuthB.php';
include_once dirname(__FILE__) . '/../database/TripAttribute.php';
$auth = new AuthB();
if (!$auth->canSynchTripAttribute()) {
    $response = errorResponse(RESPONSE_UNAUTHORIZED);
} else {
    if (isGetMethod()) {
        if (isset($_GET['hash'])) {
            $hash = $_GET['hash'];
            if ($hash === '') {
                $response = errorResponse(RESPONSE_BAD_REQUEST);
            } else {
                $object = TripAttribute::findByHash($hash);
                if ($object === null) {
                    $response = errorResponse(RESPONSE_NOT_FOUND);
                } else {
                    $response = successResponse();
                    $response['tripId'] = $object->getTripId();
                    $response['name'] = $object->getName();
                    $response['created'] = $object->getCreated();
                    $response['updated'] = $object->getUpdated();
                    $response['value'] = $object->getValue();
                    $response['deleted'] = $object->getDeleted();
                    $response['hash'] = $object->getHash();
                }
            }
        } else {
            $response = errorResponse(RESPONSE_BAD_REQUEST);