File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -21,18 +21,17 @@ trait CreatesWithType
21
21
* @throws RequestException
22
22
* @throws UnknownAPIMethodException
23
23
*/
24
- public function create (EntityTypeEnum $ entityType , EntityData $ data ): EntityData
24
+ public function create (EntityTypeEnum $ entityType , EntityData $ data, array $ extraData = [] ): EntityData
25
25
{
26
- $ data = [$ entityType ->value => $ data ->toCreateData ()->toArray ()];
27
- return $ this ->callApi ($ entityType , $ data );
28
- }
29
-
30
- public function callApi (EntityTypeEnum $ entityType , array $ data ): EntityData {
31
26
$ response = $ this ->call (
32
27
action: static ::CREATE ,
33
28
urlParams: ['type ' => $ entityType ->toUrlVariable ()],
34
- bodyData: $ data
29
+ bodyData: [
30
+ $ entityType ->value => $ data ->toCreateData ()->toArray (),
31
+ ...$ extraData ,
32
+ ]
35
33
);
34
+
36
35
return $ this ->responseToDataObject ($ response [$ entityType ->value ]);
37
36
}
38
37
}
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class InvoicesEndpoint extends Endpoint
30
30
use ChangesState;
31
31
32
32
/** @use CreatesWithType<InvoiceData> */
33
- use CreatesWithType {create as createWithType; }
33
+ use CreatesWithType { create as createWithType; }
34
34
35
35
use GeneratesAndCancelsPayment;
36
36
use GeneratesPDF;
@@ -62,11 +62,13 @@ protected function getEndpointName(): string
62
62
return static ::ENDPOINT_CONFIG ;
63
63
}
64
64
65
- public function create (EntityTypeEnum $ entityType , InvoiceData $ data , ?string $ proprietaryUid ): InvoiceData {
66
- $ data = [$ entityType ->value => $ data ->toCreateData ()->toArray ()];
67
- if ($ proprietaryUid ){
68
- $ data ['proprietary_uid ' ] = $ proprietaryUid ;
65
+ public function create (EntityTypeEnum $ entityType , InvoiceData $ data , ?string $ proprietaryUid = null ): InvoiceData
66
+ {
67
+ $ extra = [];
68
+ if ($ proprietaryUid ) {
69
+ $ extra ['proprietary_uid ' ] = $ proprietaryUid ;
69
70
}
70
- return $ this ->callApi ($ entityType , $ data );
71
+
72
+ return $ this ->createWithType ($ entityType , $ data , $ extra );
71
73
}
72
74
}
You can’t perform that action at this time.
0 commit comments