@@ -19,7 +19,7 @@ final class Client implements Builder
19
19
private ?Node \Expr $ httpStreamFactory = null ;
20
20
private ?Node \Expr $ fileSystem = null ;
21
21
22
- public function __construct (private readonly Node \Expr $ baseUrl , private readonly Node \Expr $ clientId , private readonly Node \Expr $ secret )
22
+ public function __construct (private readonly Node \Expr $ baseUrl , private readonly Node \Expr $ clientId , private readonly Node \Expr $ secret, private readonly null | Node \ Expr $ apiType )
23
23
{
24
24
}
25
25
@@ -69,15 +69,7 @@ public function withFileSystem(Node\Expr $fileSystem): self
69
69
70
70
public function getNode (): Node \Expr \MethodCall
71
71
{
72
- $ instance = new Node \Expr \MethodCall (
73
- var: new Node \Expr \New_ (
74
- new Node \Name \FullyQualified ('Diglin \\Sylius \\ApiClient \\SyliusClientBuilder ' ),
75
- ),
76
- name: new Node \Identifier ('setBaseUri ' ),
77
- args: [
78
- new Node \Arg ($ this ->baseUrl ),
79
- ],
80
- );
72
+ $ instance = $ this ->getClientBuilderNode ();
81
73
82
74
if (null !== $ this ->httpClient ) {
83
75
$ instance = new Node \Expr \MethodCall (
@@ -126,6 +118,26 @@ public function getNode(): Node\Expr\MethodCall
126
118
);
127
119
}
128
120
121
+ private function getClientBuilderNode (): Node \Expr \MethodCall
122
+ {
123
+ $ className = match ($ this ->apiType ) {
124
+ 'admin ' => 'Diglin \\Sylius \\ApiClient \\SyliusAdminClientBuilder ' ,
125
+ 'store ' => 'Diglin \\Sylius \\ApiClient \\SyliusShopClientBuilder ' ,
126
+ 'legacy ' => 'Diglin \\Sylius \\ApiClient \\SyliusClientBuilder ' ,
127
+ default => 'Diglin \\Sylius \\ApiClient \\SyliusClientBuilder ' ,
128
+ };
129
+
130
+ return new Node \Expr \MethodCall (
131
+ var: new Node \Expr \New_ (
132
+ new Node \Name \FullyQualified ($ className ),
133
+ ),
134
+ name: new Node \Identifier ('setBaseUri ' ),
135
+ args: [
136
+ new Node \Arg ($ this ->baseUrl ),
137
+ ],
138
+ );
139
+ }
140
+
129
141
private function getFactoryMethod (): string
130
142
{
131
143
if (null !== $ this ->password ) {
0 commit comments