From 06a1b727bd75a8caf1fc56a225c0bbe4899a1c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E4=B8=AD=E6=B5=B7?= Date: Tue, 18 Oct 2022 16:04:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feature=201.=20=E6=B7=BB=E5=8A=A0=EF=BC=9A?= =?UTF-8?q?=E6=8B=BC=E5=A4=9A=E5=A4=9A-=E6=8E=88=E6=9D=83=E5=A4=87?= =?UTF-8?q?=E6=A1=88-=E5=88=9B=E5=BB=BA=E3=80=81=E6=8B=BC=E5=A4=9A?= =?UTF-8?q?=E5=A4=9A-=E6=8E=88=E6=9D=83=E5=A4=87=E6=A1=88-=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E3=80=81=E6=8A=96=E9=9F=B3-=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/openapi.go | 27 +++++++++++++++++ sdk/openapi_test.go | 74 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 sdk/openapi_test.go diff --git a/sdk/openapi.go b/sdk/openapi.go index e8f4f6f..eafa02a 100644 --- a/sdk/openapi.go +++ b/sdk/openapi.go @@ -786,3 +786,30 @@ func (api *OpenApi) JdGoodsDetails(params map[string]string) (string, *Error) { apiUrl := "https://openapi.dataoke.com/api/dels/jd/goods/get-details" return api.Client.Request(apiUrl, params, GET) } + +// PddOauthGenerate 拼多多授权生成 +// @params map[string]string 请求参数 +// @return string 接口返回json字符串 +// @return *Error 异常错误 +func (api *OpenApi) PddOauthGenerate(params map[string]string) (string, *Error) { + apiUrl := "https://openapi.dataoke.com/api/ppd/generate-prom-url" + return api.Client.Request(apiUrl, params, GET) +} + +// PddOauthQuery 拼多多授权查询 +// @params map[string]string 请求参数 +// @return string 接口返回json字符串 +// @return *Error 异常错误 +func (api *OpenApi) PddOauthQuery(params map[string]string) (string, *Error) { + apiUrl := "https://openapi.dataoke.com/api/ppd/authority-query" + return api.Client.Request(apiUrl, params, GET) +} + +// TiktokOrderList 抖音订单列表 +// @params map[string]string 请求参数 +// @return string 接口返回json字符串 +// @return *Error 异常错误 +func (api *OpenApi) TiktokOrderList(params map[string]string) (string, *Error) { + apiUrl := "https://openapi.dataoke.com/api/tiktok/order-list" + return api.Client.Request(apiUrl, params, GET) +} \ No newline at end of file diff --git a/sdk/openapi_test.go b/sdk/openapi_test.go new file mode 100644 index 0000000..84cddc3 --- /dev/null +++ b/sdk/openapi_test.go @@ -0,0 +1,74 @@ +package sdk + +import ( + "fmt" + "testing" +) + +// 获取测试的SDK客户端 +func getTestSDKClient() *OpenApi { + // 1.初始化所需要的参数appKey, appSecret, version + var ( + appKey = "xxxxxxxxxx" + appSecret = "xxxxxxxxxx" + version = "v2.0.0" + ) + + // 2.初始化开放平台api的客户端句柄 + oa := &OpenApi{} + oa.AppKey = appKey + oa.AppSecret = appSecret + oa.Version = version + return oa.GetClient() +} + +// 拼多多-授权备案-创建 +func Test_PddOauthGenerate(t *testing.T) { + client := getTestSDKClient() + + // 3.准备请求参数 + params := map[string]string { + "p_id_list": `8978575_232157258`, // 推广位,仅支持单个推广位 + "custom_parameters": `{"uid":"11111","sid":"22222"}`, // 自定义参数 + } + + resp, err := client.PddOauthGenerate(params) + if err != nil { + panic(err) + } + fmt.Println(resp) +} + +// 拼多多-授权备案-查询 +func Test_PddOauthQuery(t *testing.T) { + client := getTestSDKClient() + // 3.准备请求参数 + params := map[string]string { + "pid": `8978575_232157258`, // 推广位 + "custom_parameters": `{"uid":"11111","sid":"22222"}`, // 自定义参数 + } + resp, err := client.PddOauthQuery(params) + if err != nil { + panic(err) + } + fmt.Println(resp) +} + +// 抖音-订单列表 +func Test_TiktokOrderList(t *testing.T) { + client := getTestSDKClient() + // 3.准备请求参数 + params := map[string]string { + "start_time": ``, // 开始时间 + "end_time": ``, // 结束时间 + "order_ids": `1`, // 订单ID列表,多个订单以,分割 + "external_info": ``, // 外部参数 + "page": `1`, // 页码 + "size": `20`, // 每页数量 + } + resp, err := client.TiktokOrderList(params) + if err != nil { + panic(err) + } + fmt.Println(resp) +} \ No newline at end of file -- Gitee From b5c60f19be8afeeaa5bb49827093b551fcbf504f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E4=B8=AD=E6=B5=B7?= Date: Wed, 19 Oct 2022 10:55:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?optimize=201.=20=E8=B0=83=E6=95=B4=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=AF=B7=E6=B1=82=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/openapi.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/openapi.go b/sdk/openapi.go index eafa02a..0a84ea9 100644 --- a/sdk/openapi.go +++ b/sdk/openapi.go @@ -792,7 +792,7 @@ func (api *OpenApi) JdGoodsDetails(params map[string]string) (string, *Error) { // @return string 接口返回json字符串 // @return *Error 异常错误 func (api *OpenApi) PddOauthGenerate(params map[string]string) (string, *Error) { - apiUrl := "https://openapi.dataoke.com/api/ppd/generate-prom-url" + apiUrl := "https://openapi.dataoke.com/open-api/ppd/generate-prom-url" return api.Client.Request(apiUrl, params, GET) } @@ -801,7 +801,7 @@ func (api *OpenApi) PddOauthGenerate(params map[string]string) (string, *Error) // @return string 接口返回json字符串 // @return *Error 异常错误 func (api *OpenApi) PddOauthQuery(params map[string]string) (string, *Error) { - apiUrl := "https://openapi.dataoke.com/api/ppd/authority-query" + apiUrl := "https://openapi.dataoke.com/open-api/ppd/authority-query" return api.Client.Request(apiUrl, params, GET) } @@ -810,6 +810,6 @@ func (api *OpenApi) PddOauthQuery(params map[string]string) (string, *Error) { // @return string 接口返回json字符串 // @return *Error 异常错误 func (api *OpenApi) TiktokOrderList(params map[string]string) (string, *Error) { - apiUrl := "https://openapi.dataoke.com/api/tiktok/order-list" + apiUrl := "https://openapi.dataoke.com/open-api/tiktok/order-list" return api.Client.Request(apiUrl, params, GET) } \ No newline at end of file -- Gitee From 5e4230ca034f47cd5e4af6e2ba100c980a4bc64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=9C=E4=B8=AD=E6=B5=B7?= Date: Wed, 19 Oct 2022 15:30:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feature=201.=20=E6=9B=B4=E6=94=B9=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/openapi.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/openapi.go b/sdk/openapi.go index 0a84ea9..eafa02a 100644 --- a/sdk/openapi.go +++ b/sdk/openapi.go @@ -792,7 +792,7 @@ func (api *OpenApi) JdGoodsDetails(params map[string]string) (string, *Error) { // @return string 接口返回json字符串 // @return *Error 异常错误 func (api *OpenApi) PddOauthGenerate(params map[string]string) (string, *Error) { - apiUrl := "https://openapi.dataoke.com/open-api/ppd/generate-prom-url" + apiUrl := "https://openapi.dataoke.com/api/ppd/generate-prom-url" return api.Client.Request(apiUrl, params, GET) } @@ -801,7 +801,7 @@ func (api *OpenApi) PddOauthGenerate(params map[string]string) (string, *Error) // @return string 接口返回json字符串 // @return *Error 异常错误 func (api *OpenApi) PddOauthQuery(params map[string]string) (string, *Error) { - apiUrl := "https://openapi.dataoke.com/open-api/ppd/authority-query" + apiUrl := "https://openapi.dataoke.com/api/ppd/authority-query" return api.Client.Request(apiUrl, params, GET) } @@ -810,6 +810,6 @@ func (api *OpenApi) PddOauthQuery(params map[string]string) (string, *Error) { // @return string 接口返回json字符串 // @return *Error 异常错误 func (api *OpenApi) TiktokOrderList(params map[string]string) (string, *Error) { - apiUrl := "https://openapi.dataoke.com/open-api/tiktok/order-list" + apiUrl := "https://openapi.dataoke.com/api/tiktok/order-list" return api.Client.Request(apiUrl, params, GET) } \ No newline at end of file -- Gitee