PddApi

Struct PddApi 

Source
pub struct PddApi<'a> { /* private fields */ }
Expand description

拼多多平台 API

提供拼多多平台相关的 API 调用方法

§Example

use ztk_rust_sdk::ZtkClient;
use ztk_rust_sdk::pdd::PddConvertRequest;

#[tokio::main]
async fn main() -> ztk_rust_sdk::ZtkResult<()> {
    let client = ZtkClient::new("your_appkey").build()?;
     
    let request = PddConvertRequest::new(
        "pdd_app_key",
        "pdd_app_secret",
        "pid",
        "453581732819"
    );
     
    let result = client.pdd().convert(request).await?;
    println!("转链结果: {:?}", result);
     
    Ok(())
}

Implementations§

Source§

impl<'a> PddApi<'a>

Source

pub fn new(client: &'a ZtkClient) -> Self

创建拼多多 API 实例

§Arguments
  • client - ZtkClient 引用
Source

pub async fn convert( &self, request: PddConvertRequest, ) -> ZtkResult<PddConvertResponse>

拼多多转链

将商品 ID 或推广短链转换为推广链接

§Arguments
  • request - 转链请求参数
§Returns

返回转链结果,包含多种推广链接

§Example
let request = PddConvertRequest::new("pdd_app_key", "pdd_app_secret", "pid", "453581732819")
    .custom_parameters(r#"{"uid":"user123"}"#);
let result = client.pdd().convert(request).await?;
Source

pub async fn goods_detail_simple( &self, request: PddGoodsDetailSimpleRequest, ) -> ZtkResult<PddGoodsDetailSimpleResponse>

商品详情 (简版)

获取拼多多商品的基本详情信息

§Arguments
  • request - 商品详情请求参数
§Returns

返回商品基本信息

§Example
let request = PddGoodsDetailSimpleRequest::new("pdd_app_key", "pdd_app_secret", "pid", "453581732819");
let result = client.pdd().goods_detail_simple(request).await?;
Source

pub async fn goods_detail_full( &self, request: PddGoodsDetailFullRequest, ) -> ZtkResult<PddGoodsDetailFullResponse>

商品详情 (详版)

获取拼多多商品的详细信息,支持多种筛选条件

§Arguments
  • request - 商品详情请求参数
§Returns

返回商品详细信息

§Example
let request = PddGoodsDetailFullRequest::new("pdd_app_key", "pdd_app_secret", "pid", "453581732819")
    .sort_type(2)
    .with_coupon(true);
let result = client.pdd().goods_detail_full(request).await?;
Source

pub async fn query_orders( &self, request: PddOrderQueryRequest, ) -> ZtkResult<PddOrderResponse>

订单查询

查询拼多多推广订单

§Arguments
  • request - 订单查询请求参数
§Returns

返回订单列表数据

§Example
let request = PddOrderQueryRequest::new("pdd_app_key", "pdd_app_secret", 1699200000, 1699286400)
    .page(1)
    .page_size(50);
let result = client.pdd().query_orders(request).await?;
Source

pub async fn authorize( &self, request: PddAuthorizeRequest, ) -> ZtkResult<PddAuthorizeResponse>

授权备案

获取授权备案 URL,用于在服务器上进行 PID 授权备案

§Arguments
  • request - 授权备案请求参数
§Returns

返回授权备案 URL

§Example
let request = PddAuthorizeRequest::new("pdd_app_key", "pdd_app_secret", "pid");
let result = client.pdd().authorize(request).await?;
// 使用返回的 URL 在服务器浏览器中打开进行授权备案
Source

pub async fn authorize_query( &self, request: PddAuthorizeQueryRequest, ) -> ZtkResult<PddAuthorizeQueryResponse>

授权备案查询

查询 PID 授权备案状态

§Arguments
  • request - 授权备案查询请求参数
§Returns

返回授权备案状态

§Example
let request = PddAuthorizeQueryRequest::new("pdd_app_key", "pdd_app_secret", "pid");
let result = client.pdd().authorize_query(request).await?;
if result.response.map(|r| r.bind == Some(1)).unwrap_or(false) {
    println!("授权备案成功");
}

Auto Trait Implementations§

§

impl<'a> Freeze for PddApi<'a>

§

impl<'a> !RefUnwindSafe for PddApi<'a>

§

impl<'a> Send for PddApi<'a>

§

impl<'a> Sync for PddApi<'a>

§

impl<'a> Unpin for PddApi<'a>

§

impl<'a> !UnwindSafe for PddApi<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more