use serde::Serialize;
use crate::request::Params;
#[derive(Debug, Serialize)]
pub struct PddGoodsRecommendParam {
pub limit: Option<u64>,
pub cat_id: Option<u64>,
pub channel_type: Option<u64>,
pub offset: Option<u64>,
pub goods_ids: Option<Vec<u64>>,
pub goods_sign_list: Option<Vec<String>>,
pub pid: Option<String>,
pub custom_parameters: Option<String>,
pub list_id: Option<String>,
}
impl Params for PddGoodsRecommendParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(limit) = self.limit {
params.push(("limit".to_owned(), limit.to_string()));
}
if let Some(cat_id) = self.cat_id {
params.push(("cat_id".to_owned(), cat_id.to_string()));
}
if let Some(channel_type) = self.channel_type {
params.push(("channel_type".to_owned(), channel_type.to_string()));
}
if let Some(offset) = self.offset {
params.push(("offset".to_owned(), offset.to_string()));
}
if let Some(pid) = self.pid.to_owned() {
params.push(("pid".to_owned(), pid.to_string()));
}
if let Some(list_id) = self.list_id.to_owned() {
params.push(("list_id".to_owned(), list_id.to_string()));
}
if let Some(custom_parameters) = self.custom_parameters.to_owned() {
params.push(("custom_parameters".to_owned(), custom_parameters.to_string()));
}
if let Some(goods_sign_list) = self.goods_sign_list.to_owned() {
params.push(("goods_sign_list".to_owned(), format!("[{:?}]",goods_sign_list.join(",").to_string())));
}
if let Some(goods_ids) = self.goods_ids.to_owned() {
params.push(("goods_ids".to_owned(), format!("[{:?}]",goods_ids.iter().map(|item| item.to_string()).collect::<Vec<_>>().join(",").to_string())));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddGoodsSearchParam {
pub activity_tags: Option<Vec<u64>>,
pub block_cats: Option<Vec<u64>>,
pub cat_id: Option<u64>,
pub custom_parameters: Option<String>,
pub goods_sign_list: Option<Vec<String>>,
pub is_brand_goods: Option<bool>,
pub with_coupon: Option<bool>,
pub keyword: Option<String>,
pub list_id: Option<String>,
pub merchant_type: Option<u8>,
pub opt_id: Option<u64>,
pub page: Option<u64>,
pub page_size: Option<u64>,
pub pid: Option<String>,
pub sort_type: Option<u8>,
pub merchant_type_list: Option<Vec<u8>>,
pub block_cat_packages: Option<Vec<u8>>,
}
impl Params for PddGoodsSearchParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(page) = self.page {
params.push(("page".to_owned(), page.to_string()));
}
if let Some(cat_id) = self.cat_id {
params.push(("cat_id".to_owned(), cat_id.to_string()));
}
if let Some(page_size) = self.page_size {
params.push(("page_size".to_owned(), page_size.to_string()));
}
if let Some(keyword) = self.keyword.to_owned() {
params.push(("keyword".to_owned(), keyword));
}
if let Some(pid) = self.pid.to_owned() {
params.push(("pid".to_owned(), pid.to_string()));
}
if let Some(list_id) = self.list_id.to_owned() {
params.push(("list_id".to_owned(), list_id));
}
if let Some(custom_parameters) = self.custom_parameters.to_owned() {
params.push(("custom_parameters".to_owned(), custom_parameters));
}
if let Some(is_brand_goods) = self.is_brand_goods.to_owned() {
params.push(("is_brand_goods".to_owned(), is_brand_goods.to_string()));
}
if let Some(with_coupon) = self.with_coupon.to_owned() {
params.push(("with_coupon".to_owned(), with_coupon.to_string()));
}
if let Some(merchant_type) = self.merchant_type.to_owned() {
params.push(("merchant_type".to_owned(), merchant_type.to_string()));
}
if let Some(opt_id) = self.opt_id.to_owned() {
params.push(("opt_id".to_owned(), opt_id.to_string()));
}
if let Some(sort_type) = self.sort_type.to_owned() {
params.push(("sort_type".to_owned(), sort_type.to_string()));
}
if let Some(goods_sign_list) = self.goods_sign_list.to_owned() {
params.push(("goods_sign_list".to_owned(), format!("[{:?}]",goods_sign_list.join(",").to_string())));
}
if let Some(activity_tags) = self.activity_tags.to_owned() {
params.push(("activity_tags".to_owned(), format!("[{:?}]",activity_tags.iter().map(|item| item.to_string()).collect::<Vec<_>>().join(",").to_string())));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddAuthorityQueryParam {
pub pid: Option<String>,
pub custom_parameters: Option<String>,
}
impl Params for PddAuthorityQueryParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(pid) = self.pid.to_owned() {
params.push(("pid".to_owned(), pid.to_string()));
}
if let Some(custom_parameters) = self.custom_parameters.to_owned() {
params.push(("custom_parameters".to_owned(), custom_parameters));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddPromoteUrlGenerateParam {
pub p_id: String,
pub crash_gift_id: Option<u64>,
pub custom_parameters: Option<String>,
pub generate_authority_url: Option<bool>,
pub generate_mall_collect_coupon: Option<bool>,
pub generate_qq_app: Option<bool>,
pub generate_schema_url: Option<bool>,
pub generate_short_url: Option<bool>,
pub generate_we_app: Option<bool>,
pub multi_group: Option<bool>,
pub goods_id_list: Option<Vec<u64>>,
pub zs_duo_id: Option<u64>,
pub goods_sign: Option<String>,
pub room_id_list: Option<Vec<String>>,
pub search_id: Option<String>,
pub target_id_list: Option<Vec<String>>,
}
impl Params for PddPromoteUrlGenerateParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
params.push(("p_id".to_owned(), self.p_id.to_owned()));
if let Some(custom_parameters) = self.custom_parameters.to_owned() {
params.push(("custom_parameters".to_owned(), custom_parameters));
}
if let Some(generate_authority_url) = self.generate_authority_url.to_owned() {
params.push(("generate_authority_url".to_owned(), generate_authority_url.to_string()));
}
if let Some(goods_sign) = self.goods_sign.to_owned() {
params.push(("goods_sign".to_owned(), goods_sign));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddGoodsTopParam {
pub limit: Option<u64>,
pub offset: Option<u64>,
pub sort_type: Option<u8>,
pub p_id: Option<String>,
pub custom_parameters: Option<String>,
pub list_id: Option<String>,
}
impl Params for PddGoodsTopParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(limit) = self.limit {
params.push(("limit".to_owned(), limit.to_string()));
}
if let Some(p_id) = self.p_id.to_owned() {
params.push(("p_id".to_owned(), p_id.to_string()));
}
if let Some(sort_type) = self.sort_type {
params.push(("sort_type".to_owned(), sort_type.to_string()));
}
if let Some(offset) = self.offset {
params.push(("offset".to_owned(), offset.to_string()));
}
if let Some(list_id) = self.list_id.to_owned() {
params.push(("list_id".to_owned(), list_id.to_string()));
}
if let Some(custom_parameters) = self.custom_parameters.to_owned() {
params.push(("custom_parameters".to_owned(), custom_parameters.to_string()));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddGoodsDetailParam {
pub goods_id_list: Option<Vec<u64>>,
pub goods_sign: Option<String>,
pub search_id: Option<String>,
pub pid: Option<String>,
pub custom_parameters: Option<String>,
pub zs_duo_id: Option<u64>,
}
impl Params for PddGoodsDetailParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(goods_sign) = self.goods_sign.to_owned() {
params.push(("goods_sign".to_owned(), goods_sign));
}
if let Some(pid) = self.pid.to_owned() {
params.push(("pid".to_owned(), pid));
}
if let Some(search_id) = self.search_id.to_owned() {
params.push(("search_id".to_owned(), search_id));
}
if let Some(zs_duo_id) = self.zs_duo_id {
params.push(("zs_duo_id".to_owned(), zs_duo_id.to_string()));
}
if let Some(goods_id_list) = self.goods_id_list.to_owned() {
params.push(("goods_id_list".to_owned(), format!("[{:?}]",goods_id_list.iter().map(|item| item.to_string()).collect::<Vec<_>>().join(",").to_string())));
}
if let Some(custom_parameters) = self.custom_parameters.to_owned() {
params.push(("custom_parameters".to_owned(), custom_parameters));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddZsUrlGenerateParam {
pub source_url: Option<String>,
pub pid: Option<String>,
pub custom_parameters: Option<String>,
}
impl Params for PddZsUrlGenerateParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(source_url) = self.source_url.to_owned() {
params.push(("source_url".to_owned(), source_url));
}
if let Some(pid) = self.pid.to_owned() {
params.push(("pid".to_owned(), pid));
}
if let Some(custom_parameters) = self.custom_parameters.to_owned() {
params.push(("custom_parameters".to_owned(), custom_parameters));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddRpUrlGenerateParam {
pub channel_type: Option<u64>,
pub custom_parameters: Option<String>,
pub diy_red_packet_param: Option<PddDiyRedPacket>,
pub generate_qq_app: Option<bool>,
pub generate_schema_url: Option<bool>,
pub generate_short_url: Option<bool>,
pub generate_we_app: Option<bool>,
pub p_id_list: Option<Vec<String>>,
pub amount: Option<u64>,
pub scratch_card_amount: Option<u64>,
}
#[derive(Debug, Serialize)]
pub struct PddDiyRedPacket {
pub amount_probability: Option<Vec<u64>>,
pub opt_id: Option<Vec<u64>>,
pub dis_text: Option<bool>,
pub not_show_background: Option<bool>,
pub range_items: Option<PddRangeItem>,
}
#[derive(Debug, Serialize)]
pub struct PddRangeItem {
pub range_from: Option<u64>,
pub range_id: Option<u64>,
pub range_to: Option<u64>,
}
impl Params for PddRpUrlGenerateParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(channel_type) = self.channel_type.to_owned() {
params.push(("channel_type".to_owned(), channel_type.to_string()));
}
if let Some(generate_qq_app) = self.generate_qq_app.to_owned() {
params.push(("generate_qq_app".to_owned(), generate_qq_app.to_string()));
}
if let Some(generate_schema_url) = self.generate_schema_url.to_owned() {
params.push(("generate_schema_url".to_owned(), generate_schema_url.to_string()));
}
if let Some(generate_short_url) = self.generate_short_url.to_owned() {
params.push(("generate_short_url".to_owned(), generate_short_url.to_string()));
}
if let Some(generate_we_app) = self.generate_we_app.to_owned() {
params.push(("generate_we_app".to_owned(), generate_we_app.to_string()));
}
if let Some(amount) = self.amount.to_owned() {
params.push(("amount".to_owned(), amount.to_string()));
}
if let Some(scratch_card_amount) = self.scratch_card_amount.to_owned() {
params.push(("scratch_card_amount".to_owned(), scratch_card_amount.to_string()));
}
if let Some(p_id_list) = self.p_id_list.to_owned() {
params.push(("p_id_list".to_owned(), format!("[\"{}\"]",p_id_list.join("\",\"").to_string())));
}
if let Some(diy_red_packet_param) = &self.diy_red_packet_param {
params.push(("diy_red_packet_param".to_owned(), serde_json::to_string(diy_red_packet_param).unwrap_or_default()));
}
if let Some(custom_parameters) = self.custom_parameters.to_owned() {
params.push(("custom_parameters".to_owned(), custom_parameters));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddCmsUrlGenerateParam {
pub channel_type: Option<u64>,
pub custom_parameters: Option<String>,
pub generate_schema_url: Option<bool>,
pub generate_mobile: Option<bool>,
pub generate_short_url: Option<bool>,
pub multi_group: Option<bool>,
pub p_id_list: Option<Vec<String>>,
}
impl Params for PddCmsUrlGenerateParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(channel_type) = self.channel_type.to_owned() {
params.push(("channel_type".to_owned(), channel_type.to_string()));
}
if let Some(generate_schema_url) = self.generate_schema_url.to_owned() {
params.push(("generate_schema_url".to_owned(), generate_schema_url.to_string()));
}
if let Some(generate_mobile) = self.generate_mobile.to_owned() {
params.push(("generate_mobile".to_owned(), generate_mobile.to_string()));
}
if let Some(multi_group) = self.multi_group.to_owned() {
params.push(("multi_group".to_owned(), multi_group.to_string()));
}
if let Some(generate_short_url) = self.generate_short_url.to_owned() {
params.push(("generate_short_url".to_owned(), generate_short_url.to_string()));
}
if let Some(p_id_list) = self.p_id_list.to_owned() {
params.push(("p_id_list".to_owned(), format!("[\"{}\"]",p_id_list.join("\",\"").to_string())));
}
if let Some(custom_parameters) = self.custom_parameters.to_owned() {
params.push(("custom_parameters".to_owned(), custom_parameters));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddOrderRangeQueryParam {
pub last_order_id: Option<String>,
pub start_time: Option<String>,
pub end_time: Option<String>,
pub page_size: Option<u64>,
pub query_order_type: Option<u8>,
}
impl Params for PddOrderRangeQueryParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(last_order_id) = self.last_order_id.to_owned() {
params.push(("last_order_id".to_owned(), last_order_id.to_string()));
}
if let Some(start_time) = self.start_time.to_owned() {
params.push(("start_time".to_owned(), start_time.to_string()));
}
if let Some(end_time) = self.end_time.to_owned() {
params.push(("end_time".to_owned(), end_time.to_string()));
}
if let Some(page_size) = self.page_size.to_owned() {
params.push(("page_size".to_owned(), page_size.to_string()));
}
if let Some(query_order_type) = self.query_order_type.to_owned() {
params.push(("query_order_type".to_owned(), query_order_type.to_string()));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddOrderDetailParam {
pub order_sn: String,
pub query_order_type: Option<u8>,
}
impl Params for PddOrderDetailParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
params.push(("order_sn".to_owned(), self.order_sn.to_string()));
if let Some(query_order_type) = self.query_order_type.to_owned() {
params.push(("query_order_type".to_owned(), query_order_type.to_string()));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddOrderIncrementQueryParam {
pub end_update_time: u64,
pub start_update_time: u64,
pub return_count: Option<bool>,
pub page_size: Option<u64>,
pub page: Option<u64>,
pub query_order_type: Option<u8>,
}
impl Params for PddOrderIncrementQueryParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(return_count) = self.return_count.to_owned() {
params.push(("return_count".to_owned(), return_count.to_string()));
}
params.push(("end_update_time".to_owned(), self.end_update_time.to_string()));
params.push(("start_update_time".to_owned(), self.start_update_time.to_string()));
if let Some(page_size) = self.page_size.to_owned() {
params.push(("page_size".to_owned(), page_size.to_string()));
}
if let Some(page) = self.page.to_owned() {
params.push(("page".to_owned(), page.to_string()));
}
if let Some(query_order_type) = self.query_order_type.to_owned() {
params.push(("query_order_type".to_owned(), query_order_type.to_string()));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddPidGenerateParam {
pub number: u32,
pub p_id_name_list: Option<Vec<String>>,
pub media_id: Option<u64>,
}
impl Params for PddPidGenerateParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(media_id) = self.media_id.to_owned() {
params.push(("media_id".to_owned(), media_id.to_string()));
}
params.push(("number".to_owned(), self.number.to_string()));
if let Some(p_id_name_list) = self.p_id_name_list.to_owned() {
params.push(("p_id_name_list".to_owned(), format!("[\"{}\"]",p_id_name_list.join("\",\"").to_string())));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddPidQueryParam {
pub page_size: Option<u64>,
pub page: Option<u64>,
pub status: Option<u8>,
pub pid_list: Option<Vec<String>>,
}
impl Params for PddPidQueryParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
if let Some(status) = self.status.to_owned() {
params.push(("status".to_owned(), status.to_string()));
}
if let Some(page_size) = self.page_size.to_owned() {
params.push(("page_size".to_owned(), page_size.to_string()));
}
if let Some(page) = self.page.to_owned() {
params.push(("page".to_owned(), page.to_string()));
}
if let Some(pid_list) = self.pid_list.to_owned() {
params.push(("pid_list".to_owned(), format!("[\"{}\"]",pid_list.join("\",\"").to_string())));
}
params
}
}
#[derive(Debug, Serialize)]
pub struct PddPidBindMediaParam {
pub media_id: u64,
pub pid_list: Vec<String>,
}
impl Params for PddPidBindMediaParam {
fn get_params(&self) -> Vec<(String, String)> {
let mut params = Vec::new();
params.push(("media_id".to_owned(), self.media_id.to_string()));
params.push(("pid_list".to_owned(), format!("[\"{}\"]",self.pid_list.join("\",\"").to_string())));
params
}
}