using Topsdk.Top.Ability372.Request;
using Topsdk.Top.Ability372.Response;
using Topsdk.Util;

namespace Topsdk.Top.Ability372;


public class Ability372
{

    private ITopApiClient topApiClient;

    public Ability372(ITopApiClient topApiClient)
    {
        this.topApiClient = topApiClient;
    }

    /*
        淘宝客-公用-店铺关联推荐
        taobao.tbk.shop.recommend.get
    */
    public TaobaoTbkShopRecommendGetResponse TaobaoTbkShopRecommendGet(TaobaoTbkShopRecommendGetRequest request)
    {
        var jsonResult = topApiClient.Execute(request.GetApiCode(),request.ToRequestParam(),request.ToFileParam());
        if (string.IsNullOrEmpty(jsonResult))
        {
            throw new Exception("error");
        }
        var resultObj = TopUtils.parseResultJson<TaobaoTbkShopRecommendGetResponse>(jsonResult);
        if(string.IsNullOrEmpty(resultObj.Body))
        {
            resultObj.Body = jsonResult;
        }
        return resultObj;
    }

    public ITopApiClient TopApiClient
    {
        get => topApiClient;
        set => topApiClient = value ?? throw new ArgumentNullException(nameof(value));
    }
}
