Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 585501a

Browse files
committed
feat(Subscription): add Google Cloud PubSub destination
closes #418
1 parent d1547a7 commit 585501a

File tree

3 files changed

+66
-2
lines changed

3 files changed

+66
-2
lines changed

src/Core/Model/Subscription/AzureServiceBusDestination.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
* @method AzureServiceBusDestination setType(string $type = null)
1515
* @method string getConnectionString()
1616
* @method AzureServiceBusDestination setConnectionString(string $connectionString = null)
17+
* @method string getUri()
18+
* @method AzureServiceBusDestination setUri(string $uri = null)
19+
* @method string getAccessKey()
20+
* @method AzureServiceBusDestination setAccessKey(string $accessKey = null)
1721
*/
1822
class AzureServiceBusDestination extends Destination
1923
{
@@ -22,13 +26,13 @@ public function fieldDefinitions()
2226
return [
2327
'type' => [static::TYPE => 'string'],
2428
'connectionString' => [static::TYPE => 'string'],
29+
'uri' => [static::TYPE => 'string'],
30+
'accessKey' => [static::TYPE => 'string'],
2531
];
2632
}
2733

2834
/**
2935
* @param $connectionString
30-
* @param $accessKey
31-
* @param $accessSecret
3236
* @param Context|null $context
3337
* @return AzureServiceBusDestination
3438
*/
@@ -38,4 +42,18 @@ public static function ofQueueURLAccessKeyAndSecret($connectionString, Context $
3842
->setType('AzureServiceBus')
3943
->setConnectionString($connectionString);
4044
}
45+
46+
/**
47+
* @param $uri
48+
* @param $accessKey
49+
* @param Context|null $context
50+
* @return AzureServiceBusDestination
51+
*/
52+
public static function ofUriAndAccessKey($uri, $accessKey, Context $context = null)
53+
{
54+
return static::of($context)
55+
->setType('AzureServiceBus')
56+
->setUri($uri)
57+
->setAccessKey($accessKey);
58+
}
4159
}

src/Core/Model/Subscription/Destination.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Destination extends JsonObject
1717
{
1818
const DESTINATION_SQS = 'SQS';
1919
const DESTINATION_IRON_MQ = 'IronMQ';
20+
const DESTINATION_SNS = 'SNS';
21+
const DESTINATION_AZURE_SERVICE_BUS = 'AzureServiceBus';
22+
const DESTINATION_GOOGLE_CLOUD_PUB_SUB = 'GoogleCloudPubSub';
2023

2124
public function fieldDefinitions()
2225
{
@@ -30,6 +33,9 @@ protected static function destinationType($typeId)
3033
$types = [
3134
static::DESTINATION_SQS => SQSDestination::class,
3235
static::DESTINATION_IRON_MQ => IronMQDestination::class,
36+
static::DESTINATION_SNS => SNSDestination::class,
37+
static::DESTINATION_AZURE_SERVICE_BUS => AzureServiceBusDestination::class,
38+
static::DESTINATION_GOOGLE_CLOUD_PUB_SUB => GoogleCloudPubSubDestination::class,
3339
];
3440
return isset($types[$typeId]) ? $types[$typeId] : Destination::class;
3541
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
*/
4+
5+
namespace Commercetools\Core\Model\Subscription;
6+
7+
use Commercetools\Core\Model\Common\Context;
8+
9+
/**
10+
* @package Commercetools\Core\Model\Subscription
11+
*
12+
* @method string getType()
13+
* @method GoogleCloudPubSubDestination setType(string $type = null)
14+
* @method string getProjectId()
15+
* @method GoogleCloudPubSubDestination setProjectId(string $projectId = null)
16+
* @method string getTopic()
17+
* @method GoogleCloudPubSubDestination setTopic(string $topic = null)
18+
*/
19+
class GoogleCloudPubSubDestination extends Destination
20+
{
21+
public function fieldDefinitions()
22+
{
23+
return [
24+
'type' => [static::TYPE => 'string'],
25+
'projectId' => [static::TYPE => 'string'],
26+
'topic' => [static::TYPE => 'string'],
27+
];
28+
}
29+
30+
/**
31+
* @param string $projectId
32+
* @param string $topic
33+
* @param Context $context
34+
* @return GoogleCloudPubSubDestination
35+
*/
36+
public static function ofProjectIdAndTopic($projectId, $topic, Context $context = null)
37+
{
38+
return static::of($context)->setType('GoogleCloudPubSub')->setProjectId($projectId)->setTopic($topic);
39+
}
40+
}

0 commit comments

Comments
 (0)