-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from joselinoneto/feature/enablewatchos
enable watchos
- Loading branch information
Showing
8 changed files
with
108 additions
and
128 deletions.
There are no files selected for viewing
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
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
29 changes: 0 additions & 29 deletions
29
Tests/ToolboxAPIClientTests/Network/Professions/Manager/ProfessionsManagerAPI.swift
This file was deleted.
Oops, something went wrong.
64 changes: 0 additions & 64 deletions
64
Tests/ToolboxAPIClientTests/Network/Professions/Targets/ProfessionTarget.swift
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
Tests/ToolboxAPIClientTests/Network/Story/Manager/StoryManagerAPI.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Zé on 21/03/21. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
// | ||
import ToolboxAPIClient | ||
|
||
public class StoryManagerAPI: StoryRequestable { | ||
public func getStorys() -> AnyPublisher<[StoryDto]?, Error> { | ||
BaseNetworkWorker<[StoryDto]>(target: StoryTarget.getStorys).urlRequest() | ||
} | ||
|
||
public func getStorys(limit: Int) -> AnyPublisher<[StoryDto]?, Error> { | ||
BaseNetworkWorker<[StoryDto]>(target: StoryTarget.getStorysWith(limit)).urlRequest() | ||
} | ||
|
||
public func getStory(storyId: String) -> AnyPublisher<StoryDto?, Error> { | ||
BaseNetworkWorker<StoryDto>(target: StoryTarget.getStoryBy(storyId)).urlRequest() | ||
} | ||
|
||
public func createStory(_ model: StoryDto) -> AnyPublisher<StoryDto?, Error> { | ||
BaseNetworkWorker<StoryDto>(target: StoryTarget.postStory).urlRequest(contentBody: model) | ||
} | ||
} |
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
64 changes: 64 additions & 0 deletions
64
Tests/ToolboxAPIClientTests/Network/Story/Targets/StoryTarget.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Zé on 20/03/21. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
import ToolboxAPIClient | ||
|
||
public protocol StoryRequestable { | ||
func getStorys() -> AnyPublisher<[StoryDto]?, Error> | ||
func getStorys(limit: Int) -> AnyPublisher<[StoryDto]?, Error> | ||
func getStory(storyId: String) -> AnyPublisher<StoryDto?, Error> | ||
func createStory(_ model: StoryDto) -> AnyPublisher<StoryDto?, Error> | ||
} | ||
|
||
public enum StoryTarget { | ||
case getStorys | ||
case getStorysWith(_ limt: Int) | ||
case getStoryBy(_ professionId: String) | ||
case postStory | ||
} | ||
|
||
extension StoryTarget: TargetType { | ||
public var queryString: [URLQueryItem] { | ||
switch self { | ||
case .getStorysWith(let limit): | ||
return [URLQueryItem(name: "limit", value: "\(limit)")] | ||
default: | ||
return [] | ||
} | ||
} | ||
|
||
public var baseURL: URL { | ||
URL(string: "https://astronomia-api.herokuapp.com/")! | ||
} | ||
|
||
public var path: String { | ||
switch self { | ||
case .getStorys, | ||
.getStorysWith: | ||
return "stories" | ||
case .postStory: | ||
return "stories" | ||
case .getStoryBy(let storyid): | ||
return "stories/\(storyid)" | ||
} | ||
} | ||
|
||
public var method: HttpMethodEnum { | ||
switch self { | ||
case .getStorys, .getStoryBy, .getStorysWith: | ||
return .get | ||
case .postStory: | ||
return .post | ||
} | ||
} | ||
|
||
public var headers: [String : String]? { | ||
["Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiIxMTY3MDNFOS1CRjdFLTQyMEEtQjhFRi1BMjY1MTI5NzlEMjEiLCJzdWIiOiJhc3Ryb25vbWlhX2FwaSIsImV4cCI6NjQwOTIyMTEyMDAsImFkbWluIjp0cnVlfQ.D-ZoYLLVfdGaXrIfVl5BlKslN2oFezBpa0PguKCXmhs"] | ||
} | ||
} |
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