This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate func newHandleNetworkResponse(_ response: HTTPURLResponse) -> Result<String, NetworkReponse> { | |
switch response.statusCode { | |
case 200...299: return Result.success("Success") | |
case 401...500: return Result.failure(.authenticationError) | |
case 501...599: return Result.failure(.badRequest) | |
case 600: return Result.failure(.outdated) | |
default: return Result.failure(.failed) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fileprivate func newHandleNetworkResponse(_ response: HTTPURLResponse) -> Result<String, NetworkReponse> { | |
switch response.statusCode { | |
case 200...299: return Result.success("Success") | |
case 401...500: return Result.failure(.authenticationError) | |
case 501...599: return Result.failure(.badRequest) | |
case 600: return Result.failure(.outdated) | |
default: return Result.failure(.failed) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum NetworkReponse: String, Error { // Conform to Error | |
case authenticationError = "You need to be authenticated first." | |
case badRequest = "Bad Request" | |
case outdated = "The url you requested is outdated." | |
case failed = "Network request failed." | |
case noData = "Response returned with no data to decode." | |
case unableToDecode = "We could not decode the response." | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum NetworkReponse: String, Error { | |
case authenticationError = "You need to be authenticated first." | |
case badRequest = "Bad Request" | |
case outdated = "The url you requested is outdated." | |
case failed = "Network request failed." | |
case noData = "Response returned with no data to decode." | |
case unableToDecode = "We could not decode the response." | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct NetworkManager { | |
static let environment: NetworkEnvironment = .production | |
private let keywordRouter = Router<KeywordAPI>() | |
private let scryfallRouter = Router<ScryfallAPI>() | |
enum NetworkReponse: String { | |
case success | |
case authenticationError = "You need to be authenticated first." | |
case badRequest = "Bad Request" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListDeque: | |
def __init__(self, iterable=None): | |
# Initialize a new list to store the items | |
self.list = list() | |
if iterable is not None: | |
self.list.extend(iterable) | |
def __repr__(self): | |
"""Return a string representation of this stack.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from doubly_linked_list import DoublyLinkedList | |
class Deque: | |
def __init__(self, iterable=None): | |
# Initialize a new Doubly linked list to store the items | |
self.list = DoublyLinkedList() | |
if iterable is not None: | |
for item in iterable: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from linkedlist import LinkedList | |
class LinkedListDeque: | |
def __init__(self, iterable=None): | |
# Initialize a new Linked list to store the items | |
self.list = LinkedList() | |
if iterable is not None: | |
for item in iterable: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UnittestingTests.swift | |
// UnittestingTests | |
// | |
// Created by Jackson Ho on 4/8/19. | |
// Copyright © 2019 Jackson Ho. All rights reserved. | |
// | |
import XCTest | |
@testable import Unittesting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.title = "Hello Testing World" | |
setupTextField() | |
} | |
NewerOlder