Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions codegen/layouts/partials/route-method.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{{{methodPhpDoc this}}}
public function {{methodName}}({{{signatureParams}}}): {{returnType}} {
{{#if requiresAtLeastOneParameter}}
if ({{#each atLeastOneParameterNames}}{{#unless @first}} && {{/unless}}${{this}} === null{{/each}}) {
throw new \InvalidArgumentException("At least one parameter is required for {{path}}");
}
{{/if}}
{{#if hasParams}}
$request_payload = [];

Expand All @@ -17,6 +12,13 @@
}
{{/if}}
{{/each}}
{{#if requiresAtLeastOneParameter}}
\Seam\Http\RequestParameters::requireAtLeastOne(
"{{path}}",
$request_payload,
[{{#each atLeastOneParameterNames}}"{{this}}"{{#unless @last}}, {{/unless}}{{/each}}],
);
{{/if}}

{{/if}}
{{#unless returnsVoid}}$res = Body::decode({{/unless}}$this->client->request(
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@seamapi/blueprint": "^1.12.0",
"@seamapi/fake-seam-connect": "2.0.6",
"@seamapi/smith": "^1.1.1",
"@seamapi/types": "1.1142.0",
"@seamapi/types": "1.1153.0",
"change-case": "^5.4.4",
"execa": "^10.0.1",
"prettier": "^3.9.6"
Expand Down
26 changes: 26 additions & 0 deletions src/Http/RequestParameters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Seam\Http;

final class RequestParameters
{
/**
* @param array<string, mixed> $parameters
* @param list<string> $parameterNames Non-pagination parameters that can satisfy the requirement.
*/
public static function requireAtLeastOne(
string $path,
array $parameters,
array $parameterNames,
): void {
foreach ($parameterNames as $name) {
if (($parameters[$name] ?? null) !== null) {
return;
}
}

throw new \InvalidArgumentException(
"At least one parameter is required for $path",
);
}
}
54 changes: 54 additions & 0 deletions src/Resources/AccessCode.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Resources/AcsEntrance.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 48 additions & 1 deletion src/Resources/Device.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 48 additions & 1 deletion src/Resources/Phone.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions src/Resources/UnmanagedAccessCode.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading