Skip to content

Commit

Permalink
[#5] feat: requestTickers 메서드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HoonHaChoi committed Feb 24, 2022
1 parent ebfa79a commit 788cab0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions BithumbMarket/BithumbMarket/Network/APIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ struct APIService {
}
}

func requestTickers(url: URL?, completion: @escaping (Result<[Ticker], HTTPError>) -> Void) {
requestResource(url: url) { result in
switch result {
case .success(let data):
let serializeData = serialize(data: data)

switch serializeData {
case .success(let tickers):
completion(.success(tickers))
case .failure(let error):
completion(.failure(error))
}
case .failure(let error):
completion(.failure(error))
}
}
}

private func requestResource(url: URL?, completion: @escaping (Result<Data, HTTPError>) -> Void) {
guard let url = url else {
completion(.failure(.invalidURL))
Expand Down

0 comments on commit 788cab0

Please sign in to comment.