43 lines
937 B
Swift
43 lines
937 B
Swift
//
|
|
// GetItemsEndpoint.swift
|
|
// APIService
|
|
//
|
|
// Created by Javier Cicchelli on 04/12/2022.
|
|
// Copyright © 2022 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
struct GetItemsEndpoint: Endpoint {
|
|
let path: String
|
|
let method: RequestMethod
|
|
let credentials: BasicCredentials
|
|
let headers: [String : String]
|
|
let body: [String : String]?
|
|
}
|
|
|
|
// MARK: - Initialisers
|
|
|
|
extension GetItemsEndpoint {
|
|
init(
|
|
itemId: String,
|
|
username: String,
|
|
password: String
|
|
) {
|
|
self.path = .init(format: .Formats.itemsWithId, itemId)
|
|
self.method = .get
|
|
self.credentials = .init(
|
|
username: username,
|
|
password: password
|
|
)
|
|
self.headers = [.Header.Keys.contentType: .Header.Values.contentTypeJSON]
|
|
self.body = nil
|
|
}
|
|
}
|
|
|
|
// MARK: - String+Formats
|
|
|
|
private extension String {
|
|
enum Formats {
|
|
static let itemsWithId = "/items/%@"
|
|
}
|
|
}
|