Completed
Push — master ( f20108...eb6666 )
by Marin
03:29
created

Webhook   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 0
cbo 1
dl 0
loc 104
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 4 1
A getTrigger() 0 4 1
A getCount() 0 4 1
A setMetadata() 0 4 1
1
<?php
2
3
namespace Anorgan\OnFleet;
4
5
/**
6
 * Class Webhook
7
 * @package Anorgan\OnFleet
8
 */
9
class Webhook extends Entity
10
{
11
    /**
12
     * Task started by worker. Request includes: taskId, data.task
13
     */
14
    const TRIGGER_TASK_STARTED          = 0;
15
16
    /**
17
     * Worker ETA less than or equal to notification threshold. Request includes: taskId, data.task
18
     */
19
    const TRIGGER_TASK_ETA              = 1;
20
21
    /**
22
     * Worker arriving, 150 meters away or closer. Request includes: taskId, data.task
23
     */
24
    const TRIGGER_TASK_ARRIVAL          = 2;
25
26
    /**
27
     * Task completed by worker. Request includes: taskId, data.task
28
     */
29
    const TRIGGER_TASK_COMPLETED        = 3;
30
31
    /**
32
     * Task failed. Request includes: taskId, data.task
33
     */
34
    const TRIGGER_TASK_FAILED           = 4;
35
36
    /**
37
     * New task created. Request includes: taskId, data.task
38
     */
39
    const TRIGGER_TASK_CREATED          = 6;
40
41
    /**
42
     * Task updated, including assignment changes. Request includes: taskId, data.task
43
     */
44
    const TRIGGER_TASK_UPDATED          = 7;
45
46
    /**
47
     * Task deleted. Request includes: taskId
48
     */
49
    const TRIGGER_TASK_DELETED          = 8;
50
51
    /**
52
     * Task assigned to worker. Request includes: taskId, data.task
53
     */
54
    const TRIGGER_TASK_ASSIGNED         = 9;
55
56
    /**
57
     * Task unassigned from worker. Request includes: taskId, data.task
58
     */
59
    const TRIGGER_TASK_UNASSIGNED       = 10;
60
61
    /**
62
     * Worker status changed (0 for off-duty, 1 for on-duty). Request includes: workerId, status, data.worker
63
     */
64
    const TRIGGER_WORKER_DUTY           = 5;
65
66
    protected $url;
67
    protected $trigger;
68
    protected $count;
69
70
    protected $endpoint = 'webhooks';
71
72
    protected static $properties = [
73
        'id',
74
        'url',
75
        'trigger',
76
        'count',
77
    ];
78
79
    /**
80
     * @return mixed
81
     */
82
    public function getUrl()
83
    {
84
        return $this->url;
85
    }
86
87
    /**
88
     * @return mixed
89
     */
90
    public function getTrigger()
91
    {
92
        return $this->trigger;
93
    }
94
95
    /**
96
     * Total number of successful requests made for a webhook.
97
     * @return int
98
     */
99
    public function getCount()
100
    {
101
        return $this->count;
102
    }
103
104
    /**
105
     * @param array $metadata
106
     * @internal
107
     */
108
    public function setMetadata(array $metadata)
109
    {
110
        throw new \BadMethodCallException('Webhook does not support metadata');
111
    }
112
}
113