Skip to content

Commit

Permalink
Fix internal
Browse files Browse the repository at this point in the history
  • Loading branch information
Pepijn98 committed Nov 14, 2019
1 parent f1258f1 commit 1f5b838
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# azurlane-swift
Wrapper for the unofficial azur lane json api in Swift

## Example
## Install
Import the library into your Package.swift
`.package(url: "https://github.com/azurlane-api/azurlane-swift.git", .branch("master"))`

## Example
12 changes: 6 additions & 6 deletions Sources/AzurLane/AzurLane.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ public enum Category: String {
}

public struct AzurLane {
let version = "1.0.0"
public let version = "1.0.0"
private let client: Client

init(_ userAgent: String? = nil) {
public init(_ userAgent: String? = nil) {
if let ua = userAgent {
self.client = Client(ua)
} else {
self.client = Client("azurlane-swift/v\(version) (https://github.com/azurlane-api/azurlane-swift)")
}
}

func getShipBy(name: String, result: @escaping (Result<ShipResponse, AzurLaneAPIError>) -> Void) {
public func getShipBy(name: String, result: @escaping (Result<ShipResponse, AzurLaneAPIError>) -> Void) {
client.fetchResource(.shipByName, params: [URLQueryItem(name: "name", value: name)], completion: result)
}

func getShipBy(id: String, result: @escaping (Result<ShipResponse, AzurLaneAPIError>) -> Void) {
public func getShipBy(id: String, result: @escaping (Result<ShipResponse, AzurLaneAPIError>) -> Void) {
client.fetchResource(.shipByID, params: [URLQueryItem(name: "id", value: id)], completion: result)
}

func getShips(from category: Category, with value: String, result: @escaping (Result<ShipsResponse, AzurLaneAPIError>) -> Void) {
public func getShips(from category: Category, with value: String, result: @escaping (Result<ShipsResponse, AzurLaneAPIError>) -> Void) {
client.fetchResource(.ships, params: [URLQueryItem(name: "orderBy", value: category.rawValue), URLQueryItem(name: category.rawValue, value: value)], completion: result)
}

func getBuildInfo(from time: String, result: @escaping (Result<BuildResponse, AzurLaneAPIError>) -> Void) {
public func getBuildInfo(from time: String, result: @escaping (Result<BuildResponse, AzurLaneAPIError>) -> Void) {
client.fetchResource(.construction, params: [URLQueryItem(name: "time", value: time)], completion: result)
}

Expand Down

0 comments on commit 1f5b838

Please sign in to comment.