Labrador   ![Build Status] ![Latest Version] ![labrador: rustc 1.13+]

Labrador - Mini client for rust

This create offers:

Features:

Supported Platform

| Platform | is supported | |---------------------------------------------------------------------------|--------------| | Wechat:mp(微信公众号),cp(企业微信),miniapp(微信小程序),pay(微信支付) | √ | | Alipay(支付宝) | √ |
| Taobao(淘宝客) | √ | | JD(京东联盟) | √ |
| PDD(拼多多-多多客) | √ |


You may be looking for:

Labrador in action

Click to show Cargo.toml. Run this code in the playground.

```toml [dependencies]

The core APIs

labrador = { version = "0.1.0", features = ["wechat", "alipay"] }

```

API Documentation

Example

With Wechat(微信开放平台、包含微信支付)

```rust use labrador::{WeChatPayClient, SimpleStorage, TradeType, WeChatPayRequestV3, Amount, Payer}; use chrono::{Local, SecondsFormat};

#[tokio::main] async fn main() { let c = WeChatPayClient::new("appid", "secret", SimpleStorage::new()); let mut client =c.wxpay(); let date = Local::now().torfc3339opts(SecondsFormat::Secs, false); let result = client.unifiedorderv3(TradeType::Jsapi, WeChatPayRequestV3 { appid: "appid".tostring().into(), mchid: "mchid".tostring(), description: "测试商品支付".tostring(), outtradeno: "1602920235sdfsdfas32234234".tostring(), timeexpire: date, attach: None, notifyurl: "https:xxx.cn/trade/notify".tostring(), amount: Amount { total: 1, currency: String::from("CNY").into(), payertotal: None, payercurrency: None }, payer: Payer { openid: "oUVZc6SuGx3bsNPUA-davo4Dt7Us".tostring() }.into(), detail: None, sceneinfo: None, settleinfo: None }); match result.await { Ok(res) => {} Err(err) => {} } } ```

With Alipay(支付宝)

```rust use labrador::{AlipayTradeWapPayRequest, AlipayClient};

#[tokio::main] async fn main() { let param = AlipayTradeWapPayRequest::default(); let client = AlipayClient::new("appKey", false); match client.wap_pay("POST".into(), param).await { Ok(res) => {} Err(err) => {} } match result.await { Ok(res) => {} Err(err) => {} } } ```

With Taobao(淘宝客相关)

```rust use labrador::{TbItemDetailRequest, TaobaoClient};

#[tokio::main] async fn main() { let client = TaobaoClient::::new("appkey", "secret"); let req = TbItemDetailRequest { numiids: Some("597649283190".tostring()), platform: None, ip: None }; let result = client.getitemdetail(req); match result.await { Ok(res) => { } Err(err) => { } } } ```

With JD(京东,目前暂时只支持联盟相关)

```rust use labrador::{JDClient, JdOrderRawQueryParam}; use chrono::{Local, SecondsFormat};

#[tokio::main] async fn main() { let client = JDClient::::new("appkey", "secert"); let param = JdOrderRawQueryParam { pageindex: 1.into(), pagesize: 10.into(), billtype: 1, starttime: "2022-08-02 21:23:00".tostring(), endtime: "2022-08-02 21:43:00".tostring(), childunionid: None, key: None, fields: None }; let result = client.queryraw_order(param); match result.await { Ok(res) => { } Err(err) => { } } } ```

With Custom Request

You can implement this trait and then use the custom request

Feature

We will gradually improve the corresponding API

Developing

To setup the development envrionment run cargo run.

Contributers

MrPan <1049058427@qq.com>

Getting help

Labrador is a personal project. At the beginning, I just like Labrador dog because of my hobbies. I hope this project will grow more and more lovely. Many practical database functions will be added in the future. I hope you can actively help this project grow and put forward suggestions. I believe the future will be better and better.


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Labrador by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.