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
Requestvalues.Declaration
Parameters
jwtThe token used to authorize outgoing requests.
fetchDataThe 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 & SendableParameters
requestThe 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 -> EmptyResponseParameters
requestThe generated request to execute.
Return Value
An
EmptyResponsevalue when the request succeeds. -
requestAllPages(_:Asynchronous) Executes the initial paged request and follows
nextlinks until every page has been fetched.The returned
responsesarray preserves page order. The returneddataarray is the concatenation of every page’sdatacollection 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: SendableParameters
requestThe 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 & SendableParameters
responseA previously decoded paged response.
Return Value
The next decoded page, or
nilwhen nonextlink 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: SendableParameters
responseThe first page that has already been fetched.
Return Value
All page responses including
response, plus a flattened array of every item.
View on GitHub