1
+ {#
2
+ This example template is a simplified version of the one we use in
3
+ https://github.com/svix/svix-webhooks
4
+
5
+ It currently depends on the (non-generated) `crate::error::Result`,
6
+ `crate::Configuration` and `crate::request::Request`
7
+
8
+ A PR to make it more generic (e.g. use reqwest directly) would be welcome
9
+ -#}
10
+ // this file is @generated
1
11
{% set resource_type_name = resource .name | to_upper_camel_case -%}
2
12
3
13
use crate::{
@@ -8,25 +18,12 @@ use crate::{
8
18
9
19
{% for op in resource .operations -%}
10
20
{% if op | has_query_or_header_params %}
11
- {% if not op | has_required_query_or_header_params -%}
12
- #[derive(Default)]
13
- {% endif -%}
14
21
pub struct {{ resource_type_name }}{{ op.name | to_upper_camel_case }}Options {
15
22
{% for p in op .query_params -%}
16
- {% if p .type .is_datetime () -%}
17
- {% set ty = "String" -%}
18
- {% else -%}
19
- {% set ty = p .type .to_rust () -%}
20
- {% endif -%}
23
+ {% set ty = p .type .to_rust () -%}
21
24
{% if not p .required %}{% set ty %} Option<{{ ty }}>{% endset %}{% endif %}
22
25
{% if p .description is defined -%}
23
26
{{ p.description | to_doc_comment(style="rust") }}
24
- {# we currently use String for date-time params, for backwards compat -#}
25
- {# document the format so it's not _that_ awkward -#}
26
- {% if p .type .is_datetime () -%}
27
- ///
28
- /// RFC3339 date string.
29
- {% endif -%}
30
27
{% endif -%}
31
28
pub {{ p.name | to_snake_case }}: {{ ty }},
32
29
{% endfor -%}
@@ -95,11 +92,6 @@ impl<'a> {{ resource_type_name }}<'a> {
95
92
;
96
93
{% endif -%}
97
94
98
- {% if has_header_params -%}
99
- {# unpack PostOptions -#}
100
- let PostOptions { idempotency_key } = options.unwrap_or_default();
101
- {% endif -%}
102
-
103
95
{# make the request #}
104
96
crate::request::Request::new(http1::Method::{{ op.method | upper }}, "{{ op.path }}")
105
97
@@ -131,15 +123,4 @@ impl<'a> {{ resource_type_name }}<'a> {
131
123
.execute(self.cfg)
132
124
.await
133
125
}
134
-
135
- {% set extra_path -%}
136
- api_extra/{{ resource.name | to_snake_case }}_{{ op.name | to_snake_case }}.rs
137
- {% - endset -%}
138
- {% include extra_path ignore missing %}
139
- {% endfor %}
140
126
}
141
-
142
- {% set extra_path -%}
143
- api_extra/{{ resource.name | to_snake_case }}.rs
144
- {% - endset -%}
145
- {% include extra_path ignore missing %}
0 commit comments