Skip to content

Commit 49d429a

Browse files
committed
Chapter 16 reset
1 parent d06b5e7 commit 49d429a

File tree

141 files changed

+4831
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+4831
-0
lines changed

Chapter 16/MyProjectApi/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/

Chapter 16/MyProjectApi/Package.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// swift-tools-version:5.3
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "MyProjectApi",
6+
platforms: [
7+
.macOS(.v11),
8+
.iOS(.v13),
9+
.tvOS(.v13),
10+
.watchOS(.v6),
11+
],
12+
products: [
13+
.library(name: "MyProjectApi", targets: ["MyProjectApi"]),
14+
],
15+
targets: [
16+
.target(name: "MyProjectApi", dependencies: []),
17+
.testTarget(name: "MyProjectApiTests", dependencies: ["MyProjectApi"]),
18+
]
19+
)

Chapter 16/MyProjectApi/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# MyProjectApi
2+
3+
A description of this package.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import Foundation
2+
3+
public struct BlogCategoryListObject: Codable {
4+
public let id: UUID
5+
public let title: String
6+
7+
public init(id: UUID, title: String) {
8+
self.id = id
9+
self.title = title
10+
}
11+
}
12+
13+
public struct BlogCategoryGetObject: Codable {
14+
public let id: UUID
15+
public let title: String
16+
public var posts: [BlogPostListObject]?
17+
18+
public init(id: UUID, title: String, posts: [BlogPostListObject]? = nil) {
19+
self.id = id
20+
self.title = title
21+
self.posts = posts
22+
}
23+
}
24+
25+
public struct BlogCategoryCreateObject: Codable {
26+
public var title: String
27+
28+
public init(title: String) {
29+
self.title = title
30+
}
31+
}
32+
33+
public struct BlogCategoryUpdateObject: Codable {
34+
public var title: String
35+
36+
public init(title: String) {
37+
self.title = title
38+
}
39+
}
40+
41+
public struct BlogCategoryPatchObject: Codable {
42+
public var title: String
43+
44+
public init(title: String) {
45+
self.title = title
46+
}
47+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import Foundation
2+
3+
public struct BlogPostListObject: Codable {
4+
public let id: UUID
5+
public let title: String
6+
public let slug: String
7+
public let image: String
8+
public let excerpt: String
9+
public let date: Date
10+
11+
public init(id: UUID, title: String, slug: String, image: String, excerpt: String, date: Date) {
12+
self.id = id
13+
self.title = title
14+
self.slug = slug
15+
self.image = image
16+
self.excerpt = excerpt
17+
self.date = date
18+
}
19+
}
20+
21+
public struct BlogPostGetObject: Codable {
22+
public var id: UUID
23+
public var title: String
24+
public var slug: String
25+
public var image: String
26+
public var excerpt: String
27+
public var date: Date
28+
public var content: String
29+
30+
public init(id: UUID, title: String, slug: String, image: String, excerpt: String, date: Date, content: String) {
31+
self.id = id
32+
self.title = title
33+
self.slug = slug
34+
self.image = image
35+
self.excerpt = excerpt
36+
self.date = date
37+
self.content = content
38+
}
39+
}
40+
41+
public struct BlogPostUpsertObject: Codable {
42+
public var title: String
43+
public var slug: String
44+
public var image: String
45+
public var excerpt: String
46+
public var date: Date
47+
public var content: String
48+
public var categoryId: String
49+
50+
public init(title: String, slug: String, image: String, excerpt: String, date: Date, content: String, categoryId: String) {
51+
self.title = title
52+
self.slug = slug
53+
self.image = image
54+
self.excerpt = excerpt
55+
self.date = date
56+
self.content = content
57+
self.categoryId = categoryId
58+
}
59+
}
60+
61+
public struct BlogPostPatchObject: Codable {
62+
public var title: String?
63+
public var slug: String?
64+
public var image: String?
65+
public var excerpt: String?
66+
public var date: Date?
67+
public var content: String?
68+
public var categoryId: String?
69+
70+
public init(title: String? = nil, slug: String? = nil, image: String? = nil, excerpt: String? = nil, date: Date? = nil, content: String? = nil, categoryId: String? = nil) {
71+
self.title = title
72+
self.slug = slug
73+
self.image = image
74+
self.excerpt = excerpt
75+
self.date = date
76+
self.content = content
77+
self.categoryId = categoryId
78+
}
79+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Foundation
2+
3+
public struct UserTokenGetObject: Codable {
4+
5+
public let id: UUID
6+
public let value: String
7+
8+
public init(id: UUID, value: String) {
9+
self.id = id
10+
self.value = value
11+
}
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import XCTest
2+
3+
import MyProjectApiTests
4+
5+
var tests = [XCTestCaseEntry]()
6+
tests += MyProjectApiTests.allTests()
7+
XCTMain(tests)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import XCTest
2+
@testable import MyProjectApi
3+
4+
final class MyProjectApiTests: XCTestCase {
5+
6+
func testExample() {
7+
XCTAssertTrue(true)
8+
}
9+
10+
static var allTests = [
11+
("testExample", testExample),
12+
]
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import XCTest
2+
3+
#if !canImport(ObjectiveC)
4+
public func allTests() -> [XCTestCaseEntry] {
5+
return [
6+
testCase(MyProjectApiTests.allTests),
7+
]
8+
}
9+
#endif

0 commit comments

Comments
 (0)