sendgrid_api/
transactional_templates_versions.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct TransactionalTemplatesVersions {
5    pub client: Client,
6}
7
8impl TransactionalTemplatesVersions {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        TransactionalTemplatesVersions { client }
12    }
13
14    /**
15     * Create a new transactional template version.
16     *
17     * This function performs a `POST` to the `/templates/{template_id}/versions` endpoint.
18     *
19     * **This endpoint allows you to create a new version of a template.**
20     *
21     * **Parameters:**
22     *
23     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
24     */
25    pub async fn post_templates_template_version(
26        &self,
27        template_id: &str,
28        body: &crate::types::TransactionalTemplateVersionCreate,
29    ) -> ClientResult<crate::Response<crate::types::TransactionalTemplateVersionOutputAllOf>> {
30        let url = self.client.url(
31            &format!(
32                "/templates/{}/versions",
33                crate::progenitor_support::encode_path(template_id),
34            ),
35            None,
36        );
37        self.client
38            .post(
39                &url,
40                crate::Message {
41                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
42                    content_type: None,
43                },
44            )
45            .await
46    }
47    /**
48     * Activate a transactional template version.
49     *
50     * This function performs a `POST` to the `/templates/{template_id}/versions/{version_id}/activate` endpoint.
51     *
52     * **This endpoint allows you to activate a version of one of your templates.**
53     *
54     * **Parameters:**
55     *
56     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
57     */
58    pub async fn post_templates_template_versions_version_activate(
59        &self,
60        template_id: &str,
61        version_id: &str,
62    ) -> ClientResult<crate::Response<crate::types::TransactionalTemplateVersionOutputAllOf>> {
63        let url = self.client.url(
64            &format!(
65                "/templates/{}/versions/{}/activate",
66                crate::progenitor_support::encode_path(template_id),
67                crate::progenitor_support::encode_path(version_id),
68            ),
69            None,
70        );
71        self.client
72            .post(
73                &url,
74                crate::Message {
75                    body: None,
76                    content_type: None,
77                },
78            )
79            .await
80    }
81    /**
82     * Retrieve a specific transactional template version.
83     *
84     * This function performs a `GET` to the `/templates/{template_id}/versions/{version_id}` endpoint.
85     *
86     * **This endpoint allows you to retrieve a specific version of a template.**
87     *
88     * **Parameters:**
89     *
90     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
91     */
92    pub async fn get_templates_template_versions_version(
93        &self,
94        template_id: &str,
95        version_id: &str,
96    ) -> ClientResult<crate::Response<crate::types::TransactionalTemplateVersionOutputAllOf>> {
97        let url = self.client.url(
98            &format!(
99                "/templates/{}/versions/{}",
100                crate::progenitor_support::encode_path(template_id),
101                crate::progenitor_support::encode_path(version_id),
102            ),
103            None,
104        );
105        self.client
106            .get(
107                &url,
108                crate::Message {
109                    body: None,
110                    content_type: None,
111                },
112            )
113            .await
114    }
115    /**
116     * Delete a transactional template version.
117     *
118     * This function performs a `DELETE` to the `/templates/{template_id}/versions/{version_id}` endpoint.
119     *
120     * **This endpoint allows you to delete a transactional template version.**
121     *
122     * **Parameters:**
123     *
124     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
125     */
126    pub async fn delete_templates_template_versions_version(
127        &self,
128        template_id: &str,
129        version_id: &str,
130    ) -> ClientResult<crate::Response<()>> {
131        let url = self.client.url(
132            &format!(
133                "/templates/{}/versions/{}",
134                crate::progenitor_support::encode_path(template_id),
135                crate::progenitor_support::encode_path(version_id),
136            ),
137            None,
138        );
139        self.client
140            .delete(
141                &url,
142                crate::Message {
143                    body: None,
144                    content_type: None,
145                },
146            )
147            .await
148    }
149    /**
150     * Edit a transactional template version.
151     *
152     * This function performs a `PATCH` to the `/templates/{template_id}/versions/{version_id}` endpoint.
153     *
154     * **This endpoint allows you to edit the content of your template version.**
155     *
156     * **Parameters:**
157     *
158     * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
159     */
160    pub async fn patch_templates_template_versions_version(
161        &self,
162        template_id: &str,
163        version_id: &str,
164        body: &crate::types::TransactionalTemplateVersionCreate,
165    ) -> ClientResult<crate::Response<crate::types::TransactionalTemplateVersionOutputAllOf>> {
166        let url = self.client.url(
167            &format!(
168                "/templates/{}/versions/{}",
169                crate::progenitor_support::encode_path(template_id),
170                crate::progenitor_support::encode_path(version_id),
171            ),
172            None,
173        );
174        self.client
175            .patch(
176                &url,
177                crate::Message {
178                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
179                    content_type: None,
180                },
181            )
182            .await
183    }
184}