pub struct GoogleClient { /* private fields */ }Expand description
Low-level client for the Google Ads REST API.
Implementations§
Source§impl GoogleClient
impl GoogleClient
Sourcepub fn new(
access_token: SecretString,
developer_token: String,
customer_id: &str,
login_customer_id: Option<&str>,
) -> Result<Self>
pub fn new( access_token: SecretString, developer_token: String, customer_id: &str, login_customer_id: Option<&str>, ) -> Result<Self>
Create a new client for the given customer account.
customer_id and login_customer_id accept dashed form
(123-456-7890); dashes are stripped.
§Errors
Returns an error if the underlying HTTP client cannot be built.
Sourcepub fn new_with_base_url(
access_token: SecretString,
developer_token: String,
customer_id: &str,
login_customer_id: Option<&str>,
base_url: String,
) -> Result<Self>
pub fn new_with_base_url( access_token: SecretString, developer_token: String, customer_id: &str, login_customer_id: Option<&str>, base_url: String, ) -> Result<Self>
Create a new client with a custom base URL (e.g. for wiremock tests).
Starts with no retries so tests stay deterministic; production
constructors opt in via Self::with_retry_policy.
§Errors
Returns an error if the underlying HTTP client cannot be built.
Sourcepub const fn with_retry_policy(self, policy: RetryPolicy) -> Self
pub const fn with_retry_policy(self, policy: RetryPolicy) -> Self
Replace the retry policy (reads retry transient failures, writes only rate limits and connection failures).
Sourcepub fn customer_id(&self) -> &str
pub fn customer_id(&self) -> &str
The customer ID (dashes stripped).
Sourcepub async fn search(&self, query: &str) -> Result<Value>
pub async fn search(&self, query: &str) -> Result<Value>
Run a GAQL query through googleAds:search.
§Errors
Returns MktError::ApiError for non-2xx responses and
MktError::Http for transport failures.
Sourcepub async fn search_page(
&self,
query: &str,
page_token: Option<&str>,
) -> Result<Value>
pub async fn search_page( &self, query: &str, page_token: Option<&str>, ) -> Result<Value>
Run a GAQL query requesting a specific results page.
§Errors
Returns MktError::ApiError for non-2xx responses and
MktError::Http for transport failures.
Sourcepub async fn mutate(&self, resource: &str, operations: &Value) -> Result<Value>
pub async fn mutate(&self, resource: &str, operations: &Value) -> Result<Value>
Send mutate operations to a resource endpoint, e.g.
mutate("campaigns", ops) posts to customers/{cid}/campaigns:mutate.
§Errors
Returns MktError::ApiError for non-2xx responses and
MktError::Http for transport failures.
Sourcepub async fn mutate_atomic(&self, operations: &Value) -> Result<Value>
pub async fn mutate_atomic(&self, operations: &Value) -> Result<Value>
Send cross-resource operations to the atomic googleAds:mutate
endpoint as one transactional request.
operations is the mutateOperations array, where each entry
wraps a per-resource operation (e.g. campaignBudgetOperation,
campaignOperation). Operations may reference resources created
earlier in the same array via temporary negative IDs.
partialFailure is disabled so either every operation succeeds or
none is applied, and responseContentType requests the mutated
resource names back.
§Errors
Returns MktError::ApiError for non-2xx responses and
MktError::Http for transport failures.