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

namespace Topsdk.Top.Ability374;


public class Ability374
{

    private ITopApiClient topApiClient;

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

    /*
        淘宝客-推广者-官方活动转链
        taobao.tbk.activity.info.get
    */
    public TaobaoTbkActivityInfoGetResponse TaobaoTbkActivityInfoGet(TaobaoTbkActivityInfoGetRequest request)
    {
        var jsonResult = topApiClient.Execute(request.GetApiCode(),request.ToRequestParam(),request.ToFileParam());
        if (string.IsNullOrEmpty(jsonResult))
        {
            throw new Exception("error");
        }
        var resultObj = TopUtils.parseResultJson<TaobaoTbkActivityInfoGetResponse>(jsonResult);
        if(string.IsNullOrEmpty(resultObj.Body))
        {
            resultObj.Body = jsonResult;
        }
        return resultObj;
    }

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