Skip to content

Add a feature to automatically remove wrappering #2081

@zms9110750

Description

@zms9110750

now , many API return a wrapper

public record PixivResponse<T>(
    bool Error,
    string? Message,
    T Body)
{ 
    public T Body { get => Error ? throw new PixivException(Message) : field; init; } = Body;
    
    public void ThrowIfError()
    {
        if (Error)
        {
            throw new PixivException(Message);
        }
    }
}

now, we must to

public interface IPixivClient
{

    [Get("user/{id}")]
    Task<PixivResponse<UserInfo>> GetUser(string id);
}

If there is a way to automatically parse the T Body, it would be very convenient.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions