package ability585

import (
	"errors"
	"git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk"
	request2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability585/request"
	response2 "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability585/response"
	"git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/util"
	"log"
)

type Ability585 struct {
	Client *topsdk.TopClient
}

func NewAbility585(client *topsdk.TopClient) *Ability585 {
	return &Ability585{client}
}

/*
   查询商品
*/
func (ability *Ability585) AlibabaWdkSkuQuery(req *request2.AlibabaWdkSkuQueryRequest, session string) (*response2.AlibabaWdkSkuQueryResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.sku.query", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSkuQueryResponse{}
	if err != nil {
		log.Println("alibabaWdkSkuQuery error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   更新商品
*/
func (ability *Ability585) AlibabaWdkSkuUpdate(req *request2.AlibabaWdkSkuUpdateRequest, session string) (*response2.AlibabaWdkSkuUpdateResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.sku.update", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSkuUpdateResponse{}
	if err != nil {
		log.Println("alibabaWdkSkuUpdate error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   更新渠道商品
*/
func (ability *Ability585) AlibabaWdkSkuChannelskuUpdate(req *request2.AlibabaWdkSkuChannelskuUpdateRequest, session string) (*response2.AlibabaWdkSkuChannelskuUpdateResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.sku.channelsku.update", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSkuChannelskuUpdateResponse{}
	if err != nil {
		log.Println("alibabaWdkSkuChannelskuUpdate error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   新增渠道商品
*/
func (ability *Ability585) AlibabaWdkSkuChannelskuAdd(req *request2.AlibabaWdkSkuChannelskuAddRequest, session string) (*response2.AlibabaWdkSkuChannelskuAddResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.sku.channelsku.add", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSkuChannelskuAddResponse{}
	if err != nil {
		log.Println("alibabaWdkSkuChannelskuAdd error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   新增商品
*/
func (ability *Ability585) AlibabaWdkSkuAdd(req *request2.AlibabaWdkSkuAddRequest, session string) (*response2.AlibabaWdkSkuAddResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.sku.add", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSkuAddResponse{}
	if err != nil {
		log.Println("alibabaWdkSkuAdd error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   查询渠道商品
*/
func (ability *Ability585) AlibabaWdkSkuChannelskuQuery(req *request2.AlibabaWdkSkuChannelskuQueryRequest, session string) (*response2.AlibabaWdkSkuChannelskuQueryResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.sku.channelsku.query", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSkuChannelskuQueryResponse{}
	if err != nil {
		log.Println("alibabaWdkSkuChannelskuQuery error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   系列品-商品排序
*/
func (ability *Ability585) AlibabaWdkSeriesSort(req *request2.AlibabaWdkSeriesSortRequest, session string) (*response2.AlibabaWdkSeriesSortResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.series.sort", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSeriesSortResponse{}
	if err != nil {
		log.Println("alibabaWdkSeriesSort error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   组合商品查询接口
*/
func (ability *Ability585) AlibabaWdkSkuCombineskuQuery(req *request2.AlibabaWdkSkuCombineskuQueryRequest, session string) (*response2.AlibabaWdkSkuCombineskuQueryResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.sku.combinesku.query", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSkuCombineskuQueryResponse{}
	if err != nil {
		log.Println("alibabaWdkSkuCombineskuQuery error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   组合商品更新接口
*/
func (ability *Ability585) AlibabaWdkSkuCombineskuUpdate(req *request2.AlibabaWdkSkuCombineskuUpdateRequest, session string) (*response2.AlibabaWdkSkuCombineskuUpdateResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.sku.combinesku.update", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSkuCombineskuUpdateResponse{}
	if err != nil {
		log.Println("alibabaWdkSkuCombineskuUpdate error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   组合商品新增接口
*/
func (ability *Ability585) AlibabaWdkSkuCombineskuAdd(req *request2.AlibabaWdkSkuCombineskuAddRequest, session string) (*response2.AlibabaWdkSkuCombineskuAddResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.sku.combinesku.add", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSkuCombineskuAddResponse{}
	if err != nil {
		log.Println("alibabaWdkSkuCombineskuAdd error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   查询平台类目
*/
func (ability *Ability585) AlibabaWdkPlatformCategoryQuery(req *request2.AlibabaWdkPlatformCategoryQueryRequest, session string) (*response2.AlibabaWdkPlatformCategoryQueryResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.platform.category.query", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkPlatformCategoryQueryResponse{}
	if err != nil {
		log.Println("alibabaWdkPlatformCategoryQuery error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   系列品商品变更-添加商品
*/
func (ability *Ability585) AlibabaWdkSeriesSkuAdd(req *request2.AlibabaWdkSeriesSkuAddRequest, session string) (*response2.AlibabaWdkSeriesSkuAddResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.series.sku.add", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSeriesSkuAddResponse{}
	if err != nil {
		log.Println("alibabaWdkSeriesSkuAdd error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   商家产品服务-编辑产品
*/
func (ability *Ability585) AlibabaWdkMerchantproductEdit(req *request2.AlibabaWdkMerchantproductEditRequest, session string) (*response2.AlibabaWdkMerchantproductEditResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.merchantproduct.edit", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkMerchantproductEditResponse{}
	if err != nil {
		log.Println("alibabaWdkMerchantproductEdit error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   系列品商品变更-移除商品
*/
func (ability *Ability585) AlibabaWdkSeriesSkuRemove(req *request2.AlibabaWdkSeriesSkuRemoveRequest, session string) (*response2.AlibabaWdkSeriesSkuRemoveResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.series.sku.remove", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSeriesSkuRemoveResponse{}
	if err != nil {
		log.Println("alibabaWdkSeriesSkuRemove error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   系列品变更-更新系列
*/
func (ability *Ability585) AlibabaWdkSeriesEdit(req *request2.AlibabaWdkSeriesEditRequest, session string) (*response2.AlibabaWdkSeriesEditResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.series.edit", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSeriesEditResponse{}
	if err != nil {
		log.Println("alibabaWdkSeriesEdit error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   系列品商品变更-重置默认商品
*/
func (ability *Ability585) AlibabaWdkSeriesDefaultskuReset(req *request2.AlibabaWdkSeriesDefaultskuResetRequest, session string) (*response2.AlibabaWdkSeriesDefaultskuResetResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.series.defaultsku.reset", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkSeriesDefaultskuResetResponse{}
	if err != nil {
		log.Println("alibabaWdkSeriesDefaultskuReset error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   盒马帮退货信息回传接口
*/
func (ability *Ability585) AlibabaWdkWholesaleInboundorderCommit(req *request2.AlibabaWdkWholesaleInboundorderCommitRequest) (*response2.AlibabaWdkWholesaleInboundorderCommitResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.Execute("alibaba.wdk.wholesale.inboundorder.commit", req.ToMap(), req.ToFileMap())
	var respStruct = response2.AlibabaWdkWholesaleInboundorderCommitResponse{}
	if err != nil {
		log.Println("alibabaWdkWholesaleInboundorderCommit error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   盒马帮发货信息回传接口
*/
func (ability *Ability585) AlibabaWdkWholesaleOutboundorderCommit(req *request2.AlibabaWdkWholesaleOutboundorderCommitRequest, session string) (*response2.AlibabaWdkWholesaleOutboundorderCommitResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.ExecuteWithSession("alibaba.wdk.wholesale.outboundorder.commit", req.ToMap(), req.ToFileMap(), session)
	var respStruct = response2.AlibabaWdkWholesaleOutboundorderCommitResponse{}
	if err != nil {
		log.Println("alibabaWdkWholesaleOutboundorderCommit error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}

/*
   盒马帮采购确认订单接口
*/
func (ability *Ability585) AlibabaWdkWholesaleOrderCommit(req *request2.AlibabaWdkWholesaleOrderCommitRequest) (*response2.AlibabaWdkWholesaleOrderCommitResponse, error) {
	if ability.Client == nil {
		return nil, errors.New("Ability585 topClient is nil")
	}
	var jsonStr, err = ability.Client.Execute("alibaba.wdk.wholesale.order.commit", req.ToMap(), req.ToFileMap())
	var respStruct = response2.AlibabaWdkWholesaleOrderCommitResponse{}
	if err != nil {
		log.Println("alibabaWdkWholesaleOrderCommit error", err)
		return &respStruct, err
	}
	err = util.HandleJsonResponse(jsonStr, &respStruct)
	if respStruct.Body == "" || len(respStruct.Body) == 0 {
		respStruct.Body = jsonStr
	}
	return &respStruct, err
}
