pdk-contracts-lib 1.9.1-alpha.2

PDK Contracts Library
Documentation
// Copyright (c) 2026, Salesforce, Inc.,
// All rights reserved.
// For full license text, see the LICENSE.txt file

use crate::api::ClientData;
use serde::{Deserialize, Serialize};

#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct AccessToken {
    access_token: String,
    token_type: String,
}

impl AccessToken {
    pub fn new(access_token: String, token_type: String) -> Self {
        Self {
            access_token,
            token_type,
        }
    }

    pub fn get_access_token(&self) -> &str {
        &self.access_token
    }
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct ContractsRequestParams {
    pub next_url: Option<String>,
    pub hash_algorithm: String,
}

impl ContractsRequestParams {
    pub fn new(next_url: Option<String>, hash_algorithm: String) -> Self {
        Self {
            next_url,
            hash_algorithm,
        }
    }
}

#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct Contract {
    pub contract_id: String,
    pub api_id: String,
    pub version_id: String,
    pub sla_tier_id: Option<String>,
    pub client_id: String,
    pub client_secret: String,
    pub client_secret_salt: String,
    pub client_name: String,
    pub removed: bool,
}

impl Contract {
    pub fn cast_to_client_information(self) -> ClientData {
        ClientData {
            client_id: self.client_id,
            client_name: self.client_name,
            sla_id: self.sla_tier_id,
        }
    }
}