Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Fábio Salata committed Oct 30, 2021
2 parents 2423217 + 9edb121 commit b72d170
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Counters/Counters/Model/Counter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ struct Counter: Decodable, Equatable {
}

struct CounterPayload: Codable, Equatable {
let id: String?
let title: String?
var id: String?
var title: String?
}
10 changes: 5 additions & 5 deletions Counters/Counters/Service/CountersService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import Combine

final class CountersService {
private let client: APIClient
Expand All @@ -20,22 +19,23 @@ final class CountersService {
}

func increment(id: String, completion: @escaping (Result<[Counter], APIError>, URLResponse?) -> Void) {
let payload = CounterPayload(id: id, title: nil)
let payload = CounterPayload(id: id)
client.request(target: CounterServiceTarget.increment(payload: payload), completion: completion)
}

func decrement(id: String, completion: @escaping (Result<[Counter], APIError>, URLResponse?) -> Void) {
let payload = CounterPayload(id: id, title: nil)
let payload = CounterPayload(id: id)
client.request(target: CounterServiceTarget.decrement(payload: payload), completion: completion)
}

func save(title: String, completion: @escaping (Result<[Counter], APIError>, URLResponse?) -> Void) {
let payload = CounterPayload(id: nil, title: title)
let payload = CounterPayload(title: title)
client.request(target: CounterServiceTarget.save(payload: payload), completion: completion)
}

func delete(id: String, completion: @escaping (Result<[Counter], APIError>, URLResponse?) -> Void) {
client.request(target: CounterServiceTarget.delete(payload: CounterPayload(id: id, title: nil)),
let payload = CounterPayload(id: id)
client.request(target: CounterServiceTarget.delete(payload: payload),
completion: completion)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import Combine

final class CreateCounterViewModel {
private let service: CountersService
Expand Down
1 change: 0 additions & 1 deletion Counters/Network/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//

import Foundation
import Combine

class APIClient {
private var session: URLSessionProtocol
Expand Down
2 changes: 0 additions & 2 deletions Counters/Network/Protocols/URLSessionProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import Foundation

typealias APIResponse = URLSession.DataTaskPublisher.Output

protocol URLSessionProtocol {
func dataTask(with request: URLRequest,
completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask
Expand Down

0 comments on commit b72d170

Please sign in to comment.