BagbutikService

public actor BagbutikService

Service responsible for sending generated App Store Connect requests.

A service instance owns the current JWT and automatically refreshes its signature before a request is sent if the token has expired. It also centralizes response decoding, HTTP error mapping, and pagination helpers for responses conforming to PagedResponse.

  • Creates a service that can execute generated Request values.

    Declaration

    Swift

    public init(jwt: JWT, fetchData: @escaping FetchData = URLSession.shared.data(for:delegate:))

    Parameters

    jwt

    The token used to authorize outgoing requests.

    fetchData

    The transport closure used to execute requests. The default uses URLSession.shared.

  • request(_:) Asynchronous

    Executes a single request and decodes the response body into the request’s response type.

    Declaration

    Swift

    public func request<T>(_ request: Request<T, ErrorResponse>) async throws -> T
        where T: Decodable & Sendable

    Parameters

    request

    The generated request to execute.

    Return Value

    The decoded response value.

  • request(_:) Asynchronous

    Executes a request that is expected to succeed without returning a response body.

    Declaration

    Swift

    @discardableResult
    public func request(_ request: Request<EmptyResponse, ErrorResponse>) async throws -> EmptyResponse

    Parameters

    request

    The generated request to execute.

    Return Value

    An EmptyResponse value when the request succeeds.

  • requestAllPages(_:) Asynchronous

    Executes the initial paged request and follows next links until every page has been fetched.

    The returned responses array preserves page order. The returned data array is the concatenation of every page’s data collection in that same order.

    Declaration

    Swift

    public func requestAllPages<T>(_ request: Request<T, ErrorResponse>) async throws -> (responses: [T], data: [T.Data])
        where T: Decodable & PagedResponse & Sendable, T.Data: Sendable

    Parameters

    request

    The first paged request to execute.

    Return Value

    All decoded page responses and a flattened array of every resource item.

  • requestNextPage(for:) Asynchronous

    Fetches the next page for a paged response.

    Declaration

    Swift

    public func requestNextPage<T>(for response: T) async throws -> T?
        where T: Decodable & PagedResponse & Sendable

    Parameters

    response

    A previously decoded paged response.

    Return Value

    The next decoded page, or nil when no next link is available.

  • requestAllPages(for:) Asynchronous

    Continues fetching pages starting from an already decoded first page.

    This is useful when you need to inspect the first page before deciding whether to load the rest of the result set.

    Declaration

    Swift

    public func requestAllPages<T>(for response: T) async throws -> (responses: [T], data: [T.Data])
        where T: Decodable & PagedResponse & Sendable, T.Data: Sendable

    Parameters

    response

    The first page that has already been fetched.

    Return Value

    All page responses including response, plus a flattened array of every item.