#![allow(clippy::all, unused_imports, dead_code)]
//! Auto-generated API actors for Stripe
//!
//! Service: Stripe (stripe)
//! Payment processing platform
//!
//! Required env var: STRIPE_API_KEY (API key)
//!
//! Generated by api-schema-gen codegen — do not edit manually.
use crate::{Actor, ActorBehavior, Message, Port};
use anyhow::{Error, Result};
use reflow_actor::{message::EncodableValue, ActorContext};
use reflow_actor_macro::actor;
use serde_json::{json, Value};
use std::collections::HashMap;
use std::time::Duration;
const BASE_URL: &str = "https://api.stripe.com/v1";
const ENV_KEY: &str = "STRIPE_API_KEY";
/// Apply authentication to the request builder.
fn apply_auth(
config: &reflow_actor::ActorConfig,
mut builder: reqwest::RequestBuilder,
) -> Result<reqwest::RequestBuilder> {
let credential = config
.get_config_or_env(ENV_KEY)
.ok_or_else(|| anyhow::anyhow!("Missing env var: {}", ENV_KEY))?;
builder = builder.header("Authorization", format!("{} {}", "Bearer", credential));
Ok(builder)
}
/// create payment_intent via Stripe API
///
/// Method: POST /payment_intents
#[actor(
StripeCreatePaymentIntentActor,
inports::<100>(amount, currency),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_intent(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/payment_intents".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /payment_intents failed: {}", e).into()),
);
}
}
Ok(output)
}
/// create customer via Stripe API
///
/// Method: POST /customers
#[actor(
StripeCreateCustomerActor,
inports::<100>(email),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customer(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/customers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /customers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// list charges via Stripe API
///
/// Method: GET /charges
#[actor(
StripeListChargesActor,
inports::<100>(limit),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_list_charges(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/charges".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /charges failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve account
///
/// Method: GET /v1/account
#[actor(
StripeReadAccountActor,
inports::<100>(expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_account(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/account".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/account failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create an account link
///
/// Method: POST /v1/account_links
#[actor(
StripeCreateAccountLinksActor,
inports::<100>(type_, collection_options, refresh_url, account, collect, expand, return_url),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_account_links(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/account_links".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collection_options") {
body.insert("collection_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("refresh_url") {
body.insert("refresh_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account") {
body.insert("account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collect") {
body.insert("collect".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/account_links failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create an Account Session
///
/// Method: POST /v1/account_sessions
#[actor(
StripeCreateAccountSessionsActor,
inports::<100>(expand, account, components),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_account_sessions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/account_sessions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account") {
body.insert("account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("components") {
body.insert("components".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/account_sessions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all connected accounts
///
/// Method: GET /v1/accounts
#[actor(
StripeReadAccountsActor,
inports::<100>(created, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/accounts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/accounts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// <p>With <a href=\"/docs/connect\">Connect</a>, you can create Stripe accounts for your users.\nTo do this, you’ll first need to <a href=\"https://dashboard.stripe.com/account/applications/settings\">register your platform</a>.</p>\n\n<p>If you’ve already collected information for your connected accounts, you <a href=\"/docs/connect/best-practices#onboarding\">can prefill that information</a> when\ncreating the account. Connect Onboarding won’t ask for the prefilled information during account onboarding.\nYou can prefill any information on the account.</p>
///
/// Method: POST /v1/accounts
#[actor(
StripeCreateAccountsActor,
inports::<100>(type_, business_type, email, documents, groups, account_token, individual, business_profile, capabilities, company, country, default_currency, external_account, bank_account, metadata, settings, tos_acceptance, controller, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/accounts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("business_type") {
body.insert("business_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("documents") {
body.insert("documents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("groups") {
body.insert("groups".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_token") {
body.insert("account_token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("individual") {
body.insert("individual".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("business_profile") {
body.insert("business_profile".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("capabilities") {
body.insert("capabilities".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("company") {
body.insert("company".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("country") {
body.insert("country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_currency") {
body.insert("default_currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("external_account") {
body.insert("external_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bank_account") {
body.insert("bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("settings") {
body.insert("settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tos_acceptance") {
body.insert("tos_acceptance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("controller") {
body.insert("controller".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/accounts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete an account
///
/// Method: DELETE /v1/accounts/{account}
#[actor(
StripeDeleteAccountsAccountActor,
inports::<100>(account, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_accounts_account(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/accounts/{{account}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve account
///
/// Method: GET /v1/accounts/{account}
#[actor(
StripeReadAccountsAccountActor,
inports::<100>(account, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/accounts/{{account}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update an account
///
/// Method: POST /v1/accounts/{account}
#[actor(
StripeCreateAccountsAccountActor,
inports::<100>(account, default_currency, account_token, documents, groups, email, settings, business_type, individual, company, business_profile, expand, capabilities, metadata, tos_acceptance, external_account),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("default_currency") {
body.insert("default_currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_token") {
body.insert("account_token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("documents") {
body.insert("documents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("groups") {
body.insert("groups".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("settings") {
body.insert("settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("business_type") {
body.insert("business_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("individual") {
body.insert("individual".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("company") {
body.insert("company".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("business_profile") {
body.insert("business_profile".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("capabilities") {
body.insert("capabilities".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tos_acceptance") {
body.insert("tos_acceptance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("external_account") {
body.insert("external_account".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/accounts/{{account}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create an external account
///
/// Method: POST /v1/accounts/{account}/bank_accounts
#[actor(
StripeCreateAccountsAccountBankAccountsActor,
inports::<100>(account, metadata, bank_account, default_for_currency, external_account, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_bank_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/bank_accounts".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bank_account") {
body.insert("bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_for_currency") {
body.insert("default_for_currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("external_account") {
body.insert("external_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/accounts/{{account}}/bank_accounts failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve an external account
///
/// Method: GET /v1/accounts/{account}/bank_accounts/{id}
#[actor(
StripeReadAccountsAccountBankAccountsIdActor,
inports::<100>(account, expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account_bank_accounts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/bank_accounts/{id}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/accounts/{{account}}/bank_accounts/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// <p>Updates the metadata, account holder name, account holder type of a bank account belonging to\na connected account and optionally sets it as the default for its currency. Other bank account\ndetails are not editable by design.</p>\n\n<p>You can only update bank accounts when <a href=\"/api/accounts/object#account_object-controller-requirement_collection\">account.controller.requirement_collection</a> is <code>application</code>, which includes <a href=\"/connect/custom-accounts\">Custom accounts</a>.</p>\n\n<p>You can re-enable a disabled bank account by performing an update call without providing any\narguments or changes.</p>
///
/// Method: POST /v1/accounts/{account}/bank_accounts/{id}
#[actor(
StripeCreateAccountsAccountBankAccountsIdActor,
inports::<100>(account, id, address_zip, address_country, exp_month, expand, documents, exp_year, metadata, name, address_state, account_type, account_holder_type, account_holder_name, address_line1, address_line2, default_for_currency, address_city),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_bank_accounts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/bank_accounts/{id}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("address_zip") {
body.insert("address_zip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_country") {
body.insert("address_country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_month") {
body.insert("exp_month".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("documents") {
body.insert("documents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_year") {
body.insert("exp_year".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_state") {
body.insert("address_state".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_type") {
body.insert("account_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_type") {
body.insert("account_holder_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_name") {
body.insert("account_holder_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line1") {
body.insert("address_line1".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line2") {
body.insert("address_line2".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_for_currency") {
body.insert("default_for_currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_city") {
body.insert("address_city".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/accounts/{{account}}/bank_accounts/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete an external account
///
/// Method: DELETE /v1/accounts/{account}/bank_accounts/{id}
#[actor(
StripeDeleteAccountsAccountBankAccountsIdActor,
inports::<100>(account, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_accounts_account_bank_accounts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/bank_accounts/{id}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/accounts/{{account}}/bank_accounts/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all account capabilities
///
/// Method: GET /v1/accounts/{account}/capabilities
#[actor(
StripeReadAccountsAccountCapabilitiesActor,
inports::<100>(account, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account_capabilities(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/capabilities".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/accounts/{{account}}/capabilities failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update an Account Capability
///
/// Method: POST /v1/accounts/{account}/capabilities/{capability}
#[actor(
StripeCreateAccountsAccountCapabilitiesCapabilityActor,
inports::<100>(account, capability, expand, requested),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_capabilities_capability(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/capabilities/{capability}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("capability") {
endpoint = endpoint.replace("{{capability}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("requested") {
body.insert("requested".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/accounts/{{account}}/capabilities/{{capability}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve an Account Capability
///
/// Method: GET /v1/accounts/{account}/capabilities/{capability}
#[actor(
StripeReadAccountsAccountCapabilitiesCapabilityActor,
inports::<100>(account, capability, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account_capabilities_capability(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/capabilities/{capability}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("capability") {
endpoint = endpoint.replace("{{capability}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/accounts/{{account}}/capabilities/{{capability}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all external accounts
///
/// Method: GET /v1/accounts/{account}/external_accounts
#[actor(
StripeReadAccountsAccountExternalAccountsActor,
inports::<100>(account, ending_before, expand, limit, object, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account_external_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/external_accounts".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("object") {
query_pairs.push(("object", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/accounts/{{account}}/external_accounts failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create an external account
///
/// Method: POST /v1/accounts/{account}/external_accounts
#[actor(
StripeCreateAccountsAccountExternalAccountsActor,
inports::<100>(account, default_for_currency, expand, metadata, external_account, bank_account),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_external_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/external_accounts".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("default_for_currency") {
body.insert("default_for_currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("external_account") {
body.insert("external_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bank_account") {
body.insert("bank_account".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/accounts/{{account}}/external_accounts failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete an external account
///
/// Method: DELETE /v1/accounts/{account}/external_accounts/{id}
#[actor(
StripeDeleteAccountsAccountExternalAccountsIdActor,
inports::<100>(account, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_accounts_account_external_accounts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/external_accounts/{id}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/accounts/{{account}}/external_accounts/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve an external account
///
/// Method: GET /v1/accounts/{account}/external_accounts/{id}
#[actor(
StripeReadAccountsAccountExternalAccountsIdActor,
inports::<100>(account, expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account_external_accounts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/external_accounts/{id}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/accounts/{{account}}/external_accounts/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// <p>Updates the metadata, account holder name, account holder type of a bank account belonging to\na connected account and optionally sets it as the default for its currency. Other bank account\ndetails are not editable by design.</p>\n\n<p>You can only update bank accounts when <a href=\"/api/accounts/object#account_object-controller-requirement_collection\">account.controller.requirement_collection</a> is <code>application</code>, which includes <a href=\"/connect/custom-accounts\">Custom accounts</a>.</p>\n\n<p>You can re-enable a disabled bank account by performing an update call without providing any\narguments or changes.</p>
///
/// Method: POST /v1/accounts/{account}/external_accounts/{id}
#[actor(
StripeCreateAccountsAccountExternalAccountsIdActor,
inports::<100>(account, id, address_country, documents, exp_month, account_holder_name, address_line1, account_type, address_zip, address_line2, metadata, name, address_city, default_for_currency, expand, account_holder_type, address_state, exp_year),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_external_accounts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/external_accounts/{id}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("address_country") {
body.insert("address_country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("documents") {
body.insert("documents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_month") {
body.insert("exp_month".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_name") {
body.insert("account_holder_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line1") {
body.insert("address_line1".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_type") {
body.insert("account_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_zip") {
body.insert("address_zip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line2") {
body.insert("address_line2".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_city") {
body.insert("address_city".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_for_currency") {
body.insert("default_for_currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_type") {
body.insert("account_holder_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_state") {
body.insert("address_state".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_year") {
body.insert("exp_year".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/accounts/{{account}}/external_accounts/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a login link
///
/// Method: POST /v1/accounts/{account}/login_links
#[actor(
StripeCreateAccountsAccountLoginLinksActor,
inports::<100>(account, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_login_links(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/login_links".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/accounts/{{account}}/login_links failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all persons
///
/// Method: GET /v1/accounts/{account}/people
#[actor(
StripeReadAccountsAccountPeopleActor,
inports::<100>(account, ending_before, expand, limit, relationship, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account_people(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/people".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("relationship") {
query_pairs.push(("relationship", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/accounts/{{account}}/people failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a person
///
/// Method: POST /v1/accounts/{account}/people
#[actor(
StripeCreateAccountsAccountPeopleActor,
inports::<100>(account, expand, ssn_last_4, first_name_kanji, id_number, last_name, additional_tos_acceptances, maiden_name, metadata, last_name_kanji, person_token, address_kana, registered_address, address, first_name_kana, political_exposure, first_name, full_name_aliases, id_number_secondary, dob, us_cfpb_data, last_name_kana, address_kanji, nationality, documents, email, gender, phone, relationship, verification),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_people(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/people".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ssn_last_4") {
body.insert("ssn_last_4".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name_kanji") {
body.insert("first_name_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id_number") {
body.insert("id_number".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name") {
body.insert("last_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("additional_tos_acceptances") {
body.insert("additional_tos_acceptances".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("maiden_name") {
body.insert("maiden_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name_kanji") {
body.insert("last_name_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("person_token") {
body.insert("person_token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kana") {
body.insert("address_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("registered_address") {
body.insert("registered_address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address") {
body.insert("address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name_kana") {
body.insert("first_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("political_exposure") {
body.insert("political_exposure".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name") {
body.insert("first_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("full_name_aliases") {
body.insert("full_name_aliases".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id_number_secondary") {
body.insert("id_number_secondary".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("dob") {
body.insert("dob".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("us_cfpb_data") {
body.insert("us_cfpb_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name_kana") {
body.insert("last_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kanji") {
body.insert("address_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nationality") {
body.insert("nationality".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("documents") {
body.insert("documents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("gender") {
body.insert("gender".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone") {
body.insert("phone".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("relationship") {
body.insert("relationship".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("verification") {
body.insert("verification".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/accounts/{{account}}/people failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete a person
///
/// Method: DELETE /v1/accounts/{account}/people/{person}
#[actor(
StripeDeleteAccountsAccountPeoplePersonActor,
inports::<100>(account, person, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_accounts_account_people_person(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/people/{person}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("person") {
endpoint = endpoint.replace("{{person}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/accounts/{{account}}/people/{{person}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a person
///
/// Method: GET /v1/accounts/{account}/people/{person}
#[actor(
StripeReadAccountsAccountPeoplePersonActor,
inports::<100>(account, expand, person, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account_people_person(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/people/{person}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("person") {
endpoint = endpoint.replace("{{person}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/accounts/{{account}}/people/{{person}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a person
///
/// Method: POST /v1/accounts/{account}/people/{person}
#[actor(
StripeCreateAccountsAccountPeoplePersonActor,
inports::<100>(account, person, first_name, address_kana, political_exposure, registered_address, verification, email, id_number_secondary, dob, last_name_kana, full_name_aliases, id_number, last_name_kanji, ssn_last_4, first_name_kanji, maiden_name, metadata, address, first_name_kana, expand, last_name, us_cfpb_data, documents, address_kanji, person_token, phone, relationship, gender, additional_tos_acceptances, nationality),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_people_person(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/people/{person}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("person") {
endpoint = endpoint.replace("{{person}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("first_name") {
body.insert("first_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kana") {
body.insert("address_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("political_exposure") {
body.insert("political_exposure".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("registered_address") {
body.insert("registered_address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("verification") {
body.insert("verification".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id_number_secondary") {
body.insert("id_number_secondary".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("dob") {
body.insert("dob".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name_kana") {
body.insert("last_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("full_name_aliases") {
body.insert("full_name_aliases".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id_number") {
body.insert("id_number".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name_kanji") {
body.insert("last_name_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ssn_last_4") {
body.insert("ssn_last_4".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name_kanji") {
body.insert("first_name_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("maiden_name") {
body.insert("maiden_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address") {
body.insert("address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name_kana") {
body.insert("first_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name") {
body.insert("last_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("us_cfpb_data") {
body.insert("us_cfpb_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("documents") {
body.insert("documents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kanji") {
body.insert("address_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("person_token") {
body.insert("person_token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone") {
body.insert("phone".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("relationship") {
body.insert("relationship".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("gender") {
body.insert("gender".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("additional_tos_acceptances") {
body.insert("additional_tos_acceptances".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nationality") {
body.insert("nationality".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/accounts/{{account}}/people/{{person}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a person
///
/// Method: POST /v1/accounts/{account}/persons
#[actor(
StripeCreateAccountsAccountPersonsActor,
inports::<100>(account, id_number_secondary, documents, first_name_kana, last_name_kanji, nationality, verification, maiden_name, dob, ssn_last_4, address_kana, person_token, id_number, additional_tos_acceptances, us_cfpb_data, full_name_aliases, address_kanji, first_name_kanji, first_name, phone, political_exposure, last_name_kana, metadata, email, gender, registered_address, last_name, expand, relationship, address),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_persons(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/persons".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("id_number_secondary") {
body.insert("id_number_secondary".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("documents") {
body.insert("documents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name_kana") {
body.insert("first_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name_kanji") {
body.insert("last_name_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nationality") {
body.insert("nationality".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("verification") {
body.insert("verification".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("maiden_name") {
body.insert("maiden_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("dob") {
body.insert("dob".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ssn_last_4") {
body.insert("ssn_last_4".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kana") {
body.insert("address_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("person_token") {
body.insert("person_token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id_number") {
body.insert("id_number".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("additional_tos_acceptances") {
body.insert("additional_tos_acceptances".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("us_cfpb_data") {
body.insert("us_cfpb_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("full_name_aliases") {
body.insert("full_name_aliases".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kanji") {
body.insert("address_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name_kanji") {
body.insert("first_name_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name") {
body.insert("first_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone") {
body.insert("phone".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("political_exposure") {
body.insert("political_exposure".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name_kana") {
body.insert("last_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("gender") {
body.insert("gender".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("registered_address") {
body.insert("registered_address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name") {
body.insert("last_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("relationship") {
body.insert("relationship".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address") {
body.insert("address".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/accounts/{{account}}/persons failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all persons
///
/// Method: GET /v1/accounts/{account}/persons
#[actor(
StripeReadAccountsAccountPersonsActor,
inports::<100>(account, ending_before, expand, limit, relationship, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account_persons(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/persons".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("relationship") {
query_pairs.push(("relationship", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/accounts/{{account}}/persons failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete a person
///
/// Method: DELETE /v1/accounts/{account}/persons/{person}
#[actor(
StripeDeleteAccountsAccountPersonsPersonActor,
inports::<100>(account, person, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_accounts_account_persons_person(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/persons/{person}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("person") {
endpoint = endpoint.replace("{{person}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/accounts/{{account}}/persons/{{person}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a person
///
/// Method: POST /v1/accounts/{account}/persons/{person}
#[actor(
StripeCreateAccountsAccountPersonsPersonActor,
inports::<100>(account, person, address_kanji, us_cfpb_data, email, documents, last_name_kanji, id_number_secondary, first_name_kana, gender, metadata, address_kana, first_name, registered_address, additional_tos_acceptances, full_name_aliases, nationality, person_token, last_name_kana, expand, dob, political_exposure, ssn_last_4, last_name, phone, id_number, first_name_kanji, relationship, address, maiden_name, verification),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_persons_person(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/persons/{person}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("person") {
endpoint = endpoint.replace("{{person}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("address_kanji") {
body.insert("address_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("us_cfpb_data") {
body.insert("us_cfpb_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("documents") {
body.insert("documents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name_kanji") {
body.insert("last_name_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id_number_secondary") {
body.insert("id_number_secondary".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name_kana") {
body.insert("first_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("gender") {
body.insert("gender".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kana") {
body.insert("address_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name") {
body.insert("first_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("registered_address") {
body.insert("registered_address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("additional_tos_acceptances") {
body.insert("additional_tos_acceptances".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("full_name_aliases") {
body.insert("full_name_aliases".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nationality") {
body.insert("nationality".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("person_token") {
body.insert("person_token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name_kana") {
body.insert("last_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("dob") {
body.insert("dob".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("political_exposure") {
body.insert("political_exposure".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ssn_last_4") {
body.insert("ssn_last_4".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("last_name") {
body.insert("last_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone") {
body.insert("phone".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id_number") {
body.insert("id_number".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("first_name_kanji") {
body.insert("first_name_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("relationship") {
body.insert("relationship".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address") {
body.insert("address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("maiden_name") {
body.insert("maiden_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("verification") {
body.insert("verification".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/accounts/{{account}}/persons/{{person}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a person
///
/// Method: GET /v1/accounts/{account}/persons/{person}
#[actor(
StripeReadAccountsAccountPersonsPersonActor,
inports::<100>(account, expand, person, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_accounts_account_persons_person(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/persons/{person}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("person") {
endpoint = endpoint.replace("{{person}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/accounts/{{account}}/persons/{{person}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Reject an account
///
/// Method: POST /v1/accounts/{account}/reject
#[actor(
StripeCreateAccountsAccountRejectActor,
inports::<100>(account, reason, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_accounts_account_reject(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/accounts/{account}/reject".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("reason") {
body.insert("reason".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/accounts/{{account}}/reject failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// <p>Create an apple pay domain.</p>
///
/// Method: POST /v1/apple_pay/domains
#[actor(
StripeCreateApplePayDomainsActor,
inports::<100>(expand, domain_name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_apple_pay_domains(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/apple_pay/domains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("domain_name") {
body.insert("domain_name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/apple_pay/domains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// <p>List apple pay domains.</p>
///
/// Method: GET /v1/apple_pay/domains
#[actor(
StripeReadApplePayDomainsActor,
inports::<100>(domain_name, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_apple_pay_domains(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/apple_pay/domains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("domain_name") {
query_pairs.push(("domain_name", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/apple_pay/domains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// <p>Delete an apple pay domain.</p>
///
/// Method: DELETE /v1/apple_pay/domains/{domain}
#[actor(
StripeDeleteApplePayDomainsDomainActor,
inports::<100>(domain, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_apple_pay_domains_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/apple_pay/domains/{domain}".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/apple_pay/domains/{{domain}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// <p>Retrieve an apple pay domain.</p>
///
/// Method: GET /v1/apple_pay/domains/{domain}
#[actor(
StripeReadApplePayDomainsDomainActor,
inports::<100>(domain, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_apple_pay_domains_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/apple_pay/domains/{domain}".to_string();
if let Some(val) = inputs.get("domain") {
endpoint = endpoint.replace("{{domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/apple_pay/domains/{{domain}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all application fees
///
/// Method: GET /v1/application_fees
#[actor(
StripeReadApplicationFeesActor,
inports::<100>(charge, created, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_application_fees(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/application_fees".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("charge") {
query_pairs.push(("charge", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/application_fees failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update an application fee refund
///
/// Method: POST /v1/application_fees/{fee}/refunds/{id}
#[actor(
StripeCreateApplicationFeesFeeRefundsIdActor,
inports::<100>(fee, id, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_application_fees_fee_refunds_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/application_fees/{fee}/refunds/{id}".to_string();
if let Some(val) = inputs.get("fee") {
endpoint = endpoint.replace("{{fee}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/application_fees/{{fee}}/refunds/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve an application fee refund
///
/// Method: GET /v1/application_fees/{fee}/refunds/{id}
#[actor(
StripeReadApplicationFeesFeeRefundsIdActor,
inports::<100>(expand, fee, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_application_fees_fee_refunds_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/application_fees/{fee}/refunds/{id}".to_string();
if let Some(val) = inputs.get("fee") {
endpoint = endpoint.replace("{{fee}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/application_fees/{{fee}}/refunds/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve an application fee
///
/// Method: GET /v1/application_fees/{id}
#[actor(
StripeReadApplicationFeesIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_application_fees_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/application_fees/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/application_fees/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
///
///
/// Method: POST /v1/application_fees/{id}/refund
#[actor(
StripeCreateApplicationFeesIdRefundActor,
inports::<100>(id, expand, amount, directive),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_application_fees_id_refund(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/application_fees/{id}/refund".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("directive") {
body.insert("directive".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/application_fees/{{id}}/refund failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all application fee refunds
///
/// Method: GET /v1/application_fees/{id}/refunds
#[actor(
StripeReadApplicationFeesIdRefundsActor,
inports::<100>(ending_before, expand, id, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_application_fees_id_refunds(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/application_fees/{id}/refunds".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/application_fees/{{id}}/refunds failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create an application fee refund
///
/// Method: POST /v1/application_fees/{id}/refunds
#[actor(
StripeCreateApplicationFeesIdRefundsActor,
inports::<100>(id, amount, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_application_fees_id_refunds(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/application_fees/{id}/refunds".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/application_fees/{{id}}/refunds failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Set a Secret
///
/// Method: POST /v1/apps/secrets
#[actor(
StripeCreateAppsSecretsActor,
inports::<100>(expand, payload, expires_at, scope, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_apps_secrets(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/apps/secrets".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payload") {
body.insert("payload".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("scope") {
body.insert("scope".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/apps/secrets failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List secrets
///
/// Method: GET /v1/apps/secrets
#[actor(
StripeReadAppsSecretsActor,
inports::<100>(ending_before, expand, limit, scope, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_apps_secrets(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/apps/secrets".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("scope") {
query_pairs.push(("scope", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/apps/secrets failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a Secret
///
/// Method: POST /v1/apps/secrets/delete
#[actor(
StripeCreateAppsSecretsDeleteActor,
inports::<100>(expand, scope, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_apps_secrets_delete(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/apps/secrets/delete".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("scope") {
body.insert("scope".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/apps/secrets/delete failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Find a Secret
///
/// Method: GET /v1/apps/secrets/find
#[actor(
StripeReadAppsSecretsFindActor,
inports::<100>(expand, name, scope, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_apps_secrets_find(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/apps/secrets/find".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("name") {
query_pairs.push(("name", super::message_to_str(val)));
}
if let Some(val) = inputs.get("scope") {
query_pairs.push(("scope", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/apps/secrets/find failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve balance
///
/// Method: GET /v1/balance
#[actor(
StripeReadBalanceActor,
inports::<100>(expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_balance(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/balance".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/balance failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all balance transactions
///
/// Method: GET /v1/balance/history
#[actor(
StripeReadBalanceHistoryActor,
inports::<100>(created, currency, ending_before, expand, limit, payout, source, starting_after, type_, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_balance_history(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/balance/history".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("currency") {
query_pairs.push(("currency", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payout") {
query_pairs.push(("payout", super::message_to_str(val)));
}
if let Some(val) = inputs.get("source") {
query_pairs.push(("source", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/balance/history failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a balance transaction
///
/// Method: GET /v1/balance/history/{id}
#[actor(
StripeReadBalanceHistoryIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_balance_history_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/balance/history/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/balance/history/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update balance settings
///
/// Method: POST /v1/balance_settings
#[actor(
StripeCreateBalanceSettingsActor,
inports::<100>(payments, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_balance_settings(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/balance_settings".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("payments") {
body.insert("payments".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/balance_settings failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve balance settings
///
/// Method: GET /v1/balance_settings
#[actor(
StripeReadBalanceSettingsActor,
inports::<100>(expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_balance_settings(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/balance_settings".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/balance_settings failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all balance transactions
///
/// Method: GET /v1/balance_transactions
#[actor(
StripeReadBalanceTransactionsActor,
inports::<100>(created, currency, ending_before, expand, limit, payout, source, starting_after, type_, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_balance_transactions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/balance_transactions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("currency") {
query_pairs.push(("currency", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payout") {
query_pairs.push(("payout", super::message_to_str(val)));
}
if let Some(val) = inputs.get("source") {
query_pairs.push(("source", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/balance_transactions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a balance transaction
///
/// Method: GET /v1/balance_transactions/{id}
#[actor(
StripeReadBalanceTransactionsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_balance_transactions_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/balance_transactions/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/balance_transactions/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List billing alerts
///
/// Method: GET /v1/billing/alerts
#[actor(
StripeReadBillingAlertsActor,
inports::<100>(alert_type, ending_before, expand, limit, meter, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_alerts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/alerts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("alert_type") {
query_pairs.push(("alert_type", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("meter") {
query_pairs.push(("meter", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/billing/alerts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a billing alert
///
/// Method: POST /v1/billing/alerts
#[actor(
StripeCreateBillingAlertsActor,
inports::<100>(expand, title, alert_type, usage_threshold),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_alerts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/alerts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("title") {
body.insert("title".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alert_type") {
body.insert("alert_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("usage_threshold") {
body.insert("usage_threshold".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/billing/alerts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a billing alert
///
/// Method: GET /v1/billing/alerts/{id}
#[actor(
StripeReadBillingAlertsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_alerts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/alerts/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/billing/alerts/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Activate a billing alert
///
/// Method: POST /v1/billing/alerts/{id}/activate
#[actor(
StripeCreateBillingAlertsIdActivateActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_alerts_id_activate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/alerts/{id}/activate".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing/alerts/{{id}}/activate failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Archive a billing alert
///
/// Method: POST /v1/billing/alerts/{id}/archive
#[actor(
StripeCreateBillingAlertsIdArchiveActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_alerts_id_archive(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/alerts/{id}/archive".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing/alerts/{{id}}/archive failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Deactivate a billing alert
///
/// Method: POST /v1/billing/alerts/{id}/deactivate
#[actor(
StripeCreateBillingAlertsIdDeactivateActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_alerts_id_deactivate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/alerts/{id}/deactivate".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing/alerts/{{id}}/deactivate failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve the credit balance summary for a customer
///
/// Method: GET /v1/billing/credit_balance_summary
#[actor(
StripeReadBillingCreditBalanceSummaryActor,
inports::<100>(customer, customer_account, expand, filter, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_credit_balance_summary(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/credit_balance_summary".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("filter") {
query_pairs.push(("filter", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/billing/credit_balance_summary failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List credit balance transactions
///
/// Method: GET /v1/billing/credit_balance_transactions
#[actor(
StripeReadBillingCreditBalanceTransactionsActor,
inports::<100>(credit_grant, customer, customer_account, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_credit_balance_transactions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/credit_balance_transactions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("credit_grant") {
query_pairs.push(("credit_grant", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/billing/credit_balance_transactions failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a credit balance transaction
///
/// Method: GET /v1/billing/credit_balance_transactions/{id}
#[actor(
StripeReadBillingCreditBalanceTransactionsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_credit_balance_transactions_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/credit_balance_transactions/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/billing/credit_balance_transactions/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List credit grants
///
/// Method: GET /v1/billing/credit_grants
#[actor(
StripeReadBillingCreditGrantsActor,
inports::<100>(customer, customer_account, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_credit_grants(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/credit_grants".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/billing/credit_grants failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a credit grant
///
/// Method: POST /v1/billing/credit_grants
#[actor(
StripeCreateBillingCreditGrantsActor,
inports::<100>(amount, category, priority, customer, metadata, customer_account, applicability_config, expand, name, effective_at, expires_at),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_credit_grants(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/credit_grants".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("category") {
body.insert("category".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("priority") {
body.insert("priority".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("applicability_config") {
body.insert("applicability_config".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("effective_at") {
body.insert("effective_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/billing/credit_grants failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a credit grant
///
/// Method: POST /v1/billing/credit_grants/{id}
#[actor(
StripeCreateBillingCreditGrantsIdActor,
inports::<100>(id, metadata, expires_at, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_credit_grants_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/credit_grants/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing/credit_grants/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a credit grant
///
/// Method: GET /v1/billing/credit_grants/{id}
#[actor(
StripeReadBillingCreditGrantsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_credit_grants_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/credit_grants/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/billing/credit_grants/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Expire a credit grant
///
/// Method: POST /v1/billing/credit_grants/{id}/expire
#[actor(
StripeCreateBillingCreditGrantsIdExpireActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_credit_grants_id_expire(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/credit_grants/{id}/expire".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing/credit_grants/{{id}}/expire failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Void a credit grant
///
/// Method: POST /v1/billing/credit_grants/{id}/void
#[actor(
StripeCreateBillingCreditGrantsIdVoidActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_credit_grants_id_void(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/credit_grants/{id}/void".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing/credit_grants/{{id}}/void failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a billing meter event adjustment
///
/// Method: POST /v1/billing/meter_event_adjustments
#[actor(
StripeCreateBillingMeterEventAdjustmentsActor,
inports::<100>(cancel, expand, type_, event_name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_meter_event_adjustments(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/meter_event_adjustments".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("cancel") {
body.insert("cancel".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("event_name") {
body.insert("event_name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing/meter_event_adjustments failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a billing meter event
///
/// Method: POST /v1/billing/meter_events
#[actor(
StripeCreateBillingMeterEventsActor,
inports::<100>(expand, payload, timestamp, identifier, event_name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_meter_events(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/meter_events".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payload") {
body.insert("payload".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("timestamp") {
body.insert("timestamp".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("identifier") {
body.insert("identifier".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("event_name") {
body.insert("event_name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/billing/meter_events failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List billing meters
///
/// Method: GET /v1/billing/meters
#[actor(
StripeReadBillingMetersActor,
inports::<100>(ending_before, expand, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_meters(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/meters".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/billing/meters failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a billing meter
///
/// Method: POST /v1/billing/meters
#[actor(
StripeCreateBillingMetersActor,
inports::<100>(default_aggregation, display_name, event_name, event_time_window, value_settings, expand, customer_mapping),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_meters(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing/meters".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("default_aggregation") {
body.insert("default_aggregation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("display_name") {
body.insert("display_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("event_name") {
body.insert("event_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("event_time_window") {
body.insert("event_time_window".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("value_settings") {
body.insert("value_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_mapping") {
body.insert("customer_mapping".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/billing/meters failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a billing meter
///
/// Method: POST /v1/billing/meters/{id}
#[actor(
StripeCreateBillingMetersIdActor,
inports::<100>(id, expand, display_name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_meters_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/meters/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("display_name") {
body.insert("display_name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/billing/meters/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a billing meter
///
/// Method: GET /v1/billing/meters/{id}
#[actor(
StripeReadBillingMetersIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_meters_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/meters/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/billing/meters/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Deactivate a billing meter
///
/// Method: POST /v1/billing/meters/{id}/deactivate
#[actor(
StripeCreateBillingMetersIdDeactivateActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_meters_id_deactivate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/meters/{id}/deactivate".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing/meters/{{id}}/deactivate failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List billing meter event summaries
///
/// Method: GET /v1/billing/meters/{id}/event_summaries
#[actor(
StripeReadBillingMetersIdEventSummariesActor,
inports::<100>(customer, end_time, ending_before, expand, id, limit, start_time, starting_after, value_grouping_window, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_meters_id_event_summaries(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/meters/{id}/event_summaries".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("end_time") {
query_pairs.push(("end_time", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("start_time") {
query_pairs.push(("start_time", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("value_grouping_window") {
query_pairs.push(("value_grouping_window", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/billing/meters/{{id}}/event_summaries failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Reactivate a billing meter
///
/// Method: POST /v1/billing/meters/{id}/reactivate
#[actor(
StripeCreateBillingMetersIdReactivateActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_meters_id_reactivate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing/meters/{id}/reactivate".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing/meters/{{id}}/reactivate failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List portal configurations
///
/// Method: GET /v1/billing_portal/configurations
#[actor(
StripeReadBillingPortalConfigurationsActor,
inports::<100>(active, ending_before, expand, is_default, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_portal_configurations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing_portal/configurations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("active") {
query_pairs.push(("active", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("is_default") {
query_pairs.push(("is_default", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/billing_portal/configurations failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a portal configuration
///
/// Method: POST /v1/billing_portal/configurations
#[actor(
StripeCreateBillingPortalConfigurationsActor,
inports::<100>(business_profile, expand, login_page, default_return_url, features, metadata, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_portal_configurations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing_portal/configurations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("business_profile") {
body.insert("business_profile".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("login_page") {
body.insert("login_page".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_return_url") {
body.insert("default_return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("features") {
body.insert("features".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/billing_portal/configurations failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a portal configuration
///
/// Method: POST /v1/billing_portal/configurations/{configuration}
#[actor(
StripeCreateBillingPortalConfigurationsConfigurationActor,
inports::<100>(configuration, metadata, name, active, expand, features, business_profile, default_return_url, login_page),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_portal_configurations_configuration(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing_portal/configurations/{configuration}".to_string();
if let Some(val) = inputs.get("configuration") {
endpoint = endpoint.replace("{{configuration}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("features") {
body.insert("features".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("business_profile") {
body.insert("business_profile".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_return_url") {
body.insert("default_return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("login_page") {
body.insert("login_page".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/billing_portal/configurations/{{configuration}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a portal configuration
///
/// Method: GET /v1/billing_portal/configurations/{configuration}
#[actor(
StripeReadBillingPortalConfigurationsConfigurationActor,
inports::<100>(configuration, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_billing_portal_configurations_configuration(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/billing_portal/configurations/{configuration}".to_string();
if let Some(val) = inputs.get("configuration") {
endpoint = endpoint.replace("{{configuration}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/billing_portal/configurations/{{configuration}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a portal session
///
/// Method: POST /v1/billing_portal/sessions
#[actor(
StripeCreateBillingPortalSessionsActor,
inports::<100>(customer, customer_account, flow_data, on_behalf_of, configuration, return_url, expand, locale),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_billing_portal_sessions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/billing_portal/sessions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("flow_data") {
body.insert("flow_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("configuration") {
body.insert("configuration".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("locale") {
body.insert("locale".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/billing_portal/sessions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// <p>This method is no longer recommended—use the <a href=\"/docs/api/payment_intents\">Payment Intents API</a>\nto initiate a new payment instead. Confirmation of the PaymentIntent creates the <code>Charge</code>\nobject used to request payment.</p>
///
/// Method: POST /v1/charges
#[actor(
StripeCreateChargesActor,
inports::<100>(currency, application_fee, statement_descriptor_suffix, card, metadata, transfer_group, capture, shipping, on_behalf_of, radar_options, description, source, transfer_data, application_fee_amount, customer, receipt_email, destination, statement_descriptor, amount, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_charges(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/charges".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee") {
body.insert("application_fee".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor_suffix") {
body.insert(
"statement_descriptor_suffix".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_group") {
body.insert("transfer_group".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("capture") {
body.insert("capture".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("radar_options") {
body.insert("radar_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("receipt_email") {
body.insert("receipt_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("destination") {
body.insert("destination".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/charges failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all charges
///
/// Method: GET /v1/charges
#[actor(
StripeReadChargesActor,
inports::<100>(created, customer, ending_before, expand, limit, payment_intent, starting_after, transfer_group, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_charges(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/charges".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment_intent") {
query_pairs.push(("payment_intent", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("transfer_group") {
query_pairs.push(("transfer_group", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/charges failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Search charges
///
/// Method: GET /v1/charges/search
#[actor(
StripeReadChargesSearchActor,
inports::<100>(expand, limit, page, query, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_charges_search(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/charges/search".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("page") {
query_pairs.push(("page", super::message_to_str(val)));
}
if let Some(val) = inputs.get("query") {
query_pairs.push(("query", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/charges/search failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a charge
///
/// Method: GET /v1/charges/{charge}
#[actor(
StripeReadChargesChargeActor,
inports::<100>(charge, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_charges_charge(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/charges/{{charge}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a charge
///
/// Method: POST /v1/charges/{charge}
#[actor(
StripeCreateChargesChargeActor,
inports::<100>(charge, customer, metadata, transfer_group, description, shipping, expand, receipt_email, fraud_details),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_charges_charge(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_group") {
body.insert("transfer_group".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("receipt_email") {
body.insert("receipt_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fraud_details") {
body.insert("fraud_details".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/charges/{{charge}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Capture a payment
///
/// Method: POST /v1/charges/{charge}/capture
#[actor(
StripeCreateChargesChargeCaptureActor,
inports::<100>(charge, application_fee, transfer_data, application_fee_amount, receipt_email, transfer_group, statement_descriptor, statement_descriptor_suffix, amount, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_charges_charge_capture(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}/capture".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("application_fee") {
body.insert("application_fee".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("receipt_email") {
body.insert("receipt_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_group") {
body.insert("transfer_group".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor_suffix") {
body.insert(
"statement_descriptor_suffix".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/charges/{{charge}}/capture failed: {}", e).into()),
);
}
}
Ok(output)
}
///
///
/// Method: POST /v1/charges/{charge}/dispute
#[actor(
StripeCreateChargesChargeDisputeActor,
inports::<100>(charge, expand, submit, evidence, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_charges_charge_dispute(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}/dispute".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("submit") {
body.insert("submit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("evidence") {
body.insert("evidence".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/charges/{{charge}}/dispute failed: {}", e).into()),
);
}
}
Ok(output)
}
/// <p>Retrieve a dispute for a specified charge.</p>
///
/// Method: GET /v1/charges/{charge}/dispute
#[actor(
StripeReadChargesChargeDisputeActor,
inports::<100>(charge, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_charges_charge_dispute(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}/dispute".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/charges/{{charge}}/dispute failed: {}", e).into()),
);
}
}
Ok(output)
}
///
///
/// Method: POST /v1/charges/{charge}/dispute/close
#[actor(
StripeCreateChargesChargeDisputeCloseActor,
inports::<100>(charge, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_charges_charge_dispute_close(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}/dispute/close".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/charges/{{charge}}/dispute/close failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a refund
///
/// Method: POST /v1/charges/{charge}/refund
#[actor(
StripeCreateChargesChargeRefundActor,
inports::<100>(charge, expand, reverse_transfer, instructions_email, metadata, reason, amount, payment_intent, refund_application_fee),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_charges_charge_refund(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}/refund".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reverse_transfer") {
body.insert("reverse_transfer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("instructions_email") {
body.insert("instructions_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reason") {
body.insert("reason".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent") {
body.insert("payment_intent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("refund_application_fee") {
body.insert("refund_application_fee".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/charges/{{charge}}/refund failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all refunds
///
/// Method: GET /v1/charges/{charge}/refunds
#[actor(
StripeReadChargesChargeRefundsActor,
inports::<100>(charge, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_charges_charge_refunds(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}/refunds".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/charges/{{charge}}/refunds failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create customer balance refund
///
/// Method: POST /v1/charges/{charge}/refunds
#[actor(
StripeCreateChargesChargeRefundsActor,
inports::<100>(charge, refund_application_fee, reverse_transfer, amount, origin, instructions_email, payment_intent, reason, currency, expand, metadata, customer),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_charges_charge_refunds(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}/refunds".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("refund_application_fee") {
body.insert("refund_application_fee".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reverse_transfer") {
body.insert("reverse_transfer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("origin") {
body.insert("origin".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("instructions_email") {
body.insert("instructions_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent") {
body.insert("payment_intent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reason") {
body.insert("reason".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/charges/{{charge}}/refunds failed: {}", e).into()),
);
}
}
Ok(output)
}
/// <p>Retrieves the details of an existing refund.</p>
///
/// Method: GET /v1/charges/{charge}/refunds/{refund}
#[actor(
StripeReadChargesChargeRefundsRefundActor,
inports::<100>(charge, expand, refund, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_charges_charge_refunds_refund(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}/refunds/{refund}".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("refund") {
endpoint = endpoint.replace("{{refund}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/charges/{{charge}}/refunds/{{refund}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// <p>Update a specified refund.</p>
///
/// Method: POST /v1/charges/{charge}/refunds/{refund}
#[actor(
StripeCreateChargesChargeRefundsRefundActor,
inports::<100>(charge, refund, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_charges_charge_refunds_refund(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/charges/{charge}/refunds/{refund}".to_string();
if let Some(val) = inputs.get("charge") {
endpoint = endpoint.replace("{{charge}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("refund") {
endpoint = endpoint.replace("{{refund}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/charges/{{charge}}/refunds/{{refund}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all Checkout Sessions
///
/// Method: GET /v1/checkout/sessions
#[actor(
StripeReadCheckoutSessionsActor,
inports::<100>(created, customer, customer_account, customer_details, ending_before, expand, limit, payment_intent, payment_link, starting_after, status, subscription, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_checkout_sessions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/checkout/sessions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_details") {
query_pairs.push(("customer_details", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment_intent") {
query_pairs.push(("payment_intent", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment_link") {
query_pairs.push(("payment_link", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if let Some(val) = inputs.get("subscription") {
query_pairs.push(("subscription", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/checkout/sessions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a Checkout Session
///
/// Method: POST /v1/checkout/sessions
#[actor(
StripeCreateCheckoutSessionsActor,
inports::<100>(allow_promotion_codes, payment_method_options, shipping_options, success_url, tax_id_collection, ui_mode, line_items, client_reference_id, excluded_payment_method_types, payment_method_data, customer_creation, name_collection, payment_method_configuration, submit_type, return_url, saved_payment_method_options, billing_address_collection, permissions, customer_account, currency, discounts, phone_number_collection, expires_at, metadata, subscription_data, origin_context, mode, wallet_options, shipping_address_collection, automatic_tax, expand, redirect_on_completion, optional_items, custom_fields, cancel_url, after_expiration, payment_intent_data, consent_collection, invoice_creation, payment_method_collection, branding_settings, adaptive_pricing, locale, custom_text, customer_email, customer_update, customer, payment_method_types, setup_intent_data),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_checkout_sessions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/checkout/sessions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("allow_promotion_codes") {
body.insert("allow_promotion_codes".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_options") {
body.insert("payment_method_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_options") {
body.insert("shipping_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("success_url") {
body.insert("success_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_id_collection") {
body.insert("tax_id_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ui_mode") {
body.insert("ui_mode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("line_items") {
body.insert("line_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("client_reference_id") {
body.insert("client_reference_id".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("excluded_payment_method_types") {
body.insert(
"excluded_payment_method_types".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("payment_method_data") {
body.insert("payment_method_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_creation") {
body.insert("customer_creation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name_collection") {
body.insert("name_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_configuration") {
body.insert(
"payment_method_configuration".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("submit_type") {
body.insert("submit_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("saved_payment_method_options") {
body.insert(
"saved_payment_method_options".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("billing_address_collection") {
body.insert("billing_address_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("permissions") {
body.insert("permissions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone_number_collection") {
body.insert("phone_number_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription_data") {
body.insert("subscription_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("origin_context") {
body.insert("origin_context".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mode") {
body.insert("mode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("wallet_options") {
body.insert("wallet_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_address_collection") {
body.insert(
"shipping_address_collection".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("redirect_on_completion") {
body.insert("redirect_on_completion".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("optional_items") {
body.insert("optional_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom_fields") {
body.insert("custom_fields".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancel_url") {
body.insert("cancel_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("after_expiration") {
body.insert("after_expiration".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent_data") {
body.insert("payment_intent_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("consent_collection") {
body.insert("consent_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_creation") {
body.insert("invoice_creation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_collection") {
body.insert("payment_method_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("branding_settings") {
body.insert("branding_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("adaptive_pricing") {
body.insert("adaptive_pricing".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("locale") {
body.insert("locale".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom_text") {
body.insert("custom_text".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_email") {
body.insert("customer_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_update") {
body.insert("customer_update".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_types") {
body.insert("payment_method_types".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("setup_intent_data") {
body.insert("setup_intent_data".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/checkout/sessions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a Checkout Session
///
/// Method: GET /v1/checkout/sessions/{session}
#[actor(
StripeReadCheckoutSessionsSessionActor,
inports::<100>(expand, session, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_checkout_sessions_session(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/checkout/sessions/{session}".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/checkout/sessions/{{session}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a Checkout Session
///
/// Method: POST /v1/checkout/sessions/{session}
#[actor(
StripeCreateCheckoutSessionsSessionActor,
inports::<100>(session, metadata, collected_information, expand, shipping_options, line_items),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_checkout_sessions_session(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/checkout/sessions/{session}".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collected_information") {
body.insert("collected_information".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_options") {
body.insert("shipping_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("line_items") {
body.insert("line_items".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/checkout/sessions/{{session}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Expire a Checkout Session
///
/// Method: POST /v1/checkout/sessions/{session}/expire
#[actor(
StripeCreateCheckoutSessionsSessionExpireActor,
inports::<100>(session, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_checkout_sessions_session_expire(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/checkout/sessions/{session}/expire".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/checkout/sessions/{{session}}/expire failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Checkout Session's line items
///
/// Method: GET /v1/checkout/sessions/{session}/line_items
#[actor(
StripeReadCheckoutSessionsSessionLineItemsActor,
inports::<100>(ending_before, expand, limit, session, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_checkout_sessions_session_line_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/checkout/sessions/{session}/line_items".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/checkout/sessions/{{session}}/line_items failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List orders
///
/// Method: GET /v1/climate/orders
#[actor(
StripeReadClimateOrdersActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_climate_orders(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/climate/orders".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/climate/orders failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create an order
///
/// Method: POST /v1/climate/orders
#[actor(
StripeCreateClimateOrdersActor,
inports::<100>(expand, metric_tons, beneficiary, currency, amount, metadata, product),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_climate_orders(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/climate/orders".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metric_tons") {
body.insert("metric_tons".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("beneficiary") {
body.insert("beneficiary".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("product") {
body.insert("product".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/climate/orders failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update an order
///
/// Method: POST /v1/climate/orders/{order}
#[actor(
StripeCreateClimateOrdersOrderActor,
inports::<100>(order, metadata, beneficiary, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_climate_orders_order(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/climate/orders/{order}".to_string();
if let Some(val) = inputs.get("order") {
endpoint = endpoint.replace("{{order}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("beneficiary") {
body.insert("beneficiary".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/climate/orders/{{order}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an order
///
/// Method: GET /v1/climate/orders/{order}
#[actor(
StripeReadClimateOrdersOrderActor,
inports::<100>(expand, order, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_climate_orders_order(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/climate/orders/{order}".to_string();
if let Some(val) = inputs.get("order") {
endpoint = endpoint.replace("{{order}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/climate/orders/{{order}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Cancel an order
///
/// Method: POST /v1/climate/orders/{order}/cancel
#[actor(
StripeCreateClimateOrdersOrderCancelActor,
inports::<100>(order, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_climate_orders_order_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/climate/orders/{order}/cancel".to_string();
if let Some(val) = inputs.get("order") {
endpoint = endpoint.replace("{{order}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/climate/orders/{{order}}/cancel failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List products
///
/// Method: GET /v1/climate/products
#[actor(
StripeReadClimateProductsActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_climate_products(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/climate/products".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/climate/products failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a product
///
/// Method: GET /v1/climate/products/{product}
#[actor(
StripeReadClimateProductsProductActor,
inports::<100>(expand, product, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_climate_products_product(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/climate/products/{product}".to_string();
if let Some(val) = inputs.get("product") {
endpoint = endpoint.replace("{{product}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/climate/products/{{product}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List suppliers
///
/// Method: GET /v1/climate/suppliers
#[actor(
StripeReadClimateSuppliersActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_climate_suppliers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/climate/suppliers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/climate/suppliers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a supplier
///
/// Method: GET /v1/climate/suppliers/{supplier}
#[actor(
StripeReadClimateSuppliersSupplierActor,
inports::<100>(expand, supplier, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_climate_suppliers_supplier(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/climate/suppliers/{supplier}".to_string();
if let Some(val) = inputs.get("supplier") {
endpoint = endpoint.replace("{{supplier}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/climate/suppliers/{{supplier}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a ConfirmationToken
///
/// Method: GET /v1/confirmation_tokens/{confirmation_token}
#[actor(
StripeReadConfirmationTokensConfirmationTokenActor,
inports::<100>(confirmation_token, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_confirmation_tokens_confirmation_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/confirmation_tokens/{confirmation_token}".to_string();
if let Some(val) = inputs.get("confirmation_token") {
endpoint = endpoint.replace("{{confirmation_token}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/confirmation_tokens/{{confirmation_token}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List Country Specs
///
/// Method: GET /v1/country_specs
#[actor(
StripeReadCountrySpecsActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_country_specs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/country_specs".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/country_specs failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a Country Spec
///
/// Method: GET /v1/country_specs/{country}
#[actor(
StripeReadCountrySpecsCountryActor,
inports::<100>(country, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_country_specs_country(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/country_specs/{country}".to_string();
if let Some(val) = inputs.get("country") {
endpoint = endpoint.replace("{{country}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/country_specs/{{country}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all coupons
///
/// Method: GET /v1/coupons
#[actor(
StripeReadCouponsActor,
inports::<100>(created, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_coupons(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/coupons".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/coupons failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a coupon
///
/// Method: POST /v1/coupons
#[actor(
StripeCreateCouponsActor,
inports::<100>(currency, name, duration, percent_off, applies_to, currency_options, redeem_by, id, amount_off, expand, duration_in_months, max_redemptions, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_coupons(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/coupons".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("duration") {
body.insert("duration".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("percent_off") {
body.insert("percent_off".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("applies_to") {
body.insert("applies_to".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency_options") {
body.insert("currency_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("redeem_by") {
body.insert("redeem_by".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id") {
body.insert("id".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_off") {
body.insert("amount_off".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("duration_in_months") {
body.insert("duration_in_months".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("max_redemptions") {
body.insert("max_redemptions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/coupons failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a coupon
///
/// Method: GET /v1/coupons/{coupon}
#[actor(
StripeReadCouponsCouponActor,
inports::<100>(coupon, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_coupons_coupon(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/coupons/{coupon}".to_string();
if let Some(val) = inputs.get("coupon") {
endpoint = endpoint.replace("{{coupon}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/coupons/{{coupon}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a coupon
///
/// Method: POST /v1/coupons/{coupon}
#[actor(
StripeCreateCouponsCouponActor,
inports::<100>(coupon, metadata, currency_options, expand, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_coupons_coupon(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/coupons/{coupon}".to_string();
if let Some(val) = inputs.get("coupon") {
endpoint = endpoint.replace("{{coupon}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency_options") {
body.insert("currency_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/coupons/{{coupon}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a coupon
///
/// Method: DELETE /v1/coupons/{coupon}
#[actor(
StripeDeleteCouponsCouponActor,
inports::<100>(coupon, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_coupons_coupon(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/coupons/{coupon}".to_string();
if let Some(val) = inputs.get("coupon") {
endpoint = endpoint.replace("{{coupon}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/coupons/{{coupon}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a credit note
///
/// Method: POST /v1/credit_notes
#[actor(
StripeCreateCreditNotesActor,
inports::<100>(out_of_band_amount, refunds, amount, invoice, reason, shipping_cost, effective_at, lines, memo, metadata, refund_amount, expand, credit_amount, email_type),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_credit_notes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/credit_notes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("out_of_band_amount") {
body.insert("out_of_band_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("refunds") {
body.insert("refunds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice") {
body.insert("invoice".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reason") {
body.insert("reason".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_cost") {
body.insert("shipping_cost".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("effective_at") {
body.insert("effective_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("lines") {
body.insert("lines".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("memo") {
body.insert("memo".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("refund_amount") {
body.insert("refund_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("credit_amount") {
body.insert("credit_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email_type") {
body.insert("email_type".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/credit_notes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all credit notes
///
/// Method: GET /v1/credit_notes
#[actor(
StripeReadCreditNotesActor,
inports::<100>(created, customer, customer_account, ending_before, expand, invoice, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_credit_notes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/credit_notes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("invoice") {
query_pairs.push(("invoice", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/credit_notes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Preview a credit note
///
/// Method: GET /v1/credit_notes/preview
#[actor(
StripeReadCreditNotesPreviewActor,
inports::<100>(amount, credit_amount, effective_at, email_type, expand, invoice, lines, memo, metadata, out_of_band_amount, reason, refund_amount, refunds, shipping_cost, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_credit_notes_preview(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/credit_notes/preview".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("amount") {
query_pairs.push(("amount", super::message_to_str(val)));
}
if let Some(val) = inputs.get("credit_amount") {
query_pairs.push(("credit_amount", super::message_to_str(val)));
}
if let Some(val) = inputs.get("effective_at") {
query_pairs.push(("effective_at", super::message_to_str(val)));
}
if let Some(val) = inputs.get("email_type") {
query_pairs.push(("email_type", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("invoice") {
query_pairs.push(("invoice", super::message_to_str(val)));
}
if let Some(val) = inputs.get("lines") {
query_pairs.push(("lines", super::message_to_str(val)));
}
if let Some(val) = inputs.get("memo") {
query_pairs.push(("memo", super::message_to_str(val)));
}
if let Some(val) = inputs.get("metadata") {
query_pairs.push(("metadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("out_of_band_amount") {
query_pairs.push(("out_of_band_amount", super::message_to_str(val)));
}
if let Some(val) = inputs.get("reason") {
query_pairs.push(("reason", super::message_to_str(val)));
}
if let Some(val) = inputs.get("refund_amount") {
query_pairs.push(("refund_amount", super::message_to_str(val)));
}
if let Some(val) = inputs.get("refunds") {
query_pairs.push(("refunds", super::message_to_str(val)));
}
if let Some(val) = inputs.get("shipping_cost") {
query_pairs.push(("shipping_cost", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/credit_notes/preview failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a credit note preview's line items
///
/// Method: GET /v1/credit_notes/preview/lines
#[actor(
StripeReadCreditNotesPreviewLinesActor,
inports::<100>(amount, credit_amount, effective_at, email_type, ending_before, expand, invoice, limit, lines, memo, metadata, out_of_band_amount, reason, refund_amount, refunds, shipping_cost, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_credit_notes_preview_lines(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/credit_notes/preview/lines".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("amount") {
query_pairs.push(("amount", super::message_to_str(val)));
}
if let Some(val) = inputs.get("credit_amount") {
query_pairs.push(("credit_amount", super::message_to_str(val)));
}
if let Some(val) = inputs.get("effective_at") {
query_pairs.push(("effective_at", super::message_to_str(val)));
}
if let Some(val) = inputs.get("email_type") {
query_pairs.push(("email_type", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("invoice") {
query_pairs.push(("invoice", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("lines") {
query_pairs.push(("lines", super::message_to_str(val)));
}
if let Some(val) = inputs.get("memo") {
query_pairs.push(("memo", super::message_to_str(val)));
}
if let Some(val) = inputs.get("metadata") {
query_pairs.push(("metadata", super::message_to_str(val)));
}
if let Some(val) = inputs.get("out_of_band_amount") {
query_pairs.push(("out_of_band_amount", super::message_to_str(val)));
}
if let Some(val) = inputs.get("reason") {
query_pairs.push(("reason", super::message_to_str(val)));
}
if let Some(val) = inputs.get("refund_amount") {
query_pairs.push(("refund_amount", super::message_to_str(val)));
}
if let Some(val) = inputs.get("refunds") {
query_pairs.push(("refunds", super::message_to_str(val)));
}
if let Some(val) = inputs.get("shipping_cost") {
query_pairs.push(("shipping_cost", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/credit_notes/preview/lines failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a credit note's line items
///
/// Method: GET /v1/credit_notes/{credit_note}/lines
#[actor(
StripeReadCreditNotesCreditNoteLinesActor,
inports::<100>(credit_note, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_credit_notes_credit_note_lines(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/credit_notes/{credit_note}/lines".to_string();
if let Some(val) = inputs.get("credit_note") {
endpoint = endpoint.replace("{{credit_note}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/credit_notes/{{credit_note}}/lines failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a credit note
///
/// Method: GET /v1/credit_notes/{id}
#[actor(
StripeReadCreditNotesIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_credit_notes_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/credit_notes/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/credit_notes/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a credit note
///
/// Method: POST /v1/credit_notes/{id}
#[actor(
StripeCreateCreditNotesIdActor,
inports::<100>(id, metadata, expand, memo),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_credit_notes_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/credit_notes/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("memo") {
body.insert("memo".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/credit_notes/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Void a credit note
///
/// Method: POST /v1/credit_notes/{id}/void
#[actor(
StripeCreateCreditNotesIdVoidActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_credit_notes_id_void(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/credit_notes/{id}/void".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/credit_notes/{{id}}/void failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a Customer Session
///
/// Method: POST /v1/customer_sessions
#[actor(
StripeCreateCustomerSessionsActor,
inports::<100>(customer, expand, customer_account, components),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customer_sessions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/customer_sessions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("components") {
body.insert("components".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/customer_sessions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all customers
///
/// Method: GET /v1/customers
#[actor(
StripeReadCustomersActor,
inports::<100>(created, email, ending_before, expand, limit, starting_after, test_clock, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/customers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("email") {
query_pairs.push(("email", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("test_clock") {
query_pairs.push(("test_clock", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/customers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a customer
///
/// Method: POST /v1/customers
#[actor(
StripeCreateCustomersActor,
inports::<100>(cash_balance, description, tax, shipping, source, business_name, metadata, preferred_locales, tax_id_data, individual_name, invoice_prefix, email, address, phone, balance, payment_method, test_clock, next_invoice_sequence, tax_exempt, invoice_settings, expand, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/customers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("cash_balance") {
body.insert("cash_balance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax") {
body.insert("tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("business_name") {
body.insert("business_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("preferred_locales") {
body.insert("preferred_locales".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_id_data") {
body.insert("tax_id_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("individual_name") {
body.insert("individual_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_prefix") {
body.insert("invoice_prefix".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address") {
body.insert("address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone") {
body.insert("phone".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("balance") {
body.insert("balance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("test_clock") {
body.insert("test_clock".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("next_invoice_sequence") {
body.insert("next_invoice_sequence".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_exempt") {
body.insert("tax_exempt".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_settings") {
body.insert("invoice_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/customers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Search customers
///
/// Method: GET /v1/customers/search
#[actor(
StripeReadCustomersSearchActor,
inports::<100>(expand, limit, page, query, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_search(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/customers/search".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("page") {
query_pairs.push(("page", super::message_to_str(val)));
}
if let Some(val) = inputs.get("query") {
query_pairs.push(("query", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/customers/search failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a customer
///
/// Method: GET /v1/customers/{customer}
#[actor(
StripeReadCustomersCustomerActor,
inports::<100>(customer, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/customers/{{customer}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a customer
///
/// Method: DELETE /v1/customers/{customer}
#[actor(
StripeDeleteCustomersCustomerActor,
inports::<100>(customer, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_customers_customer(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/customers/{{customer}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a customer
///
/// Method: POST /v1/customers/{customer}
#[actor(
StripeCreateCustomersCustomerActor,
inports::<100>(customer, default_card, individual_name, name, source, expand, cash_balance, bank_account, card, default_alipay_account, description, next_invoice_sequence, preferred_locales, email, invoice_settings, address, phone, balance, business_name, shipping, tax, metadata, tax_exempt, default_bank_account, default_source, invoice_prefix),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("default_card") {
body.insert("default_card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("individual_name") {
body.insert("individual_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cash_balance") {
body.insert("cash_balance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bank_account") {
body.insert("bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_alipay_account") {
body.insert("default_alipay_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("next_invoice_sequence") {
body.insert("next_invoice_sequence".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("preferred_locales") {
body.insert("preferred_locales".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_settings") {
body.insert("invoice_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address") {
body.insert("address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone") {
body.insert("phone".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("balance") {
body.insert("balance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("business_name") {
body.insert("business_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax") {
body.insert("tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_exempt") {
body.insert("tax_exempt".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_bank_account") {
body.insert("default_bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_source") {
body.insert("default_source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_prefix") {
body.insert("invoice_prefix".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/customers/{{customer}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List customer balance transactions
///
/// Method: GET /v1/customers/{customer}/balance_transactions
#[actor(
StripeReadCustomersCustomerBalanceTransactionsActor,
inports::<100>(created, customer, ending_before, expand, invoice, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_balance_transactions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/balance_transactions".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("invoice") {
query_pairs.push(("invoice", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/customers/{{customer}}/balance_transactions failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a customer balance transaction
///
/// Method: POST /v1/customers/{customer}/balance_transactions
#[actor(
StripeCreateCustomersCustomerBalanceTransactionsActor,
inports::<100>(customer, amount, description, expand, currency, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_balance_transactions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/balance_transactions".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/customers/{{customer}}/balance_transactions failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a customer credit balance transaction
///
/// Method: POST /v1/customers/{customer}/balance_transactions/{transaction}
#[actor(
StripeCreateCustomersCustomerBalanceTransactionsTransactionActor,
inports::<100>(customer, transaction, metadata, expand, description),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_balance_transactions_transaction(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/balance_transactions/{transaction}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("transaction") {
endpoint = endpoint.replace("{{transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/customers/{{customer}}/balance_transactions/{{transaction}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Retrieve a customer balance transaction
///
/// Method: GET /v1/customers/{customer}/balance_transactions/{transaction}
#[actor(
StripeReadCustomersCustomerBalanceTransactionsTransactionActor,
inports::<100>(customer, expand, transaction, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_balance_transactions_transaction(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/balance_transactions/{transaction}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("transaction") {
endpoint = endpoint.replace("{{transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/customers/{{customer}}/balance_transactions/{{transaction}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Create a card
///
/// Method: POST /v1/customers/{customer}/bank_accounts
#[actor(
StripeCreateCustomersCustomerBankAccountsActor,
inports::<100>(customer, bank_account, alipay_account, card, expand, source, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_bank_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/bank_accounts".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("bank_account") {
body.insert("bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alipay_account") {
body.insert("alipay_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/customers/{{customer}}/bank_accounts failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete a customer source
///
/// Method: DELETE /v1/customers/{customer}/bank_accounts/{id}
#[actor(
StripeDeleteCustomersCustomerBankAccountsIdActor,
inports::<100>(customer, id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_customers_customer_bank_accounts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/bank_accounts/{id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/customers/{{customer}}/bank_accounts/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// <p>Update a specified source for a given customer.</p>
///
/// Method: POST /v1/customers/{customer}/bank_accounts/{id}
#[actor(
StripeCreateCustomersCustomerBankAccountsIdActor,
inports::<100>(customer, id, address_country, address_zip, account_holder_name, exp_year, name, address_city, exp_month, expand, address_line2, account_holder_type, metadata, owner, address_state, address_line1),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_bank_accounts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/bank_accounts/{id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("address_country") {
body.insert("address_country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_zip") {
body.insert("address_zip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_name") {
body.insert("account_holder_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_year") {
body.insert("exp_year".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_city") {
body.insert("address_city".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_month") {
body.insert("exp_month".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line2") {
body.insert("address_line2".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_type") {
body.insert("account_holder_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("owner") {
body.insert("owner".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_state") {
body.insert("address_state".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line1") {
body.insert("address_line1".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/customers/{{customer}}/bank_accounts/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Verify a bank account
///
/// Method: POST /v1/customers/{customer}/bank_accounts/{id}/verify
#[actor(
StripeCreateCustomersCustomerBankAccountsIdVerifyActor,
inports::<100>(customer, id, expand, amounts),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_bank_accounts_id_verify(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/bank_accounts/{id}/verify".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amounts") {
body.insert("amounts".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/customers/{{customer}}/bank_accounts/{{id}}/verify failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a card
///
/// Method: POST /v1/customers/{customer}/cards
#[actor(
StripeCreateCustomersCustomerCardsActor,
inports::<100>(customer, source, card, alipay_account, bank_account, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_cards(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/cards".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alipay_account") {
body.insert("alipay_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bank_account") {
body.insert("bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/customers/{{customer}}/cards failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// <p>Update a specified source for a given customer.</p>
///
/// Method: POST /v1/customers/{customer}/cards/{id}
#[actor(
StripeCreateCustomersCustomerCardsIdActor,
inports::<100>(customer, id, exp_year, address_line2, metadata, name, owner, address_zip, account_holder_type, expand, address_city, address_line1, account_holder_name, address_country, address_state, exp_month),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_cards_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/cards/{id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("exp_year") {
body.insert("exp_year".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line2") {
body.insert("address_line2".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("owner") {
body.insert("owner".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_zip") {
body.insert("address_zip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_type") {
body.insert("account_holder_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_city") {
body.insert("address_city".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line1") {
body.insert("address_line1".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_name") {
body.insert("account_holder_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_country") {
body.insert("address_country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_state") {
body.insert("address_state".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_month") {
body.insert("exp_month".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/customers/{{customer}}/cards/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete a customer source
///
/// Method: DELETE /v1/customers/{customer}/cards/{id}
#[actor(
StripeDeleteCustomersCustomerCardsIdActor,
inports::<100>(customer, id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_customers_customer_cards_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/cards/{id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/customers/{{customer}}/cards/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a cash balance
///
/// Method: GET /v1/customers/{customer}/cash_balance
#[actor(
StripeReadCustomersCustomerCashBalanceActor,
inports::<100>(customer, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_cash_balance(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/cash_balance".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/customers/{{customer}}/cash_balance failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a cash balance's settings
///
/// Method: POST /v1/customers/{customer}/cash_balance
#[actor(
StripeCreateCustomersCustomerCashBalanceActor,
inports::<100>(customer, expand, settings),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_cash_balance(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/cash_balance".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("settings") {
body.insert("settings".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/customers/{{customer}}/cash_balance failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List cash balance transactions
///
/// Method: GET /v1/customers/{customer}/cash_balance_transactions
#[actor(
StripeReadCustomersCustomerCashBalanceTransactionsActor,
inports::<100>(customer, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_cash_balance_transactions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/cash_balance_transactions".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/customers/{{customer}}/cash_balance_transactions failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a cash balance transaction
///
/// Method: GET /v1/customers/{customer}/cash_balance_transactions/{transaction}
#[actor(
StripeReadCustomersCustomerCashBalanceTransactionsTransactionActor,
inports::<100>(customer, expand, transaction, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_cash_balance_transactions_transaction(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/customers/{customer}/cash_balance_transactions/{transaction}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("transaction") {
endpoint = endpoint.replace("{{transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/customers/{{customer}}/cash_balance_transactions/{{transaction}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Delete a customer discount
///
/// Method: DELETE /v1/customers/{customer}/discount
#[actor(
StripeDeleteCustomersCustomerDiscountActor,
inports::<100>(customer, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_customers_customer_discount(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/discount".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/customers/{{customer}}/discount failed: {}", e).into(),
),
);
}
}
Ok(output)
}
///
///
/// Method: GET /v1/customers/{customer}/discount
#[actor(
StripeReadCustomersCustomerDiscountActor,
inports::<100>(customer, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_discount(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/discount".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/customers/{{customer}}/discount failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create or retrieve funding instructions for a customer cash balance
///
/// Method: POST /v1/customers/{customer}/funding_instructions
#[actor(
StripeCreateCustomersCustomerFundingInstructionsActor,
inports::<100>(customer, expand, funding_type, currency, bank_transfer),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_funding_instructions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/funding_instructions".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("funding_type") {
body.insert("funding_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bank_transfer") {
body.insert("bank_transfer".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/customers/{{customer}}/funding_instructions failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List a Customer's PaymentMethods
///
/// Method: GET /v1/customers/{customer}/payment_methods
#[actor(
StripeReadCustomersCustomerPaymentMethodsActor,
inports::<100>(allow_redisplay, customer, ending_before, expand, limit, starting_after, type_, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_payment_methods(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/payment_methods".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("allow_redisplay") {
query_pairs.push(("allow_redisplay", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/customers/{{customer}}/payment_methods failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Customer's PaymentMethod
///
/// Method: GET /v1/customers/{customer}/payment_methods/{payment_method}
#[actor(
StripeReadCustomersCustomerPaymentMethodsPaymentMethodActor,
inports::<100>(customer, expand, payment_method, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_payment_methods_payment_method(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/payment_methods/{payment_method}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("payment_method") {
endpoint = endpoint.replace("{{payment_method}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/customers/{{customer}}/payment_methods/{{payment_method}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Create a card
///
/// Method: POST /v1/customers/{customer}/sources
#[actor(
StripeCreateCustomersCustomerSourcesActor,
inports::<100>(customer, source, bank_account, alipay_account, card, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_sources(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/sources".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bank_account") {
body.insert("bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alipay_account") {
body.insert("alipay_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/customers/{{customer}}/sources failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// <p>List sources for a specified customer.</p>
///
/// Method: GET /v1/customers/{customer}/sources
#[actor(
StripeReadCustomersCustomerSourcesActor,
inports::<100>(customer, ending_before, expand, limit, object, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_sources(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/sources".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("object") {
query_pairs.push(("object", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/customers/{{customer}}/sources failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete a customer source
///
/// Method: DELETE /v1/customers/{customer}/sources/{id}
#[actor(
StripeDeleteCustomersCustomerSourcesIdActor,
inports::<100>(customer, id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_customers_customer_sources_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/sources/{id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/customers/{{customer}}/sources/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// <p>Retrieve a specified source for a given customer.</p>
///
/// Method: GET /v1/customers/{customer}/sources/{id}
#[actor(
StripeReadCustomersCustomerSourcesIdActor,
inports::<100>(customer, expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_sources_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/sources/{id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/customers/{{customer}}/sources/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// <p>Update a specified source for a given customer.</p>
///
/// Method: POST /v1/customers/{customer}/sources/{id}
#[actor(
StripeCreateCustomersCustomerSourcesIdActor,
inports::<100>(customer, id, account_holder_type, account_holder_name, address_city, address_country, address_state, owner, exp_month, address_line1, expand, exp_year, metadata, name, address_zip, address_line2),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_sources_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/sources/{id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("account_holder_type") {
body.insert("account_holder_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_name") {
body.insert("account_holder_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_city") {
body.insert("address_city".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_country") {
body.insert("address_country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_state") {
body.insert("address_state".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("owner") {
body.insert("owner".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_month") {
body.insert("exp_month".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line1") {
body.insert("address_line1".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_year") {
body.insert("exp_year".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_zip") {
body.insert("address_zip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line2") {
body.insert("address_line2".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/customers/{{customer}}/sources/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Verify a bank account
///
/// Method: POST /v1/customers/{customer}/sources/{id}/verify
#[actor(
StripeCreateCustomersCustomerSourcesIdVerifyActor,
inports::<100>(customer, id, expand, amounts),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_sources_id_verify(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/sources/{id}/verify".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amounts") {
body.insert("amounts".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/customers/{{customer}}/sources/{{id}}/verify failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List active subscriptions
///
/// Method: GET /v1/customers/{customer}/subscriptions
#[actor(
StripeReadCustomersCustomerSubscriptionsActor,
inports::<100>(customer, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_subscriptions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/subscriptions".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/customers/{{customer}}/subscriptions failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a subscription
///
/// Method: POST /v1/customers/{customer}/subscriptions
#[actor(
StripeCreateCustomersCustomerSubscriptionsActor,
inports::<100>(customer, billing_thresholds, trial_settings, currency, automatic_tax, items, default_tax_rates, days_until_due, cancel_at, expand, off_session, transfer_data, billing_cycle_anchor, cancel_at_period_end, backdate_start_date, proration_behavior, invoice_settings, add_invoice_items, default_source, payment_behavior, discounts, payment_settings, collection_method, trial_period_days, pending_invoice_item_interval, metadata, default_payment_method, trial_end, trial_from_plan, application_fee_percent),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_subscriptions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/subscriptions".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("billing_thresholds") {
body.insert("billing_thresholds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_settings") {
body.insert("trial_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("items") {
body.insert("items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_tax_rates") {
body.insert("default_tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("days_until_due") {
body.insert("days_until_due".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancel_at") {
body.insert("cancel_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("off_session") {
body.insert("off_session".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_cycle_anchor") {
body.insert("billing_cycle_anchor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancel_at_period_end") {
body.insert("cancel_at_period_end".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("backdate_start_date") {
body.insert("backdate_start_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("proration_behavior") {
body.insert("proration_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_settings") {
body.insert("invoice_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("add_invoice_items") {
body.insert("add_invoice_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_source") {
body.insert("default_source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_behavior") {
body.insert("payment_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_settings") {
body.insert("payment_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collection_method") {
body.insert("collection_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_period_days") {
body.insert("trial_period_days".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pending_invoice_item_interval") {
body.insert(
"pending_invoice_item_interval".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_payment_method") {
body.insert("default_payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_end") {
body.insert("trial_end".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_from_plan") {
body.insert("trial_from_plan".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_percent") {
body.insert("application_fee_percent".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/customers/{{customer}}/subscriptions failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a subscription on a customer
///
/// Method: POST /v1/customers/{customer}/subscriptions/{subscription_exposed_id}
#[actor(
StripeCreateCustomersCustomerSubscriptionsSubscriptionExposedIdActor,
inports::<100>(customer, subscription_exposed_id, metadata, transfer_data, pause_collection, payment_behavior, pending_invoice_item_interval, cancel_at, application_fee_percent, items, default_source, off_session, trial_end, add_invoice_items, billing_thresholds, trial_from_plan, proration_behavior, default_payment_method, trial_settings, cancel_at_period_end, discounts, payment_settings, billing_cycle_anchor, days_until_due, collection_method, default_tax_rates, invoice_settings, automatic_tax, expand, proration_date, cancellation_details),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_subscriptions_subscription_exposed_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/customers/{customer}/subscriptions/{subscription_exposed_id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("subscription_exposed_id") {
endpoint = endpoint.replace("{{subscription_exposed_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pause_collection") {
body.insert("pause_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_behavior") {
body.insert("payment_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pending_invoice_item_interval") {
body.insert(
"pending_invoice_item_interval".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("cancel_at") {
body.insert("cancel_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_percent") {
body.insert("application_fee_percent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("items") {
body.insert("items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_source") {
body.insert("default_source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("off_session") {
body.insert("off_session".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_end") {
body.insert("trial_end".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("add_invoice_items") {
body.insert("add_invoice_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_thresholds") {
body.insert("billing_thresholds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_from_plan") {
body.insert("trial_from_plan".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("proration_behavior") {
body.insert("proration_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_payment_method") {
body.insert("default_payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_settings") {
body.insert("trial_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancel_at_period_end") {
body.insert("cancel_at_period_end".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_settings") {
body.insert("payment_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_cycle_anchor") {
body.insert("billing_cycle_anchor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("days_until_due") {
body.insert("days_until_due".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collection_method") {
body.insert("collection_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_tax_rates") {
body.insert("default_tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_settings") {
body.insert("invoice_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("proration_date") {
body.insert("proration_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancellation_details") {
body.insert("cancellation_details".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/customers/{{customer}}/subscriptions/{{subscription_exposed_id}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Cancel a subscription
///
/// Method: DELETE /v1/customers/{customer}/subscriptions/{subscription_exposed_id}
#[actor(
StripeDeleteCustomersCustomerSubscriptionsSubscriptionExposedIdActor,
inports::<100>(customer, subscription_exposed_id, expand, invoice_now, prorate),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_customers_customer_subscriptions_subscription_exposed_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/customers/{customer}/subscriptions/{subscription_exposed_id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("subscription_exposed_id") {
endpoint = endpoint.replace("{{subscription_exposed_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("DELETE /v1/customers/{{customer}}/subscriptions/{{subscription_exposed_id}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Retrieve a subscription
///
/// Method: GET /v1/customers/{customer}/subscriptions/{subscription_exposed_id}
#[actor(
StripeReadCustomersCustomerSubscriptionsSubscriptionExposedIdActor,
inports::<100>(customer, expand, subscription_exposed_id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_subscriptions_subscription_exposed_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/customers/{customer}/subscriptions/{subscription_exposed_id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("subscription_exposed_id") {
endpoint = endpoint.replace("{{subscription_exposed_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/customers/{{customer}}/subscriptions/{{subscription_exposed_id}} failed: {}", e).into()));
}
}
Ok(output)
}
///
///
/// Method: GET /v1/customers/{customer}/subscriptions/{subscription_exposed_id}/discount
#[actor(
StripeReadCustomersCustomerSubscriptionsSubscriptionExposedIdDiscountActor,
inports::<100>(customer, expand, subscription_exposed_id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_subscriptions_subscription_exposed_id_discount(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/customers/{customer}/subscriptions/{subscription_exposed_id}/discount".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("subscription_exposed_id") {
endpoint = endpoint.replace("{{subscription_exposed_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/customers/{{customer}}/subscriptions/{{subscription_exposed_id}}/discount failed: {}", e).into()));
}
}
Ok(output)
}
/// Delete a customer discount
///
/// Method: DELETE /v1/customers/{customer}/subscriptions/{subscription_exposed_id}/discount
#[actor(
StripeDeleteCustomersCustomerSubscriptionsSubscriptionExposedIdDiscountActor,
inports::<100>(customer, subscription_exposed_id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_customers_customer_subscriptions_subscription_exposed_id_discount(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/customers/{customer}/subscriptions/{subscription_exposed_id}/discount".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("subscription_exposed_id") {
endpoint = endpoint.replace("{{subscription_exposed_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("DELETE /v1/customers/{{customer}}/subscriptions/{{subscription_exposed_id}}/discount failed: {}", e).into()));
}
}
Ok(output)
}
/// List all Customer tax IDs
///
/// Method: GET /v1/customers/{customer}/tax_ids
#[actor(
StripeReadCustomersCustomerTaxIdsActor,
inports::<100>(customer, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_tax_ids(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/tax_ids".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/customers/{{customer}}/tax_ids failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a Customer tax ID
///
/// Method: POST /v1/customers/{customer}/tax_ids
#[actor(
StripeCreateCustomersCustomerTaxIdsActor,
inports::<100>(customer, expand, type_, value),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_customers_customer_tax_ids(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/tax_ids".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("value") {
body.insert("value".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/customers/{{customer}}/tax_ids failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Customer tax ID
///
/// Method: GET /v1/customers/{customer}/tax_ids/{id}
#[actor(
StripeReadCustomersCustomerTaxIdsIdActor,
inports::<100>(customer, expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_customers_customer_tax_ids_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/tax_ids/{id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/customers/{{customer}}/tax_ids/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete a Customer tax ID
///
/// Method: DELETE /v1/customers/{customer}/tax_ids/{id}
#[actor(
StripeDeleteCustomersCustomerTaxIdsIdActor,
inports::<100>(customer, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_customers_customer_tax_ids_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/customers/{customer}/tax_ids/{id}".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/customers/{{customer}}/tax_ids/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all disputes
///
/// Method: GET /v1/disputes
#[actor(
StripeReadDisputesActor,
inports::<100>(charge, created, ending_before, expand, limit, payment_intent, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_disputes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/disputes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("charge") {
query_pairs.push(("charge", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment_intent") {
query_pairs.push(("payment_intent", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/disputes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a dispute
///
/// Method: GET /v1/disputes/{dispute}
#[actor(
StripeReadDisputesDisputeActor,
inports::<100>(dispute, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_disputes_dispute(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/disputes/{dispute}".to_string();
if let Some(val) = inputs.get("dispute") {
endpoint = endpoint.replace("{{dispute}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/disputes/{{dispute}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a dispute
///
/// Method: POST /v1/disputes/{dispute}
#[actor(
StripeCreateDisputesDisputeActor,
inports::<100>(dispute, expand, submit, metadata, evidence),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_disputes_dispute(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/disputes/{dispute}".to_string();
if let Some(val) = inputs.get("dispute") {
endpoint = endpoint.replace("{{dispute}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("submit") {
body.insert("submit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("evidence") {
body.insert("evidence".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/disputes/{{dispute}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Close a dispute
///
/// Method: POST /v1/disputes/{dispute}/close
#[actor(
StripeCreateDisputesDisputeCloseActor,
inports::<100>(dispute, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_disputes_dispute_close(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/disputes/{dispute}/close".to_string();
if let Some(val) = inputs.get("dispute") {
endpoint = endpoint.replace("{{dispute}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/disputes/{{dispute}}/close failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all active entitlements
///
/// Method: GET /v1/entitlements/active_entitlements
#[actor(
StripeReadEntitlementsActiveEntitlementsActor,
inports::<100>(customer, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_entitlements_active_entitlements(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/entitlements/active_entitlements".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/entitlements/active_entitlements failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve an active entitlement
///
/// Method: GET /v1/entitlements/active_entitlements/{id}
#[actor(
StripeReadEntitlementsActiveEntitlementsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_entitlements_active_entitlements_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/entitlements/active_entitlements/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/entitlements/active_entitlements/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a feature
///
/// Method: POST /v1/entitlements/features
#[actor(
StripeCreateEntitlementsFeaturesActor,
inports::<100>(name, metadata, expand, lookup_key),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_entitlements_features(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/entitlements/features".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("lookup_key") {
body.insert("lookup_key".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/entitlements/features failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all features
///
/// Method: GET /v1/entitlements/features
#[actor(
StripeReadEntitlementsFeaturesActor,
inports::<100>(archived, ending_before, expand, limit, lookup_key, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_entitlements_features(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/entitlements/features".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("archived") {
query_pairs.push(("archived", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("lookup_key") {
query_pairs.push(("lookup_key", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/entitlements/features failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a feature
///
/// Method: GET /v1/entitlements/features/{id}
#[actor(
StripeReadEntitlementsFeaturesIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_entitlements_features_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/entitlements/features/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/entitlements/features/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Updates a feature
///
/// Method: POST /v1/entitlements/features/{id}
#[actor(
StripeCreateEntitlementsFeaturesIdActor,
inports::<100>(id, name, active, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_entitlements_features_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/entitlements/features/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/entitlements/features/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create an ephemeral key
///
/// Method: POST /v1/ephemeral_keys
#[actor(
StripeCreateEphemeralKeysActor,
inports::<100>(verification_session, expand, issuing_card, customer, nonce),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_ephemeral_keys(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/ephemeral_keys".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("verification_session") {
body.insert("verification_session".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("issuing_card") {
body.insert("issuing_card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nonce") {
body.insert("nonce".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/ephemeral_keys failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Immediately invalidate an ephemeral key
///
/// Method: DELETE /v1/ephemeral_keys/{key}
#[actor(
StripeDeleteEphemeralKeysKeyActor,
inports::<100>(key, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_ephemeral_keys_key(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/ephemeral_keys/{key}".to_string();
if let Some(val) = inputs.get("key") {
endpoint = endpoint.replace("{{key}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/ephemeral_keys/{{key}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all events
///
/// Method: GET /v1/events
#[actor(
StripeReadEventsActor,
inports::<100>(created, delivery_success, ending_before, expand, limit, starting_after, type_, types, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_events(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/events".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("delivery_success") {
query_pairs.push(("delivery_success", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if let Some(val) = inputs.get("types") {
query_pairs.push(("types", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/events failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an event
///
/// Method: GET /v1/events/{id}
#[actor(
StripeReadEventsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_events_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/events/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/events/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all exchange rates
///
/// Method: GET /v1/exchange_rates
#[actor(
StripeReadExchangeRatesActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_exchange_rates(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/exchange_rates".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/exchange_rates failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an exchange rate
///
/// Method: GET /v1/exchange_rates/{rate_id}
#[actor(
StripeReadExchangeRatesRateIdActor,
inports::<100>(expand, rate_id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_exchange_rates_rate_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/exchange_rates/{rate_id}".to_string();
if let Some(val) = inputs.get("rate_id") {
endpoint = endpoint.replace("{{rate_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/exchange_rates/{{rate_id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// <p>Updates the metadata, account holder name, account holder type of a bank account belonging to\na connected account and optionally sets it as the default for its currency. Other bank account\ndetails are not editable by design.</p>\n\n<p>You can only update bank accounts when <a href=\"/api/accounts/object#account_object-controller-requirement_collection\">account.controller.requirement_collection</a> is <code>application</code>, which includes <a href=\"/connect/custom-accounts\">Custom accounts</a>.</p>\n\n<p>You can re-enable a disabled bank account by performing an update call without providing any\narguments or changes.</p>
///
/// Method: POST /v1/external_accounts/{id}
#[actor(
StripeCreateExternalAccountsIdActor,
inports::<100>(id, exp_month, metadata, address_zip, expand, documents, name, exp_year, default_for_currency, address_country, account_holder_type, account_type, address_line1, address_line2, address_state, address_city, account_holder_name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_external_accounts_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/external_accounts/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("exp_month") {
body.insert("exp_month".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_zip") {
body.insert("address_zip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("documents") {
body.insert("documents".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_year") {
body.insert("exp_year".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_for_currency") {
body.insert("default_for_currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_country") {
body.insert("address_country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_type") {
body.insert("account_holder_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_type") {
body.insert("account_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line1") {
body.insert("address_line1".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_line2") {
body.insert("address_line2".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_state") {
body.insert("address_state".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_city") {
body.insert("address_city".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder_name") {
body.insert("account_holder_name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/external_accounts/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a file link
///
/// Method: POST /v1/file_links
#[actor(
StripeCreateFileLinksActor,
inports::<100>(expires_at, file, metadata, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_file_links(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/file_links".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("file") {
body.insert("file".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/file_links failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all file links
///
/// Method: GET /v1/file_links
#[actor(
StripeReadFileLinksActor,
inports::<100>(created, ending_before, expand, expired, file, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_file_links(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/file_links".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expired") {
query_pairs.push(("expired", super::message_to_str(val)));
}
if let Some(val) = inputs.get("file") {
query_pairs.push(("file", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/file_links failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a file link
///
/// Method: GET /v1/file_links/{link}
#[actor(
StripeReadFileLinksLinkActor,
inports::<100>(expand, link, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_file_links_link(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/file_links/{link}".to_string();
if let Some(val) = inputs.get("link") {
endpoint = endpoint.replace("{{link}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/file_links/{{link}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a file link
///
/// Method: POST /v1/file_links/{link}
#[actor(
StripeCreateFileLinksLinkActor,
inports::<100>(link, expand, expires_at, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_file_links_link(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/file_links/{link}".to_string();
if let Some(val) = inputs.get("link") {
endpoint = endpoint.replace("{{link}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/file_links/{{link}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all files
///
/// Method: GET /v1/files
#[actor(
StripeReadFilesActor,
inports::<100>(created, ending_before, expand, limit, purpose, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_files(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/files".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("purpose") {
query_pairs.push(("purpose", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/files failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a file
///
/// Method: POST /v1/files
#[actor(
StripeCreateFilesActor,
inports::<100>(expand, file, file_link_data, purpose),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_files(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/files".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("file") {
body.insert("file".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("file_link_data") {
body.insert("file_link_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("purpose") {
body.insert("purpose".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/files failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a file
///
/// Method: GET /v1/files/{file}
#[actor(
StripeReadFilesFileActor,
inports::<100>(expand, file, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_files_file(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/files/{file}".to_string();
if let Some(val) = inputs.get("file") {
endpoint = endpoint.replace("{{file}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/files/{{file}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List Accounts
///
/// Method: GET /v1/financial_connections/accounts
#[actor(
StripeReadFinancialConnectionsAccountsActor,
inports::<100>(account_holder, ending_before, expand, limit, session, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_financial_connections_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/financial_connections/accounts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("account_holder") {
query_pairs.push(("account_holder", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("session") {
query_pairs.push(("session", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/financial_connections/accounts failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve an Account
///
/// Method: GET /v1/financial_connections/accounts/{account}
#[actor(
StripeReadFinancialConnectionsAccountsAccountActor,
inports::<100>(account, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_financial_connections_accounts_account(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/financial_connections/accounts/{account}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/financial_connections/accounts/{{account}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Disconnect an Account
///
/// Method: POST /v1/financial_connections/accounts/{account}/disconnect
#[actor(
StripeCreateFinancialConnectionsAccountsAccountDisconnectActor,
inports::<100>(account, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_financial_connections_accounts_account_disconnect(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/financial_connections/accounts/{account}/disconnect".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/financial_connections/accounts/{{account}}/disconnect failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List Account Owners
///
/// Method: GET /v1/financial_connections/accounts/{account}/owners
#[actor(
StripeReadFinancialConnectionsAccountsAccountOwnersActor,
inports::<100>(account, ending_before, expand, limit, ownership, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_financial_connections_accounts_account_owners(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/financial_connections/accounts/{account}/owners".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ownership") {
query_pairs.push(("ownership", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/financial_connections/accounts/{{account}}/owners failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Refresh Account data
///
/// Method: POST /v1/financial_connections/accounts/{account}/refresh
#[actor(
StripeCreateFinancialConnectionsAccountsAccountRefreshActor,
inports::<100>(account, expand, features),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_financial_connections_accounts_account_refresh(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/financial_connections/accounts/{account}/refresh".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("features") {
body.insert("features".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/financial_connections/accounts/{{account}}/refresh failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Subscribe to data refreshes for an Account
///
/// Method: POST /v1/financial_connections/accounts/{account}/subscribe
#[actor(
StripeCreateFinancialConnectionsAccountsAccountSubscribeActor,
inports::<100>(account, features, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_financial_connections_accounts_account_subscribe(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/financial_connections/accounts/{account}/subscribe".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("features") {
body.insert("features".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/financial_connections/accounts/{{account}}/subscribe failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Unsubscribe from data refreshes for an Account
///
/// Method: POST /v1/financial_connections/accounts/{account}/unsubscribe
#[actor(
StripeCreateFinancialConnectionsAccountsAccountUnsubscribeActor,
inports::<100>(account, expand, features),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_financial_connections_accounts_account_unsubscribe(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/financial_connections/accounts/{account}/unsubscribe".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("features") {
body.insert("features".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/financial_connections/accounts/{{account}}/unsubscribe failed: {}", e).into()));
}
}
Ok(output)
}
/// Create a Session
///
/// Method: POST /v1/financial_connections/sessions
#[actor(
StripeCreateFinancialConnectionsSessionsActor,
inports::<100>(expand, filters, prefetch, return_url, account_holder, permissions),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_financial_connections_sessions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/financial_connections/sessions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("filters") {
body.insert("filters".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("prefetch") {
body.insert("prefetch".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder") {
body.insert("account_holder".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("permissions") {
body.insert("permissions".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/financial_connections/sessions failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Session
///
/// Method: GET /v1/financial_connections/sessions/{session}
#[actor(
StripeReadFinancialConnectionsSessionsSessionActor,
inports::<100>(expand, session, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_financial_connections_sessions_session(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/financial_connections/sessions/{session}".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/financial_connections/sessions/{{session}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List Transactions
///
/// Method: GET /v1/financial_connections/transactions
#[actor(
StripeReadFinancialConnectionsTransactionsActor,
inports::<100>(account, ending_before, expand, limit, starting_after, transacted_at, transaction_refresh, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_financial_connections_transactions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/financial_connections/transactions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("account") {
query_pairs.push(("account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("transacted_at") {
query_pairs.push(("transacted_at", super::message_to_str(val)));
}
if let Some(val) = inputs.get("transaction_refresh") {
query_pairs.push(("transaction_refresh", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/financial_connections/transactions failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Transaction
///
/// Method: GET /v1/financial_connections/transactions/{transaction}
#[actor(
StripeReadFinancialConnectionsTransactionsTransactionActor,
inports::<100>(expand, transaction, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_financial_connections_transactions_transaction(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/financial_connections/transactions/{transaction}".to_string();
if let Some(val) = inputs.get("transaction") {
endpoint = endpoint.replace("{{transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/financial_connections/transactions/{{transaction}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a ForwardingRequest
///
/// Method: POST /v1/forwarding/requests
#[actor(
StripeCreateForwardingRequestsActor,
inports::<100>(metadata, request, url, expand, replacements, payment_method),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_forwarding_requests(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/forwarding/requests".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("request") {
body.insert("request".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("url") {
body.insert("url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("replacements") {
body.insert("replacements".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/forwarding/requests failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all ForwardingRequests
///
/// Method: GET /v1/forwarding/requests
#[actor(
StripeReadForwardingRequestsActor,
inports::<100>(created, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_forwarding_requests(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/forwarding/requests".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/forwarding/requests failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a ForwardingRequest
///
/// Method: GET /v1/forwarding/requests/{id}
#[actor(
StripeReadForwardingRequestsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_forwarding_requests_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/forwarding/requests/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/forwarding/requests/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List VerificationReports
///
/// Method: GET /v1/identity/verification_reports
#[actor(
StripeReadIdentityVerificationReportsActor,
inports::<100>(client_reference_id, created, ending_before, expand, limit, starting_after, type_, verification_session, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_identity_verification_reports(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/identity/verification_reports".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("client_reference_id") {
query_pairs.push(("client_reference_id", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if let Some(val) = inputs.get("verification_session") {
query_pairs.push(("verification_session", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/identity/verification_reports failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a VerificationReport
///
/// Method: GET /v1/identity/verification_reports/{report}
#[actor(
StripeReadIdentityVerificationReportsReportActor,
inports::<100>(expand, report, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_identity_verification_reports_report(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/identity/verification_reports/{report}".to_string();
if let Some(val) = inputs.get("report") {
endpoint = endpoint.replace("{{report}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/identity/verification_reports/{{report}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List VerificationSessions
///
/// Method: GET /v1/identity/verification_sessions
#[actor(
StripeReadIdentityVerificationSessionsActor,
inports::<100>(client_reference_id, created, ending_before, expand, limit, related_customer, related_customer_account, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_identity_verification_sessions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/identity/verification_sessions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("client_reference_id") {
query_pairs.push(("client_reference_id", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("related_customer") {
query_pairs.push(("related_customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("related_customer_account") {
query_pairs.push(("related_customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/identity/verification_sessions failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a VerificationSession
///
/// Method: POST /v1/identity/verification_sessions
#[actor(
StripeCreateIdentityVerificationSessionsActor,
inports::<100>(return_url, client_reference_id, related_customer_account, type_, expand, metadata, options, related_customer, verification_flow, provided_details, related_person),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_identity_verification_sessions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/identity/verification_sessions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("client_reference_id") {
body.insert("client_reference_id".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("related_customer_account") {
body.insert("related_customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("options") {
body.insert("options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("related_customer") {
body.insert("related_customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("verification_flow") {
body.insert("verification_flow".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("provided_details") {
body.insert("provided_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("related_person") {
body.insert("related_person".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/identity/verification_sessions failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a VerificationSession
///
/// Method: GET /v1/identity/verification_sessions/{session}
#[actor(
StripeReadIdentityVerificationSessionsSessionActor,
inports::<100>(expand, session, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_identity_verification_sessions_session(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/identity/verification_sessions/{session}".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/identity/verification_sessions/{{session}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a VerificationSession
///
/// Method: POST /v1/identity/verification_sessions/{session}
#[actor(
StripeCreateIdentityVerificationSessionsSessionActor,
inports::<100>(session, options, expand, type_, provided_details, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_identity_verification_sessions_session(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/identity/verification_sessions/{session}".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("options") {
body.insert("options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("provided_details") {
body.insert("provided_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/identity/verification_sessions/{{session}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Cancel a VerificationSession
///
/// Method: POST /v1/identity/verification_sessions/{session}/cancel
#[actor(
StripeCreateIdentityVerificationSessionsSessionCancelActor,
inports::<100>(session, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_identity_verification_sessions_session_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/identity/verification_sessions/{session}/cancel".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/identity/verification_sessions/{{session}}/cancel failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Redact a VerificationSession
///
/// Method: POST /v1/identity/verification_sessions/{session}/redact
#[actor(
StripeCreateIdentityVerificationSessionsSessionRedactActor,
inports::<100>(session, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_identity_verification_sessions_session_redact(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/identity/verification_sessions/{session}/redact".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/identity/verification_sessions/{{session}}/redact failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all payments for an invoice
///
/// Method: GET /v1/invoice_payments
#[actor(
StripeReadInvoicePaymentsActor,
inports::<100>(created, ending_before, expand, invoice, limit, payment, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoice_payments(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/invoice_payments".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("invoice") {
query_pairs.push(("invoice", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment") {
query_pairs.push(("payment", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/invoice_payments failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an InvoicePayment
///
/// Method: GET /v1/invoice_payments/{invoice_payment}
#[actor(
StripeReadInvoicePaymentsInvoicePaymentActor,
inports::<100>(expand, invoice_payment, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoice_payments_invoice_payment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoice_payments/{invoice_payment}".to_string();
if let Some(val) = inputs.get("invoice_payment") {
endpoint = endpoint.replace("{{invoice_payment}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/invoice_payments/{{invoice_payment}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all invoice rendering templates
///
/// Method: GET /v1/invoice_rendering_templates
#[actor(
StripeReadInvoiceRenderingTemplatesActor,
inports::<100>(ending_before, expand, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoice_rendering_templates(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/invoice_rendering_templates".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/invoice_rendering_templates failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an invoice rendering template
///
/// Method: GET /v1/invoice_rendering_templates/{template}
#[actor(
StripeReadInvoiceRenderingTemplatesTemplateActor,
inports::<100>(expand, template, version, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoice_rendering_templates_template(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoice_rendering_templates/{template}".to_string();
if let Some(val) = inputs.get("template") {
endpoint = endpoint.replace("{{template}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("version") {
query_pairs.push(("version", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/invoice_rendering_templates/{{template}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Archive an invoice rendering template
///
/// Method: POST /v1/invoice_rendering_templates/{template}/archive
#[actor(
StripeCreateInvoiceRenderingTemplatesTemplateArchiveActor,
inports::<100>(template, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoice_rendering_templates_template_archive(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoice_rendering_templates/{template}/archive".to_string();
if let Some(val) = inputs.get("template") {
endpoint = endpoint.replace("{{template}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/invoice_rendering_templates/{{template}}/archive failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Unarchive an invoice rendering template
///
/// Method: POST /v1/invoice_rendering_templates/{template}/unarchive
#[actor(
StripeCreateInvoiceRenderingTemplatesTemplateUnarchiveActor,
inports::<100>(template, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoice_rendering_templates_template_unarchive(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoice_rendering_templates/{template}/unarchive".to_string();
if let Some(val) = inputs.get("template") {
endpoint = endpoint.replace("{{template}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/invoice_rendering_templates/{{template}}/unarchive failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all invoice items
///
/// Method: GET /v1/invoiceitems
#[actor(
StripeReadInvoiceitemsActor,
inports::<100>(created, customer, customer_account, ending_before, expand, invoice, limit, pending, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoiceitems(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/invoiceitems".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("invoice") {
query_pairs.push(("invoice", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("pending") {
query_pairs.push(("pending", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/invoiceitems failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create an invoice item
///
/// Method: POST /v1/invoiceitems
#[actor(
StripeCreateInvoiceitemsActor,
inports::<100>(discounts, invoice, expand, metadata, customer_account, period, unit_amount_decimal, description, tax_code, price_data, quantity, currency, discountable, amount, tax_behavior, tax_rates, pricing, customer, subscription),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoiceitems(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/invoiceitems".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice") {
body.insert("invoice".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("period") {
body.insert("period".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("unit_amount_decimal") {
body.insert("unit_amount_decimal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_code") {
body.insert("tax_code".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("price_data") {
body.insert("price_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("quantity") {
body.insert("quantity".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discountable") {
body.insert("discountable".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_behavior") {
body.insert("tax_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_rates") {
body.insert("tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pricing") {
body.insert("pricing".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription") {
body.insert("subscription".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/invoiceitems failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an invoice item
///
/// Method: GET /v1/invoiceitems/{invoiceitem}
#[actor(
StripeReadInvoiceitemsInvoiceitemActor,
inports::<100>(expand, invoiceitem, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoiceitems_invoiceitem(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoiceitems/{invoiceitem}".to_string();
if let Some(val) = inputs.get("invoiceitem") {
endpoint = endpoint.replace("{{invoiceitem}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/invoiceitems/{{invoiceitem}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update an invoice item
///
/// Method: POST /v1/invoiceitems/{invoiceitem}
#[actor(
StripeCreateInvoiceitemsInvoiceitemActor,
inports::<100>(invoiceitem, period, tax_rates, quantity, unit_amount_decimal, discountable, description, amount, price_data, tax_behavior, pricing, metadata, tax_code, discounts, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoiceitems_invoiceitem(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoiceitems/{invoiceitem}".to_string();
if let Some(val) = inputs.get("invoiceitem") {
endpoint = endpoint.replace("{{invoiceitem}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("period") {
body.insert("period".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_rates") {
body.insert("tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("quantity") {
body.insert("quantity".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("unit_amount_decimal") {
body.insert("unit_amount_decimal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discountable") {
body.insert("discountable".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("price_data") {
body.insert("price_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_behavior") {
body.insert("tax_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pricing") {
body.insert("pricing".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_code") {
body.insert("tax_code".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/invoiceitems/{{invoiceitem}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete an invoice item
///
/// Method: DELETE /v1/invoiceitems/{invoiceitem}
#[actor(
StripeDeleteInvoiceitemsInvoiceitemActor,
inports::<100>(invoiceitem, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_invoiceitems_invoiceitem(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoiceitems/{invoiceitem}".to_string();
if let Some(val) = inputs.get("invoiceitem") {
endpoint = endpoint.replace("{{invoiceitem}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/invoiceitems/{{invoiceitem}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create an invoice
///
/// Method: POST /v1/invoices
#[actor(
StripeCreateInvoicesActor,
inports::<100>(application_fee_amount, from_invoice, on_behalf_of, shipping_cost, automatic_tax, pending_invoice_items_behavior, statement_descriptor, due_date, subscription, metadata, default_tax_rates, number, currency, automatically_finalizes_at, expand, issuer, footer, customer_account, collection_method, discounts, default_source, payment_settings, transfer_data, customer, effective_at, rendering, default_payment_method, auto_advance, shipping_details, description, days_until_due, account_tax_ids, custom_fields),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/invoices".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("from_invoice") {
body.insert("from_invoice".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_cost") {
body.insert("shipping_cost".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pending_invoice_items_behavior") {
body.insert(
"pending_invoice_items_behavior".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("due_date") {
body.insert("due_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription") {
body.insert("subscription".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_tax_rates") {
body.insert("default_tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("number") {
body.insert("number".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatically_finalizes_at") {
body.insert("automatically_finalizes_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("issuer") {
body.insert("issuer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("footer") {
body.insert("footer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collection_method") {
body.insert("collection_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_source") {
body.insert("default_source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_settings") {
body.insert("payment_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("effective_at") {
body.insert("effective_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("rendering") {
body.insert("rendering".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_payment_method") {
body.insert("default_payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("auto_advance") {
body.insert("auto_advance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_details") {
body.insert("shipping_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("days_until_due") {
body.insert("days_until_due".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_tax_ids") {
body.insert("account_tax_ids".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom_fields") {
body.insert("custom_fields".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/invoices failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all invoices
///
/// Method: GET /v1/invoices
#[actor(
StripeReadInvoicesActor,
inports::<100>(collection_method, created, customer, customer_account, due_date, ending_before, expand, limit, starting_after, status, subscription, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoices(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/invoices".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("collection_method") {
query_pairs.push(("collection_method", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("due_date") {
query_pairs.push(("due_date", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if let Some(val) = inputs.get("subscription") {
query_pairs.push(("subscription", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/invoices failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a preview invoice
///
/// Method: POST /v1/invoices/create_preview
#[actor(
StripeCreateInvoicesCreatePreviewActor,
inports::<100>(currency, expand, subscription, customer_details, preview_mode, on_behalf_of, issuer, invoice_items, schedule_details, customer, customer_account, subscription_details, automatic_tax, discounts, schedule),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_create_preview(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/invoices/create_preview".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription") {
body.insert("subscription".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_details") {
body.insert("customer_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("preview_mode") {
body.insert("preview_mode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("issuer") {
body.insert("issuer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_items") {
body.insert("invoice_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("schedule_details") {
body.insert("schedule_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription_details") {
body.insert("subscription_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("schedule") {
body.insert("schedule".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/invoices/create_preview failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Search invoices
///
/// Method: GET /v1/invoices/search
#[actor(
StripeReadInvoicesSearchActor,
inports::<100>(expand, limit, page, query, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoices_search(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/invoices/search".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("page") {
query_pairs.push(("page", super::message_to_str(val)));
}
if let Some(val) = inputs.get("query") {
query_pairs.push(("query", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/invoices/search failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a draft invoice
///
/// Method: DELETE /v1/invoices/{invoice}
#[actor(
StripeDeleteInvoicesInvoiceActor,
inports::<100>(invoice, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_invoices_invoice(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/invoices/{{invoice}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update an invoice
///
/// Method: POST /v1/invoices/{invoice}
#[actor(
StripeCreateInvoicesInvoiceActor,
inports::<100>(invoice, statement_descriptor, transfer_data, automatic_tax, default_tax_rates, collection_method, effective_at, metadata, on_behalf_of, number, payment_settings, shipping_cost, discounts, due_date, application_fee_amount, expand, footer, default_payment_method, auto_advance, issuer, description, rendering, shipping_details, automatically_finalizes_at, custom_fields, account_tax_ids, default_source, days_until_due),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_tax_rates") {
body.insert("default_tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collection_method") {
body.insert("collection_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("effective_at") {
body.insert("effective_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("number") {
body.insert("number".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_settings") {
body.insert("payment_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_cost") {
body.insert("shipping_cost".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("due_date") {
body.insert("due_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("footer") {
body.insert("footer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_payment_method") {
body.insert("default_payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("auto_advance") {
body.insert("auto_advance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("issuer") {
body.insert("issuer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("rendering") {
body.insert("rendering".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_details") {
body.insert("shipping_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatically_finalizes_at") {
body.insert("automatically_finalizes_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom_fields") {
body.insert("custom_fields".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_tax_ids") {
body.insert("account_tax_ids".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_source") {
body.insert("default_source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("days_until_due") {
body.insert("days_until_due".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/invoices/{{invoice}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an invoice
///
/// Method: GET /v1/invoices/{invoice}
#[actor(
StripeReadInvoicesInvoiceActor,
inports::<100>(expand, invoice, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoices_invoice(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/invoices/{{invoice}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Bulk add invoice line items
///
/// Method: POST /v1/invoices/{invoice}/add_lines
#[actor(
StripeCreateInvoicesInvoiceAddLinesActor,
inports::<100>(invoice, expand, invoice_metadata, lines),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_add_lines(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/add_lines".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_metadata") {
body.insert("invoice_metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("lines") {
body.insert("lines".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/invoices/{{invoice}}/add_lines failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Attach a payment to an Invoice
///
/// Method: POST /v1/invoices/{invoice}/attach_payment
#[actor(
StripeCreateInvoicesInvoiceAttachPaymentActor,
inports::<100>(invoice, expand, payment_record, payment_intent),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_attach_payment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/attach_payment".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_record") {
body.insert("payment_record".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent") {
body.insert("payment_intent".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/invoices/{{invoice}}/attach_payment failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Finalize an invoice
///
/// Method: POST /v1/invoices/{invoice}/finalize
#[actor(
StripeCreateInvoicesInvoiceFinalizeActor,
inports::<100>(invoice, expand, auto_advance),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_finalize(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/finalize".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("auto_advance") {
body.insert("auto_advance".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/invoices/{{invoice}}/finalize failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve an invoice's line items
///
/// Method: GET /v1/invoices/{invoice}/lines
#[actor(
StripeReadInvoicesInvoiceLinesActor,
inports::<100>(ending_before, expand, invoice, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_invoices_invoice_lines(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/lines".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/invoices/{{invoice}}/lines failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update an invoice's line item
///
/// Method: POST /v1/invoices/{invoice}/lines/{line_item_id}
#[actor(
StripeCreateInvoicesInvoiceLinesLineItemIdActor,
inports::<100>(invoice, line_item_id, quantity, period, discountable, tax_rates, amount, tax_amounts, expand, pricing, metadata, price_data, discounts, description),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_lines_line_item_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/lines/{line_item_id}".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("line_item_id") {
endpoint = endpoint.replace("{{line_item_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("quantity") {
body.insert("quantity".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("period") {
body.insert("period".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discountable") {
body.insert("discountable".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_rates") {
body.insert("tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_amounts") {
body.insert("tax_amounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pricing") {
body.insert("pricing".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("price_data") {
body.insert("price_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/invoices/{{invoice}}/lines/{{line_item_id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Mark an invoice as uncollectible
///
/// Method: POST /v1/invoices/{invoice}/mark_uncollectible
#[actor(
StripeCreateInvoicesInvoiceMarkUncollectibleActor,
inports::<100>(invoice, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_mark_uncollectible(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/mark_uncollectible".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/invoices/{{invoice}}/mark_uncollectible failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Pay an invoice
///
/// Method: POST /v1/invoices/{invoice}/pay
#[actor(
StripeCreateInvoicesInvoicePayActor,
inports::<100>(invoice, source, mandate, expand, off_session, paid_out_of_band, forgive, payment_method),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_pay(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/pay".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mandate") {
body.insert("mandate".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("off_session") {
body.insert("off_session".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("paid_out_of_band") {
body.insert("paid_out_of_band".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("forgive") {
body.insert("forgive".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/invoices/{{invoice}}/pay failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Bulk remove invoice line items
///
/// Method: POST /v1/invoices/{invoice}/remove_lines
#[actor(
StripeCreateInvoicesInvoiceRemoveLinesActor,
inports::<100>(invoice, expand, invoice_metadata, lines),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_remove_lines(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/remove_lines".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_metadata") {
body.insert("invoice_metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("lines") {
body.insert("lines".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/invoices/{{invoice}}/remove_lines failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Send an invoice for manual payment
///
/// Method: POST /v1/invoices/{invoice}/send
#[actor(
StripeCreateInvoicesInvoiceSendActor,
inports::<100>(invoice, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_send(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/send".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/invoices/{{invoice}}/send failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Bulk update invoice line items
///
/// Method: POST /v1/invoices/{invoice}/update_lines
#[actor(
StripeCreateInvoicesInvoiceUpdateLinesActor,
inports::<100>(invoice, invoice_metadata, lines, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_update_lines(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/update_lines".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("invoice_metadata") {
body.insert("invoice_metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("lines") {
body.insert("lines".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/invoices/{{invoice}}/update_lines failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Void an invoice
///
/// Method: POST /v1/invoices/{invoice}/void
#[actor(
StripeCreateInvoicesInvoiceVoidActor,
inports::<100>(invoice, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_invoices_invoice_void(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/invoices/{invoice}/void".to_string();
if let Some(val) = inputs.get("invoice") {
endpoint = endpoint.replace("{{invoice}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/invoices/{{invoice}}/void failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all authorizations
///
/// Method: GET /v1/issuing/authorizations
#[actor(
StripeReadIssuingAuthorizationsActor,
inports::<100>(card, cardholder, created, ending_before, expand, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_authorizations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/authorizations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("card") {
query_pairs.push(("card", super::message_to_str(val)));
}
if let Some(val) = inputs.get("cardholder") {
query_pairs.push(("cardholder", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/issuing/authorizations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an authorization
///
/// Method: GET /v1/issuing/authorizations/{authorization}
#[actor(
StripeReadIssuingAuthorizationsAuthorizationActor,
inports::<100>(authorization, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_authorizations_authorization(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/authorizations/{authorization}".to_string();
if let Some(val) = inputs.get("authorization") {
endpoint = endpoint.replace("{{authorization}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/issuing/authorizations/{{authorization}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update an authorization
///
/// Method: POST /v1/issuing/authorizations/{authorization}
#[actor(
StripeCreateIssuingAuthorizationsAuthorizationActor,
inports::<100>(authorization, metadata, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_authorizations_authorization(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/authorizations/{authorization}".to_string();
if let Some(val) = inputs.get("authorization") {
endpoint = endpoint.replace("{{authorization}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/issuing/authorizations/{{authorization}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all cardholders
///
/// Method: GET /v1/issuing/cardholders
#[actor(
StripeReadIssuingCardholdersActor,
inports::<100>(created, email, ending_before, expand, limit, phone_number, starting_after, status, type_, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_cardholders(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/cardholders".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("email") {
query_pairs.push(("email", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("phone_number") {
query_pairs.push(("phone_number", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/issuing/cardholders failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a cardholder
///
/// Method: POST /v1/issuing/cardholders
#[actor(
StripeCreateIssuingCardholdersActor,
inports::<100>(spending_controls, email, metadata, expand, phone_number, type_, preferred_locales, individual, company, billing, status, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_cardholders(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/cardholders".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("spending_controls") {
body.insert("spending_controls".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone_number") {
body.insert("phone_number".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("preferred_locales") {
body.insert("preferred_locales".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("individual") {
body.insert("individual".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("company") {
body.insert("company".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing") {
body.insert("billing".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/issuing/cardholders failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a cardholder
///
/// Method: GET /v1/issuing/cardholders/{cardholder}
#[actor(
StripeReadIssuingCardholdersCardholderActor,
inports::<100>(cardholder, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_cardholders_cardholder(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/cardholders/{cardholder}".to_string();
if let Some(val) = inputs.get("cardholder") {
endpoint = endpoint.replace("{{cardholder}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/issuing/cardholders/{{cardholder}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a cardholder
///
/// Method: POST /v1/issuing/cardholders/{cardholder}
#[actor(
StripeCreateIssuingCardholdersCardholderActor,
inports::<100>(cardholder, metadata, status, company, spending_controls, billing, expand, phone_number, email, individual, preferred_locales),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_cardholders_cardholder(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/cardholders/{cardholder}".to_string();
if let Some(val) = inputs.get("cardholder") {
endpoint = endpoint.replace("{{cardholder}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("company") {
body.insert("company".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("spending_controls") {
body.insert("spending_controls".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing") {
body.insert("billing".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone_number") {
body.insert("phone_number".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("email") {
body.insert("email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("individual") {
body.insert("individual".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("preferred_locales") {
body.insert("preferred_locales".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/issuing/cardholders/{{cardholder}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a card
///
/// Method: POST /v1/issuing/cards
#[actor(
StripeCreateIssuingCardsActor,
inports::<100>(exp_year, exp_month, currency, shipping, personalization_design, metadata, replacement_reason, second_line, expand, spending_controls, cardholder, financial_account, replacement_for, status, type_, pin),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_cards(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/cards".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("exp_year") {
body.insert("exp_year".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("exp_month") {
body.insert("exp_month".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("personalization_design") {
body.insert("personalization_design".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("replacement_reason") {
body.insert("replacement_reason".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("second_line") {
body.insert("second_line".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("spending_controls") {
body.insert("spending_controls".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cardholder") {
body.insert("cardholder".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("financial_account") {
body.insert("financial_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("replacement_for") {
body.insert("replacement_for".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pin") {
body.insert("pin".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/issuing/cards failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all cards
///
/// Method: GET /v1/issuing/cards
#[actor(
StripeReadIssuingCardsActor,
inports::<100>(cardholder, created, ending_before, exp_month, exp_year, expand, last4, limit, personalization_design, starting_after, status, type_, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_cards(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/cards".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("cardholder") {
query_pairs.push(("cardholder", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("exp_month") {
query_pairs.push(("exp_month", super::message_to_str(val)));
}
if let Some(val) = inputs.get("exp_year") {
query_pairs.push(("exp_year", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("last4") {
query_pairs.push(("last4", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("personalization_design") {
query_pairs.push(("personalization_design", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/issuing/cards failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a card
///
/// Method: GET /v1/issuing/cards/{card}
#[actor(
StripeReadIssuingCardsCardActor,
inports::<100>(card, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_cards_card(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/cards/{card}".to_string();
if let Some(val) = inputs.get("card") {
endpoint = endpoint.replace("{{card}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/issuing/cards/{{card}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a card
///
/// Method: POST /v1/issuing/cards/{card}
#[actor(
StripeCreateIssuingCardsCardActor,
inports::<100>(card, expand, shipping, status, cancellation_reason, spending_controls, personalization_design, metadata, pin),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_cards_card(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/cards/{card}".to_string();
if let Some(val) = inputs.get("card") {
endpoint = endpoint.replace("{{card}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancellation_reason") {
body.insert("cancellation_reason".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("spending_controls") {
body.insert("spending_controls".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("personalization_design") {
body.insert("personalization_design".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pin") {
body.insert("pin".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/issuing/cards/{{card}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all disputes
///
/// Method: GET /v1/issuing/disputes
#[actor(
StripeReadIssuingDisputesActor,
inports::<100>(created, ending_before, expand, limit, starting_after, status, transaction, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_disputes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/disputes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if let Some(val) = inputs.get("transaction") {
query_pairs.push(("transaction", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/issuing/disputes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a dispute
///
/// Method: POST /v1/issuing/disputes
#[actor(
StripeCreateIssuingDisputesActor,
inports::<100>(metadata, expand, amount, transaction, evidence, treasury),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_disputes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/disputes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transaction") {
body.insert("transaction".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("evidence") {
body.insert("evidence".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("treasury") {
body.insert("treasury".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/issuing/disputes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a dispute
///
/// Method: POST /v1/issuing/disputes/{dispute}
#[actor(
StripeCreateIssuingDisputesDisputeActor,
inports::<100>(dispute, amount, evidence, metadata, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_disputes_dispute(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/disputes/{dispute}".to_string();
if let Some(val) = inputs.get("dispute") {
endpoint = endpoint.replace("{{dispute}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("evidence") {
body.insert("evidence".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/issuing/disputes/{{dispute}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a dispute
///
/// Method: GET /v1/issuing/disputes/{dispute}
#[actor(
StripeReadIssuingDisputesDisputeActor,
inports::<100>(dispute, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_disputes_dispute(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/disputes/{dispute}".to_string();
if let Some(val) = inputs.get("dispute") {
endpoint = endpoint.replace("{{dispute}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/issuing/disputes/{{dispute}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Submit a dispute
///
/// Method: POST /v1/issuing/disputes/{dispute}/submit
#[actor(
StripeCreateIssuingDisputesDisputeSubmitActor,
inports::<100>(dispute, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_disputes_dispute_submit(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/disputes/{dispute}/submit".to_string();
if let Some(val) = inputs.get("dispute") {
endpoint = endpoint.replace("{{dispute}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/issuing/disputes/{{dispute}}/submit failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all personalization designs
///
/// Method: GET /v1/issuing/personalization_designs
#[actor(
StripeReadIssuingPersonalizationDesignsActor,
inports::<100>(ending_before, expand, limit, lookup_keys, preferences, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_personalization_designs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/personalization_designs".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("lookup_keys") {
query_pairs.push(("lookup_keys", super::message_to_str(val)));
}
if let Some(val) = inputs.get("preferences") {
query_pairs.push(("preferences", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/issuing/personalization_designs failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a personalization design
///
/// Method: POST /v1/issuing/personalization_designs
#[actor(
StripeCreateIssuingPersonalizationDesignsActor,
inports::<100>(lookup_key, card_logo, name, metadata, preferences, expand, carrier_text, transfer_lookup_key, physical_bundle),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_personalization_designs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/personalization_designs".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("lookup_key") {
body.insert("lookup_key".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card_logo") {
body.insert("card_logo".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("preferences") {
body.insert("preferences".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("carrier_text") {
body.insert("carrier_text".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_lookup_key") {
body.insert("transfer_lookup_key".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("physical_bundle") {
body.insert("physical_bundle".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/issuing/personalization_designs failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a personalization design
///
/// Method: POST /v1/issuing/personalization_designs/{personalization_design}
#[actor(
StripeCreateIssuingPersonalizationDesignsPersonalizationDesignActor,
inports::<100>(personalization_design, carrier_text, lookup_key, transfer_lookup_key, name, preferences, card_logo, physical_bundle, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_personalization_designs_personalization_design(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/personalization_designs/{personalization_design}".to_string();
if let Some(val) = inputs.get("personalization_design") {
endpoint = endpoint.replace("{{personalization_design}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("carrier_text") {
body.insert("carrier_text".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("lookup_key") {
body.insert("lookup_key".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_lookup_key") {
body.insert("transfer_lookup_key".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("preferences") {
body.insert("preferences".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card_logo") {
body.insert("card_logo".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("physical_bundle") {
body.insert("physical_bundle".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/issuing/personalization_designs/{{personalization_design}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Retrieve a personalization design
///
/// Method: GET /v1/issuing/personalization_designs/{personalization_design}
#[actor(
StripeReadIssuingPersonalizationDesignsPersonalizationDesignActor,
inports::<100>(expand, personalization_design, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_personalization_designs_personalization_design(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/personalization_designs/{personalization_design}".to_string();
if let Some(val) = inputs.get("personalization_design") {
endpoint = endpoint.replace("{{personalization_design}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/issuing/personalization_designs/{{personalization_design}} failed: {}", e).into()));
}
}
Ok(output)
}
/// List all physical bundles
///
/// Method: GET /v1/issuing/physical_bundles
#[actor(
StripeReadIssuingPhysicalBundlesActor,
inports::<100>(ending_before, expand, limit, starting_after, status, type_, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_physical_bundles(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/physical_bundles".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/issuing/physical_bundles failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a physical bundle
///
/// Method: GET /v1/issuing/physical_bundles/{physical_bundle}
#[actor(
StripeReadIssuingPhysicalBundlesPhysicalBundleActor,
inports::<100>(expand, physical_bundle, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_physical_bundles_physical_bundle(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/physical_bundles/{physical_bundle}".to_string();
if let Some(val) = inputs.get("physical_bundle") {
endpoint = endpoint.replace("{{physical_bundle}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/issuing/physical_bundles/{{physical_bundle}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a settlement
///
/// Method: POST /v1/issuing/settlements/{settlement}
#[actor(
StripeCreateIssuingSettlementsSettlementActor,
inports::<100>(settlement, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_settlements_settlement(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/settlements/{settlement}".to_string();
if let Some(val) = inputs.get("settlement") {
endpoint = endpoint.replace("{{settlement}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/issuing/settlements/{{settlement}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a settlement
///
/// Method: GET /v1/issuing/settlements/{settlement}
#[actor(
StripeReadIssuingSettlementsSettlementActor,
inports::<100>(expand, settlement, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_settlements_settlement(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/settlements/{settlement}".to_string();
if let Some(val) = inputs.get("settlement") {
endpoint = endpoint.replace("{{settlement}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/issuing/settlements/{{settlement}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all issuing tokens for card
///
/// Method: GET /v1/issuing/tokens
#[actor(
StripeReadIssuingTokensActor,
inports::<100>(card, created, ending_before, expand, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_tokens(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/tokens".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("card") {
query_pairs.push(("card", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/issuing/tokens failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an issuing token
///
/// Method: GET /v1/issuing/tokens/{token}
#[actor(
StripeReadIssuingTokensTokenActor,
inports::<100>(expand, token, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_tokens_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/tokens/{token}".to_string();
if let Some(val) = inputs.get("token") {
endpoint = endpoint.replace("{{token}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/issuing/tokens/{{token}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a token status
///
/// Method: POST /v1/issuing/tokens/{token}
#[actor(
StripeCreateIssuingTokensTokenActor,
inports::<100>(token, status, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_tokens_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/tokens/{token}".to_string();
if let Some(val) = inputs.get("token") {
endpoint = endpoint.replace("{{token}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("status") {
body.insert("status".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/issuing/tokens/{{token}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all transactions
///
/// Method: GET /v1/issuing/transactions
#[actor(
StripeReadIssuingTransactionsActor,
inports::<100>(card, cardholder, created, ending_before, expand, limit, starting_after, type_, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_transactions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/issuing/transactions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("card") {
query_pairs.push(("card", super::message_to_str(val)));
}
if let Some(val) = inputs.get("cardholder") {
query_pairs.push(("cardholder", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/issuing/transactions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a transaction
///
/// Method: GET /v1/issuing/transactions/{transaction}
#[actor(
StripeReadIssuingTransactionsTransactionActor,
inports::<100>(expand, transaction, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_issuing_transactions_transaction(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/transactions/{transaction}".to_string();
if let Some(val) = inputs.get("transaction") {
endpoint = endpoint.replace("{{transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/issuing/transactions/{{transaction}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a transaction
///
/// Method: POST /v1/issuing/transactions/{transaction}
#[actor(
StripeCreateIssuingTransactionsTransactionActor,
inports::<100>(transaction, metadata, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_issuing_transactions_transaction(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/issuing/transactions/{transaction}".to_string();
if let Some(val) = inputs.get("transaction") {
endpoint = endpoint.replace("{{transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/issuing/transactions/{{transaction}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a Session
///
/// Method: POST /v1/link_account_sessions
#[actor(
StripeCreateLinkAccountSessionsActor,
inports::<100>(prefetch, account_holder, expand, permissions, return_url, filters),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_link_account_sessions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/link_account_sessions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("prefetch") {
body.insert("prefetch".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account_holder") {
body.insert("account_holder".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("permissions") {
body.insert("permissions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("filters") {
body.insert("filters".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/link_account_sessions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a Session
///
/// Method: GET /v1/link_account_sessions/{session}
#[actor(
StripeReadLinkAccountSessionsSessionActor,
inports::<100>(expand, session, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_link_account_sessions_session(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/link_account_sessions/{session}".to_string();
if let Some(val) = inputs.get("session") {
endpoint = endpoint.replace("{{session}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/link_account_sessions/{{session}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List Accounts
///
/// Method: GET /v1/linked_accounts
#[actor(
StripeReadLinkedAccountsActor,
inports::<100>(account_holder, ending_before, expand, limit, session, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_linked_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/linked_accounts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("account_holder") {
query_pairs.push(("account_holder", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("session") {
query_pairs.push(("session", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/linked_accounts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an Account
///
/// Method: GET /v1/linked_accounts/{account}
#[actor(
StripeReadLinkedAccountsAccountActor,
inports::<100>(account, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_linked_accounts_account(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/linked_accounts/{account}".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/linked_accounts/{{account}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Disconnect an Account
///
/// Method: POST /v1/linked_accounts/{account}/disconnect
#[actor(
StripeCreateLinkedAccountsAccountDisconnectActor,
inports::<100>(account, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_linked_accounts_account_disconnect(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/linked_accounts/{account}/disconnect".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/linked_accounts/{{account}}/disconnect failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List Account Owners
///
/// Method: GET /v1/linked_accounts/{account}/owners
#[actor(
StripeReadLinkedAccountsAccountOwnersActor,
inports::<100>(account, ending_before, expand, limit, ownership, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_linked_accounts_account_owners(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/linked_accounts/{account}/owners".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ownership") {
query_pairs.push(("ownership", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/linked_accounts/{{account}}/owners failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Refresh Account data
///
/// Method: POST /v1/linked_accounts/{account}/refresh
#[actor(
StripeCreateLinkedAccountsAccountRefreshActor,
inports::<100>(account, features, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_linked_accounts_account_refresh(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/linked_accounts/{account}/refresh".to_string();
if let Some(val) = inputs.get("account") {
endpoint = endpoint.replace("{{account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("features") {
body.insert("features".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/linked_accounts/{{account}}/refresh failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Mandate
///
/// Method: GET /v1/mandates/{mandate}
#[actor(
StripeReadMandatesMandateActor,
inports::<100>(expand, mandate, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_mandates_mandate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/mandates/{mandate}".to_string();
if let Some(val) = inputs.get("mandate") {
endpoint = endpoint.replace("{{mandate}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/mandates/{{mandate}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List Payment Attempt Records
///
/// Method: GET /v1/payment_attempt_records
#[actor(
StripeReadPaymentAttemptRecordsActor,
inports::<100>(expand, limit, payment_record, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_attempt_records(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_attempt_records".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment_record") {
query_pairs.push(("payment_record", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payment_attempt_records failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a Payment Attempt Record
///
/// Method: GET /v1/payment_attempt_records/{id}
#[actor(
StripeReadPaymentAttemptRecordsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_attempt_records_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_attempt_records/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/payment_attempt_records/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all PaymentIntents
///
/// Method: GET /v1/payment_intents
#[actor(
StripeReadPaymentIntentsActor,
inports::<100>(created, customer, customer_account, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_intents(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_intents".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payment_intents failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a PaymentIntent
///
/// Method: POST /v1/payment_intents
#[actor(
StripeCreatePaymentIntentsActor,
inports::<100>(customer_account, amount_details, error_on_requires_action, expand, confirmation_token, mandate_data, metadata, application_fee_amount, shipping, payment_method_types, payment_method_options, receipt_email, statement_descriptor_suffix, currency, transfer_group, confirmation_method, setup_future_usage, on_behalf_of, payment_method, radar_options, payment_details, payment_method_configuration, automatic_payment_methods, return_url, statement_descriptor, confirm, transfer_data, excluded_payment_method_types, description, payment_method_data, mandate, customer, capture_method, use_stripe_sdk, amount, hooks, off_session),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_intents(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_intents".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_details") {
body.insert("amount_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("error_on_requires_action") {
body.insert("error_on_requires_action".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("confirmation_token") {
body.insert("confirmation_token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mandate_data") {
body.insert("mandate_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_types") {
body.insert("payment_method_types".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_options") {
body.insert("payment_method_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("receipt_email") {
body.insert("receipt_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor_suffix") {
body.insert(
"statement_descriptor_suffix".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_group") {
body.insert("transfer_group".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("confirmation_method") {
body.insert("confirmation_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("setup_future_usage") {
body.insert("setup_future_usage".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("radar_options") {
body.insert("radar_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_details") {
body.insert("payment_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_configuration") {
body.insert(
"payment_method_configuration".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("automatic_payment_methods") {
body.insert("automatic_payment_methods".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("confirm") {
body.insert("confirm".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("excluded_payment_method_types") {
body.insert(
"excluded_payment_method_types".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_data") {
body.insert("payment_method_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mandate") {
body.insert("mandate".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("capture_method") {
body.insert("capture_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("use_stripe_sdk") {
body.insert("use_stripe_sdk".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("hooks") {
body.insert("hooks".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("off_session") {
body.insert("off_session".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/payment_intents failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Search PaymentIntents
///
/// Method: GET /v1/payment_intents/search
#[actor(
StripeReadPaymentIntentsSearchActor,
inports::<100>(expand, limit, page, query, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_intents_search(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_intents/search".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("page") {
query_pairs.push(("page", super::message_to_str(val)));
}
if let Some(val) = inputs.get("query") {
query_pairs.push(("query", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payment_intents/search failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a PaymentIntent
///
/// Method: GET /v1/payment_intents/{intent}
#[actor(
StripeReadPaymentIntentsIntentActor,
inports::<100>(client_secret, expand, intent, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_intents_intent(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_intents/{intent}".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("client_secret") {
query_pairs.push(("client_secret", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payment_intents/{{intent}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a PaymentIntent
///
/// Method: POST /v1/payment_intents/{intent}
#[actor(
StripeCreatePaymentIntentsIntentActor,
inports::<100>(intent, payment_method, customer_account, hooks, customer, amount, payment_method_options, application_fee_amount, currency, metadata, payment_method_data, setup_future_usage, transfer_data, payment_method_configuration, payment_details, payment_method_types, description, amount_details, excluded_payment_method_types, statement_descriptor_suffix, receipt_email, expand, shipping, transfer_group, statement_descriptor, capture_method),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_intents_intent(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_intents/{intent}".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("hooks") {
body.insert("hooks".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_options") {
body.insert("payment_method_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_data") {
body.insert("payment_method_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("setup_future_usage") {
body.insert("setup_future_usage".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_configuration") {
body.insert(
"payment_method_configuration".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("payment_details") {
body.insert("payment_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_types") {
body.insert("payment_method_types".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_details") {
body.insert("amount_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("excluded_payment_method_types") {
body.insert(
"excluded_payment_method_types".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("statement_descriptor_suffix") {
body.insert(
"statement_descriptor_suffix".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("receipt_email") {
body.insert("receipt_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_group") {
body.insert("transfer_group".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("capture_method") {
body.insert("capture_method".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/payment_intents/{{intent}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all PaymentIntent LineItems
///
/// Method: GET /v1/payment_intents/{intent}/amount_details_line_items
#[actor(
StripeReadPaymentIntentsIntentAmountDetailsLineItemsActor,
inports::<100>(ending_before, expand, intent, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_intents_intent_amount_details_line_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_intents/{intent}/amount_details_line_items".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/payment_intents/{{intent}}/amount_details_line_items failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Reconcile a customer_balance PaymentIntent
///
/// Method: POST /v1/payment_intents/{intent}/apply_customer_balance
#[actor(
StripeCreatePaymentIntentsIntentApplyCustomerBalanceActor,
inports::<100>(intent, amount, expand, currency),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_intents_intent_apply_customer_balance(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_intents/{intent}/apply_customer_balance".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_intents/{{intent}}/apply_customer_balance failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Cancel a PaymentIntent
///
/// Method: POST /v1/payment_intents/{intent}/cancel
#[actor(
StripeCreatePaymentIntentsIntentCancelActor,
inports::<100>(intent, expand, cancellation_reason),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_intents_intent_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_intents/{intent}/cancel".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancellation_reason") {
body.insert("cancellation_reason".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/payment_intents/{{intent}}/cancel failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Capture a PaymentIntent
///
/// Method: POST /v1/payment_intents/{intent}/capture
#[actor(
StripeCreatePaymentIntentsIntentCaptureActor,
inports::<100>(intent, metadata, transfer_data, hooks, payment_details, amount_to_capture, final_capture, expand, statement_descriptor, amount_details, statement_descriptor_suffix, application_fee_amount),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_intents_intent_capture(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_intents/{intent}/capture".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("hooks") {
body.insert("hooks".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_details") {
body.insert("payment_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_to_capture") {
body.insert("amount_to_capture".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("final_capture") {
body.insert("final_capture".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_details") {
body.insert("amount_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor_suffix") {
body.insert(
"statement_descriptor_suffix".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/payment_intents/{{intent}}/capture failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Confirm a PaymentIntent
///
/// Method: POST /v1/payment_intents/{intent}/confirm
#[actor(
StripeCreatePaymentIntentsIntentConfirmActor,
inports::<100>(intent, expand, use_stripe_sdk, payment_method_data, amount_details, hooks, mandate, off_session, payment_details, excluded_payment_method_types, payment_method_options, client_secret, return_url, payment_method_types, setup_future_usage, radar_options, confirmation_token, mandate_data, capture_method, payment_method, receipt_email, error_on_requires_action, shipping),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_intents_intent_confirm(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_intents/{intent}/confirm".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("use_stripe_sdk") {
body.insert("use_stripe_sdk".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_data") {
body.insert("payment_method_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_details") {
body.insert("amount_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("hooks") {
body.insert("hooks".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mandate") {
body.insert("mandate".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("off_session") {
body.insert("off_session".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_details") {
body.insert("payment_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("excluded_payment_method_types") {
body.insert(
"excluded_payment_method_types".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("payment_method_options") {
body.insert("payment_method_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("client_secret") {
body.insert("client_secret".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_types") {
body.insert("payment_method_types".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("setup_future_usage") {
body.insert("setup_future_usage".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("radar_options") {
body.insert("radar_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("confirmation_token") {
body.insert("confirmation_token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mandate_data") {
body.insert("mandate_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("capture_method") {
body.insert("capture_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("receipt_email") {
body.insert("receipt_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("error_on_requires_action") {
body.insert("error_on_requires_action".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/payment_intents/{{intent}}/confirm failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Increment an authorization
///
/// Method: POST /v1/payment_intents/{intent}/increment_authorization
#[actor(
StripeCreatePaymentIntentsIntentIncrementAuthorizationActor,
inports::<100>(intent, hooks, statement_descriptor, amount, amount_details, description, application_fee_amount, expand, transfer_data, payment_details, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_intents_intent_increment_authorization(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_intents/{intent}/increment_authorization".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("hooks") {
body.insert("hooks".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_details") {
body.insert("amount_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_details") {
body.insert("payment_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_intents/{{intent}}/increment_authorization failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Verify microdeposits on a PaymentIntent
///
/// Method: POST /v1/payment_intents/{intent}/verify_microdeposits
#[actor(
StripeCreatePaymentIntentsIntentVerifyMicrodepositsActor,
inports::<100>(intent, client_secret, descriptor_code, expand, amounts),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_intents_intent_verify_microdeposits(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_intents/{intent}/verify_microdeposits".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("client_secret") {
body.insert("client_secret".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("descriptor_code") {
body.insert("descriptor_code".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amounts") {
body.insert("amounts".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_intents/{{intent}}/verify_microdeposits failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a payment link
///
/// Method: POST /v1/payment_links
#[actor(
StripeCreatePaymentLinksActor,
inports::<100>(application_fee_percent, shipping_options, currency, automatic_tax, inactive_message, customer_creation, phone_number_collection, after_completion, payment_method_types, application_fee_amount, tax_id_collection, restrictions, consent_collection, transfer_data, line_items, billing_address_collection, invoice_creation, custom_text, name_collection, submit_type, allow_promotion_codes, subscription_data, payment_intent_data, expand, custom_fields, shipping_address_collection, optional_items, metadata, on_behalf_of, payment_method_collection),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_links(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_links".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("application_fee_percent") {
body.insert("application_fee_percent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_options") {
body.insert("shipping_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("inactive_message") {
body.insert("inactive_message".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_creation") {
body.insert("customer_creation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone_number_collection") {
body.insert("phone_number_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("after_completion") {
body.insert("after_completion".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_types") {
body.insert("payment_method_types".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_id_collection") {
body.insert("tax_id_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("restrictions") {
body.insert("restrictions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("consent_collection") {
body.insert("consent_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("line_items") {
body.insert("line_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_address_collection") {
body.insert("billing_address_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_creation") {
body.insert("invoice_creation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom_text") {
body.insert("custom_text".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name_collection") {
body.insert("name_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("submit_type") {
body.insert("submit_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("allow_promotion_codes") {
body.insert("allow_promotion_codes".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription_data") {
body.insert("subscription_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent_data") {
body.insert("payment_intent_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom_fields") {
body.insert("custom_fields".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_address_collection") {
body.insert(
"shipping_address_collection".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("optional_items") {
body.insert("optional_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_collection") {
body.insert("payment_method_collection".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/payment_links failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all payment links
///
/// Method: GET /v1/payment_links
#[actor(
StripeReadPaymentLinksActor,
inports::<100>(active, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_links(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_links".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("active") {
query_pairs.push(("active", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payment_links failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a payment link
///
/// Method: POST /v1/payment_links/{payment_link}
#[actor(
StripeCreatePaymentLinksPaymentLinkActor,
inports::<100>(payment_link, billing_address_collection, after_completion, metadata, active, customer_creation, custom_text, tax_id_collection, line_items, inactive_message, subscription_data, phone_number_collection, payment_intent_data, name_collection, payment_method_collection, invoice_creation, expand, optional_items, payment_method_types, automatic_tax, custom_fields, restrictions, allow_promotion_codes, shipping_address_collection, submit_type),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_links_payment_link(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_links/{payment_link}".to_string();
if let Some(val) = inputs.get("payment_link") {
endpoint = endpoint.replace("{{payment_link}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("billing_address_collection") {
body.insert("billing_address_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("after_completion") {
body.insert("after_completion".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_creation") {
body.insert("customer_creation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom_text") {
body.insert("custom_text".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_id_collection") {
body.insert("tax_id_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("line_items") {
body.insert("line_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("inactive_message") {
body.insert("inactive_message".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription_data") {
body.insert("subscription_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone_number_collection") {
body.insert("phone_number_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent_data") {
body.insert("payment_intent_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name_collection") {
body.insert("name_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_collection") {
body.insert("payment_method_collection".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_creation") {
body.insert("invoice_creation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("optional_items") {
body.insert("optional_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_types") {
body.insert("payment_method_types".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom_fields") {
body.insert("custom_fields".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("restrictions") {
body.insert("restrictions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("allow_promotion_codes") {
body.insert("allow_promotion_codes".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_address_collection") {
body.insert(
"shipping_address_collection".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("submit_type") {
body.insert("submit_type".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/payment_links/{{payment_link}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve payment link
///
/// Method: GET /v1/payment_links/{payment_link}
#[actor(
StripeReadPaymentLinksPaymentLinkActor,
inports::<100>(expand, payment_link, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_links_payment_link(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_links/{payment_link}".to_string();
if let Some(val) = inputs.get("payment_link") {
endpoint = endpoint.replace("{{payment_link}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/payment_links/{{payment_link}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a payment link's line items
///
/// Method: GET /v1/payment_links/{payment_link}/line_items
#[actor(
StripeReadPaymentLinksPaymentLinkLineItemsActor,
inports::<100>(ending_before, expand, limit, payment_link, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_links_payment_link_line_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_links/{payment_link}/line_items".to_string();
if let Some(val) = inputs.get("payment_link") {
endpoint = endpoint.replace("{{payment_link}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/payment_links/{{payment_link}}/line_items failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List payment method configurations
///
/// Method: GET /v1/payment_method_configurations
#[actor(
StripeReadPaymentMethodConfigurationsActor,
inports::<100>(application, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_method_configurations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_method_configurations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("application") {
query_pairs.push(("application", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/payment_method_configurations failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a payment method configuration
///
/// Method: POST /v1/payment_method_configurations
#[actor(
StripeCreatePaymentMethodConfigurationsActor,
inports::<100>(naver_pay, swish, blik, link, zip, paynow, konbini, samsung_pay, google_pay, p24, twint, mb_way, us_bank_account, wechat_pay, klarna, eps, fr_meal_voucher_conecs, payco, pix, au_becs_debit, crypto, parent, expand, promptpay, fpx, name, paypal, mobilepay, afterpay_clearpay, affirm, bacs_debit, multibanco, payto, giropay, boleto, satispay, sepa_debit, grabpay, apple_pay, customer_balance, alma, bancontact, kr_card, cartes_bancaires, amazon_pay, ideal, cashapp, nz_bank_account, billie, alipay, apple_pay_later, jcb, oxxo, revolut_pay, card, pay_by_bank, sofort, acss_debit, kakao_pay),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_method_configurations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_method_configurations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("naver_pay") {
body.insert("naver_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("swish") {
body.insert("swish".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("blik") {
body.insert("blik".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("link") {
body.insert("link".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("zip") {
body.insert("zip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("paynow") {
body.insert("paynow".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("konbini") {
body.insert("konbini".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("samsung_pay") {
body.insert("samsung_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("google_pay") {
body.insert("google_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("p24") {
body.insert("p24".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("twint") {
body.insert("twint".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mb_way") {
body.insert("mb_way".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("us_bank_account") {
body.insert("us_bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("wechat_pay") {
body.insert("wechat_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("klarna") {
body.insert("klarna".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("eps") {
body.insert("eps".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fr_meal_voucher_conecs") {
body.insert("fr_meal_voucher_conecs".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payco") {
body.insert("payco".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pix") {
body.insert("pix".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("au_becs_debit") {
body.insert("au_becs_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("crypto") {
body.insert("crypto".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("parent") {
body.insert("parent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("promptpay") {
body.insert("promptpay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fpx") {
body.insert("fpx".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("paypal") {
body.insert("paypal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mobilepay") {
body.insert("mobilepay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("afterpay_clearpay") {
body.insert("afterpay_clearpay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("affirm") {
body.insert("affirm".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bacs_debit") {
body.insert("bacs_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("multibanco") {
body.insert("multibanco".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payto") {
body.insert("payto".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("giropay") {
body.insert("giropay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("boleto") {
body.insert("boleto".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("satispay") {
body.insert("satispay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sepa_debit") {
body.insert("sepa_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("grabpay") {
body.insert("grabpay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("apple_pay") {
body.insert("apple_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_balance") {
body.insert("customer_balance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alma") {
body.insert("alma".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bancontact") {
body.insert("bancontact".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("kr_card") {
body.insert("kr_card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cartes_bancaires") {
body.insert("cartes_bancaires".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amazon_pay") {
body.insert("amazon_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ideal") {
body.insert("ideal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cashapp") {
body.insert("cashapp".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nz_bank_account") {
body.insert("nz_bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billie") {
body.insert("billie".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alipay") {
body.insert("alipay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("apple_pay_later") {
body.insert("apple_pay_later".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("jcb") {
body.insert("jcb".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("oxxo") {
body.insert("oxxo".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("revolut_pay") {
body.insert("revolut_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pay_by_bank") {
body.insert("pay_by_bank".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sofort") {
body.insert("sofort".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("acss_debit") {
body.insert("acss_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("kakao_pay") {
body.insert("kakao_pay".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/payment_method_configurations failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve payment method configuration
///
/// Method: GET /v1/payment_method_configurations/{configuration}
#[actor(
StripeReadPaymentMethodConfigurationsConfigurationActor,
inports::<100>(configuration, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_method_configurations_configuration(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_method_configurations/{configuration}".to_string();
if let Some(val) = inputs.get("configuration") {
endpoint = endpoint.replace("{{configuration}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/payment_method_configurations/{{configuration}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update payment method configuration
///
/// Method: POST /v1/payment_method_configurations/{configuration}
#[actor(
StripeCreatePaymentMethodConfigurationsConfigurationActor,
inports::<100>(configuration, swish, p24, paynow, cashapp, naver_pay, klarna, konbini, apple_pay_later, ideal, samsung_pay, active, nz_bank_account, pay_by_bank, satispay, billie, payco, promptpay, grabpay, payto, bancontact, jcb, name, sofort, google_pay, mb_way, multibanco, blik, zip, amazon_pay, oxxo, boleto, apple_pay, cartes_bancaires, alipay, card, crypto, kr_card, mobilepay, link, customer_balance, revolut_pay, giropay, bacs_debit, afterpay_clearpay, eps, paypal, wechat_pay, fpx, expand, affirm, pix, kakao_pay, au_becs_debit, acss_debit, us_bank_account, fr_meal_voucher_conecs, sepa_debit, alma, twint),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_method_configurations_configuration(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_method_configurations/{configuration}".to_string();
if let Some(val) = inputs.get("configuration") {
endpoint = endpoint.replace("{{configuration}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("swish") {
body.insert("swish".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("p24") {
body.insert("p24".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("paynow") {
body.insert("paynow".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cashapp") {
body.insert("cashapp".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("naver_pay") {
body.insert("naver_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("klarna") {
body.insert("klarna".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("konbini") {
body.insert("konbini".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("apple_pay_later") {
body.insert("apple_pay_later".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ideal") {
body.insert("ideal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("samsung_pay") {
body.insert("samsung_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nz_bank_account") {
body.insert("nz_bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pay_by_bank") {
body.insert("pay_by_bank".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("satispay") {
body.insert("satispay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billie") {
body.insert("billie".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payco") {
body.insert("payco".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("promptpay") {
body.insert("promptpay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("grabpay") {
body.insert("grabpay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payto") {
body.insert("payto".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bancontact") {
body.insert("bancontact".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("jcb") {
body.insert("jcb".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sofort") {
body.insert("sofort".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("google_pay") {
body.insert("google_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mb_way") {
body.insert("mb_way".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("multibanco") {
body.insert("multibanco".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("blik") {
body.insert("blik".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("zip") {
body.insert("zip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amazon_pay") {
body.insert("amazon_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("oxxo") {
body.insert("oxxo".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("boleto") {
body.insert("boleto".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("apple_pay") {
body.insert("apple_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cartes_bancaires") {
body.insert("cartes_bancaires".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alipay") {
body.insert("alipay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("crypto") {
body.insert("crypto".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("kr_card") {
body.insert("kr_card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mobilepay") {
body.insert("mobilepay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("link") {
body.insert("link".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_balance") {
body.insert("customer_balance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("revolut_pay") {
body.insert("revolut_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("giropay") {
body.insert("giropay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bacs_debit") {
body.insert("bacs_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("afterpay_clearpay") {
body.insert("afterpay_clearpay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("eps") {
body.insert("eps".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("paypal") {
body.insert("paypal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("wechat_pay") {
body.insert("wechat_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fpx") {
body.insert("fpx".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("affirm") {
body.insert("affirm".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pix") {
body.insert("pix".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("kakao_pay") {
body.insert("kakao_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("au_becs_debit") {
body.insert("au_becs_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("acss_debit") {
body.insert("acss_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("us_bank_account") {
body.insert("us_bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fr_meal_voucher_conecs") {
body.insert("fr_meal_voucher_conecs".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sepa_debit") {
body.insert("sepa_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alma") {
body.insert("alma".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("twint") {
body.insert("twint".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_method_configurations/{{configuration}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a payment method domain
///
/// Method: POST /v1/payment_method_domains
#[actor(
StripeCreatePaymentMethodDomainsActor,
inports::<100>(domain_name, enabled, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_method_domains(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_method_domains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("domain_name") {
body.insert("domain_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enabled") {
body.insert("enabled".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/payment_method_domains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List payment method domains
///
/// Method: GET /v1/payment_method_domains
#[actor(
StripeReadPaymentMethodDomainsActor,
inports::<100>(domain_name, enabled, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_method_domains(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_method_domains".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("domain_name") {
query_pairs.push(("domain_name", super::message_to_str(val)));
}
if let Some(val) = inputs.get("enabled") {
query_pairs.push(("enabled", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payment_method_domains failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a payment method domain
///
/// Method: POST /v1/payment_method_domains/{payment_method_domain}
#[actor(
StripeCreatePaymentMethodDomainsPaymentMethodDomainActor,
inports::<100>(payment_method_domain, expand, enabled),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_method_domains_payment_method_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_method_domains/{payment_method_domain}".to_string();
if let Some(val) = inputs.get("payment_method_domain") {
endpoint = endpoint.replace("{{payment_method_domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enabled") {
body.insert("enabled".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_method_domains/{{payment_method_domain}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a payment method domain
///
/// Method: GET /v1/payment_method_domains/{payment_method_domain}
#[actor(
StripeReadPaymentMethodDomainsPaymentMethodDomainActor,
inports::<100>(expand, payment_method_domain, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_method_domains_payment_method_domain(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_method_domains/{payment_method_domain}".to_string();
if let Some(val) = inputs.get("payment_method_domain") {
endpoint = endpoint.replace("{{payment_method_domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/payment_method_domains/{{payment_method_domain}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Validate an existing payment method domain
///
/// Method: POST /v1/payment_method_domains/{payment_method_domain}/validate
#[actor(
StripeCreatePaymentMethodDomainsPaymentMethodDomainValidateActor,
inports::<100>(payment_method_domain, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_method_domains_payment_method_domain_validate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_method_domains/{payment_method_domain}/validate".to_string();
if let Some(val) = inputs.get("payment_method_domain") {
endpoint = endpoint.replace("{{payment_method_domain}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/payment_method_domains/{{payment_method_domain}}/validate failed: {}", e).into()));
}
}
Ok(output)
}
/// Shares a PaymentMethod
///
/// Method: POST /v1/payment_methods
#[actor(
StripeCreatePaymentMethodsActor,
inports::<100>(satispay, custom, type_, au_becs_debit, bancontact, twint, bacs_debit, promptpay, boleto, us_bank_account, mobilepay, sofort, alma, card, zip, kr_card, oxxo, klarna, mb_way, amazon_pay, multibanco, payto, radar_options, expand, payco, paypal, affirm, pay_by_bank, billie, eps, ideal, billing_details, metadata, acss_debit, p24, alipay, customer, afterpay_clearpay, allow_redisplay, kakao_pay, samsung_pay, nz_bank_account, pix, blik, crypto, konbini, giropay, sepa_debit, revolut_pay, grabpay, customer_balance, fpx, paynow, interac_present, naver_pay, payment_method, wechat_pay, cashapp, swish, link),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_methods(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_methods".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("satispay") {
body.insert("satispay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom") {
body.insert("custom".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("au_becs_debit") {
body.insert("au_becs_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bancontact") {
body.insert("bancontact".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("twint") {
body.insert("twint".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bacs_debit") {
body.insert("bacs_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("promptpay") {
body.insert("promptpay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("boleto") {
body.insert("boleto".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("us_bank_account") {
body.insert("us_bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mobilepay") {
body.insert("mobilepay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sofort") {
body.insert("sofort".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alma") {
body.insert("alma".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("zip") {
body.insert("zip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("kr_card") {
body.insert("kr_card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("oxxo") {
body.insert("oxxo".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("klarna") {
body.insert("klarna".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mb_way") {
body.insert("mb_way".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amazon_pay") {
body.insert("amazon_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("multibanco") {
body.insert("multibanco".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payto") {
body.insert("payto".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("radar_options") {
body.insert("radar_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payco") {
body.insert("payco".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("paypal") {
body.insert("paypal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("affirm") {
body.insert("affirm".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pay_by_bank") {
body.insert("pay_by_bank".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billie") {
body.insert("billie".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("eps") {
body.insert("eps".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ideal") {
body.insert("ideal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_details") {
body.insert("billing_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("acss_debit") {
body.insert("acss_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("p24") {
body.insert("p24".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alipay") {
body.insert("alipay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("afterpay_clearpay") {
body.insert("afterpay_clearpay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("allow_redisplay") {
body.insert("allow_redisplay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("kakao_pay") {
body.insert("kakao_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("samsung_pay") {
body.insert("samsung_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nz_bank_account") {
body.insert("nz_bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pix") {
body.insert("pix".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("blik") {
body.insert("blik".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("crypto") {
body.insert("crypto".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("konbini") {
body.insert("konbini".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("giropay") {
body.insert("giropay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sepa_debit") {
body.insert("sepa_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("revolut_pay") {
body.insert("revolut_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("grabpay") {
body.insert("grabpay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_balance") {
body.insert("customer_balance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fpx") {
body.insert("fpx".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("paynow") {
body.insert("paynow".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("interac_present") {
body.insert("interac_present".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("naver_pay") {
body.insert("naver_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("wechat_pay") {
body.insert("wechat_pay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cashapp") {
body.insert("cashapp".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("swish") {
body.insert("swish".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("link") {
body.insert("link".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/payment_methods failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List PaymentMethods
///
/// Method: GET /v1/payment_methods
#[actor(
StripeReadPaymentMethodsActor,
inports::<100>(allow_redisplay, customer, customer_account, ending_before, expand, limit, starting_after, type_, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_methods(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_methods".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("allow_redisplay") {
query_pairs.push(("allow_redisplay", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payment_methods failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a PaymentMethod
///
/// Method: POST /v1/payment_methods/{payment_method}
#[actor(
StripeCreatePaymentMethodsPaymentMethodActor,
inports::<100>(payment_method, allow_redisplay, us_bank_account, expand, metadata, card, billing_details, payto),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_methods_payment_method(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_methods/{payment_method}".to_string();
if let Some(val) = inputs.get("payment_method") {
endpoint = endpoint.replace("{{payment_method}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("allow_redisplay") {
body.insert("allow_redisplay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("us_bank_account") {
body.insert("us_bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_details") {
body.insert("billing_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payto") {
body.insert("payto".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/payment_methods/{{payment_method}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a PaymentMethod
///
/// Method: GET /v1/payment_methods/{payment_method}
#[actor(
StripeReadPaymentMethodsPaymentMethodActor,
inports::<100>(expand, payment_method, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_methods_payment_method(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_methods/{payment_method}".to_string();
if let Some(val) = inputs.get("payment_method") {
endpoint = endpoint.replace("{{payment_method}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/payment_methods/{{payment_method}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Attach a PaymentMethod to a Customer
///
/// Method: POST /v1/payment_methods/{payment_method}/attach
#[actor(
StripeCreatePaymentMethodsPaymentMethodAttachActor,
inports::<100>(payment_method, customer, customer_account, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_methods_payment_method_attach(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_methods/{payment_method}/attach".to_string();
if let Some(val) = inputs.get("payment_method") {
endpoint = endpoint.replace("{{payment_method}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_methods/{{payment_method}}/attach failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Detach a PaymentMethod from a Customer
///
/// Method: POST /v1/payment_methods/{payment_method}/detach
#[actor(
StripeCreatePaymentMethodsPaymentMethodDetachActor,
inports::<100>(payment_method, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_methods_payment_method_detach(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_methods/{payment_method}/detach".to_string();
if let Some(val) = inputs.get("payment_method") {
endpoint = endpoint.replace("{{payment_method}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_methods/{{payment_method}}/detach failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Report a payment
///
/// Method: POST /v1/payment_records/report_payment
#[actor(
StripeCreatePaymentRecordsReportPaymentActor,
inports::<100>(guaranteed, amount_requested, initiated_at, payment_method_details, processor_details, shipping_details, description, failed, expand, outcome, customer_details, metadata, customer_presence),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_records_report_payment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payment_records/report_payment".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("guaranteed") {
body.insert("guaranteed".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_requested") {
body.insert("amount_requested".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("initiated_at") {
body.insert("initiated_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_details") {
body.insert("payment_method_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("processor_details") {
body.insert("processor_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_details") {
body.insert("shipping_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("failed") {
body.insert("failed".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("outcome") {
body.insert("outcome".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_details") {
body.insert("customer_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_presence") {
body.insert("customer_presence".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/payment_records/report_payment failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Payment Record
///
/// Method: GET /v1/payment_records/{id}
#[actor(
StripeReadPaymentRecordsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payment_records_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_records/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payment_records/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Report a payment attempt
///
/// Method: POST /v1/payment_records/{id}/report_payment_attempt
#[actor(
StripeCreatePaymentRecordsIdReportPaymentAttemptActor,
inports::<100>(id, description, guaranteed, expand, initiated_at, payment_method_details, metadata, shipping_details, outcome, failed),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_records_id_report_payment_attempt(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_records/{id}/report_payment_attempt".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("guaranteed") {
body.insert("guaranteed".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("initiated_at") {
body.insert("initiated_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_details") {
body.insert("payment_method_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_details") {
body.insert("shipping_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("outcome") {
body.insert("outcome".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("failed") {
body.insert("failed".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_records/{{id}}/report_payment_attempt failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Report payment attempt canceled
///
/// Method: POST /v1/payment_records/{id}/report_payment_attempt_canceled
#[actor(
StripeCreatePaymentRecordsIdReportPaymentAttemptCanceledActor,
inports::<100>(id, expand, canceled_at, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_records_id_report_payment_attempt_canceled(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_records/{id}/report_payment_attempt_canceled".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("canceled_at") {
body.insert("canceled_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/payment_records/{{id}}/report_payment_attempt_canceled failed: {}", e).into()));
}
}
Ok(output)
}
/// Report payment attempt failed
///
/// Method: POST /v1/payment_records/{id}/report_payment_attempt_failed
#[actor(
StripeCreatePaymentRecordsIdReportPaymentAttemptFailedActor,
inports::<100>(id, metadata, failed_at, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_records_id_report_payment_attempt_failed(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_records/{id}/report_payment_attempt_failed".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("failed_at") {
body.insert("failed_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_records/{{id}}/report_payment_attempt_failed failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Report payment attempt guaranteed
///
/// Method: POST /v1/payment_records/{id}/report_payment_attempt_guaranteed
#[actor(
StripeCreatePaymentRecordsIdReportPaymentAttemptGuaranteedActor,
inports::<100>(id, guaranteed_at, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_records_id_report_payment_attempt_guaranteed(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_records/{id}/report_payment_attempt_guaranteed".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("guaranteed_at") {
body.insert("guaranteed_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/payment_records/{{id}}/report_payment_attempt_guaranteed failed: {}", e).into()));
}
}
Ok(output)
}
/// Report payment attempt informational
///
/// Method: POST /v1/payment_records/{id}/report_payment_attempt_informational
#[actor(
StripeCreatePaymentRecordsIdReportPaymentAttemptInformationalActor,
inports::<100>(id, metadata, customer_details, description, expand, shipping_details),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_records_id_report_payment_attempt_informational(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_records/{id}/report_payment_attempt_informational".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_details") {
body.insert("customer_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_details") {
body.insert("shipping_details".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/payment_records/{{id}}/report_payment_attempt_informational failed: {}", e).into()));
}
}
Ok(output)
}
/// Report a refund
///
/// Method: POST /v1/payment_records/{id}/report_refund
#[actor(
StripeCreatePaymentRecordsIdReportRefundActor,
inports::<100>(id, refunded, amount, initiated_at, expand, metadata, outcome, processor_details),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payment_records_id_report_refund(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payment_records/{id}/report_refund".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("refunded") {
body.insert("refunded".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("initiated_at") {
body.insert("initiated_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("outcome") {
body.insert("outcome".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("processor_details") {
body.insert("processor_details".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/payment_records/{{id}}/report_refund failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a payout
///
/// Method: POST /v1/payouts
#[actor(
StripeCreatePayoutsActor,
inports::<100>(expand, statement_descriptor, amount, description, method, destination, payout_method, source_type, currency, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payouts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payouts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("method") {
body.insert("method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("destination") {
body.insert("destination".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payout_method") {
body.insert("payout_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source_type") {
body.insert("source_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/payouts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all payouts
///
/// Method: GET /v1/payouts
#[actor(
StripeReadPayoutsActor,
inports::<100>(arrival_date, created, destination, ending_before, expand, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payouts(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/payouts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("arrival_date") {
query_pairs.push(("arrival_date", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("destination") {
query_pairs.push(("destination", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payouts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a payout
///
/// Method: POST /v1/payouts/{payout}
#[actor(
StripeCreatePayoutsPayoutActor,
inports::<100>(payout, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payouts_payout(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payouts/{payout}".to_string();
if let Some(val) = inputs.get("payout") {
endpoint = endpoint.replace("{{payout}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/payouts/{{payout}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a payout
///
/// Method: GET /v1/payouts/{payout}
#[actor(
StripeReadPayoutsPayoutActor,
inports::<100>(expand, payout, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_payouts_payout(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payouts/{payout}".to_string();
if let Some(val) = inputs.get("payout") {
endpoint = endpoint.replace("{{payout}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/payouts/{{payout}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Cancel a payout
///
/// Method: POST /v1/payouts/{payout}/cancel
#[actor(
StripeCreatePayoutsPayoutCancelActor,
inports::<100>(payout, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payouts_payout_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payouts/{payout}/cancel".to_string();
if let Some(val) = inputs.get("payout") {
endpoint = endpoint.replace("{{payout}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/payouts/{{payout}}/cancel failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Reverse a payout
///
/// Method: POST /v1/payouts/{payout}/reverse
#[actor(
StripeCreatePayoutsPayoutReverseActor,
inports::<100>(payout, metadata, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_payouts_payout_reverse(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/payouts/{payout}/reverse".to_string();
if let Some(val) = inputs.get("payout") {
endpoint = endpoint.replace("{{payout}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/payouts/{{payout}}/reverse failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all plans
///
/// Method: GET /v1/plans
#[actor(
StripeReadPlansActor,
inports::<100>(active, created, ending_before, expand, limit, product, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_plans(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/plans".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("active") {
query_pairs.push(("active", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("product") {
query_pairs.push(("product", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/plans failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a plan
///
/// Method: POST /v1/plans
#[actor(
StripeCreatePlansActor,
inports::<100>(product, trial_period_days, active, interval, tiers, amount_decimal, nickname, expand, interval_count, meter, tiers_mode, id, transform_usage, billing_scheme, metadata, usage_type, amount, currency),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_plans(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/plans".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("product") {
body.insert("product".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_period_days") {
body.insert("trial_period_days".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("interval") {
body.insert("interval".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tiers") {
body.insert("tiers".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_decimal") {
body.insert("amount_decimal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nickname") {
body.insert("nickname".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("interval_count") {
body.insert("interval_count".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("meter") {
body.insert("meter".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tiers_mode") {
body.insert("tiers_mode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id") {
body.insert("id".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transform_usage") {
body.insert("transform_usage".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_scheme") {
body.insert("billing_scheme".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("usage_type") {
body.insert("usage_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/plans failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a plan
///
/// Method: DELETE /v1/plans/{plan}
#[actor(
StripeDeletePlansPlanActor,
inports::<100>(plan, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_plans_plan(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/plans/{plan}".to_string();
if let Some(val) = inputs.get("plan") {
endpoint = endpoint.replace("{{plan}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/plans/{{plan}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a plan
///
/// Method: GET /v1/plans/{plan}
#[actor(
StripeReadPlansPlanActor,
inports::<100>(expand, plan, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_plans_plan(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/plans/{plan}".to_string();
if let Some(val) = inputs.get("plan") {
endpoint = endpoint.replace("{{plan}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/plans/{{plan}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a plan
///
/// Method: POST /v1/plans/{plan}
#[actor(
StripeCreatePlansPlanActor,
inports::<100>(plan, active, expand, metadata, nickname, product, trial_period_days),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_plans_plan(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/plans/{plan}".to_string();
if let Some(val) = inputs.get("plan") {
endpoint = endpoint.replace("{{plan}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nickname") {
body.insert("nickname".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("product") {
body.insert("product".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_period_days") {
body.insert("trial_period_days".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/plans/{{plan}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all prices
///
/// Method: GET /v1/prices
#[actor(
StripeReadPricesActor,
inports::<100>(active, created, currency, ending_before, expand, limit, lookup_keys, product, recurring, starting_after, type_, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_prices(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/prices".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("active") {
query_pairs.push(("active", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("currency") {
query_pairs.push(("currency", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("lookup_keys") {
query_pairs.push(("lookup_keys", super::message_to_str(val)));
}
if let Some(val) = inputs.get("product") {
query_pairs.push(("product", super::message_to_str(val)));
}
if let Some(val) = inputs.get("recurring") {
query_pairs.push(("recurring", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("type_") {
query_pairs.push(("type", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/prices failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a price
///
/// Method: POST /v1/prices
#[actor(
StripeCreatePricesActor,
inports::<100>(lookup_key, tiers_mode, active, currency, custom_unit_amount, tax_behavior, unit_amount, expand, recurring, product, unit_amount_decimal, metadata, nickname, billing_scheme, transfer_lookup_key, tiers, transform_quantity, currency_options, product_data),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_prices(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/prices".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("lookup_key") {
body.insert("lookup_key".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tiers_mode") {
body.insert("tiers_mode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("custom_unit_amount") {
body.insert("custom_unit_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_behavior") {
body.insert("tax_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("unit_amount") {
body.insert("unit_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("recurring") {
body.insert("recurring".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("product") {
body.insert("product".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("unit_amount_decimal") {
body.insert("unit_amount_decimal".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nickname") {
body.insert("nickname".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_scheme") {
body.insert("billing_scheme".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_lookup_key") {
body.insert("transfer_lookup_key".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tiers") {
body.insert("tiers".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transform_quantity") {
body.insert("transform_quantity".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency_options") {
body.insert("currency_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("product_data") {
body.insert("product_data".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/prices failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Search prices
///
/// Method: GET /v1/prices/search
#[actor(
StripeReadPricesSearchActor,
inports::<100>(expand, limit, page, query, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_prices_search(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/prices/search".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("page") {
query_pairs.push(("page", super::message_to_str(val)));
}
if let Some(val) = inputs.get("query") {
query_pairs.push(("query", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/prices/search failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a price
///
/// Method: POST /v1/prices/{price}
#[actor(
StripeCreatePricesPriceActor,
inports::<100>(price, tax_behavior, transfer_lookup_key, nickname, lookup_key, active, currency_options, metadata, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_prices_price(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/prices/{price}".to_string();
if let Some(val) = inputs.get("price") {
endpoint = endpoint.replace("{{price}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("tax_behavior") {
body.insert("tax_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_lookup_key") {
body.insert("transfer_lookup_key".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nickname") {
body.insert("nickname".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("lookup_key") {
body.insert("lookup_key".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency_options") {
body.insert("currency_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/prices/{{price}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a price
///
/// Method: GET /v1/prices/{price}
#[actor(
StripeReadPricesPriceActor,
inports::<100>(expand, price, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_prices_price(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/prices/{price}".to_string();
if let Some(val) = inputs.get("price") {
endpoint = endpoint.replace("{{price}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/prices/{{price}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all products
///
/// Method: GET /v1/products
#[actor(
StripeReadProductsActor,
inports::<100>(active, created, ending_before, expand, ids, limit, shippable, starting_after, url, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_products(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/products".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("active") {
query_pairs.push(("active", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ids") {
query_pairs.push(("ids", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("shippable") {
query_pairs.push(("shippable", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("url") {
query_pairs.push(("url", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/products failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a product
///
/// Method: POST /v1/products
#[actor(
StripeCreateProductsActor,
inports::<100>(tax_code, url, statement_descriptor, metadata, active, images, default_price_data, shippable, name, unit_label, id, expand, description, marketing_features, package_dimensions),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_products(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/products".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("tax_code") {
body.insert("tax_code".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("url") {
body.insert("url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("images") {
body.insert("images".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_price_data") {
body.insert("default_price_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shippable") {
body.insert("shippable".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("unit_label") {
body.insert("unit_label".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("id") {
body.insert("id".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("marketing_features") {
body.insert("marketing_features".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("package_dimensions") {
body.insert("package_dimensions".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/products failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Search products
///
/// Method: GET /v1/products/search
#[actor(
StripeReadProductsSearchActor,
inports::<100>(expand, limit, page, query, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_products_search(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/products/search".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("page") {
query_pairs.push(("page", super::message_to_str(val)));
}
if let Some(val) = inputs.get("query") {
query_pairs.push(("query", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/products/search failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a product
///
/// Method: GET /v1/products/{id}
#[actor(
StripeReadProductsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_products_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/products/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/products/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a product
///
/// Method: POST /v1/products/{id}
#[actor(
StripeCreateProductsIdActor,
inports::<100>(id, url, description, images, marketing_features, name, package_dimensions, default_price, metadata, tax_code, expand, active, shippable, unit_label, statement_descriptor),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_products_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/products/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("url") {
body.insert("url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("images") {
body.insert("images".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("marketing_features") {
body.insert("marketing_features".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("package_dimensions") {
body.insert("package_dimensions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_price") {
body.insert("default_price".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_code") {
body.insert("tax_code".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shippable") {
body.insert("shippable".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("unit_label") {
body.insert("unit_label".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/products/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a product
///
/// Method: DELETE /v1/products/{id}
#[actor(
StripeDeleteProductsIdActor,
inports::<100>(id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_products_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/products/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/products/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all features attached to a product
///
/// Method: GET /v1/products/{product}/features
#[actor(
StripeReadProductsProductFeaturesActor,
inports::<100>(ending_before, expand, limit, product, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_products_product_features(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/products/{product}/features".to_string();
if let Some(val) = inputs.get("product") {
endpoint = endpoint.replace("{{product}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/products/{{product}}/features failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Attach a feature to a product
///
/// Method: POST /v1/products/{product}/features
#[actor(
StripeCreateProductsProductFeaturesActor,
inports::<100>(product, expand, entitlement_feature),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_products_product_features(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/products/{product}/features".to_string();
if let Some(val) = inputs.get("product") {
endpoint = endpoint.replace("{{product}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("entitlement_feature") {
body.insert("entitlement_feature".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/products/{{product}}/features failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Remove a feature from a product
///
/// Method: DELETE /v1/products/{product}/features/{id}
#[actor(
StripeDeleteProductsProductFeaturesIdActor,
inports::<100>(id, product, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_products_product_features_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/products/{product}/features/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("product") {
endpoint = endpoint.replace("{{product}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/products/{{product}}/features/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a product_feature
///
/// Method: GET /v1/products/{product}/features/{id}
#[actor(
StripeReadProductsProductFeaturesIdActor,
inports::<100>(expand, id, product, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_products_product_features_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/products/{product}/features/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("product") {
endpoint = endpoint.replace("{{product}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/products/{{product}}/features/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all promotion codes
///
/// Method: GET /v1/promotion_codes
#[actor(
StripeReadPromotionCodesActor,
inports::<100>(active, code, coupon, created, customer, customer_account, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_promotion_codes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/promotion_codes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("active") {
query_pairs.push(("active", super::message_to_str(val)));
}
if let Some(val) = inputs.get("code") {
query_pairs.push(("code", super::message_to_str(val)));
}
if let Some(val) = inputs.get("coupon") {
query_pairs.push(("coupon", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/promotion_codes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a promotion code
///
/// Method: POST /v1/promotion_codes
#[actor(
StripeCreatePromotionCodesActor,
inports::<100>(expires_at, max_redemptions, code, active, metadata, promotion, customer_account, restrictions, expand, customer),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_promotion_codes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/promotion_codes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("max_redemptions") {
body.insert("max_redemptions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("code") {
body.insert("code".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("promotion") {
body.insert("promotion".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("restrictions") {
body.insert("restrictions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/promotion_codes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a promotion code
///
/// Method: GET /v1/promotion_codes/{promotion_code}
#[actor(
StripeReadPromotionCodesPromotionCodeActor,
inports::<100>(expand, promotion_code, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_promotion_codes_promotion_code(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/promotion_codes/{promotion_code}".to_string();
if let Some(val) = inputs.get("promotion_code") {
endpoint = endpoint.replace("{{promotion_code}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/promotion_codes/{{promotion_code}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a promotion code
///
/// Method: POST /v1/promotion_codes/{promotion_code}
#[actor(
StripeCreatePromotionCodesPromotionCodeActor,
inports::<100>(promotion_code, expand, active, restrictions, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_promotion_codes_promotion_code(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/promotion_codes/{promotion_code}".to_string();
if let Some(val) = inputs.get("promotion_code") {
endpoint = endpoint.replace("{{promotion_code}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("restrictions") {
body.insert("restrictions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/promotion_codes/{{promotion_code}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all quotes
///
/// Method: GET /v1/quotes
#[actor(
StripeReadQuotesActor,
inports::<100>(customer, customer_account, ending_before, expand, limit, starting_after, status, test_clock, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_quotes(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/quotes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if let Some(val) = inputs.get("test_clock") {
query_pairs.push(("test_clock", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/quotes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a quote
///
/// Method: POST /v1/quotes
#[actor(
StripeCreateQuotesActor,
inports::<100>(metadata, default_tax_rates, on_behalf_of, expires_at, test_clock, line_items, from_quote, collection_method, application_fee_percent, subscription_data, transfer_data, customer_account, footer, discounts, header, automatic_tax, application_fee_amount, customer, description, expand, invoice_settings),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_quotes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/quotes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_tax_rates") {
body.insert("default_tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("test_clock") {
body.insert("test_clock".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("line_items") {
body.insert("line_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("from_quote") {
body.insert("from_quote".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collection_method") {
body.insert("collection_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_percent") {
body.insert("application_fee_percent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription_data") {
body.insert("subscription_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("footer") {
body.insert("footer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("header") {
body.insert("header".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_settings") {
body.insert("invoice_settings".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/quotes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a quote
///
/// Method: GET /v1/quotes/{quote}
#[actor(
StripeReadQuotesQuoteActor,
inports::<100>(expand, quote, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_quotes_quote(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/quotes/{quote}".to_string();
if let Some(val) = inputs.get("quote") {
endpoint = endpoint.replace("{{quote}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/quotes/{{quote}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a quote
///
/// Method: POST /v1/quotes/{quote}
#[actor(
StripeCreateQuotesQuoteActor,
inports::<100>(quote, expand, on_behalf_of, default_tax_rates, application_fee_amount, application_fee_percent, collection_method, customer_account, subscription_data, customer, transfer_data, metadata, invoice_settings, footer, expires_at, description, automatic_tax, discounts, header, line_items),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_quotes_quote(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/quotes/{quote}".to_string();
if let Some(val) = inputs.get("quote") {
endpoint = endpoint.replace("{{quote}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_tax_rates") {
body.insert("default_tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_amount") {
body.insert("application_fee_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_percent") {
body.insert("application_fee_percent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collection_method") {
body.insert("collection_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription_data") {
body.insert("subscription_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_settings") {
body.insert("invoice_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("footer") {
body.insert("footer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("header") {
body.insert("header".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("line_items") {
body.insert("line_items".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/quotes/{{quote}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Accept a quote
///
/// Method: POST /v1/quotes/{quote}/accept
#[actor(
StripeCreateQuotesQuoteAcceptActor,
inports::<100>(quote, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_quotes_quote_accept(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/quotes/{quote}/accept".to_string();
if let Some(val) = inputs.get("quote") {
endpoint = endpoint.replace("{{quote}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/quotes/{{quote}}/accept failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Cancel a quote
///
/// Method: POST /v1/quotes/{quote}/cancel
#[actor(
StripeCreateQuotesQuoteCancelActor,
inports::<100>(quote, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_quotes_quote_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/quotes/{quote}/cancel".to_string();
if let Some(val) = inputs.get("quote") {
endpoint = endpoint.replace("{{quote}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/quotes/{{quote}}/cancel failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a quote's upfront line items
///
/// Method: GET /v1/quotes/{quote}/computed_upfront_line_items
#[actor(
StripeReadQuotesQuoteComputedUpfrontLineItemsActor,
inports::<100>(ending_before, expand, limit, quote, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_quotes_quote_computed_upfront_line_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/quotes/{quote}/computed_upfront_line_items".to_string();
if let Some(val) = inputs.get("quote") {
endpoint = endpoint.replace("{{quote}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/quotes/{{quote}}/computed_upfront_line_items failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Finalize a quote
///
/// Method: POST /v1/quotes/{quote}/finalize
#[actor(
StripeCreateQuotesQuoteFinalizeActor,
inports::<100>(quote, expand, expires_at),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_quotes_quote_finalize(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/quotes/{quote}/finalize".to_string();
if let Some(val) = inputs.get("quote") {
endpoint = endpoint.replace("{{quote}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/quotes/{{quote}}/finalize failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a quote's line items
///
/// Method: GET /v1/quotes/{quote}/line_items
#[actor(
StripeReadQuotesQuoteLineItemsActor,
inports::<100>(ending_before, expand, limit, quote, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_quotes_quote_line_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/quotes/{quote}/line_items".to_string();
if let Some(val) = inputs.get("quote") {
endpoint = endpoint.replace("{{quote}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/quotes/{{quote}}/line_items failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Download quote PDF
///
/// Method: GET /v1/quotes/{quote}/pdf
#[actor(
StripeReadQuotesQuotePdfActor,
inports::<100>(expand, quote, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_quotes_quote_pdf(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/quotes/{quote}/pdf".to_string();
if let Some(val) = inputs.get("quote") {
endpoint = endpoint.replace("{{quote}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/quotes/{{quote}}/pdf failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all early fraud warnings
///
/// Method: GET /v1/radar/early_fraud_warnings
#[actor(
StripeReadRadarEarlyFraudWarningsActor,
inports::<100>(charge, created, ending_before, expand, limit, payment_intent, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_radar_early_fraud_warnings(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/radar/early_fraud_warnings".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("charge") {
query_pairs.push(("charge", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment_intent") {
query_pairs.push(("payment_intent", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/radar/early_fraud_warnings failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an early fraud warning
///
/// Method: GET /v1/radar/early_fraud_warnings/{early_fraud_warning}
#[actor(
StripeReadRadarEarlyFraudWarningsEarlyFraudWarningActor,
inports::<100>(early_fraud_warning, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_radar_early_fraud_warnings_early_fraud_warning(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/radar/early_fraud_warnings/{early_fraud_warning}".to_string();
if let Some(val) = inputs.get("early_fraud_warning") {
endpoint = endpoint.replace("{{early_fraud_warning}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/radar/early_fraud_warnings/{{early_fraud_warning}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a Payment Evaluation
///
/// Method: POST /v1/radar/payment_evaluations
#[actor(
StripeCreateRadarPaymentEvaluationsActor,
inports::<100>(expand, metadata, payment_details, customer_details, client_device_metadata_details),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_radar_payment_evaluations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/radar/payment_evaluations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_details") {
body.insert("payment_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_details") {
body.insert("customer_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("client_device_metadata_details") {
body.insert(
"client_device_metadata_details".to_string(),
val.clone().into(),
);
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/radar/payment_evaluations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a value list item
///
/// Method: POST /v1/radar/value_list_items
#[actor(
StripeCreateRadarValueListItemsActor,
inports::<100>(value_list, value, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_radar_value_list_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/radar/value_list_items".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("value_list") {
body.insert("value_list".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("value") {
body.insert("value".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/radar/value_list_items failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all value list items
///
/// Method: GET /v1/radar/value_list_items
#[actor(
StripeReadRadarValueListItemsActor,
inports::<100>(created, ending_before, expand, limit, starting_after, value, value_list, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_radar_value_list_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/radar/value_list_items".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("value") {
query_pairs.push(("value", super::message_to_str(val)));
}
if let Some(val) = inputs.get("value_list") {
query_pairs.push(("value_list", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/radar/value_list_items failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a value list item
///
/// Method: DELETE /v1/radar/value_list_items/{item}
#[actor(
StripeDeleteRadarValueListItemsItemActor,
inports::<100>(item, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_radar_value_list_items_item(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/radar/value_list_items/{item}".to_string();
if let Some(val) = inputs.get("item") {
endpoint = endpoint.replace("{{item}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/radar/value_list_items/{{item}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a value list item
///
/// Method: GET /v1/radar/value_list_items/{item}
#[actor(
StripeReadRadarValueListItemsItemActor,
inports::<100>(expand, item, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_radar_value_list_items_item(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/radar/value_list_items/{item}".to_string();
if let Some(val) = inputs.get("item") {
endpoint = endpoint.replace("{{item}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/radar/value_list_items/{{item}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a value list
///
/// Method: POST /v1/radar/value_lists
#[actor(
StripeCreateRadarValueListsActor,
inports::<100>(name, item_type, alias, metadata, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_radar_value_lists(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/radar/value_lists".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("item_type") {
body.insert("item_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("alias") {
body.insert("alias".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/radar/value_lists failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all value lists
///
/// Method: GET /v1/radar/value_lists
#[actor(
StripeReadRadarValueListsActor,
inports::<100>(alias, contains, created, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_radar_value_lists(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/radar/value_lists".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("alias") {
query_pairs.push(("alias", super::message_to_str(val)));
}
if let Some(val) = inputs.get("contains") {
query_pairs.push(("contains", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/radar/value_lists failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a value list
///
/// Method: POST /v1/radar/value_lists/{value_list}
#[actor(
StripeCreateRadarValueListsValueListActor,
inports::<100>(value_list, alias, metadata, name, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_radar_value_lists_value_list(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/radar/value_lists/{value_list}".to_string();
if let Some(val) = inputs.get("value_list") {
endpoint = endpoint.replace("{{value_list}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("alias") {
body.insert("alias".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/radar/value_lists/{{value_list}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a value list
///
/// Method: GET /v1/radar/value_lists/{value_list}
#[actor(
StripeReadRadarValueListsValueListActor,
inports::<100>(expand, value_list, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_radar_value_lists_value_list(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/radar/value_lists/{value_list}".to_string();
if let Some(val) = inputs.get("value_list") {
endpoint = endpoint.replace("{{value_list}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/radar/value_lists/{{value_list}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Delete a value list
///
/// Method: DELETE /v1/radar/value_lists/{value_list}
#[actor(
StripeDeleteRadarValueListsValueListActor,
inports::<100>(value_list, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_radar_value_lists_value_list(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/radar/value_lists/{value_list}".to_string();
if let Some(val) = inputs.get("value_list") {
endpoint = endpoint.replace("{{value_list}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/radar/value_lists/{{value_list}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all refunds
///
/// Method: GET /v1/refunds
#[actor(
StripeReadRefundsActor,
inports::<100>(charge, created, ending_before, expand, limit, payment_intent, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_refunds(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/refunds".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("charge") {
query_pairs.push(("charge", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment_intent") {
query_pairs.push(("payment_intent", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/refunds failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create customer balance refund
///
/// Method: POST /v1/refunds
#[actor(
StripeCreateRefundsActor,
inports::<100>(reverse_transfer, customer, origin, payment_intent, charge, refund_application_fee, currency, amount, instructions_email, reason, metadata, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_refunds(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/refunds".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("reverse_transfer") {
body.insert("reverse_transfer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("origin") {
body.insert("origin".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent") {
body.insert("payment_intent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("charge") {
body.insert("charge".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("refund_application_fee") {
body.insert("refund_application_fee".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("instructions_email") {
body.insert("instructions_email".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reason") {
body.insert("reason".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/refunds failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a refund
///
/// Method: GET /v1/refunds/{refund}
#[actor(
StripeReadRefundsRefundActor,
inports::<100>(expand, refund, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_refunds_refund(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/refunds/{refund}".to_string();
if let Some(val) = inputs.get("refund") {
endpoint = endpoint.replace("{{refund}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/refunds/{{refund}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a refund
///
/// Method: POST /v1/refunds/{refund}
#[actor(
StripeCreateRefundsRefundActor,
inports::<100>(refund, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_refunds_refund(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/refunds/{refund}".to_string();
if let Some(val) = inputs.get("refund") {
endpoint = endpoint.replace("{{refund}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/refunds/{{refund}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Cancel a refund
///
/// Method: POST /v1/refunds/{refund}/cancel
#[actor(
StripeCreateRefundsRefundCancelActor,
inports::<100>(refund, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_refunds_refund_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/refunds/{refund}/cancel".to_string();
if let Some(val) = inputs.get("refund") {
endpoint = endpoint.replace("{{refund}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/refunds/{{refund}}/cancel failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all Report Runs
///
/// Method: GET /v1/reporting/report_runs
#[actor(
StripeReadReportingReportRunsActor,
inports::<100>(created, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_reporting_report_runs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/reporting/report_runs".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/reporting/report_runs failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a Report Run
///
/// Method: POST /v1/reporting/report_runs
#[actor(
StripeCreateReportingReportRunsActor,
inports::<100>(expand, report_type, parameters),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_reporting_report_runs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/reporting/report_runs".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("report_type") {
body.insert("report_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("parameters") {
body.insert("parameters".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/reporting/report_runs failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a Report Run
///
/// Method: GET /v1/reporting/report_runs/{report_run}
#[actor(
StripeReadReportingReportRunsReportRunActor,
inports::<100>(expand, report_run, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_reporting_report_runs_report_run(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/reporting/report_runs/{report_run}".to_string();
if let Some(val) = inputs.get("report_run") {
endpoint = endpoint.replace("{{report_run}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/reporting/report_runs/{{report_run}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all Report Types
///
/// Method: GET /v1/reporting/report_types
#[actor(
StripeReadReportingReportTypesActor,
inports::<100>(expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_reporting_report_types(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/reporting/report_types".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/reporting/report_types failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a Report Type
///
/// Method: GET /v1/reporting/report_types/{report_type}
#[actor(
StripeReadReportingReportTypesReportTypeActor,
inports::<100>(expand, report_type, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_reporting_report_types_report_type(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/reporting/report_types/{report_type}".to_string();
if let Some(val) = inputs.get("report_type") {
endpoint = endpoint.replace("{{report_type}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/reporting/report_types/{{report_type}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all open reviews
///
/// Method: GET /v1/reviews
#[actor(
StripeReadReviewsActor,
inports::<100>(created, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_reviews(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/reviews".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/reviews failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a review
///
/// Method: GET /v1/reviews/{review}
#[actor(
StripeReadReviewsReviewActor,
inports::<100>(expand, review, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_reviews_review(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/reviews/{review}".to_string();
if let Some(val) = inputs.get("review") {
endpoint = endpoint.replace("{{review}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/reviews/{{review}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Approve a review
///
/// Method: POST /v1/reviews/{review}/approve
#[actor(
StripeCreateReviewsReviewApproveActor,
inports::<100>(review, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_reviews_review_approve(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/reviews/{review}/approve".to_string();
if let Some(val) = inputs.get("review") {
endpoint = endpoint.replace("{{review}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/reviews/{{review}}/approve failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all SetupAttempts
///
/// Method: GET /v1/setup_attempts
#[actor(
StripeReadSetupAttemptsActor,
inports::<100>(created, ending_before, expand, limit, setup_intent, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_setup_attempts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/setup_attempts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("setup_intent") {
query_pairs.push(("setup_intent", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/setup_attempts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a SetupIntent
///
/// Method: POST /v1/setup_intents
#[actor(
StripeCreateSetupIntentsActor,
inports::<100>(excluded_payment_method_types, use_stripe_sdk, expand, customer_account, confirm, customer, payment_method, metadata, description, payment_method_configuration, mandate_data, return_url, usage, payment_method_data, on_behalf_of, automatic_payment_methods, payment_method_options, payment_method_types, flow_directions, single_use, attach_to_self, confirmation_token),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_setup_intents(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/setup_intents".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("excluded_payment_method_types") {
body.insert(
"excluded_payment_method_types".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("use_stripe_sdk") {
body.insert("use_stripe_sdk".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("confirm") {
body.insert("confirm".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_configuration") {
body.insert(
"payment_method_configuration".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("mandate_data") {
body.insert("mandate_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("usage") {
body.insert("usage".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_data") {
body.insert("payment_method_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_payment_methods") {
body.insert("automatic_payment_methods".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_options") {
body.insert("payment_method_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_types") {
body.insert("payment_method_types".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("flow_directions") {
body.insert("flow_directions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("single_use") {
body.insert("single_use".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("attach_to_self") {
body.insert("attach_to_self".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("confirmation_token") {
body.insert("confirmation_token".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/setup_intents failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all SetupIntents
///
/// Method: GET /v1/setup_intents
#[actor(
StripeReadSetupIntentsActor,
inports::<100>(attach_to_self, created, customer, customer_account, ending_before, expand, limit, payment_method, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_setup_intents(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/setup_intents".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("attach_to_self") {
query_pairs.push(("attach_to_self", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment_method") {
query_pairs.push(("payment_method", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/setup_intents failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a SetupIntent
///
/// Method: POST /v1/setup_intents/{intent}
#[actor(
StripeCreateSetupIntentsIntentActor,
inports::<100>(intent, excluded_payment_method_types, customer, payment_method, flow_directions, payment_method_data, payment_method_options, payment_method_types, attach_to_self, payment_method_configuration, metadata, description, expand, customer_account),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_setup_intents_intent(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/setup_intents/{intent}".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("excluded_payment_method_types") {
body.insert(
"excluded_payment_method_types".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("flow_directions") {
body.insert("flow_directions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_data") {
body.insert("payment_method_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_options") {
body.insert("payment_method_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_types") {
body.insert("payment_method_types".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("attach_to_self") {
body.insert("attach_to_self".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_configuration") {
body.insert(
"payment_method_configuration".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/setup_intents/{{intent}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a SetupIntent
///
/// Method: GET /v1/setup_intents/{intent}
#[actor(
StripeReadSetupIntentsIntentActor,
inports::<100>(client_secret, expand, intent, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_setup_intents_intent(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/setup_intents/{intent}".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("client_secret") {
query_pairs.push(("client_secret", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/setup_intents/{{intent}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Cancel a SetupIntent
///
/// Method: POST /v1/setup_intents/{intent}/cancel
#[actor(
StripeCreateSetupIntentsIntentCancelActor,
inports::<100>(intent, cancellation_reason, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_setup_intents_intent_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/setup_intents/{intent}/cancel".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("cancellation_reason") {
body.insert("cancellation_reason".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/setup_intents/{{intent}}/cancel failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Confirm a SetupIntent
///
/// Method: POST /v1/setup_intents/{intent}/confirm
#[actor(
StripeCreateSetupIntentsIntentConfirmActor,
inports::<100>(intent, return_url, payment_method_options, expand, payment_method_data, confirmation_token, client_secret, payment_method, mandate_data, use_stripe_sdk),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_setup_intents_intent_confirm(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/setup_intents/{intent}/confirm".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_options") {
body.insert("payment_method_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_data") {
body.insert("payment_method_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("confirmation_token") {
body.insert("confirmation_token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("client_secret") {
body.insert("client_secret".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mandate_data") {
body.insert("mandate_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("use_stripe_sdk") {
body.insert("use_stripe_sdk".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/setup_intents/{{intent}}/confirm failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Verify microdeposits on a SetupIntent
///
/// Method: POST /v1/setup_intents/{intent}/verify_microdeposits
#[actor(
StripeCreateSetupIntentsIntentVerifyMicrodepositsActor,
inports::<100>(intent, client_secret, expand, amounts, descriptor_code),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_setup_intents_intent_verify_microdeposits(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/setup_intents/{intent}/verify_microdeposits".to_string();
if let Some(val) = inputs.get("intent") {
endpoint = endpoint.replace("{{intent}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("client_secret") {
body.insert("client_secret".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amounts") {
body.insert("amounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("descriptor_code") {
body.insert("descriptor_code".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/setup_intents/{{intent}}/verify_microdeposits failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all shipping rates
///
/// Method: GET /v1/shipping_rates
#[actor(
StripeReadShippingRatesActor,
inports::<100>(active, created, currency, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_shipping_rates(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/shipping_rates".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("active") {
query_pairs.push(("active", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("currency") {
query_pairs.push(("currency", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/shipping_rates failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a shipping rate
///
/// Method: POST /v1/shipping_rates
#[actor(
StripeCreateShippingRatesActor,
inports::<100>(type_, delivery_estimate, display_name, fixed_amount, tax_behavior, tax_code, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_shipping_rates(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/shipping_rates".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("delivery_estimate") {
body.insert("delivery_estimate".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("display_name") {
body.insert("display_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fixed_amount") {
body.insert("fixed_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_behavior") {
body.insert("tax_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_code") {
body.insert("tax_code".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/shipping_rates failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a shipping rate
///
/// Method: GET /v1/shipping_rates/{shipping_rate_token}
#[actor(
StripeReadShippingRatesShippingRateTokenActor,
inports::<100>(expand, shipping_rate_token, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_shipping_rates_shipping_rate_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/shipping_rates/{shipping_rate_token}".to_string();
if let Some(val) = inputs.get("shipping_rate_token") {
endpoint = endpoint.replace("{{shipping_rate_token}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/shipping_rates/{{shipping_rate_token}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a shipping rate
///
/// Method: POST /v1/shipping_rates/{shipping_rate_token}
#[actor(
StripeCreateShippingRatesShippingRateTokenActor,
inports::<100>(shipping_rate_token, active, expand, fixed_amount, metadata, tax_behavior),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_shipping_rates_shipping_rate_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/shipping_rates/{shipping_rate_token}".to_string();
if let Some(val) = inputs.get("shipping_rate_token") {
endpoint = endpoint.replace("{{shipping_rate_token}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fixed_amount") {
body.insert("fixed_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_behavior") {
body.insert("tax_behavior".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/shipping_rates/{{shipping_rate_token}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update an existing Sigma Query
///
/// Method: POST /v1/sigma/saved_queries/{id}
#[actor(
StripeCreateSigmaSavedQueriesIdActor,
inports::<100>(id, name, expand, sql),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_sigma_saved_queries_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sigma/saved_queries/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("sql") {
body.insert("sql".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/sigma/saved_queries/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all scheduled query runs
///
/// Method: GET /v1/sigma/scheduled_query_runs
#[actor(
StripeReadSigmaScheduledQueryRunsActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_sigma_scheduled_query_runs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/sigma/scheduled_query_runs".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/sigma/scheduled_query_runs failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a scheduled query run
///
/// Method: GET /v1/sigma/scheduled_query_runs/{scheduled_query_run}
#[actor(
StripeReadSigmaScheduledQueryRunsScheduledQueryRunActor,
inports::<100>(expand, scheduled_query_run, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_sigma_scheduled_query_runs_scheduled_query_run(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sigma/scheduled_query_runs/{scheduled_query_run}".to_string();
if let Some(val) = inputs.get("scheduled_query_run") {
endpoint = endpoint.replace("{{scheduled_query_run}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/sigma/scheduled_query_runs/{{scheduled_query_run}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Shares a source
///
/// Method: POST /v1/sources
#[actor(
StripeCreateSourcesActor,
inports::<100>(amount, type_, statement_descriptor, customer, receiver, original_source, token, currency, owner, source_order, redirect, usage, mandate, metadata, flow, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_sources(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/sources".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("receiver") {
body.insert("receiver".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("original_source") {
body.insert("original_source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("token") {
body.insert("token".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("owner") {
body.insert("owner".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source_order") {
body.insert("source_order".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("redirect") {
body.insert("redirect".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("usage") {
body.insert("usage".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mandate") {
body.insert("mandate".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("flow") {
body.insert("flow".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/sources failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a source
///
/// Method: GET /v1/sources/{source}
#[actor(
StripeReadSourcesSourceActor,
inports::<100>(client_secret, expand, source, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_sources_source(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sources/{source}".to_string();
if let Some(val) = inputs.get("source") {
endpoint = endpoint.replace("{{source}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("client_secret") {
query_pairs.push(("client_secret", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/sources/{{source}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a source
///
/// Method: POST /v1/sources/{source}
#[actor(
StripeCreateSourcesSourceActor,
inports::<100>(source, expand, mandate, metadata, owner, amount, source_order),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_sources_source(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sources/{source}".to_string();
if let Some(val) = inputs.get("source") {
endpoint = endpoint.replace("{{source}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mandate") {
body.insert("mandate".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("owner") {
body.insert("owner".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source_order") {
body.insert("source_order".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/sources/{{source}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a Source MandateNotification
///
/// Method: GET /v1/sources/{source}/mandate_notifications/{mandate_notification}
#[actor(
StripeReadSourcesSourceMandateNotificationsMandateNotificationActor,
inports::<100>(expand, mandate_notification, source, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_sources_source_mandate_notifications_mandate_notification(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/sources/{source}/mandate_notifications/{mandate_notification}".to_string();
if let Some(val) = inputs.get("mandate_notification") {
endpoint = endpoint.replace("{{mandate_notification}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("source") {
endpoint = endpoint.replace("{{source}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/sources/{{source}}/mandate_notifications/{{mandate_notification}} failed: {}", e).into()));
}
}
Ok(output)
}
/// <p>List source transactions for a given source.</p>
///
/// Method: GET /v1/sources/{source}/source_transactions
#[actor(
StripeReadSourcesSourceSourceTransactionsActor,
inports::<100>(ending_before, expand, limit, source, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_sources_source_source_transactions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sources/{source}/source_transactions".to_string();
if let Some(val) = inputs.get("source") {
endpoint = endpoint.replace("{{source}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/sources/{{source}}/source_transactions failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a source transaction
///
/// Method: GET /v1/sources/{source}/source_transactions/{source_transaction}
#[actor(
StripeReadSourcesSourceSourceTransactionsSourceTransactionActor,
inports::<100>(expand, source, source_transaction, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_sources_source_source_transactions_source_transaction(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sources/{source}/source_transactions/{source_transaction}".to_string();
if let Some(val) = inputs.get("source") {
endpoint = endpoint.replace("{{source}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("source_transaction") {
endpoint = endpoint.replace("{{source_transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/sources/{{source}}/source_transactions/{{source_transaction}} failed: {}", e).into()));
}
}
Ok(output)
}
/// <p>Verify a given source.</p>
///
/// Method: POST /v1/sources/{source}/verify
#[actor(
StripeCreateSourcesSourceVerifyActor,
inports::<100>(source, expand, values),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_sources_source_verify(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/sources/{source}/verify".to_string();
if let Some(val) = inputs.get("source") {
endpoint = endpoint.replace("{{source}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("values") {
body.insert("values".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/sources/{{source}}/verify failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all subscription items
///
/// Method: GET /v1/subscription_items
#[actor(
StripeReadSubscriptionItemsActor,
inports::<100>(ending_before, expand, limit, starting_after, subscription, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_subscription_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/subscription_items".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("subscription") {
query_pairs.push(("subscription", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/subscription_items failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a subscription item
///
/// Method: POST /v1/subscription_items
#[actor(
StripeCreateSubscriptionItemsActor,
inports::<100>(proration_behavior, tax_rates, quantity, subscription, billing_thresholds, payment_behavior, proration_date, price_data, price, discounts, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscription_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/subscription_items".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("proration_behavior") {
body.insert("proration_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_rates") {
body.insert("tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("quantity") {
body.insert("quantity".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("subscription") {
body.insert("subscription".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_thresholds") {
body.insert("billing_thresholds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_behavior") {
body.insert("payment_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("proration_date") {
body.insert("proration_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("price_data") {
body.insert("price_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("price") {
body.insert("price".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/subscription_items failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a subscription item
///
/// Method: POST /v1/subscription_items/{item}
#[actor(
StripeCreateSubscriptionItemsItemActor,
inports::<100>(item, proration_behavior, off_session, billing_thresholds, quantity, proration_date, expand, metadata, price, payment_behavior, discounts, price_data, tax_rates),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscription_items_item(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscription_items/{item}".to_string();
if let Some(val) = inputs.get("item") {
endpoint = endpoint.replace("{{item}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("proration_behavior") {
body.insert("proration_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("off_session") {
body.insert("off_session".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_thresholds") {
body.insert("billing_thresholds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("quantity") {
body.insert("quantity".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("proration_date") {
body.insert("proration_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("price") {
body.insert("price".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_behavior") {
body.insert("payment_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("price_data") {
body.insert("price_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_rates") {
body.insert("tax_rates".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/subscription_items/{{item}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a subscription item
///
/// Method: GET /v1/subscription_items/{item}
#[actor(
StripeReadSubscriptionItemsItemActor,
inports::<100>(expand, item, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_subscription_items_item(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscription_items/{item}".to_string();
if let Some(val) = inputs.get("item") {
endpoint = endpoint.replace("{{item}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/subscription_items/{{item}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a subscription item
///
/// Method: DELETE /v1/subscription_items/{item}
#[actor(
StripeDeleteSubscriptionItemsItemActor,
inports::<100>(item, proration_behavior, clear_usage, proration_date, payment_behavior),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_subscription_items_item(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscription_items/{item}".to_string();
if let Some(val) = inputs.get("item") {
endpoint = endpoint.replace("{{item}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/subscription_items/{{item}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all schedules
///
/// Method: GET /v1/subscription_schedules
#[actor(
StripeReadSubscriptionSchedulesActor,
inports::<100>(canceled_at, completed_at, created, customer, customer_account, ending_before, expand, limit, released_at, scheduled, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_subscription_schedules(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/subscription_schedules".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("canceled_at") {
query_pairs.push(("canceled_at", super::message_to_str(val)));
}
if let Some(val) = inputs.get("completed_at") {
query_pairs.push(("completed_at", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("released_at") {
query_pairs.push(("released_at", super::message_to_str(val)));
}
if let Some(val) = inputs.get("scheduled") {
query_pairs.push(("scheduled", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/subscription_schedules failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a schedule
///
/// Method: POST /v1/subscription_schedules
#[actor(
StripeCreateSubscriptionSchedulesActor,
inports::<100>(customer, default_settings, phases, expand, start_date, metadata, customer_account, billing_mode, end_behavior, from_subscription),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscription_schedules(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/subscription_schedules".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_settings") {
body.insert("default_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phases") {
body.insert("phases".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("start_date") {
body.insert("start_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_mode") {
body.insert("billing_mode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("end_behavior") {
body.insert("end_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("from_subscription") {
body.insert("from_subscription".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/subscription_schedules failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a schedule
///
/// Method: GET /v1/subscription_schedules/{schedule}
#[actor(
StripeReadSubscriptionSchedulesScheduleActor,
inports::<100>(expand, schedule, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_subscription_schedules_schedule(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscription_schedules/{schedule}".to_string();
if let Some(val) = inputs.get("schedule") {
endpoint = endpoint.replace("{{schedule}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/subscription_schedules/{{schedule}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a schedule
///
/// Method: POST /v1/subscription_schedules/{schedule}
#[actor(
StripeCreateSubscriptionSchedulesScheduleActor,
inports::<100>(schedule, end_behavior, expand, phases, metadata, proration_behavior, default_settings),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscription_schedules_schedule(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscription_schedules/{schedule}".to_string();
if let Some(val) = inputs.get("schedule") {
endpoint = endpoint.replace("{{schedule}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("end_behavior") {
body.insert("end_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phases") {
body.insert("phases".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("proration_behavior") {
body.insert("proration_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_settings") {
body.insert("default_settings".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/subscription_schedules/{{schedule}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Cancel a schedule
///
/// Method: POST /v1/subscription_schedules/{schedule}/cancel
#[actor(
StripeCreateSubscriptionSchedulesScheduleCancelActor,
inports::<100>(schedule, invoice_now, prorate, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscription_schedules_schedule_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscription_schedules/{schedule}/cancel".to_string();
if let Some(val) = inputs.get("schedule") {
endpoint = endpoint.replace("{{schedule}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("invoice_now") {
body.insert("invoice_now".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("prorate") {
body.insert("prorate".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/subscription_schedules/{{schedule}}/cancel failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Release a schedule
///
/// Method: POST /v1/subscription_schedules/{schedule}/release
#[actor(
StripeCreateSubscriptionSchedulesScheduleReleaseActor,
inports::<100>(schedule, preserve_cancel_date, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscription_schedules_schedule_release(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscription_schedules/{schedule}/release".to_string();
if let Some(val) = inputs.get("schedule") {
endpoint = endpoint.replace("{{schedule}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("preserve_cancel_date") {
body.insert("preserve_cancel_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/subscription_schedules/{{schedule}}/release failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a subscription
///
/// Method: POST /v1/subscriptions
#[actor(
StripeCreateSubscriptionsActor,
inports::<100>(default_source, invoice_settings, metadata, discounts, payment_settings, billing_cycle_anchor, pending_invoice_item_interval, billing_cycle_anchor_config, trial_from_plan, default_payment_method, days_until_due, cancel_at, payment_behavior, automatic_tax, add_invoice_items, application_fee_percent, off_session, description, currency, items, proration_behavior, backdate_start_date, collection_method, on_behalf_of, trial_settings, billing_thresholds, customer, transfer_data, trial_end, trial_period_days, customer_account, cancel_at_period_end, default_tax_rates, billing_mode, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscriptions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/subscriptions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("default_source") {
body.insert("default_source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_settings") {
body.insert("invoice_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_settings") {
body.insert("payment_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_cycle_anchor") {
body.insert("billing_cycle_anchor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pending_invoice_item_interval") {
body.insert(
"pending_invoice_item_interval".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("billing_cycle_anchor_config") {
body.insert(
"billing_cycle_anchor_config".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("trial_from_plan") {
body.insert("trial_from_plan".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_payment_method") {
body.insert("default_payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("days_until_due") {
body.insert("days_until_due".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancel_at") {
body.insert("cancel_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_behavior") {
body.insert("payment_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("add_invoice_items") {
body.insert("add_invoice_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_percent") {
body.insert("application_fee_percent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("off_session") {
body.insert("off_session".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("items") {
body.insert("items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("proration_behavior") {
body.insert("proration_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("backdate_start_date") {
body.insert("backdate_start_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collection_method") {
body.insert("collection_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_settings") {
body.insert("trial_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_thresholds") {
body.insert("billing_thresholds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_end") {
body.insert("trial_end".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_period_days") {
body.insert("trial_period_days".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_account") {
body.insert("customer_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancel_at_period_end") {
body.insert("cancel_at_period_end".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_tax_rates") {
body.insert("default_tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_mode") {
body.insert("billing_mode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/subscriptions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List subscriptions
///
/// Method: GET /v1/subscriptions
#[actor(
StripeReadSubscriptionsActor,
inports::<100>(automatic_tax, collection_method, created, current_period_end, current_period_start, customer, customer_account, ending_before, expand, limit, price, starting_after, status, test_clock, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_subscriptions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/subscriptions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("automatic_tax") {
query_pairs.push(("automatic_tax", super::message_to_str(val)));
}
if let Some(val) = inputs.get("collection_method") {
query_pairs.push(("collection_method", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("current_period_end") {
query_pairs.push(("current_period_end", super::message_to_str(val)));
}
if let Some(val) = inputs.get("current_period_start") {
query_pairs.push(("current_period_start", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer_account") {
query_pairs.push(("customer_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("price") {
query_pairs.push(("price", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if let Some(val) = inputs.get("test_clock") {
query_pairs.push(("test_clock", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/subscriptions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Search subscriptions
///
/// Method: GET /v1/subscriptions/search
#[actor(
StripeReadSubscriptionsSearchActor,
inports::<100>(expand, limit, page, query, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_subscriptions_search(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/subscriptions/search".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("page") {
query_pairs.push(("page", super::message_to_str(val)));
}
if let Some(val) = inputs.get("query") {
query_pairs.push(("query", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/subscriptions/search failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a subscription
///
/// Method: GET /v1/subscriptions/{subscription_exposed_id}
#[actor(
StripeReadSubscriptionsSubscriptionExposedIdActor,
inports::<100>(expand, subscription_exposed_id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_subscriptions_subscription_exposed_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscriptions/{subscription_exposed_id}".to_string();
if let Some(val) = inputs.get("subscription_exposed_id") {
endpoint = endpoint.replace("{{subscription_exposed_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/subscriptions/{{subscription_exposed_id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a subscription
///
/// Method: POST /v1/subscriptions/{subscription_exposed_id}
#[actor(
StripeCreateSubscriptionsSubscriptionExposedIdActor,
inports::<100>(subscription_exposed_id, default_source, application_fee_percent, description, pending_invoice_item_interval, proration_date, expand, trial_settings, on_behalf_of, proration_behavior, automatic_tax, cancel_at_period_end, collection_method, cancel_at, billing_cycle_anchor, items, billing_thresholds, payment_behavior, add_invoice_items, trial_end, off_session, invoice_settings, default_payment_method, cancellation_details, trial_from_plan, payment_settings, default_tax_rates, days_until_due, transfer_data, metadata, discounts, pause_collection),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscriptions_subscription_exposed_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscriptions/{subscription_exposed_id}".to_string();
if let Some(val) = inputs.get("subscription_exposed_id") {
endpoint = endpoint.replace("{{subscription_exposed_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("default_source") {
body.insert("default_source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("application_fee_percent") {
body.insert("application_fee_percent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pending_invoice_item_interval") {
body.insert(
"pending_invoice_item_interval".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("proration_date") {
body.insert("proration_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_settings") {
body.insert("trial_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("proration_behavior") {
body.insert("proration_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("automatic_tax") {
body.insert("automatic_tax".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancel_at_period_end") {
body.insert("cancel_at_period_end".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collection_method") {
body.insert("collection_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancel_at") {
body.insert("cancel_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_cycle_anchor") {
body.insert("billing_cycle_anchor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("items") {
body.insert("items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_thresholds") {
body.insert("billing_thresholds".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_behavior") {
body.insert("payment_behavior".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("add_invoice_items") {
body.insert("add_invoice_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_end") {
body.insert("trial_end".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("off_session") {
body.insert("off_session".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("invoice_settings") {
body.insert("invoice_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_payment_method") {
body.insert("default_payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cancellation_details") {
body.insert("cancellation_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("trial_from_plan") {
body.insert("trial_from_plan".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_settings") {
body.insert("payment_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("default_tax_rates") {
body.insert("default_tax_rates".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("days_until_due") {
body.insert("days_until_due".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_data") {
body.insert("transfer_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("discounts") {
body.insert("discounts".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pause_collection") {
body.insert("pause_collection".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/subscriptions/{{subscription_exposed_id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Cancel a subscription
///
/// Method: DELETE /v1/subscriptions/{subscription_exposed_id}
#[actor(
StripeDeleteSubscriptionsSubscriptionExposedIdActor,
inports::<100>(subscription_exposed_id, cancellation_details, expand, prorate, invoice_now),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_subscriptions_subscription_exposed_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscriptions/{subscription_exposed_id}".to_string();
if let Some(val) = inputs.get("subscription_exposed_id") {
endpoint = endpoint.replace("{{subscription_exposed_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/subscriptions/{{subscription_exposed_id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete a subscription discount
///
/// Method: DELETE /v1/subscriptions/{subscription_exposed_id}/discount
#[actor(
StripeDeleteSubscriptionsSubscriptionExposedIdDiscountActor,
inports::<100>(subscription_exposed_id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_subscriptions_subscription_exposed_id_discount(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscriptions/{subscription_exposed_id}/discount".to_string();
if let Some(val) = inputs.get("subscription_exposed_id") {
endpoint = endpoint.replace("{{subscription_exposed_id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/subscriptions/{{subscription_exposed_id}}/discount failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Migrate a subscription
///
/// Method: POST /v1/subscriptions/{subscription}/migrate
#[actor(
StripeCreateSubscriptionsSubscriptionMigrateActor,
inports::<100>(subscription, expand, billing_mode),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscriptions_subscription_migrate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscriptions/{subscription}/migrate".to_string();
if let Some(val) = inputs.get("subscription") {
endpoint = endpoint.replace("{{subscription}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_mode") {
body.insert("billing_mode".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/subscriptions/{{subscription}}/migrate failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Resume a subscription
///
/// Method: POST /v1/subscriptions/{subscription}/resume
#[actor(
StripeCreateSubscriptionsSubscriptionResumeActor,
inports::<100>(subscription, proration_date, billing_cycle_anchor, expand, proration_behavior),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_subscriptions_subscription_resume(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/subscriptions/{subscription}/resume".to_string();
if let Some(val) = inputs.get("subscription") {
endpoint = endpoint.replace("{{subscription}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("proration_date") {
body.insert("proration_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("billing_cycle_anchor") {
body.insert("billing_cycle_anchor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("proration_behavior") {
body.insert("proration_behavior".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/subscriptions/{{subscription}}/resume failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Find a Tax Association
///
/// Method: GET /v1/tax/associations/find
#[actor(
StripeReadTaxAssociationsFindActor,
inports::<100>(expand, payment_intent, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_associations_find(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax/associations/find".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("payment_intent") {
query_pairs.push(("payment_intent", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax/associations/find failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a Tax Calculation
///
/// Method: POST /v1/tax/calculations
#[actor(
StripeCreateTaxCalculationsActor,
inports::<100>(currency, shipping_cost, tax_date, customer, expand, ship_from_details, line_items, customer_details),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tax_calculations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax/calculations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_cost") {
body.insert("shipping_cost".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_date") {
body.insert("tax_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("ship_from_details") {
body.insert("ship_from_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("line_items") {
body.insert("line_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("customer_details") {
body.insert("customer_details".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/tax/calculations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a Tax Calculation
///
/// Method: GET /v1/tax/calculations/{calculation}
#[actor(
StripeReadTaxCalculationsCalculationActor,
inports::<100>(calculation, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_calculations_calculation(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax/calculations/{calculation}".to_string();
if let Some(val) = inputs.get("calculation") {
endpoint = endpoint.replace("{{calculation}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/tax/calculations/{{calculation}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a calculation's line items
///
/// Method: GET /v1/tax/calculations/{calculation}/line_items
#[actor(
StripeReadTaxCalculationsCalculationLineItemsActor,
inports::<100>(calculation, ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_calculations_calculation_line_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax/calculations/{calculation}/line_items".to_string();
if let Some(val) = inputs.get("calculation") {
endpoint = endpoint.replace("{{calculation}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/tax/calculations/{{calculation}}/line_items failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a registration
///
/// Method: POST /v1/tax/registrations
#[actor(
StripeCreateTaxRegistrationsActor,
inports::<100>(expires_at, country, country_options, active_from, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tax_registrations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax/registrations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("country") {
body.insert("country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("country_options") {
body.insert("country_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active_from") {
body.insert("active_from".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/tax/registrations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List registrations
///
/// Method: GET /v1/tax/registrations
#[actor(
StripeReadTaxRegistrationsActor,
inports::<100>(ending_before, expand, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_registrations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax/registrations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax/registrations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a registration
///
/// Method: GET /v1/tax/registrations/{id}
#[actor(
StripeReadTaxRegistrationsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_registrations_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax/registrations/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax/registrations/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a registration
///
/// Method: POST /v1/tax/registrations/{id}
#[actor(
StripeCreateTaxRegistrationsIdActor,
inports::<100>(id, expires_at, active_from, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tax_registrations_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax/registrations/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expires_at") {
body.insert("expires_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active_from") {
body.insert("active_from".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/tax/registrations/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve settings
///
/// Method: GET /v1/tax/settings
#[actor(
StripeReadTaxSettingsActor,
inports::<100>(expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_settings(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax/settings".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax/settings failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update settings
///
/// Method: POST /v1/tax/settings
#[actor(
StripeCreateTaxSettingsActor,
inports::<100>(expand, head_office, defaults),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tax_settings(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax/settings".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("head_office") {
body.insert("head_office".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("defaults") {
body.insert("defaults".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/tax/settings failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a transaction from a calculation
///
/// Method: POST /v1/tax/transactions/create_from_calculation
#[actor(
StripeCreateTaxTransactionsCreateFromCalculationActor,
inports::<100>(posted_at, calculation, expand, metadata, reference),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tax_transactions_create_from_calculation(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax/transactions/create_from_calculation".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("posted_at") {
body.insert("posted_at".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("calculation") {
body.insert("calculation".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reference") {
body.insert("reference".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/tax/transactions/create_from_calculation failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a reversal transaction
///
/// Method: POST /v1/tax/transactions/create_reversal
#[actor(
StripeCreateTaxTransactionsCreateReversalActor,
inports::<100>(reference, shipping_cost, flat_amount, mode, expand, original_transaction, line_items, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tax_transactions_create_reversal(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax/transactions/create_reversal".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("reference") {
body.insert("reference".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping_cost") {
body.insert("shipping_cost".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("flat_amount") {
body.insert("flat_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("mode") {
body.insert("mode".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("original_transaction") {
body.insert("original_transaction".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("line_items") {
body.insert("line_items".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/tax/transactions/create_reversal failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a transaction
///
/// Method: GET /v1/tax/transactions/{transaction}
#[actor(
StripeReadTaxTransactionsTransactionActor,
inports::<100>(expand, transaction, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_transactions_transaction(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax/transactions/{transaction}".to_string();
if let Some(val) = inputs.get("transaction") {
endpoint = endpoint.replace("{{transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/tax/transactions/{{transaction}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a transaction's line items
///
/// Method: GET /v1/tax/transactions/{transaction}/line_items
#[actor(
StripeReadTaxTransactionsTransactionLineItemsActor,
inports::<100>(ending_before, expand, limit, starting_after, transaction, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_transactions_transaction_line_items(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax/transactions/{transaction}/line_items".to_string();
if let Some(val) = inputs.get("transaction") {
endpoint = endpoint.replace("{{transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/tax/transactions/{{transaction}}/line_items failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all tax codes
///
/// Method: GET /v1/tax_codes
#[actor(
StripeReadTaxCodesActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_codes(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax_codes".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax_codes failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a tax code
///
/// Method: GET /v1/tax_codes/{id}
#[actor(
StripeReadTaxCodesIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_codes_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax_codes/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax_codes/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all tax IDs
///
/// Method: GET /v1/tax_ids
#[actor(
StripeReadTaxIdsActor,
inports::<100>(ending_before, expand, limit, owner, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_ids(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax_ids".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("owner") {
query_pairs.push(("owner", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax_ids failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a tax ID
///
/// Method: POST /v1/tax_ids
#[actor(
StripeCreateTaxIdsActor,
inports::<100>(type_, expand, owner, value),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tax_ids(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax_ids".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("owner") {
body.insert("owner".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("value") {
body.insert("value".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/tax_ids failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a tax ID
///
/// Method: DELETE /v1/tax_ids/{id}
#[actor(
StripeDeleteTaxIdsIdActor,
inports::<100>(id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_tax_ids_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax_ids/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("DELETE /v1/tax_ids/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a tax ID
///
/// Method: GET /v1/tax_ids/{id}
#[actor(
StripeReadTaxIdsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_ids_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax_ids/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax_ids/{{id}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a tax rate
///
/// Method: POST /v1/tax_rates
#[actor(
StripeCreateTaxRatesActor,
inports::<100>(display_name, expand, active, jurisdiction, inclusive, tax_type, state, description, country, metadata, percentage),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tax_rates(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax_rates".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("display_name") {
body.insert("display_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("jurisdiction") {
body.insert("jurisdiction".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("inclusive") {
body.insert("inclusive".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_type") {
body.insert("tax_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("state") {
body.insert("state".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("country") {
body.insert("country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("percentage") {
body.insert("percentage".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/tax_rates failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all tax rates
///
/// Method: GET /v1/tax_rates
#[actor(
StripeReadTaxRatesActor,
inports::<100>(active, created, ending_before, expand, inclusive, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_rates(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tax_rates".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("active") {
query_pairs.push(("active", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("inclusive") {
query_pairs.push(("inclusive", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax_rates failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a tax rate
///
/// Method: GET /v1/tax_rates/{tax_rate}
#[actor(
StripeReadTaxRatesTaxRateActor,
inports::<100>(expand, tax_rate, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tax_rates_tax_rate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax_rates/{tax_rate}".to_string();
if let Some(val) = inputs.get("tax_rate") {
endpoint = endpoint.replace("{{tax_rate}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tax_rates/{{tax_rate}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a tax rate
///
/// Method: POST /v1/tax_rates/{tax_rate}
#[actor(
StripeCreateTaxRatesTaxRateActor,
inports::<100>(tax_rate, display_name, metadata, jurisdiction, active, expand, country, tax_type, description, state),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tax_rates_tax_rate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tax_rates/{tax_rate}".to_string();
if let Some(val) = inputs.get("tax_rate") {
endpoint = endpoint.replace("{{tax_rate}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("display_name") {
body.insert("display_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("jurisdiction") {
body.insert("jurisdiction".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("active") {
body.insert("active".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("country") {
body.insert("country".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tax_type") {
body.insert("tax_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("state") {
body.insert("state".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/tax_rates/{{tax_rate}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all Configurations
///
/// Method: GET /v1/terminal/configurations
#[actor(
StripeReadTerminalConfigurationsActor,
inports::<100>(ending_before, expand, is_account_default, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_terminal_configurations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/terminal/configurations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("is_account_default") {
query_pairs.push(("is_account_default", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/terminal/configurations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a Configuration
///
/// Method: POST /v1/terminal/configurations
#[actor(
StripeCreateTerminalConfigurationsActor,
inports::<100>(expand, name, bbpos_wisepos_e, offline, cellular, stripe_s700, bbpos_wisepad3, stripe_s710, tipping, reboot_window, verifone_p400, wifi),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_configurations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/terminal/configurations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bbpos_wisepos_e") {
body.insert("bbpos_wisepos_e".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("offline") {
body.insert("offline".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cellular") {
body.insert("cellular".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("stripe_s700") {
body.insert("stripe_s700".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bbpos_wisepad3") {
body.insert("bbpos_wisepad3".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("stripe_s710") {
body.insert("stripe_s710".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tipping") {
body.insert("tipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reboot_window") {
body.insert("reboot_window".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("verifone_p400") {
body.insert("verifone_p400".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("wifi") {
body.insert("wifi".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/terminal/configurations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a Configuration
///
/// Method: POST /v1/terminal/configurations/{configuration}
#[actor(
StripeCreateTerminalConfigurationsConfigurationActor,
inports::<100>(configuration, cellular, offline, verifone_p400, expand, name, bbpos_wisepos_e, bbpos_wisepad3, reboot_window, stripe_s700, tipping, stripe_s710, wifi),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_configurations_configuration(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/configurations/{configuration}".to_string();
if let Some(val) = inputs.get("configuration") {
endpoint = endpoint.replace("{{configuration}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("cellular") {
body.insert("cellular".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("offline") {
body.insert("offline".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("verifone_p400") {
body.insert("verifone_p400".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bbpos_wisepos_e") {
body.insert("bbpos_wisepos_e".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bbpos_wisepad3") {
body.insert("bbpos_wisepad3".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reboot_window") {
body.insert("reboot_window".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("stripe_s700") {
body.insert("stripe_s700".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tipping") {
body.insert("tipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("stripe_s710") {
body.insert("stripe_s710".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("wifi") {
body.insert("wifi".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/terminal/configurations/{{configuration}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete a Configuration
///
/// Method: DELETE /v1/terminal/configurations/{configuration}
#[actor(
StripeDeleteTerminalConfigurationsConfigurationActor,
inports::<100>(configuration, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_terminal_configurations_configuration(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/configurations/{configuration}".to_string();
if let Some(val) = inputs.get("configuration") {
endpoint = endpoint.replace("{{configuration}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/terminal/configurations/{{configuration}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Configuration
///
/// Method: GET /v1/terminal/configurations/{configuration}
#[actor(
StripeReadTerminalConfigurationsConfigurationActor,
inports::<100>(configuration, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_terminal_configurations_configuration(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/configurations/{configuration}".to_string();
if let Some(val) = inputs.get("configuration") {
endpoint = endpoint.replace("{{configuration}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/terminal/configurations/{{configuration}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a Connection Token
///
/// Method: POST /v1/terminal/connection_tokens
#[actor(
StripeCreateTerminalConnectionTokensActor,
inports::<100>(location, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_connection_tokens(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/terminal/connection_tokens".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("location") {
body.insert("location".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/terminal/connection_tokens failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all Locations
///
/// Method: GET /v1/terminal/locations
#[actor(
StripeReadTerminalLocationsActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_terminal_locations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/terminal/locations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/terminal/locations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a Location
///
/// Method: POST /v1/terminal/locations
#[actor(
StripeCreateTerminalLocationsActor,
inports::<100>(display_name_kana, address, address_kanji, display_name, expand, metadata, address_kana, configuration_overrides, phone, display_name_kanji),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_locations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/terminal/locations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("display_name_kana") {
body.insert("display_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address") {
body.insert("address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kanji") {
body.insert("address_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("display_name") {
body.insert("display_name".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kana") {
body.insert("address_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("configuration_overrides") {
body.insert("configuration_overrides".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone") {
body.insert("phone".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("display_name_kanji") {
body.insert("display_name_kanji".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/terminal/locations failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a Location
///
/// Method: DELETE /v1/terminal/locations/{location}
#[actor(
StripeDeleteTerminalLocationsLocationActor,
inports::<100>(location, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_terminal_locations_location(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/locations/{location}".to_string();
if let Some(val) = inputs.get("location") {
endpoint = endpoint.replace("{{location}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/terminal/locations/{{location}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Update a Location
///
/// Method: POST /v1/terminal/locations/{location}
#[actor(
StripeCreateTerminalLocationsLocationActor,
inports::<100>(location, metadata, configuration_overrides, address, phone, display_name_kanji, expand, display_name_kana, address_kana, address_kanji, display_name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_locations_location(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/locations/{location}".to_string();
if let Some(val) = inputs.get("location") {
endpoint = endpoint.replace("{{location}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("configuration_overrides") {
body.insert("configuration_overrides".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address") {
body.insert("address".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("phone") {
body.insert("phone".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("display_name_kanji") {
body.insert("display_name_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("display_name_kana") {
body.insert("display_name_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kana") {
body.insert("address_kana".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("address_kanji") {
body.insert("address_kanji".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("display_name") {
body.insert("display_name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/terminal/locations/{{location}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Location
///
/// Method: GET /v1/terminal/locations/{location}
#[actor(
StripeReadTerminalLocationsLocationActor,
inports::<100>(expand, location, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_terminal_locations_location(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/locations/{location}".to_string();
if let Some(val) = inputs.get("location") {
endpoint = endpoint.replace("{{location}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/terminal/locations/{{location}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create an Onboarding Link
///
/// Method: POST /v1/terminal/onboarding_links
#[actor(
StripeCreateTerminalOnboardingLinksActor,
inports::<100>(expand, link_type, link_options, on_behalf_of),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_onboarding_links(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/terminal/onboarding_links".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("link_type") {
body.insert("link_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("link_options") {
body.insert("link_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("on_behalf_of") {
body.insert("on_behalf_of".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/terminal/onboarding_links failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all Readers
///
/// Method: GET /v1/terminal/readers
#[actor(
StripeReadTerminalReadersActor,
inports::<100>(device_type, ending_before, expand, limit, location, serial_number, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_terminal_readers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/terminal/readers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("device_type") {
query_pairs.push(("device_type", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("location") {
query_pairs.push(("location", super::message_to_str(val)));
}
if let Some(val) = inputs.get("serial_number") {
query_pairs.push(("serial_number", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/terminal/readers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a Reader
///
/// Method: POST /v1/terminal/readers
#[actor(
StripeCreateTerminalReadersActor,
inports::<100>(label, registration_code, metadata, expand, location),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/terminal/readers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("label") {
body.insert("label".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("registration_code") {
body.insert("registration_code".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("location") {
body.insert("location".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/terminal/readers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a Reader
///
/// Method: DELETE /v1/terminal/readers/{reader}
#[actor(
StripeDeleteTerminalReadersReaderActor,
inports::<100>(reader, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_terminal_readers_reader(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("DELETE /v1/terminal/readers/{{reader}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a Reader
///
/// Method: GET /v1/terminal/readers/{reader}
#[actor(
StripeReadTerminalReadersReaderActor,
inports::<100>(expand, reader, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_terminal_readers_reader(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/terminal/readers/{{reader}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a Reader
///
/// Method: POST /v1/terminal/readers/{reader}
#[actor(
StripeCreateTerminalReadersReaderActor,
inports::<100>(reader, expand, label, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers_reader(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("label") {
body.insert("label".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/terminal/readers/{{reader}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Cancel the current reader action
///
/// Method: POST /v1/terminal/readers/{reader}/cancel_action
#[actor(
StripeCreateTerminalReadersReaderCancelActionActor,
inports::<100>(reader, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers_reader_cancel_action(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}/cancel_action".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/terminal/readers/{{reader}}/cancel_action failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Collect inputs using a Reader
///
/// Method: POST /v1/terminal/readers/{reader}/collect_inputs
#[actor(
StripeCreateTerminalReadersReaderCollectInputsActor,
inports::<100>(reader, metadata, inputs, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers_reader_collect_inputs(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}/collect_inputs".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("inputs") {
body.insert("inputs".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/terminal/readers/{{reader}}/collect_inputs failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Hand off a PaymentIntent to a Reader and collect card details
///
/// Method: POST /v1/terminal/readers/{reader}/collect_payment_method
#[actor(
StripeCreateTerminalReadersReaderCollectPaymentMethodActor,
inports::<100>(reader, expand, payment_intent, collect_config),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers_reader_collect_payment_method(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}/collect_payment_method".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent") {
body.insert("payment_intent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("collect_config") {
body.insert("collect_config".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/terminal/readers/{{reader}}/collect_payment_method failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Confirm a PaymentIntent on the Reader
///
/// Method: POST /v1/terminal/readers/{reader}/confirm_payment_intent
#[actor(
StripeCreateTerminalReadersReaderConfirmPaymentIntentActor,
inports::<100>(reader, expand, payment_intent, confirm_config),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers_reader_confirm_payment_intent(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}/confirm_payment_intent".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent") {
body.insert("payment_intent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("confirm_config") {
body.insert("confirm_config".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/terminal/readers/{{reader}}/confirm_payment_intent failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Hand-off a PaymentIntent to a Reader
///
/// Method: POST /v1/terminal/readers/{reader}/process_payment_intent
#[actor(
StripeCreateTerminalReadersReaderProcessPaymentIntentActor,
inports::<100>(reader, process_config, expand, payment_intent),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers_reader_process_payment_intent(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}/process_payment_intent".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("process_config") {
body.insert("process_config".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent") {
body.insert("payment_intent".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/terminal/readers/{{reader}}/process_payment_intent failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Hand-off a SetupIntent to a Reader
///
/// Method: POST /v1/terminal/readers/{reader}/process_setup_intent
#[actor(
StripeCreateTerminalReadersReaderProcessSetupIntentActor,
inports::<100>(reader, process_config, setup_intent, allow_redisplay, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers_reader_process_setup_intent(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}/process_setup_intent".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("process_config") {
body.insert("process_config".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("setup_intent") {
body.insert("setup_intent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("allow_redisplay") {
body.insert("allow_redisplay".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/terminal/readers/{{reader}}/process_setup_intent failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Refund a Charge or a PaymentIntent in-person
///
/// Method: POST /v1/terminal/readers/{reader}/refund_payment
#[actor(
StripeCreateTerminalReadersReaderRefundPaymentActor,
inports::<100>(reader, reverse_transfer, amount, expand, metadata, refund_application_fee, payment_intent, charge, refund_payment_config),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers_reader_refund_payment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}/refund_payment".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("reverse_transfer") {
body.insert("reverse_transfer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("refund_application_fee") {
body.insert("refund_application_fee".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent") {
body.insert("payment_intent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("charge") {
body.insert("charge".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("refund_payment_config") {
body.insert("refund_payment_config".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/terminal/readers/{{reader}}/refund_payment failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Set reader display
///
/// Method: POST /v1/terminal/readers/{reader}/set_reader_display
#[actor(
StripeCreateTerminalReadersReaderSetReaderDisplayActor,
inports::<100>(reader, cart, type_, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_readers_reader_set_reader_display(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/terminal/readers/{reader}/set_reader_display".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("cart") {
body.insert("cart".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/terminal/readers/{{reader}}/set_reader_display failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a refund using a Terminal-supported device.
///
/// Method: POST /v1/terminal/refunds
#[actor(
StripeCreateTerminalRefundsActor,
inports::<100>(charge, payment_intent, metadata, refund_application_fee, amount, reason, expand, reverse_transfer),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_terminal_refunds(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/terminal/refunds".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("charge") {
body.insert("charge".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_intent") {
body.insert("payment_intent".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("refund_application_fee") {
body.insert("refund_application_fee".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reason") {
body.insert("reason".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reverse_transfer") {
body.insert("reverse_transfer".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/terminal/refunds failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a test Confirmation Token
///
/// Method: POST /v1/test_helpers/confirmation_tokens
#[actor(
StripeCreateTestHelpersConfirmationTokensActor,
inports::<100>(return_url, payment_method, payment_method_data, setup_future_usage, payment_method_options, shipping, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_confirmation_tokens(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/test_helpers/confirmation_tokens".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("return_url") {
body.insert("return_url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method") {
body.insert("payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_data") {
body.insert("payment_method_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("setup_future_usage") {
body.insert("setup_future_usage".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("payment_method_options") {
body.insert("payment_method_options".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("shipping") {
body.insert("shipping".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/test_helpers/confirmation_tokens failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Fund a test mode cash balance
///
/// Method: POST /v1/test_helpers/customers/{customer}/fund_cash_balance
#[actor(
StripeCreateTestHelpersCustomersCustomerFundCashBalanceActor,
inports::<100>(customer, currency, amount, expand, reference),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_customers_customer_fund_cash_balance(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/customers/{customer}/fund_cash_balance".to_string();
if let Some(val) = inputs.get("customer") {
endpoint = endpoint.replace("{{customer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reference") {
body.insert("reference".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/customers/{{customer}}/fund_cash_balance failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a test-mode authorization
///
/// Method: POST /v1/test_helpers/issuing/authorizations
#[actor(
StripeCreateTestHelpersIssuingAuthorizationsActor,
inports::<100>(expand, merchant_currency, merchant_amount, network_data, verification_data, authorization_method, merchant_data, is_amount_controllable, currency, fleet, amount, fuel, amount_details, risk_assessment, card, wallet, fraud_disputability_likelihood),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_authorizations(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/test_helpers/issuing/authorizations".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("merchant_currency") {
body.insert("merchant_currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("merchant_amount") {
body.insert("merchant_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("network_data") {
body.insert("network_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("verification_data") {
body.insert("verification_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("authorization_method") {
body.insert("authorization_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("merchant_data") {
body.insert("merchant_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("is_amount_controllable") {
body.insert("is_amount_controllable".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fleet") {
body.insert("fleet".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fuel") {
body.insert("fuel".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_details") {
body.insert("amount_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("risk_assessment") {
body.insert("risk_assessment".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("wallet") {
body.insert("wallet".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fraud_disputability_likelihood") {
body.insert(
"fraud_disputability_likelihood".to_string(),
val.clone().into(),
);
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/test_helpers/issuing/authorizations failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Capture a test-mode authorization
///
/// Method: POST /v1/test_helpers/issuing/authorizations/{authorization}/capture
#[actor(
StripeCreateTestHelpersIssuingAuthorizationsAuthorizationCaptureActor,
inports::<100>(authorization, close_authorization, purchase_details, expand, capture_amount),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_authorizations_authorization_capture(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/issuing/authorizations/{authorization}/capture".to_string();
if let Some(val) = inputs.get("authorization") {
endpoint = endpoint.replace("{{authorization}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("close_authorization") {
body.insert("close_authorization".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("purchase_details") {
body.insert("purchase_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("capture_amount") {
body.insert("capture_amount".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/authorizations/{{authorization}}/capture failed: {}", e).into()));
}
}
Ok(output)
}
/// Expire a test-mode authorization
///
/// Method: POST /v1/test_helpers/issuing/authorizations/{authorization}/expire
#[actor(
StripeCreateTestHelpersIssuingAuthorizationsAuthorizationExpireActor,
inports::<100>(authorization, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_authorizations_authorization_expire(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/issuing/authorizations/{authorization}/expire".to_string();
if let Some(val) = inputs.get("authorization") {
endpoint = endpoint.replace("{{authorization}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/authorizations/{{authorization}}/expire failed: {}", e).into()));
}
}
Ok(output)
}
/// Finalize a test-mode authorization's amount
///
/// Method: POST /v1/test_helpers/issuing/authorizations/{authorization}/finalize_amount
#[actor(
StripeCreateTestHelpersIssuingAuthorizationsAuthorizationFinalizeAmountActor,
inports::<100>(authorization, final_amount, fleet, expand, fuel),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_authorizations_authorization_finalize_amount(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/issuing/authorizations/{authorization}/finalize_amount".to_string();
if let Some(val) = inputs.get("authorization") {
endpoint = endpoint.replace("{{authorization}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("final_amount") {
body.insert("final_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fleet") {
body.insert("fleet".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("fuel") {
body.insert("fuel".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/authorizations/{{authorization}}/finalize_amount failed: {}", e).into()));
}
}
Ok(output)
}
/// Respond to fraud challenge
///
/// Method: POST /v1/test_helpers/issuing/authorizations/{authorization}/fraud_challenges/respond
#[actor(
StripeCreateTestHelpersIssuingAuthorizationsAuthorizationFraudChallengesRespondActor,
inports::<100>(authorization, confirmed, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_authorizations_authorization_fraud_challenges_respond(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/issuing/authorizations/{authorization}/fraud_challenges/respond"
.to_string();
if let Some(val) = inputs.get("authorization") {
endpoint = endpoint.replace("{{authorization}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("confirmed") {
body.insert("confirmed".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/authorizations/{{authorization}}/fraud_challenges/respond failed: {}", e).into()));
}
}
Ok(output)
}
/// Increment a test-mode authorization
///
/// Method: POST /v1/test_helpers/issuing/authorizations/{authorization}/increment
#[actor(
StripeCreateTestHelpersIssuingAuthorizationsAuthorizationIncrementActor,
inports::<100>(authorization, expand, increment_amount, is_amount_controllable),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_authorizations_authorization_increment(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/issuing/authorizations/{authorization}/increment".to_string();
if let Some(val) = inputs.get("authorization") {
endpoint = endpoint.replace("{{authorization}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("increment_amount") {
body.insert("increment_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("is_amount_controllable") {
body.insert("is_amount_controllable".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/authorizations/{{authorization}}/increment failed: {}", e).into()));
}
}
Ok(output)
}
/// Reverse a test-mode authorization
///
/// Method: POST /v1/test_helpers/issuing/authorizations/{authorization}/reverse
#[actor(
StripeCreateTestHelpersIssuingAuthorizationsAuthorizationReverseActor,
inports::<100>(authorization, expand, reverse_amount),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_authorizations_authorization_reverse(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/issuing/authorizations/{authorization}/reverse".to_string();
if let Some(val) = inputs.get("authorization") {
endpoint = endpoint.replace("{{authorization}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("reverse_amount") {
body.insert("reverse_amount".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/authorizations/{{authorization}}/reverse failed: {}", e).into()));
}
}
Ok(output)
}
/// Deliver a testmode card
///
/// Method: POST /v1/test_helpers/issuing/cards/{card}/shipping/deliver
#[actor(
StripeCreateTestHelpersIssuingCardsCardShippingDeliverActor,
inports::<100>(card, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_cards_card_shipping_deliver(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/issuing/cards/{card}/shipping/deliver".to_string();
if let Some(val) = inputs.get("card") {
endpoint = endpoint.replace("{{card}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/issuing/cards/{{card}}/shipping/deliver failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Fail a testmode card
///
/// Method: POST /v1/test_helpers/issuing/cards/{card}/shipping/fail
#[actor(
StripeCreateTestHelpersIssuingCardsCardShippingFailActor,
inports::<100>(card, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_cards_card_shipping_fail(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/issuing/cards/{card}/shipping/fail".to_string();
if let Some(val) = inputs.get("card") {
endpoint = endpoint.replace("{{card}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/issuing/cards/{{card}}/shipping/fail failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Return a testmode card
///
/// Method: POST /v1/test_helpers/issuing/cards/{card}/shipping/return
#[actor(
StripeCreateTestHelpersIssuingCardsCardShippingReturnActor,
inports::<100>(card, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_cards_card_shipping_return(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/issuing/cards/{card}/shipping/return".to_string();
if let Some(val) = inputs.get("card") {
endpoint = endpoint.replace("{{card}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/issuing/cards/{{card}}/shipping/return failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Ship a testmode card
///
/// Method: POST /v1/test_helpers/issuing/cards/{card}/shipping/ship
#[actor(
StripeCreateTestHelpersIssuingCardsCardShippingShipActor,
inports::<100>(card, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_cards_card_shipping_ship(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/issuing/cards/{card}/shipping/ship".to_string();
if let Some(val) = inputs.get("card") {
endpoint = endpoint.replace("{{card}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/issuing/cards/{{card}}/shipping/ship failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Submit a testmode card
///
/// Method: POST /v1/test_helpers/issuing/cards/{card}/shipping/submit
#[actor(
StripeCreateTestHelpersIssuingCardsCardShippingSubmitActor,
inports::<100>(card, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_cards_card_shipping_submit(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/issuing/cards/{card}/shipping/submit".to_string();
if let Some(val) = inputs.get("card") {
endpoint = endpoint.replace("{{card}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/issuing/cards/{{card}}/shipping/submit failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Activate a testmode personalization design
///
/// Method: POST /v1/test_helpers/issuing/personalization_designs/{personalization_design}/activate
#[actor(
StripeCreateTestHelpersIssuingPersonalizationDesignsPersonalizationDesignActivateActor,
inports::<100>(personalization_design, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_personalization_designs_personalization_design_activate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/issuing/personalization_designs/{personalization_design}/activate"
.to_string();
if let Some(val) = inputs.get("personalization_design") {
endpoint = endpoint.replace("{{personalization_design}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/personalization_designs/{{personalization_design}}/activate failed: {}", e).into()));
}
}
Ok(output)
}
/// Deactivate a testmode personalization design
///
/// Method: POST /v1/test_helpers/issuing/personalization_designs/{personalization_design}/deactivate
#[actor(
StripeCreateTestHelpersIssuingPersonalizationDesignsPersonalizationDesignDeactivateActor,
inports::<100>(personalization_design, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_personalization_designs_personalization_design_deactivate(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/issuing/personalization_designs/{personalization_design}/deactivate"
.to_string();
if let Some(val) = inputs.get("personalization_design") {
endpoint = endpoint.replace("{{personalization_design}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/personalization_designs/{{personalization_design}}/deactivate failed: {}", e).into()));
}
}
Ok(output)
}
/// Reject a testmode personalization design
///
/// Method: POST /v1/test_helpers/issuing/personalization_designs/{personalization_design}/reject
#[actor(
StripeCreateTestHelpersIssuingPersonalizationDesignsPersonalizationDesignRejectActor,
inports::<100>(personalization_design, rejection_reasons, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_personalization_designs_personalization_design_reject(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/issuing/personalization_designs/{personalization_design}/reject"
.to_string();
if let Some(val) = inputs.get("personalization_design") {
endpoint = endpoint.replace("{{personalization_design}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("rejection_reasons") {
body.insert("rejection_reasons".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/personalization_designs/{{personalization_design}}/reject failed: {}", e).into()));
}
}
Ok(output)
}
/// Create a test-mode settlement
///
/// Method: POST /v1/test_helpers/issuing/settlements
#[actor(
StripeCreateTestHelpersIssuingSettlementsActor,
inports::<100>(expand, transaction_amount, network_settlement_identifier, transaction_count, currency, clearing_date, interchange_fees_amount, net_total_amount, network, bin),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_settlements(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/test_helpers/issuing/settlements".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transaction_amount") {
body.insert("transaction_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("network_settlement_identifier") {
body.insert(
"network_settlement_identifier".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("transaction_count") {
body.insert("transaction_count".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("clearing_date") {
body.insert("clearing_date".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("interchange_fees_amount") {
body.insert("interchange_fees_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("net_total_amount") {
body.insert("net_total_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("network") {
body.insert("network".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bin") {
body.insert("bin".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/test_helpers/issuing/settlements failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Complete a test-mode settlement
///
/// Method: POST /v1/test_helpers/issuing/settlements/{settlement}/complete
#[actor(
StripeCreateTestHelpersIssuingSettlementsSettlementCompleteActor,
inports::<100>(settlement, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_settlements_settlement_complete(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/issuing/settlements/{settlement}/complete".to_string();
if let Some(val) = inputs.get("settlement") {
endpoint = endpoint.replace("{{settlement}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/settlements/{{settlement}}/complete failed: {}", e).into()));
}
}
Ok(output)
}
/// Create a test-mode force capture
///
/// Method: POST /v1/test_helpers/issuing/transactions/create_force_capture
#[actor(
StripeCreateTestHelpersIssuingTransactionsCreateForceCaptureActor,
inports::<100>(purchase_details, card, currency, amount, expand, merchant_data),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_transactions_create_force_capture(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/test_helpers/issuing/transactions/create_force_capture".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("purchase_details") {
body.insert("purchase_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("merchant_data") {
body.insert("merchant_data".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/transactions/create_force_capture failed: {}", e).into()));
}
}
Ok(output)
}
/// Create a test-mode unlinked refund
///
/// Method: POST /v1/test_helpers/issuing/transactions/create_unlinked_refund
#[actor(
StripeCreateTestHelpersIssuingTransactionsCreateUnlinkedRefundActor,
inports::<100>(amount, expand, purchase_details, currency, merchant_data, card),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_transactions_create_unlinked_refund(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/test_helpers/issuing/transactions/create_unlinked_refund".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("purchase_details") {
body.insert("purchase_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("merchant_data") {
body.insert("merchant_data".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/transactions/create_unlinked_refund failed: {}", e).into()));
}
}
Ok(output)
}
/// Refund a test-mode transaction
///
/// Method: POST /v1/test_helpers/issuing/transactions/{transaction}/refund
#[actor(
StripeCreateTestHelpersIssuingTransactionsTransactionRefundActor,
inports::<100>(transaction, refund_amount, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_issuing_transactions_transaction_refund(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/issuing/transactions/{transaction}/refund".to_string();
if let Some(val) = inputs.get("transaction") {
endpoint = endpoint.replace("{{transaction}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("refund_amount") {
body.insert("refund_amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/issuing/transactions/{{transaction}}/refund failed: {}", e).into()));
}
}
Ok(output)
}
/// Expire a pending refund.
///
/// Method: POST /v1/test_helpers/refunds/{refund}/expire
#[actor(
StripeCreateTestHelpersRefundsRefundExpireActor,
inports::<100>(refund, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_refunds_refund_expire(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/refunds/{refund}/expire".to_string();
if let Some(val) = inputs.get("refund") {
endpoint = endpoint.replace("{{refund}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/refunds/{{refund}}/expire failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Simulate presenting a payment method
///
/// Method: POST /v1/test_helpers/terminal/readers/{reader}/present_payment_method
#[actor(
StripeCreateTestHelpersTerminalReadersReaderPresentPaymentMethodActor,
inports::<100>(reader, card_present, type_, interac_present, expand, amount_tip, card),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_terminal_readers_reader_present_payment_method(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/terminal/readers/{reader}/present_payment_method".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("card_present") {
body.insert("card_present".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("type_") {
body.insert("type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("interac_present") {
body.insert("interac_present".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount_tip") {
body.insert("amount_tip".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/terminal/readers/{{reader}}/present_payment_method failed: {}", e).into()));
}
}
Ok(output)
}
/// Simulate a successful input collection
///
/// Method: POST /v1/test_helpers/terminal/readers/{reader}/succeed_input_collection
#[actor(
StripeCreateTestHelpersTerminalReadersReaderSucceedInputCollectionActor,
inports::<100>(reader, expand, skip_non_required_inputs),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_terminal_readers_reader_succeed_input_collection(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/terminal/readers/{reader}/succeed_input_collection".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("skip_non_required_inputs") {
body.insert("skip_non_required_inputs".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/terminal/readers/{{reader}}/succeed_input_collection failed: {}", e).into()));
}
}
Ok(output)
}
/// Simulate an input collection timeout
///
/// Method: POST /v1/test_helpers/terminal/readers/{reader}/timeout_input_collection
#[actor(
StripeCreateTestHelpersTerminalReadersReaderTimeoutInputCollectionActor,
inports::<100>(reader, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_terminal_readers_reader_timeout_input_collection(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/terminal/readers/{reader}/timeout_input_collection".to_string();
if let Some(val) = inputs.get("reader") {
endpoint = endpoint.replace("{{reader}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/terminal/readers/{{reader}}/timeout_input_collection failed: {}", e).into()));
}
}
Ok(output)
}
/// Create a test clock
///
/// Method: POST /v1/test_helpers/test_clocks
#[actor(
StripeCreateTestHelpersTestClocksActor,
inports::<100>(expand, frozen_time, name),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_test_clocks(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/test_helpers/test_clocks".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("frozen_time") {
body.insert("frozen_time".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("name") {
body.insert("name".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/test_helpers/test_clocks failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all test clocks
///
/// Method: GET /v1/test_helpers/test_clocks
#[actor(
StripeReadTestHelpersTestClocksActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_test_helpers_test_clocks(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/test_helpers/test_clocks".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/test_helpers/test_clocks failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Delete a test clock
///
/// Method: DELETE /v1/test_helpers/test_clocks/{test_clock}
#[actor(
StripeDeleteTestHelpersTestClocksTestClockActor,
inports::<100>(test_clock, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_test_helpers_test_clocks_test_clock(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/test_clocks/{test_clock}".to_string();
if let Some(val) = inputs.get("test_clock") {
endpoint = endpoint.replace("{{test_clock}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/test_helpers/test_clocks/{{test_clock}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Retrieve a test clock
///
/// Method: GET /v1/test_helpers/test_clocks/{test_clock}
#[actor(
StripeReadTestHelpersTestClocksTestClockActor,
inports::<100>(expand, test_clock, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_test_helpers_test_clocks_test_clock(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/test_clocks/{test_clock}".to_string();
if let Some(val) = inputs.get("test_clock") {
endpoint = endpoint.replace("{{test_clock}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/test_helpers/test_clocks/{{test_clock}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Advance a test clock
///
/// Method: POST /v1/test_helpers/test_clocks/{test_clock}/advance
#[actor(
StripeCreateTestHelpersTestClocksTestClockAdvanceActor,
inports::<100>(test_clock, expand, frozen_time),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_test_clocks_test_clock_advance(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/test_clocks/{test_clock}/advance".to_string();
if let Some(val) = inputs.get("test_clock") {
endpoint = endpoint.replace("{{test_clock}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("frozen_time") {
body.insert("frozen_time".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/test_clocks/{{test_clock}}/advance failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Test mode: Fail an InboundTransfer
///
/// Method: POST /v1/test_helpers/treasury/inbound_transfers/{id}/fail
#[actor(
StripeCreateTestHelpersTreasuryInboundTransfersIdFailActor,
inports::<100>(id, expand, failure_details),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_inbound_transfers_id_fail(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/treasury/inbound_transfers/{id}/fail".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("failure_details") {
body.insert("failure_details".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/treasury/inbound_transfers/{{id}}/fail failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Test mode: Return an InboundTransfer
///
/// Method: POST /v1/test_helpers/treasury/inbound_transfers/{id}/return
#[actor(
StripeCreateTestHelpersTreasuryInboundTransfersIdReturnActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_inbound_transfers_id_return(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/treasury/inbound_transfers/{id}/return".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/treasury/inbound_transfers/{{id}}/return failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Test mode: Succeed an InboundTransfer
///
/// Method: POST /v1/test_helpers/treasury/inbound_transfers/{id}/succeed
#[actor(
StripeCreateTestHelpersTreasuryInboundTransfersIdSucceedActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_inbound_transfers_id_succeed(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/treasury/inbound_transfers/{id}/succeed".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/treasury/inbound_transfers/{{id}}/succeed failed: {}", e).into()));
}
}
Ok(output)
}
/// Test mode: Update an OutboundPayment
///
/// Method: POST /v1/test_helpers/treasury/outbound_payments/{id}
#[actor(
StripeCreateTestHelpersTreasuryOutboundPaymentsIdActor,
inports::<100>(id, tracking_details, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_outbound_payments_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/treasury/outbound_payments/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("tracking_details") {
body.insert("tracking_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/treasury/outbound_payments/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Test mode: Fail an OutboundPayment
///
/// Method: POST /v1/test_helpers/treasury/outbound_payments/{id}/fail
#[actor(
StripeCreateTestHelpersTreasuryOutboundPaymentsIdFailActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_outbound_payments_id_fail(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/treasury/outbound_payments/{id}/fail".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/treasury/outbound_payments/{{id}}/fail failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Test mode: Post an OutboundPayment
///
/// Method: POST /v1/test_helpers/treasury/outbound_payments/{id}/post
#[actor(
StripeCreateTestHelpersTreasuryOutboundPaymentsIdPostActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_outbound_payments_id_post(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/treasury/outbound_payments/{id}/post".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/treasury/outbound_payments/{{id}}/post failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Test mode: Return an OutboundPayment
///
/// Method: POST /v1/test_helpers/treasury/outbound_payments/{id}/return
#[actor(
StripeCreateTestHelpersTreasuryOutboundPaymentsIdReturnActor,
inports::<100>(id, returned_details, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_outbound_payments_id_return(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/test_helpers/treasury/outbound_payments/{id}/return".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("returned_details") {
body.insert("returned_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/treasury/outbound_payments/{{id}}/return failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Test mode: Update an OutboundTransfer
///
/// Method: POST /v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}
#[actor(
StripeCreateTestHelpersTreasuryOutboundTransfersOutboundTransferActor,
inports::<100>(outbound_transfer, expand, tracking_details),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_outbound_transfers_outbound_transfer(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}".to_string();
if let Some(val) = inputs.get("outbound_transfer") {
endpoint = endpoint.replace("{{outbound_transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("tracking_details") {
body.insert("tracking_details".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/treasury/outbound_transfers/{{outbound_transfer}} failed: {}", e).into()));
}
}
Ok(output)
}
/// Test mode: Fail an OutboundTransfer
///
/// Method: POST /v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail
#[actor(
StripeCreateTestHelpersTreasuryOutboundTransfersOutboundTransferFailActor,
inports::<100>(outbound_transfer, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_outbound_transfers_outbound_transfer_fail(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail".to_string();
if let Some(val) = inputs.get("outbound_transfer") {
endpoint = endpoint.replace("{{outbound_transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/treasury/outbound_transfers/{{outbound_transfer}}/fail failed: {}", e).into()));
}
}
Ok(output)
}
/// Test mode: Post an OutboundTransfer
///
/// Method: POST /v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post
#[actor(
StripeCreateTestHelpersTreasuryOutboundTransfersOutboundTransferPostActor,
inports::<100>(outbound_transfer, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_outbound_transfers_outbound_transfer_post(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post".to_string();
if let Some(val) = inputs.get("outbound_transfer") {
endpoint = endpoint.replace("{{outbound_transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/treasury/outbound_transfers/{{outbound_transfer}}/post failed: {}", e).into()));
}
}
Ok(output)
}
/// Test mode: Return an OutboundTransfer
///
/// Method: POST /v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return
#[actor(
StripeCreateTestHelpersTreasuryOutboundTransfersOutboundTransferReturnActor,
inports::<100>(outbound_transfer, returned_details, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_outbound_transfers_outbound_transfer_return(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint =
"/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return".to_string();
if let Some(val) = inputs.get("outbound_transfer") {
endpoint = endpoint.replace("{{outbound_transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("returned_details") {
body.insert("returned_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/test_helpers/treasury/outbound_transfers/{{outbound_transfer}}/return failed: {}", e).into()));
}
}
Ok(output)
}
/// Test mode: Create a ReceivedCredit
///
/// Method: POST /v1/test_helpers/treasury/received_credits
#[actor(
StripeCreateTestHelpersTreasuryReceivedCreditsActor,
inports::<100>(currency, initiating_payment_method_details, network, description, amount, expand, financial_account),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_received_credits(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/test_helpers/treasury/received_credits".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("initiating_payment_method_details") {
body.insert(
"initiating_payment_method_details".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("network") {
body.insert("network".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("financial_account") {
body.insert("financial_account".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/treasury/received_credits failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Test mode: Create a ReceivedDebit
///
/// Method: POST /v1/test_helpers/treasury/received_debits
#[actor(
StripeCreateTestHelpersTreasuryReceivedDebitsActor,
inports::<100>(expand, financial_account, description, initiating_payment_method_details, network, currency, amount),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_test_helpers_treasury_received_debits(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/test_helpers/treasury/received_debits".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("financial_account") {
body.insert("financial_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("initiating_payment_method_details") {
body.insert(
"initiating_payment_method_details".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("network") {
body.insert("network".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/test_helpers/treasury/received_debits failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a CVC update token
///
/// Method: POST /v1/tokens
#[actor(
StripeCreateTokensActor,
inports::<100>(customer, account, card, pii, person, bank_account, expand, cvc_update),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_tokens(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/tokens".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("account") {
body.insert("account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card") {
body.insert("card".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("pii") {
body.insert("pii".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("person") {
body.insert("person".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("bank_account") {
body.insert("bank_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("cvc_update") {
body.insert("cvc_update".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/tokens failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a token
///
/// Method: GET /v1/tokens/{token}
#[actor(
StripeReadTokensTokenActor,
inports::<100>(expand, token, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_tokens_token(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/tokens/{token}".to_string();
if let Some(val) = inputs.get("token") {
endpoint = endpoint.replace("{{token}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/tokens/{{token}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a top-up
///
/// Method: POST /v1/topups
#[actor(
StripeCreateTopupsActor,
inports::<100>(metadata, expand, amount, description, currency, source, statement_descriptor, transfer_group),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_topups(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/topups".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source") {
body.insert("source".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_group") {
body.insert("transfer_group".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/topups failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all top-ups
///
/// Method: GET /v1/topups
#[actor(
StripeReadTopupsActor,
inports::<100>(amount, created, ending_before, expand, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_topups(context: ActorContext) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/topups".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("amount") {
query_pairs.push(("amount", super::message_to_str(val)));
}
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/topups failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a top-up
///
/// Method: GET /v1/topups/{topup}
#[actor(
StripeReadTopupsTopupActor,
inports::<100>(expand, topup, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_topups_topup(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/topups/{topup}".to_string();
if let Some(val) = inputs.get("topup") {
endpoint = endpoint.replace("{{topup}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/topups/{{topup}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a top-up
///
/// Method: POST /v1/topups/{topup}
#[actor(
StripeCreateTopupsTopupActor,
inports::<100>(topup, description, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_topups_topup(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/topups/{topup}".to_string();
if let Some(val) = inputs.get("topup") {
endpoint = endpoint.replace("{{topup}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/topups/{{topup}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Cancel a top-up
///
/// Method: POST /v1/topups/{topup}/cancel
#[actor(
StripeCreateTopupsTopupCancelActor,
inports::<100>(topup, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_topups_topup_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/topups/{topup}/cancel".to_string();
if let Some(val) = inputs.get("topup") {
endpoint = endpoint.replace("{{topup}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/topups/{{topup}}/cancel failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a transfer
///
/// Method: POST /v1/transfers
#[actor(
StripeCreateTransfersActor,
inports::<100>(currency, source_transaction, amount, transfer_group, destination, metadata, description, source_type, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_transfers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/transfers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source_transaction") {
body.insert("source_transaction".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("transfer_group") {
body.insert("transfer_group".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("destination") {
body.insert("destination".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("source_type") {
body.insert("source_type".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/transfers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all transfers
///
/// Method: GET /v1/transfers
#[actor(
StripeReadTransfersActor,
inports::<100>(created, destination, ending_before, expand, limit, starting_after, transfer_group, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_transfers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/transfers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("destination") {
query_pairs.push(("destination", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("transfer_group") {
query_pairs.push(("transfer_group", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/transfers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a transfer reversal
///
/// Method: POST /v1/transfers/{id}/reversals
#[actor(
StripeCreateTransfersIdReversalsActor,
inports::<100>(id, amount, expand, metadata, refund_application_fee, description),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_transfers_id_reversals(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/transfers/{id}/reversals".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("refund_application_fee") {
body.insert("refund_application_fee".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/transfers/{{id}}/reversals failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all reversals
///
/// Method: GET /v1/transfers/{id}/reversals
#[actor(
StripeReadTransfersIdReversalsActor,
inports::<100>(ending_before, expand, id, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_transfers_id_reversals(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/transfers/{id}/reversals".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/transfers/{{id}}/reversals failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a transfer
///
/// Method: GET /v1/transfers/{transfer}
#[actor(
StripeReadTransfersTransferActor,
inports::<100>(expand, transfer, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_transfers_transfer(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/transfers/{transfer}".to_string();
if let Some(val) = inputs.get("transfer") {
endpoint = endpoint.replace("{{transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/transfers/{{transfer}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Update a transfer
///
/// Method: POST /v1/transfers/{transfer}
#[actor(
StripeCreateTransfersTransferActor,
inports::<100>(transfer, expand, metadata, description),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_transfers_transfer(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/transfers/{transfer}".to_string();
if let Some(val) = inputs.get("transfer") {
endpoint = endpoint.replace("{{transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/transfers/{{transfer}} failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a reversal
///
/// Method: GET /v1/transfers/{transfer}/reversals/{id}
#[actor(
StripeReadTransfersTransferReversalsIdActor,
inports::<100>(expand, id, transfer, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_transfers_transfer_reversals_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/transfers/{transfer}/reversals/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("transfer") {
endpoint = endpoint.replace("{{transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/transfers/{{transfer}}/reversals/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a reversal
///
/// Method: POST /v1/transfers/{transfer}/reversals/{id}
#[actor(
StripeCreateTransfersTransferReversalsIdActor,
inports::<100>(id, transfer, metadata, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_transfers_transfer_reversals_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/transfers/{transfer}/reversals/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
if let Some(val) = inputs.get("transfer") {
endpoint = endpoint.replace("{{transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/transfers/{{transfer}}/reversals/{{id}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create a CreditReversal
///
/// Method: POST /v1/treasury/credit_reversals
#[actor(
StripeCreateTreasuryCreditReversalsActor,
inports::<100>(expand, metadata, received_credit),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_credit_reversals(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/credit_reversals".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("received_credit") {
body.insert("received_credit".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/treasury/credit_reversals failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all CreditReversals
///
/// Method: GET /v1/treasury/credit_reversals
#[actor(
StripeReadTreasuryCreditReversalsActor,
inports::<100>(ending_before, expand, financial_account, limit, received_credit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_credit_reversals(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/credit_reversals".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("financial_account") {
query_pairs.push(("financial_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("received_credit") {
query_pairs.push(("received_credit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/treasury/credit_reversals failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a CreditReversal
///
/// Method: GET /v1/treasury/credit_reversals/{credit_reversal}
#[actor(
StripeReadTreasuryCreditReversalsCreditReversalActor,
inports::<100>(credit_reversal, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_credit_reversals_credit_reversal(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/credit_reversals/{credit_reversal}".to_string();
if let Some(val) = inputs.get("credit_reversal") {
endpoint = endpoint.replace("{{credit_reversal}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/treasury/credit_reversals/{{credit_reversal}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all DebitReversals
///
/// Method: GET /v1/treasury/debit_reversals
#[actor(
StripeReadTreasuryDebitReversalsActor,
inports::<100>(ending_before, expand, financial_account, limit, received_debit, resolution, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_debit_reversals(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/debit_reversals".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("financial_account") {
query_pairs.push(("financial_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("received_debit") {
query_pairs.push(("received_debit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("resolution") {
query_pairs.push(("resolution", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/treasury/debit_reversals failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a DebitReversal
///
/// Method: POST /v1/treasury/debit_reversals
#[actor(
StripeCreateTreasuryDebitReversalsActor,
inports::<100>(received_debit, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_debit_reversals(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/debit_reversals".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("received_debit") {
body.insert("received_debit".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/treasury/debit_reversals failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a DebitReversal
///
/// Method: GET /v1/treasury/debit_reversals/{debit_reversal}
#[actor(
StripeReadTreasuryDebitReversalsDebitReversalActor,
inports::<100>(debit_reversal, expand, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_debit_reversals_debit_reversal(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/debit_reversals/{debit_reversal}".to_string();
if let Some(val) = inputs.get("debit_reversal") {
endpoint = endpoint.replace("{{debit_reversal}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/treasury/debit_reversals/{{debit_reversal}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// List all FinancialAccounts
///
/// Method: GET /v1/treasury/financial_accounts
#[actor(
StripeReadTreasuryFinancialAccountsActor,
inports::<100>(created, ending_before, expand, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_financial_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/financial_accounts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/treasury/financial_accounts failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create a FinancialAccount
///
/// Method: POST /v1/treasury/financial_accounts
#[actor(
StripeCreateTreasuryFinancialAccountsActor,
inports::<100>(expand, metadata, nickname, platform_restrictions, supported_currencies, features),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_financial_accounts(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/financial_accounts".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nickname") {
body.insert("nickname".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("platform_restrictions") {
body.insert("platform_restrictions".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("supported_currencies") {
body.insert("supported_currencies".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("features") {
body.insert("features".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/treasury/financial_accounts failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a FinancialAccount
///
/// Method: GET /v1/treasury/financial_accounts/{financial_account}
#[actor(
StripeReadTreasuryFinancialAccountsFinancialAccountActor,
inports::<100>(expand, financial_account, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_financial_accounts_financial_account(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/financial_accounts/{financial_account}".to_string();
if let Some(val) = inputs.get("financial_account") {
endpoint = endpoint.replace("{{financial_account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/treasury/financial_accounts/{{financial_account}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a FinancialAccount
///
/// Method: POST /v1/treasury/financial_accounts/{financial_account}
#[actor(
StripeCreateTreasuryFinancialAccountsFinancialAccountActor,
inports::<100>(financial_account, expand, features, forwarding_settings, metadata, nickname, platform_restrictions),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_financial_accounts_financial_account(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/financial_accounts/{financial_account}".to_string();
if let Some(val) = inputs.get("financial_account") {
endpoint = endpoint.replace("{{financial_account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("features") {
body.insert("features".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("forwarding_settings") {
body.insert("forwarding_settings".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("nickname") {
body.insert("nickname".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("platform_restrictions") {
body.insert("platform_restrictions".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/treasury/financial_accounts/{{financial_account}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Close a FinancialAccount
///
/// Method: POST /v1/treasury/financial_accounts/{financial_account}/close
#[actor(
StripeCreateTreasuryFinancialAccountsFinancialAccountCloseActor,
inports::<100>(financial_account, expand, forwarding_settings),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_financial_accounts_financial_account_close(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/financial_accounts/{financial_account}/close".to_string();
if let Some(val) = inputs.get("financial_account") {
endpoint = endpoint.replace("{{financial_account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("forwarding_settings") {
body.insert("forwarding_settings".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/treasury/financial_accounts/{{financial_account}}/close failed: {}", e).into()));
}
}
Ok(output)
}
/// Retrieve FinancialAccount Features
///
/// Method: GET /v1/treasury/financial_accounts/{financial_account}/features
#[actor(
StripeReadTreasuryFinancialAccountsFinancialAccountFeaturesActor,
inports::<100>(expand, financial_account, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_financial_accounts_financial_account_features(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/financial_accounts/{financial_account}/features".to_string();
if let Some(val) = inputs.get("financial_account") {
endpoint = endpoint.replace("{{financial_account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("GET /v1/treasury/financial_accounts/{{financial_account}}/features failed: {}", e).into()));
}
}
Ok(output)
}
/// Update FinancialAccount Features
///
/// Method: POST /v1/treasury/financial_accounts/{financial_account}/features
#[actor(
StripeCreateTreasuryFinancialAccountsFinancialAccountFeaturesActor,
inports::<100>(financial_account, intra_stripe_flows, outbound_payments, expand, outbound_transfers, card_issuing, inbound_transfers, deposit_insurance, financial_addresses),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_financial_accounts_financial_account_features(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/financial_accounts/{financial_account}/features".to_string();
if let Some(val) = inputs.get("financial_account") {
endpoint = endpoint.replace("{{financial_account}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("intra_stripe_flows") {
body.insert("intra_stripe_flows".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("outbound_payments") {
body.insert("outbound_payments".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("outbound_transfers") {
body.insert("outbound_transfers".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("card_issuing") {
body.insert("card_issuing".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("inbound_transfers") {
body.insert("inbound_transfers".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("deposit_insurance") {
body.insert("deposit_insurance".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("financial_addresses") {
body.insert("financial_addresses".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/treasury/financial_accounts/{{financial_account}}/features failed: {}", e).into()));
}
}
Ok(output)
}
/// List all InboundTransfers
///
/// Method: GET /v1/treasury/inbound_transfers
#[actor(
StripeReadTreasuryInboundTransfersActor,
inports::<100>(ending_before, expand, financial_account, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_inbound_transfers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/inbound_transfers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("financial_account") {
query_pairs.push(("financial_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/treasury/inbound_transfers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create an InboundTransfer
///
/// Method: POST /v1/treasury/inbound_transfers
#[actor(
StripeCreateTreasuryInboundTransfersActor,
inports::<100>(financial_account, amount, expand, metadata, description, origin_payment_method, currency, statement_descriptor),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_inbound_transfers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/inbound_transfers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("financial_account") {
body.insert("financial_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("origin_payment_method") {
body.insert("origin_payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/treasury/inbound_transfers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an InboundTransfer
///
/// Method: GET /v1/treasury/inbound_transfers/{id}
#[actor(
StripeReadTreasuryInboundTransfersIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_inbound_transfers_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/inbound_transfers/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/treasury/inbound_transfers/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Cancel an InboundTransfer
///
/// Method: POST /v1/treasury/inbound_transfers/{inbound_transfer}/cancel
#[actor(
StripeCreateTreasuryInboundTransfersInboundTransferCancelActor,
inports::<100>(inbound_transfer, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_inbound_transfers_inbound_transfer_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/inbound_transfers/{inbound_transfer}/cancel".to_string();
if let Some(val) = inputs.get("inbound_transfer") {
endpoint = endpoint.replace("{{inbound_transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/treasury/inbound_transfers/{{inbound_transfer}}/cancel failed: {}", e).into()));
}
}
Ok(output)
}
/// List all OutboundPayments
///
/// Method: GET /v1/treasury/outbound_payments
#[actor(
StripeReadTreasuryOutboundPaymentsActor,
inports::<100>(created, customer, ending_before, expand, financial_account, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_outbound_payments(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/outbound_payments".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("customer") {
query_pairs.push(("customer", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("financial_account") {
query_pairs.push(("financial_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/treasury/outbound_payments failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Create an OutboundPayment
///
/// Method: POST /v1/treasury/outbound_payments
#[actor(
StripeCreateTreasuryOutboundPaymentsActor,
inports::<100>(destination_payment_method_options, customer, statement_descriptor, destination_payment_method, destination_payment_method_data, amount, currency, end_user_details, description, expand, financial_account, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_outbound_payments(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/outbound_payments".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("destination_payment_method_options") {
body.insert(
"destination_payment_method_options".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("customer") {
body.insert("customer".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("destination_payment_method") {
body.insert("destination_payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("destination_payment_method_data") {
body.insert(
"destination_payment_method_data".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("end_user_details") {
body.insert("end_user_details".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("financial_account") {
body.insert("financial_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/treasury/outbound_payments failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an OutboundPayment
///
/// Method: GET /v1/treasury/outbound_payments/{id}
#[actor(
StripeReadTreasuryOutboundPaymentsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_outbound_payments_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/outbound_payments/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/treasury/outbound_payments/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Cancel an OutboundPayment
///
/// Method: POST /v1/treasury/outbound_payments/{id}/cancel
#[actor(
StripeCreateTreasuryOutboundPaymentsIdCancelActor,
inports::<100>(id, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_outbound_payments_id_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/outbound_payments/{id}/cancel".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/treasury/outbound_payments/{{id}}/cancel failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Create an OutboundTransfer
///
/// Method: POST /v1/treasury/outbound_transfers
#[actor(
StripeCreateTreasuryOutboundTransfersActor,
inports::<100>(financial_account, statement_descriptor, destination_payment_method_data, description, currency, destination_payment_method, metadata, destination_payment_method_options, amount, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_outbound_transfers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/outbound_transfers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("financial_account") {
body.insert("financial_account".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("statement_descriptor") {
body.insert("statement_descriptor".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("destination_payment_method_data") {
body.insert(
"destination_payment_method_data".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("currency") {
body.insert("currency".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("destination_payment_method") {
body.insert("destination_payment_method".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("destination_payment_method_options") {
body.insert(
"destination_payment_method_options".to_string(),
val.clone().into(),
);
}
if let Some(val) = inputs.get("amount") {
body.insert("amount".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("POST /v1/treasury/outbound_transfers failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all OutboundTransfers
///
/// Method: GET /v1/treasury/outbound_transfers
#[actor(
StripeReadTreasuryOutboundTransfersActor,
inports::<100>(ending_before, expand, financial_account, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_outbound_transfers(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/outbound_transfers".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("financial_account") {
query_pairs.push(("financial_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/treasury/outbound_transfers failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve an OutboundTransfer
///
/// Method: GET /v1/treasury/outbound_transfers/{outbound_transfer}
#[actor(
StripeReadTreasuryOutboundTransfersOutboundTransferActor,
inports::<100>(expand, outbound_transfer, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_outbound_transfers_outbound_transfer(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/outbound_transfers/{outbound_transfer}".to_string();
if let Some(val) = inputs.get("outbound_transfer") {
endpoint = endpoint.replace("{{outbound_transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/treasury/outbound_transfers/{{outbound_transfer}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Cancel an OutboundTransfer
///
/// Method: POST /v1/treasury/outbound_transfers/{outbound_transfer}/cancel
#[actor(
StripeCreateTreasuryOutboundTransfersOutboundTransferCancelActor,
inports::<100>(outbound_transfer, expand),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_treasury_outbound_transfers_outbound_transfer_cancel(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/outbound_transfers/{outbound_transfer}/cancel".to_string();
if let Some(val) = inputs.get("outbound_transfer") {
endpoint = endpoint.replace("{{outbound_transfer}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert("error".to_string(), Message::Error(format!("POST /v1/treasury/outbound_transfers/{{outbound_transfer}}/cancel failed: {}", e).into()));
}
}
Ok(output)
}
/// List all ReceivedCredits
///
/// Method: GET /v1/treasury/received_credits
#[actor(
StripeReadTreasuryReceivedCreditsActor,
inports::<100>(ending_before, expand, financial_account, limit, linked_flows, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_received_credits(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/received_credits".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("financial_account") {
query_pairs.push(("financial_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("linked_flows") {
query_pairs.push(("linked_flows", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/treasury/received_credits failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a ReceivedCredit
///
/// Method: GET /v1/treasury/received_credits/{id}
#[actor(
StripeReadTreasuryReceivedCreditsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_received_credits_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/received_credits/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/treasury/received_credits/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all ReceivedDebits
///
/// Method: GET /v1/treasury/received_debits
#[actor(
StripeReadTreasuryReceivedDebitsActor,
inports::<100>(ending_before, expand, financial_account, limit, starting_after, status, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_received_debits(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/received_debits".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("financial_account") {
query_pairs.push(("financial_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/treasury/received_debits failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a ReceivedDebit
///
/// Method: GET /v1/treasury/received_debits/{id}
#[actor(
StripeReadTreasuryReceivedDebitsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_received_debits_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/received_debits/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/treasury/received_debits/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all TransactionEntries
///
/// Method: GET /v1/treasury/transaction_entries
#[actor(
StripeReadTreasuryTransactionEntriesActor,
inports::<100>(created, effective_at, ending_before, expand, financial_account, limit, order_by, starting_after, transaction, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_transaction_entries(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/transaction_entries".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("effective_at") {
query_pairs.push(("effective_at", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("financial_account") {
query_pairs.push(("financial_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("order_by") {
query_pairs.push(("order_by", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("transaction") {
query_pairs.push(("transaction", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/treasury/transaction_entries failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Retrieve a TransactionEntry
///
/// Method: GET /v1/treasury/transaction_entries/{id}
#[actor(
StripeReadTreasuryTransactionEntriesIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_transaction_entries_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/transaction_entries/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/treasury/transaction_entries/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// List all Transactions
///
/// Method: GET /v1/treasury/transactions
#[actor(
StripeReadTreasuryTransactionsActor,
inports::<100>(created, ending_before, expand, financial_account, limit, order_by, starting_after, status, status_transitions, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_transactions(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/treasury/transactions".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("created") {
query_pairs.push(("created", super::message_to_str(val)));
}
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("financial_account") {
query_pairs.push(("financial_account", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("order_by") {
query_pairs.push(("order_by", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status") {
query_pairs.push(("status", super::message_to_str(val)));
}
if let Some(val) = inputs.get("status_transitions") {
query_pairs.push(("status_transitions", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/treasury/transactions failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a Transaction
///
/// Method: GET /v1/treasury/transactions/{id}
#[actor(
StripeReadTreasuryTransactionsIdActor,
inports::<100>(expand, id, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_treasury_transactions_id(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/treasury/transactions/{id}".to_string();
if let Some(val) = inputs.get("id") {
endpoint = endpoint.replace("{{id}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!("GET /v1/treasury/transactions/{{id}} failed: {}", e).into(),
),
);
}
}
Ok(output)
}
/// Create a webhook endpoint
///
/// Method: POST /v1/webhook_endpoints
#[actor(
StripeCreateWebhookEndpointsActor,
inports::<100>(url, enabled_events, connect, description, api_version, expand, metadata),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_webhook_endpoints(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/webhook_endpoints".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("url") {
body.insert("url".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enabled_events") {
body.insert("enabled_events".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("connect") {
body.insert("connect".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("api_version") {
body.insert("api_version".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("POST /v1/webhook_endpoints failed: {}", e).into()),
);
}
}
Ok(output)
}
/// List all webhook endpoints
///
/// Method: GET /v1/webhook_endpoints
#[actor(
StripeReadWebhookEndpointsActor,
inports::<100>(ending_before, expand, limit, starting_after, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_webhook_endpoints(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let endpoint = "/v1/webhook_endpoints".to_string();
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("ending_before") {
query_pairs.push(("ending_before", super::message_to_str(val)));
}
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if let Some(val) = inputs.get("limit") {
query_pairs.push(("limit", super::message_to_str(val)));
}
if let Some(val) = inputs.get("starting_after") {
query_pairs.push(("starting_after", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(format!("GET /v1/webhook_endpoints failed: {}", e).into()),
);
}
}
Ok(output)
}
/// Retrieve a webhook endpoint
///
/// Method: GET /v1/webhook_endpoints/{webhook_endpoint}
#[actor(
StripeReadWebhookEndpointsWebhookEndpointActor,
inports::<100>(expand, webhook_endpoint, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_read_webhook_endpoints_webhook_endpoint(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/webhook_endpoints/{webhook_endpoint}".to_string();
if let Some(val) = inputs.get("webhook_endpoint") {
endpoint = endpoint.replace("{{webhook_endpoint}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.get(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut query_pairs: Vec<(&str, String)> = Vec::new();
if let Some(val) = inputs.get("expand") {
query_pairs.push(("expand", super::message_to_str(val)));
}
if !query_pairs.is_empty() {
builder = builder.query(&query_pairs);
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"GET /v1/webhook_endpoints/{{webhook_endpoint}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Update a webhook endpoint
///
/// Method: POST /v1/webhook_endpoints/{webhook_endpoint}
#[actor(
StripeCreateWebhookEndpointsWebhookEndpointActor,
inports::<100>(webhook_endpoint, expand, description, disabled, enabled_events, metadata, url),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_create_webhook_endpoints_webhook_endpoint(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/webhook_endpoints/{webhook_endpoint}".to_string();
if let Some(val) = inputs.get("webhook_endpoint") {
endpoint = endpoint.replace("{{webhook_endpoint}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.post(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut body = serde_json::Map::new();
if let Some(val) = inputs.get("expand") {
body.insert("expand".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("description") {
body.insert("description".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("disabled") {
body.insert("disabled".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("enabled_events") {
body.insert("enabled_events".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("metadata") {
body.insert("metadata".to_string(), val.clone().into());
}
if let Some(val) = inputs.get("url") {
body.insert("url".to_string(), val.clone().into());
}
if !body.is_empty() {
builder = builder.json(&serde_json::Value::Object(body));
}
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"POST /v1/webhook_endpoints/{{webhook_endpoint}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}
/// Delete a webhook endpoint
///
/// Method: DELETE /v1/webhook_endpoints/{webhook_endpoint}
#[actor(
StripeDeleteWebhookEndpointsWebhookEndpointActor,
inports::<100>(webhook_endpoint, body),
outports::<50>(response, error),
state(MemoryState)
)]
pub async fn stripe_delete_webhook_endpoints_webhook_endpoint(
context: ActorContext,
) -> Result<HashMap<String, Message>, Error> {
let inputs = context.get_payload();
let actor_config = context.get_config();
let mut endpoint = "/v1/webhook_endpoints/{webhook_endpoint}".to_string();
if let Some(val) = inputs.get("webhook_endpoint") {
endpoint = endpoint.replace("{{webhook_endpoint}}", &super::message_to_str(val));
}
let url = format!("{}{}", BASE_URL.trim_end_matches('/'), endpoint);
let client = reqwest::Client::builder()
.timeout(Duration::from_secs(30))
.build()?;
let mut builder = client.delete(&url);
builder = builder.header("Content-Type", "application/json");
builder = apply_auth(actor_config, builder)?;
let mut output = HashMap::new();
match builder.send().await {
Ok(resp) => {
let status = resp.status().as_u16();
let headers: HashMap<String, String> = resp
.headers()
.iter()
.filter_map(|(k, v)| v.to_str().ok().map(|val| (k.to_string(), val.to_string())))
.collect();
let body_text = resp.text().await.unwrap_or_default();
let body_value: Value =
serde_json::from_str(&body_text).unwrap_or(Value::String(body_text));
output.insert(
"response".to_string(),
Message::object(EncodableValue::from(json!({
"status": status,
"headers": headers,
"body": body_value,
}))),
);
}
Err(e) => {
output.insert(
"error".to_string(),
Message::Error(
format!(
"DELETE /v1/webhook_endpoints/{{webhook_endpoint}} failed: {}",
e
)
.into(),
),
);
}
}
Ok(output)
}