sendgrid_api/contacts_api_custom_fields.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct ContactsApiCustomFields {
5 pub client: Client,
6}
7
8impl ContactsApiCustomFields {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 ContactsApiCustomFields { client }
12 }
13
14 /**
15 * Retrieve all custom fields.
16 *
17 * This function performs a `GET` to the `/contactdb/custom_fields` endpoint.
18 *
19 * **This endpoint allows you to retrieve all custom fields.**
20 *
21 * **Parameters:**
22 *
23 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
24 */
25 pub async fn get_contactdb_custom_fields(
26 &self,
27 ) -> ClientResult<crate::Response<crate::types::ListAllCustomFieldsResponse>> {
28 let url = self.client.url("/contactdb/custom_fields", None);
29 self.client
30 .get(
31 &url,
32 crate::Message {
33 body: None,
34 content_type: None,
35 },
36 )
37 .await
38 }
39 /**
40 * Create a Custom Field.
41 *
42 * This function performs a `POST` to the `/contactdb/custom_fields` endpoint.
43 *
44 * **This endpoint allows you to create a custom field.**
45 *
46 * **You can create up to 120 custom fields.**
47 *
48 * **Parameters:**
49 *
50 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
51 */
52 pub async fn post_contactdb_custom_field(
53 &self,
54 body: &crate::types::PostContactdbCustomFieldsRequest,
55 ) -> ClientResult<crate::Response<crate::types::ContactdbCustomFieldWithAllOf>> {
56 let url = self.client.url("/contactdb/custom_fields", None);
57 self.client
58 .post(
59 &url,
60 crate::Message {
61 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
62 content_type: Some("application/json".to_string()),
63 },
64 )
65 .await
66 }
67 /**
68 * Retrieve a Custom Field.
69 *
70 * This function performs a `GET` to the `/contactdb/custom_fields/{custom_field_id}` endpoint.
71 *
72 * **This endpoint allows you to retrieve a custom field by ID.**
73 *
74 * **Parameters:**
75 *
76 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
77 */
78 pub async fn get_contactdb_custom_fields_field(
79 &self,
80 custom_field_id: i64,
81 ) -> ClientResult<crate::Response<crate::types::ContactdbCustomFieldWithAllOf>> {
82 let url = self.client.url(
83 &format!(
84 "/contactdb/custom_fields/{}",
85 crate::progenitor_support::encode_path(&custom_field_id.to_string()),
86 ),
87 None,
88 );
89 self.client
90 .get(
91 &url,
92 crate::Message {
93 body: None,
94 content_type: None,
95 },
96 )
97 .await
98 }
99 /**
100 * Delete a Custom Field.
101 *
102 * This function performs a `DELETE` to the `/contactdb/custom_fields/{custom_field_id}` endpoint.
103 *
104 * **This endpoint allows you to delete a custom field by ID.**
105 *
106 * **Parameters:**
107 *
108 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
109 */
110 pub async fn delete_contactdb_custom_fields_field(
111 &self,
112 custom_field_id: i64,
113 ) -> ClientResult<crate::Response<crate::types::GlobalErrorResponseSchema>> {
114 let url = self.client.url(
115 &format!(
116 "/contactdb/custom_fields/{}",
117 crate::progenitor_support::encode_path(&custom_field_id.to_string()),
118 ),
119 None,
120 );
121 self.client
122 .delete(
123 &url,
124 crate::Message {
125 body: None,
126 content_type: None,
127 },
128 )
129 .await
130 }
131 /**
132 * Retrieve reserved fields.
133 *
134 * This function performs a `GET` to the `/contactdb/reserved_fields` endpoint.
135 *
136 * **This endpoint allows you to list all fields that are reserved and can't be used for custom field names.**
137 *
138 * **Parameters:**
139 *
140 * * `on_behalf_of: &str` -- The license key provided with your New Relic account.
141 */
142 pub async fn get_contactdb_reserved_fields(
143 &self,
144 ) -> ClientResult<crate::Response<crate::types::GetContactdbReservedFieldsResponse>> {
145 let url = self.client.url("/contactdb/reserved_fields", None);
146 self.client
147 .get(
148 &url,
149 crate::Message {
150 body: None,
151 content_type: None,
152 },
153 )
154 .await
155 }
156}