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

namespace Topsdk.Top.Ability369;


public class Ability369
{

    private ITopApiClient topApiClient;

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

    /*
        淘宝客-推广者-权益物料精选
        taobao.tbk.dg.optimus.promotion
    */
    public TaobaoTbkDgOptimusPromotionResponse TaobaoTbkDgOptimusPromotion(TaobaoTbkDgOptimusPromotionRequest request)
    {
        var jsonResult = topApiClient.Execute(request.GetApiCode(),request.ToRequestParam(),request.ToFileParam());
        if (string.IsNullOrEmpty(jsonResult))
        {
            throw new Exception("error");
        }
        var resultObj = TopUtils.parseResultJson<TaobaoTbkDgOptimusPromotionResponse>(jsonResult);
        if(string.IsNullOrEmpty(resultObj.Body))
        {
            resultObj.Body = jsonResult;
        }
        return resultObj;
    }

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