pdd

Crates.iopdd
lib.rspdd
version0.1.4
sourcesrc
created_at2023-09-22 06:37:44.981337
updated_at2023-12-04 06:19:15.66334
description拼多多开放平台sdk
homepage
repositoryhttps://github.com/Cherrs/pdd-rs
max_upload_size
id980358
size679,509
KuriyamaMirai (Cherrs)

documentation

README

拼多多开放平台Rust SDK

基于tokio开发的拼多多开发平台sdk,支持消息推送

Examples

1.添加依赖

[dependencies]
pdd = "0.1"
tokio = { version = "1", features = ["full"] }
futures-util = "0.3"
serde_json = "1"

2.设置环境变量

set PDD_CLIENT_ID=you_client_id
set PDD_CLIENT_SECRET=you_secret

#不是必须
set PDD_ACCESS_TOKEN=you_access_token

请求订单列表

    let client = Client::from_env()?;
    let req = PddOrderListGet {
        start_confirm_at: Some(1689250974),
        end_confirm_at: Some(1689260974),
        use_has_next: Some(true),
        order_status: Some(1),
        ..Default::default()
    };
    client.send(req).await?;

消息推送

需要开启pmc-native-tlsfeature

[dependencies]
pdd = { "0.1" , features=["pmc-native-tls"] }
tokio = { version = "1", features = ["full"] }
futures-util = "0.3"
serde_json = "1"
    let client = PmcClient::new(Config::from_env()?);
    let mut s = client.connect().await?;

    while let Some(msg) = s.next().await {
        let msg = msg.unwrap();
        println!("{:?}", msg);
        
        //ack消息
        s.ack(&msg).await;
    }

图片上传

    let client = Client::from_env()?;
    let req = PddGoodsFilespaceImageUpload {
        file: Some(PddFile::from_file("examples/1.jpg").await?),
    };
    let rsp = client.file_upload(req).await?;
Commit count: 30

cargo fmt