Skip to content

Commit

Permalink
js: Adjust to SvixRequest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-jplatte committed Jan 30, 2025
1 parent 079266c commit de9e055
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions templates/svix-lib-javascript/api_extra/application_create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ public getOrCreate(
): Promise<ApplicationOut> {
const request = new SvixRequest(HttpMethod.POST, "/api/v1/app");

request.body = applicationIn;
request.setQueryParam("get_if_exists", true);
request.setHeaderParam("idempotency-key", options?.idempotencyKey);
request.setBody(applicationIn, "ApplicationIn");

return request.send(this.requestCtx);
return request.send(this.requestCtx, "ApplicationOut");
}
10 changes: 8 additions & 2 deletions templates/svix-lib-javascript/api_resource.ts.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,17 @@ export class {{ resource_type_name }} {

{# body parameter -#}
{% if op.request_body_schema_name is defined -%}
request.body = {{ op.request_body_schema_name | to_lower_camel_case }};
request.setBody(
{{ op.request_body_schema_name | to_lower_camel_case }},
"{{ op.request_body_schema_name | to_upper_camel_case }}",
);
{% endif -%}

{% if op.response_body_schema_name is defined %}
return request.send(this.requestCtx);
return request.send(
this.requestCtx,
"{{ op.response_body_schema_name | to_upper_camel_case }}",
);
{% else %}
return request.sendNoResponseBody(this.requestCtx);
{% endif -%}
Expand Down

0 comments on commit de9e055

Please sign in to comment.