# HG changeset patch # User Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> # Date 1613823004 -3600 # Node ID 2dc7d0b855d624b554a7c6693cf93d3b14428ddd # Parent 66f8783d1e2d06ff902b9237c16fa3a7bcb3a2ec Test SearchApi diff -r 66f8783d1e2d -r 2dc7d0b855d6 LazyBear/Tests/TestSearchAPI.swift --- a/LazyBear/Tests/TestSearchAPI.swift Sat Feb 20 13:09:44 2021 +0100 +++ b/LazyBear/Tests/TestSearchAPI.swift Sat Feb 20 13:10:04 2021 +0100 @@ -8,8 +8,23 @@ import SwiftUI struct TestSearchAPI: View { + @State private var companies = [CompanyModel]() + var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + Button(action: { print(companies) }) { + Text("Print companies") + } + .onAppear { + request(url: getUrl(), model: [CompanyModel].self) { self.companies = $0 } + } + } + + private func getUrl() -> String { + let baseUrl = Bundle.main.infoDictionary?["IEX_URL"] as? String ?? "Empty url" + let apiKey = Bundle.main.infoDictionary?["IEX_API"] as? String ?? "Empty key" + let url = "\(baseUrl)/search/apple?token=\(apiKey)" + + return url } }