1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use crate::rest_api::builder::RestApiBuilder;
impl<'a> RestApiBuilder<'a> {
/// Sets a custom header to indicate the package version for a given namespace.
///
/// Specifies the version of each package referenced by a client. A package version is a number
/// that identifies the set of components and behavior contained in a package. This header
/// can also be used to specify a package version when making calls to an Apex REST web service.
///
/// The Package Version header can be used with the following resources:
/// - Describe Global,
/// - sObject Describe,
/// - sObject Basic Information,
/// - sObject Rows,
/// - sObject Layouts,
/// - Query,
/// - QueryAll,
/// - Search
/// - sObject Rows by External ID.
///
/// # Parameters
/// - `namespace`: The namespace for which the package version is being set.
/// - `package_version`: The version of the package, e.g. "1.0".
///
/// # Returns
/// - A mutable reference to the current instance (`Self`) to allow method chaining.
///
/// # Example
/// ```
/// use rustsf::{RestApi, SalesforceCredentials};
/// use chrono::Utc;
///
/// #[tokio::main]
/// async fn main() {
/// let credentials = SalesforceCredentials::sfdx_url("force://PlatformCLI::token@example.com").unwrap();
/// let api = RestApi::new(credentials).await.unwrap();
///
/// let mut request = api.build().package_version_header("my_namespace", "1.0.0");
/// }
/// ```
///
/// In this example, a header with the key `x-sfdc-packageversion-my_namespace` and the value `1.0.0`
/// will be added to the `headers` collection of the client.
///
/// # See
/// https://developer.salesforce.com/docs/platform/api-rest/guide/headers-packageversion.html
pub fn package_version_header(&mut self, namespace: &str, package_version: &str) -> &mut Self {
let key = format!("x-sfdc-packageversion-{}", namespace);
self.headers.insert(key, package_version.to_string());
self
}
}