JdApi

Struct JdApi 

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

京东平台 API

提供京东平台相关的 API 调用方法

§Example

use ztk_rust_sdk::ZtkClient;
use ztk_rust_sdk::jd::{JdConvertRequest, JdChainType};

#[tokio::main]
async fn main() -> ztk_rust_sdk::ZtkResult<()> {
    let client = ZtkClient::new("your_appkey").build()?;
     
    let request = JdConvertRequest::new("https://item.jd.com/123456.html", "your_union_id")
        .chain_type(JdChainType::Short);
     
    let result = client.jd().convert(request).await?;
    println!("转链结果: {:?}", result);
     
    Ok(())
}

Implementations§

Source§

impl<'a> JdApi<'a>

Source

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

创建京东 API 实例

§Arguments
  • client - ZtkClient 引用
Source

pub async fn convert( &self, request: JdConvertRequest, ) -> ZtkResult<JdConvertResponse>

京东转链

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

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

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

§Example
let request = JdConvertRequest::new("https://item.jd.com/123456.html", "your_union_id")
    .position_id("12345")
    .chain_type(JdChainType::Short);
let result = client.jd().convert(request).await?;
Source

pub async fn jingfen_goods( &self, request: JingfenGoodsRequest, ) -> ZtkResult<JingfenGoodsResponse>

京粉精选商品

获取京粉精选商品列表

§Arguments
  • request - 京粉精选商品请求参数
§Returns

返回京粉精选商品列表

§Example
let request = JingfenGoodsRequest::new(JdEliteId::HotSale)
    .page_index(1)
    .page_size(20);
let result = client.jd().jingfen_goods(request).await?;
Source

pub async fn query_orders( &self, request: JdOrderQueryRequest, ) -> ZtkResult<JdOrderResponse>

订单查询

查询京东联盟订单

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

返回订单列表数据

§Example
let request = JdOrderQueryRequest::new("2024-01-01 00:00:00")
    .end_time("2024-01-31 23:59:59")
    .query_type(JdOrderQueryType::OrderTime)
    .page_no(1);
let result = client.jd().query_orders(request).await?;
Source

pub async fn goods_detail( &self, request: JdGoodsDetailRequest, ) -> ZtkResult<JdGoodsDetailResponse>

商品详情

获取京东商品详情信息

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

返回商品详情信息

§Example
let request = JdGoodsDetailRequest::new("10025768652616");
let result = client.jd().goods_detail(request).await?;
Source

pub async fn hot_goods( &self, request: JdHotGoodsRequest, ) -> ZtkResult<JdHotGoodsResponse>

朋友圈火爆商品

获取京东朋友圈火爆商品列表,包含精编社群推广文案

§Arguments
  • request - 朋友圈火爆商品请求参数
§Returns

返回朋友圈火爆商品列表

§Example
let request = JdHotGoodsRequest::new()
    .page_index(1)
    .page_size(20)
    .keyword("手机");
let result = client.jd().hot_goods(request).await?;

Auto Trait Implementations§

§

impl<'a> Freeze for JdApi<'a>

§

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

§

impl<'a> Send for JdApi<'a>

§

impl<'a> Sync for JdApi<'a>

§

impl<'a> Unpin for JdApi<'a>

§

impl<'a> !UnwindSafe for JdApi<'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