Skip to content

Commit 6d114aa

Browse files
authored
DX-2499 Add CallbackCredentials to Subscriptions (#86)
* DX-2499 Add `CallbackCredentials` to Subscriptions * remove unused imports * add `PublicKey`
1 parent 7bedb72 commit 6d114aa

File tree

5 files changed

+68
-4
lines changed

5 files changed

+68
-4
lines changed

src/SubscriptionsModel.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ final class Subscription extends RestEntry{
6666
"OrderType" => array("type" => "string"),
6767
"OrderId" => array("type" => "string"),
6868
"EmailSubscription" => array("type" => "\Iris\EmailSubscription"),
69-
"CallbackSubscription" => array("type" => "\Iris\CallbackSubscription")
69+
"CallbackSubscription" => array("type" => "\Iris\CallbackSubscription"),
70+
"CallbackCredentials" => array("type" => "\Iris\CallbackCredentials"),
71+
"PublicKey" => array("type" => "string")
7072
);
7173

7274

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class BasicAuthentication {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"Username" => array("type" => "string"),
10+
"Password" => array("type" => "string"),
11+
);
12+
public function __construct($data) {
13+
$this->set_data($data);
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Iris;
4+
5+
class CallbackCredentials {
6+
use BaseModel;
7+
8+
protected $fields = array(
9+
"BasicAuthentication" => array("type" => "\Iris\BasicAuthentication"),
10+
);
11+
public function __construct($data) {
12+
$this->set_data($data);
13+
}
14+
}

tests/SubscriptionsNew.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
class SubscriptionsNew extends \PHPUnit\Framework\TestCase {
4+
public static $container;
5+
public static $subscriptions;
6+
public static $index = 0;
7+
8+
public static function setUpBeforeClass(): void {
9+
$client = new Iris\Client("test", "test", Array('url' => 'https://test.com'));
10+
$account = new Iris\Account(9500249, $client);
11+
self::$subscriptions = $account->subscriptions();
12+
}
13+
14+
public function testSubsCreate() {
15+
$subscription = self::$subscriptions->create([
16+
"OrderType" => "portins",
17+
"OrderId" => "98939562-90b0-40e9-8335-5526432d9741",
18+
"EmailSubscription" => [
19+
"Email" => "[email protected]",
20+
"DigestRequested" => "DAILY"
21+
],
22+
"CallbackCredentials" => [
23+
"BasicAuthentication" => [
24+
"Username" => "username",
25+
"Password" => "password"
26+
]
27+
],
28+
"PublicKey" => "testkey"
29+
], false);
30+
31+
$json = '{"OrderType":"portins","OrderId":"98939562-90b0-40e9-8335-5526432d9741","EmailSubscription":{"Email":"[email protected]","DigestRequested":"DAILY"},"CallbackCredentials":{"BasicAuthentication":{"Username":"username","Password":"password"}},"PublicKey":"testkey"}';
32+
$this->assertEquals($json, json_encode($subscription->to_array()));
33+
34+
}
35+
36+
}

tests/test.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)