🌈 APIResource
What is APIResource
APIResource is resource management library. Resources like HTTPMethod ( GET / POST ... ) or Query ( ?hello=world ) are managed. Important Thing is APIResource does not help for your network task like Alamofire but just manage your resources. Network Task is your job except for APIResource.get
You can use this library simply URL with APIResource, but also can use with enum and ResourceBase. please check Usage
so enjoy this Library and your star will be helpful to me
Installation
APIResource is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'APIResource'
Features
- initialize APIResource with urlString
- initialize APIResource with ResourceBase
- APIResource makes URLRequest
Thanks to PostmanEcho API, I can test my features and wrote it with XCTestClass.
empty box are features tested not enough
Usage
APIResource is core of this Library. you can make this with urlString or ResourceBase
// urlString is like "http://hello.com/path?12=34"
let apiResource: APIResource = APIResource("https://postman-echo.com/get?foo1=bar1&foo2=bar2")
// conform ResourceBase
enum PostmanEchoAPI {
case getRequest
}
extension PostmanEchoAPI: ResourceBase {
var host: String? {
switch self {
case .getRequest:
return "https://postman-echo.com/"
}
}
var path: String? {
switch self {
case .getRequest:
return "/get"
}
}
var queryString: String? {
switch self {
case .getRequest:
return "?foo1=bar1&foo2=bar2"
}
}
}
let apiResource: APIResource = PostmanEchoAPI.getRequest.apiResource
Inspired By
License
APIResource is available under the MIT license. See the LICENSE file for more info.