@@ -28,16 +28,24 @@ public function createShopStruct(string $shopId, string $shopUrl, string $shopSe
2828
2929 public function createShop (ShopInterface $ shop ): void
3030 {
31+ $ item = [
32+ 'id ' => ['S ' => $ shop ->getShopId ()],
33+ 'active ' => ['BOOL ' => $ shop ->isShopActive () ? '1 ' : '0 ' ],
34+ 'confirmed ' => ['BOOL ' => $ shop ->isRegistrationConfirmed () ? '1 ' : '0 ' ],
35+ 'url ' => ['S ' => $ shop ->getShopUrl ()],
36+ 'secret ' => ['S ' => $ shop ->getShopSecret ()],
37+ 'clientId ' => ['S ' => (string ) $ shop ->getShopClientId ()],
38+ 'clientSecret ' => ['S ' => (string ) $ shop ->getShopClientSecret ()],
39+ 'pendingShopSecret ' => ['S ' => (string ) $ shop ->getPendingShopSecret ()],
40+ 'pendingShopUrl ' => ['S ' => (string ) $ shop ->getPendingShopUrl ()],
41+ 'previousShopSecret ' => ['S ' => (string ) $ shop ->getPreviousShopSecret ()],
42+ 'secretsRotatedAt ' => ['S ' => (string ) ($ shop ->getSecretsRotatedAt ()?->getTimestamp() ?? '' )],
43+ 'hasVerifiedWithDoubleSignature ' => ['BOOL ' => $ shop ->hasVerifiedWithDoubleSignature () ? '1 ' : '0 ' ],
44+ ];
45+
3146 $ this ->client ->putItem (new PutItemInput ([
3247 'TableName ' => $ this ->tableName ,
33- 'Item ' => [
34- 'id ' => ['S ' => $ shop ->getShopId ()],
35- 'active ' => ['BOOL ' => $ shop ->isShopActive () ? '1 ' : '0 ' ],
36- 'url ' => ['S ' => $ shop ->getShopUrl ()],
37- 'secret ' => ['S ' => $ shop ->getShopSecret ()],
38- 'clientId ' => ['S ' => (string ) $ shop ->getShopClientId ()],
39- 'clientSecret ' => ['S ' => (string ) $ shop ->getShopClientSecret ()],
40- ],
48+ 'Item ' => $ item ,
4149 ]));
4250 }
4351
@@ -71,13 +79,61 @@ public function getShopFromId(string $shopId): ShopInterface|null
7179 $ active = false ;
7280 }
7381
82+ $ confirmed = true ;
83+ if (isset ($ item ['confirmed ' ])) {
84+ $ confirmed = $ item ['confirmed ' ]->getBool ();
85+ if ($ confirmed === null ) {
86+ $ confirmed = false ;
87+ }
88+ }
89+
90+ $ pendingShopSecret = isset ($ item ['pendingShopSecret ' ]) ? $ item ['pendingShopSecret ' ]->getS () : null ;
91+ $ pendingShopUrl = isset ($ item ['pendingShopUrl ' ]) ? $ item ['pendingShopUrl ' ]->getS () : null ;
92+ $ previousShopSecret = isset ($ item ['previousShopSecret ' ]) ? $ item ['previousShopSecret ' ]->getS () : null ;
93+
94+ if ($ pendingShopSecret === '' ) {
95+ $ pendingShopSecret = null ;
96+ }
97+
98+ if ($ pendingShopUrl === '' ) {
99+ $ pendingShopUrl = null ;
100+ }
101+
102+ if ($ previousShopSecret === '' ) {
103+ $ previousShopSecret = null ;
104+ }
105+
106+ $ secretsRotatedAt = null ;
107+
108+ if (isset ($ item ['secretsRotatedAt ' ])) {
109+ $ timestamp = $ item ['secretsRotatedAt ' ]->getS ();
110+ if ($ timestamp !== null && $ timestamp !== '' ) {
111+ $ secretsRotatedAt = (new \DateTimeImmutable ())->setTimestamp ((int ) $ timestamp );
112+ }
113+ }
114+
115+ $ hasVerifiedWithDoubleSignature = false ;
116+ if (isset ($ item ['hasVerifiedWithDoubleSignature ' ])) {
117+ $ hasVerifiedWithDoubleSignature = $ item ['hasVerifiedWithDoubleSignature ' ]->getBool ();
118+
119+ if ($ hasVerifiedWithDoubleSignature === null ) {
120+ $ hasVerifiedWithDoubleSignature = false ;
121+ }
122+ }
123+
74124 return new DynamoDBShop (
75125 $ item ['id ' ]->getS () ?? '' ,
76126 $ item ['url ' ]->getS () ?? '' ,
77127 $ item ['secret ' ]->getS () ?? '' ,
78128 $ shopClientId ,
79129 $ shopClientSecret ,
80130 $ active ,
131+ $ pendingShopSecret ,
132+ $ pendingShopUrl ,
133+ $ previousShopSecret ,
134+ $ secretsRotatedAt ,
135+ $ hasVerifiedWithDoubleSignature ,
136+ $ confirmed ,
81137 );
82138 }
83139
@@ -88,16 +144,22 @@ public function updateShop(ShopInterface $shop): void
88144 'Key ' => [
89145 'id ' => ['S ' => $ shop ->getShopId ()],
90146 ],
91- 'UpdateExpression ' => 'SET active = :active, #u = :url, secret = :secret, clientId = :clientId, clientSecret = :clientSecret ' ,
147+ 'UpdateExpression ' => 'SET active = :active, confirmed = :confirmed, #u = :url, secret = :secret, clientId = :clientId, clientSecret = :clientSecret, pendingShopSecret = :pendingShopSecret, pendingShopUrl = :pendingShopUrl, previousShopSecret = :previousShopSecret, secretsRotatedAt = :secretsRotatedAt, hasVerifiedWithDoubleSignature = :hasVerifiedWithDoubleSignature ' ,
92148 'ExpressionAttributeNames ' => [
93149 '#u ' => 'url ' ,
94150 ],
95151 'ExpressionAttributeValues ' => [
96152 ':active ' => ['BOOL ' => $ shop ->isShopActive () ? '1 ' : '0 ' ],
153+ ':confirmed ' => ['BOOL ' => $ shop ->isRegistrationConfirmed () ? '1 ' : '0 ' ],
97154 ':url ' => ['S ' => $ shop ->getShopUrl ()],
98155 ':secret ' => ['S ' => $ shop ->getShopSecret ()],
99156 ':clientId ' => ['S ' => (string ) $ shop ->getShopClientId ()],
100157 ':clientSecret ' => ['S ' => (string ) $ shop ->getShopClientSecret ()],
158+ ':pendingShopSecret ' => ['S ' => (string ) $ shop ->getPendingShopSecret ()],
159+ ':pendingShopUrl ' => ['S ' => (string ) $ shop ->getPendingShopUrl ()],
160+ ':previousShopSecret ' => ['S ' => (string ) $ shop ->getPreviousShopSecret ()],
161+ ':secretsRotatedAt ' => ['S ' => (string ) ($ shop ->getSecretsRotatedAt ()?->getTimestamp() ?? '' )],
162+ ':hasVerifiedWithDoubleSignature ' => ['BOOL ' => $ shop ->hasVerifiedWithDoubleSignature () ? '1 ' : '0 ' ],
101163 ],
102164 ]));
103165 }
0 commit comments