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

namespace Topsdk.Top.Ability2138;


public class Ability2138
{

    private ITopApiClient topApiClient;

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

    /*
        淘宝客-推广者-新用户订单明细查询
        taobao.tbk.dg.newuser.order.get
    */
    public TaobaoTbkDgNewuserOrderGetResponse TaobaoTbkDgNewuserOrderGet(TaobaoTbkDgNewuserOrderGetRequest request)
    {
        var jsonResult = topApiClient.Execute(request.GetApiCode(),request.ToRequestParam(),request.ToFileParam());
        if (string.IsNullOrEmpty(jsonResult))
        {
            throw new Exception("error");
        }
        var resultObj = TopUtils.parseResultJson<TaobaoTbkDgNewuserOrderGetResponse>(jsonResult);
        if(string.IsNullOrEmpty(resultObj.Body))
        {
            resultObj.Body = jsonResult;
        }
        return resultObj;
    }

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