@@ -19,7 +19,7 @@ final class Client implements Builder
1919 private ?Node \Expr $ httpStreamFactory = null ;
2020 private ?Node \Expr $ fileSystem = null ;
2121
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 )
2323 {
2424 }
2525
@@ -69,15 +69,7 @@ public function withFileSystem(Node\Expr $fileSystem): self
6969
7070 public function getNode (): Node \Expr \MethodCall
7171 {
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 ();
8173
8274 if (null !== $ this ->httpClient ) {
8375 $ instance = new Node \Expr \MethodCall (
@@ -126,6 +118,26 @@ public function getNode(): Node\Expr\MethodCall
126118 );
127119 }
128120
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+
129141 private function getFactoryMethod (): string
130142 {
131143 if (null !== $ this ->password ) {
0 commit comments