Overview

Namespaces

  • Apptus
    • ESales
      • Connector
        • Report
        • Time
    • Util
      • Cache
  • PHP
  • Overview
  • Namespace
  • Class
  • Tree
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 
<?php
namespace Apptus\ESales\Connector;
/**
 * Used to represent the responses from customer data related methods (e.g. {@see Connector::checkCustomerDataJobStatus()}).
 */
class EventDataJobResult
{
    private static $STATUS_MAP = array(
        'unknown' => Status::UNKNOWN,
        'not_found' => Status::NOT_FOUND,
        'created' => Status::CREATED,
        'waiting' => Status::WAITING,
        'running' => Status::RUNNING,
        'done' => Status::DONE,
        'error' => Status::ERROR);

    public $jid;
    public $status;

    public function __construct($jid, $status)
    {
        $this->jid = $jid;
        $this->status = $status;

    }

    public function getJobID()
    {
        return $this->jid;
    }

    /**
     * @return mixed|string
     */
    public function getStatus()
    {
        $result = EventDataJobResult::$STATUS_MAP[$this->status];
        return $result == null ? Status::UNKNOWN : $result;
    }

    /**
     * @return string
     */
    public function getStatusString()
    {
        return $this->status;
    }

    /**
     * @param string $s
     * @return EventDataJobResult
     * @throws MalformedJsonException
     */
    static function parse($s)
    {
        $object = json_decode($s);

        if (is_null($object)) {
            throw new MalformedJsonException('Expected JSON object.');
        }

        $jid = $object->{'jid'};
        $status = $object->{'status'};

        if (!is_string($jid) || !is_string($status)) {
            throw new MalformedJsonException('Expected jid and status in object.');
        }

        return new EventDataJobResult($jid, strtolower($status));
    }

    static function mock($jid, $status)
    {
        return new EventDataJobResult($jid, strtolower($status));
    }
}

class Status
{
    const UNKNOWN = 'UNKNOWN';
    const NOT_FOUND = 'NOT_FOUND';
    const CREATED = 'NOT_FOUND';
    const WAITING = 'WAITING';
    const RUNNING = 'RUNNING';
    const DONE = 'DONE';
    const ERROR = 'ERROR';
}
Apptus ESales Connector PHP API documentation generated by ApiGen