/*
* Stadar Esports Data API
*
* Read-only, betting-friendly esports data across all major competitive titles. Flat-tier pricing (no per-game gates), Polar- billed subscriptions (Merchant of Record), sandbox keys for evaluation. See https://stadar.net for tier pricing. All endpoints under `/v1/...`. The version in `info.version` matches the URL prefix; non-breaking field additions ship in `/v1`, breaking changes get a `/v2`. We commit to 24 months of `/v1` support after `/v2` ships. Times are UTC end-to-end (RFC 3339). Localization is the client's problem. Cursors are opaque base64 strings; treat them as such.
*
* The version of the OpenAPI document: v1
* Contact: api@stadar.net
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for passing parameters to the method [`billing_checkout`]
#[derive(Clone, Debug)]
pub struct BillingCheckoutParams {
pub tier: String
}
/// struct for typed errors of method [`billing_checkout`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BillingCheckoutError {
Status401(models::ErrorEnvelope),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`billing_portal`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum BillingPortalError {
Status401(models::ErrorEnvelope),
UnknownValue(serde_json::Value),
}
/// 302-redirects to Polar's hosted checkout for the requested tier.
pub async fn billing_checkout(configuration: &configuration::Configuration, params: BillingCheckoutParams) -> Result<(), Error<BillingCheckoutError>> {
let uri_str = format!("{}/v1/checkout", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("tier", ¶ms.tier.to_string())]);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<BillingCheckoutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn billing_portal(configuration: &configuration::Configuration) -> Result<(), Error<BillingPortalError>> {
let uri_str = format!("{}/v1/portal", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<BillingPortalError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}