Skip to content

Commit 28214ef

Browse files
committed
Chapter 16 init
1 parent 84db186 commit 28214ef

File tree

121 files changed

+4459
-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.

121 files changed

+4459
-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/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// swift-tools-version:5.2
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "MyProjectApi",
6+
platforms: [
7+
.macOS(.v10_15),
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: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
}
48+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
}
80+
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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import XCTest
2+
@testable import MyProjectApi
3+
4+
final class MyProjectApiTests: XCTestCase {
5+
func testExample() {
6+
// This is an example of a functional test case.
7+
// Use XCTAssert and related functions to verify your tests produce the correct
8+
// results.
9+
XCTAssertEqual(MyProjectApi().text, "Hello, World!")
10+
}
11+
12+
static var allTests = [
13+
("testExample", testExample),
14+
]
15+
}
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
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.developer.applesignin</key>
6+
<array>
7+
<string>Default</string>
8+
</array>
9+
</dict>
10+
</plist>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"idiom" : "iphone",
40+
"scale" : "3x",
41+
"size" : "60x60"
42+
},
43+
{
44+
"idiom" : "ipad",
45+
"scale" : "1x",
46+
"size" : "20x20"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"scale" : "2x",
51+
"size" : "20x20"
52+
},
53+
{
54+
"idiom" : "ipad",
55+
"scale" : "1x",
56+
"size" : "29x29"
57+
},
58+
{
59+
"idiom" : "ipad",
60+
"scale" : "2x",
61+
"size" : "29x29"
62+
},
63+
{
64+
"idiom" : "ipad",
65+
"scale" : "1x",
66+
"size" : "40x40"
67+
},
68+
{
69+
"idiom" : "ipad",
70+
"scale" : "2x",
71+
"size" : "40x40"
72+
},
73+
{
74+
"idiom" : "ipad",
75+
"scale" : "1x",
76+
"size" : "76x76"
77+
},
78+
{
79+
"idiom" : "ipad",
80+
"scale" : "2x",
81+
"size" : "76x76"
82+
},
83+
{
84+
"idiom" : "ipad",
85+
"scale" : "2x",
86+
"size" : "83.5x83.5"
87+
},
88+
{
89+
"idiom" : "ios-marketing",
90+
"scale" : "1x",
91+
"size" : "1024x1024"
92+
}
93+
],
94+
"info" : {
95+
"author" : "xcode",
96+
"version" : 1
97+
}
98+
}

0 commit comments

Comments
 (0)