Skip to content

Commit 09cac4a

Browse files
authored
Verify v2 webhook modifications (#392)
* failing client boot skeleton * Scaffolding * SMS sending and validation * Complete happy path tests for requests * Webhook testing, error handling * Get factory to generate verify 2 client * Fix CRLF discrepancies over environments * Let's try CRLF again * Docs and constant use for readability * Webhooks reimagined, docs * Rehashed webhooks to be less explicit * failing client boot skeleton * Scaffolding * SMS sending and validation * Complete happy path tests for requests * Webhook testing, error handling * Get factory to generate verify 2 client * Fix CRLF discrepancies over environments * Let's try CRLF again * Docs and constant use for readability * Webhooks reimagined, docs * Rehashed webhooks to be less explicit * changed logic for webhook * New logic for webhooks and new test
1 parent 1eceec9 commit 09cac4a

9 files changed

+171
-366
lines changed

src/Verify2/VerifyObjects/VerifyEvent.php

+12-96
Original file line numberDiff line numberDiff line change
@@ -2,125 +2,41 @@
22

33
namespace Vonage\Verify2\VerifyObjects;
44

5-
use InvalidArgumentException;
6-
75
class VerifyEvent
86
{
9-
private static array $mandatoryFields = [
10-
'request_id',
11-
'triggered_at',
12-
'type',
13-
'channel',
14-
'status',
15-
'finalized_at',
16-
'client_ref'
17-
];
18-
private string $requestId;
19-
private string $triggeredAt;
20-
private string $type;
21-
private string $channel;
22-
private string $status;
23-
private string $finalizedAt;
24-
private string $clientRef;
7+
private array $data;
258

269
public function __construct(array $data)
2710
{
28-
foreach (static::$mandatoryFields as $key) {
29-
if (!array_key_exists($key, $data)) {
30-
throw new InvalidArgumentException('Verify Event missing required data `' . $key . '`');
31-
}
32-
}
33-
34-
$this->requestId = $data['request_id'];
35-
$this->triggeredAt = $data['triggered_at'];
36-
$this->type = $data['type'];
37-
$this->channel = $data['channel'];
38-
$this->status = $data['status'];
39-
$this->finalizedAt = $data['finalized_at'];
40-
$this->clientRef = $data['client_ref'];
41-
}
42-
43-
public function getRequestId(): string
44-
{
45-
return $this->requestId;
46-
}
47-
48-
public function setRequestId(string $requestId): VerifyEvent
49-
{
50-
$this->requestId = $requestId;
51-
52-
return $this;
53-
}
54-
55-
public function getTriggeredAt(): string
56-
{
57-
return $this->triggeredAt;
58-
}
59-
60-
public function setTriggeredAt(string $triggeredAt): VerifyEvent
61-
{
62-
$this->triggeredAt = $triggeredAt;
63-
64-
return $this;
11+
$this->data = $data;
6512
}
6613

67-
public function getType(): string
14+
public function __get($property)
6815
{
69-
return $this->type;
16+
return $this->data[$property] ?? null;
7017
}
7118

72-
public function setType(string $type): VerifyEvent
19+
public function __set($property, $value)
7320
{
74-
$this->type = $type;
21+
$this->data[$property] = $value;
7522

7623
return $this;
7724
}
7825

79-
public function getChannel(): string
26+
public function __isset(string $name): bool
8027
{
81-
return $this->channel;
28+
return isset($this->data[$name]);
8229
}
8330

84-
public function setChannel(string $channel): VerifyEvent
31+
public function fromArray(array $data): static
8532
{
86-
$this->channel = $channel;
33+
$this->data = $data;
8734

8835
return $this;
8936
}
9037

91-
public function getStatus(): string
38+
public function toArray(): array
9239
{
93-
return $this->status;
94-
}
95-
96-
public function setStatus(string $status): VerifyEvent
97-
{
98-
$this->status = $status;
99-
100-
return $this;
101-
}
102-
103-
public function getFinalizedAt(): string
104-
{
105-
return $this->finalizedAt;
106-
}
107-
108-
public function setFinalizedAt(string $finalizedAt): VerifyEvent
109-
{
110-
$this->finalizedAt = $finalizedAt;
111-
112-
return $this;
113-
}
114-
115-
public function getClientRef(): string
116-
{
117-
return $this->clientRef;
118-
}
119-
120-
public function setClientRef(string $clientRef): VerifyEvent
121-
{
122-
$this->clientRef = $clientRef;
123-
124-
return $this;
40+
return $this->data;
12541
}
12642
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Vonage\Verify2\VerifyObjects;
4+
5+
use Vonage\Entity\Hydrator\ArrayHydrateInterface;
6+
7+
class VerifySilentAuthEvent implements ArrayHydrateInterface
8+
{
9+
private array $data;
10+
11+
public function __construct(array $data)
12+
{
13+
$this->data = $data;
14+
}
15+
16+
public function __get($property)
17+
{
18+
return $this->data[$property] ?? null;
19+
}
20+
21+
public function __set($property, $value)
22+
{
23+
$this->data[$property] = $value;
24+
25+
return $this;
26+
}
27+
28+
public function __isset(string $name): bool
29+
{
30+
return isset($this->data[$name]);
31+
}
32+
33+
public function fromArray(array $data): static
34+
{
35+
$this->data = $data;
36+
37+
return $this;
38+
}
39+
40+
public function toArray(): array
41+
{
42+
return $this->data;
43+
}
44+
}

src/Verify2/VerifyObjects/VerifySilentAuthUpdate.php

-112
This file was deleted.

0 commit comments

Comments
 (0)