@@ -27,12 +27,12 @@ enum TabCategory {
27
27
var appID : Int
28
28
var isPresented = false
29
29
var tabCategory = TabCategory . fetchApps
30
- var apps = [ KintoneApp ] ( )
31
- var layout = [ FormLayout ] ( )
32
- var fields = [ FieldProperty ] ( )
33
- var appSettings : AppSettings ?
34
- var records = [ Record . Read ] ( )
35
- var statusSettings : AppStatusSettings ?
30
+ var appsResponse : FetchAppsResponse ?
31
+ var formLayoutResponse : FetchFormLayoutResponse ?
32
+ var fieldsResponse : FetchFieldsResponse ?
33
+ var appSettingsResponse : FetchAppSettingsResponse ?
34
+ var recordsResponse : FetchRecordsResponse ?
35
+ var appStatusSettingsResponse : FetchAppStatusSettingsResponse ?
36
36
37
37
var kintoneAPI : KintoneAPI {
38
38
. init(
@@ -61,18 +61,18 @@ enum TabCategory {
61
61
62
62
func onTask( ) async {
63
63
do {
64
- apps = try await kintoneAPI. fetchApps ( )
65
- layout = try await kintoneAPI. fetchFormLayout ( appID: appID)
66
- fields = try await kintoneAPI. fetchFields ( appID: appID)
67
- appSettings = try await kintoneAPI. fetchAppSettings ( appID: appID)
68
- records = try await kintoneAPI. fetchRecords ( appID: appID)
69
- statusSettings = try await kintoneAPI. fetchAppStatusSettings ( appID: appID)
64
+ appsResponse = try await kintoneAPI. fetchApps ( )
65
+ formLayoutResponse = try await kintoneAPI. fetchFormLayout ( appID: appID)
66
+ fieldsResponse = try await kintoneAPI. fetchFields ( appID: appID)
67
+ appSettingsResponse = try await kintoneAPI. fetchAppSettings ( appID: appID)
68
+ recordsResponse = try await kintoneAPI. fetchRecords ( appID: appID)
69
+ appStatusSettingsResponse = try await kintoneAPI. fetchAppStatusSettings ( appID: appID)
70
70
} catch {
71
71
print ( error. localizedDescription)
72
72
}
73
73
}
74
74
75
- func fetchRecordComments( recordID: Int ) async -> RecordComments ? {
75
+ func fetchRecordComments( recordID: Int ) async -> FetchRecordCommentsResponse ? {
76
76
do {
77
77
return try await kintoneAPI. fetchRecordComments ( appID: appID, recordID: recordID)
78
78
} catch {
@@ -83,9 +83,9 @@ enum TabCategory {
83
83
84
84
func updateStatus( recordIdentity: RecordIdentity . Write , action: StatusAction ) async {
85
85
do {
86
- let assignee = statusSettings ? . states. first ( where: { $0. name == action. to } ) ? . assignee. entities. first? . code
86
+ let assignee = appStatusSettingsResponse ? . states. first ( where: { $0. name == action. to } ) ? . assignee. entities. first? . code
87
87
try await kintoneAPI. updateStatus ( appID: appID, recordIdentity: recordIdentity, actionName: action. name, assignee: assignee)
88
- records = try await kintoneAPI. fetchRecords ( appID: appID)
88
+ recordsResponse = try await kintoneAPI. fetchRecords ( appID: appID)
89
89
} catch {
90
90
print ( error. localizedDescription)
91
91
}
@@ -100,7 +100,7 @@ enum TabCategory {
100
100
}
101
101
}
102
102
103
- func onSubmitRecord( fields: [ String : RecordFieldValue . Write ] ) async -> RecordIdentity . Read ? {
103
+ func onSubmitRecord( fields: [ String : RecordFieldValue . Write ] ) async -> SubmitRecordResponse ? {
104
104
do {
105
105
let fields = fields. compactMap { RecordField . Write ( code: $0. key, value: $0. value) }
106
106
let record = Record . Write ( fields: fields)
@@ -111,7 +111,7 @@ enum TabCategory {
111
111
}
112
112
}
113
113
114
- func onUpdateRecord( recordID: Int , fields: [ String : RecordFieldValue . Write ] ) async -> RecordIdentity . Read ? {
114
+ func onUpdateRecord( recordID: Int , fields: [ String : RecordFieldValue . Write ] ) async -> UpdateRecordResponse ? {
115
115
do {
116
116
let recordIdentity = RecordIdentity . Write ( id: recordID)
117
117
let fields = fields. compactMap { RecordField . Write ( code: $0. key, value: $0. value) }
@@ -132,7 +132,7 @@ enum TabCategory {
132
132
}
133
133
}
134
134
135
- func uploadFile( fileArguments: FileArguments ? ) async -> String ? {
135
+ func uploadFile( fileArguments: FileArguments ? ) async -> UploadFileResponse ? {
136
136
guard let fileArguments else { return nil }
137
137
do {
138
138
return try await kintoneAPI. uploadFile (
@@ -200,23 +200,29 @@ enum TabCategory {
200
200
. navigationBarTitleDisplayMode ( . inline)
201
201
. navigationDestination ( isPresented: $viewModel. isPresented) {
202
202
TabView ( selection: $viewModel. tabCategory) {
203
- FetchAppsView ( apps: viewModel. apps)
204
- . tabItem {
205
- Label ( " Apps " , systemImage: " app.fill " )
206
- }
207
- . tag ( TabCategory . fetchApps)
208
- FetchFormLayoutView ( layout: viewModel. layout)
209
- . tabItem {
210
- Label ( " Form Layout " , systemImage: " square.grid.2x2 " )
211
- }
212
- . tag ( TabCategory . fetchFormLayout)
213
- FetchFieldsView ( fields: viewModel. fields)
214
- . tabItem {
215
- Label ( " Fields " , systemImage: " square.3.layers.3d.down.left " )
216
- }
217
- . tag ( TabCategory . fetchFields)
203
+ FetchAppsView (
204
+ appsResponse: viewModel. appsResponse
205
+ )
206
+ . tabItem {
207
+ Label ( " Apps " , systemImage: " app.fill " )
208
+ }
209
+ . tag ( TabCategory . fetchApps)
210
+ FetchFormLayoutView (
211
+ formLayoutResponse: viewModel. formLayoutResponse
212
+ )
213
+ . tabItem {
214
+ Label ( " Form Layout " , systemImage: " square.grid.2x2 " )
215
+ }
216
+ . tag ( TabCategory . fetchFormLayout)
217
+ FetchFieldsView (
218
+ fieldsResponse: viewModel. fieldsResponse
219
+ )
220
+ . tabItem {
221
+ Label ( " Fields " , systemImage: " square.3.layers.3d.down.left " )
222
+ }
223
+ . tag ( TabCategory . fetchFields)
218
224
FetchAppSettingsView (
219
- appSettings : viewModel. appSettings ,
225
+ appSettingsResponse : viewModel. appSettingsResponse ,
220
226
downloadFileHandler: { fileKey in
221
227
await viewModel. downloadFile ( fileKey: fileKey)
222
228
}
@@ -226,8 +232,8 @@ enum TabCategory {
226
232
}
227
233
. tag ( TabCategory . fetchAppSettings)
228
234
FetchRecordsView (
229
- records : viewModel. records ,
230
- actions : viewModel. statusSettings ? . actions ?? [ ] ,
235
+ recordsResponse : viewModel. recordsResponse ,
236
+ appStatusSettingsResponse : viewModel. appStatusSettingsResponse ,
231
237
updateStatusHandler: { recordIdentity, action in
232
238
await viewModel. updateStatus ( recordIdentity: recordIdentity, action: action)
233
239
} ,
@@ -243,7 +249,7 @@ enum TabCategory {
243
249
}
244
250
. tag ( TabCategory . fetchRecords)
245
251
SubmitRecordView (
246
- fields : viewModel. fields ,
252
+ fieldsResponse : viewModel. fieldsResponse ,
247
253
onSubmitRecordHandler: { fields in
248
254
await viewModel. onSubmitRecord ( fields: fields)
249
255
} ,
@@ -265,11 +271,13 @@ enum TabCategory {
265
271
Label ( " Upload File " , systemImage: " square.and.arrow.up " )
266
272
}
267
273
. tag ( TabCategory . uploadFile)
268
- FetchAppStatusSettingsView ( statusSettings: viewModel. statusSettings)
269
- . tabItem {
270
- Label ( " Status " , systemImage: " point.bottomleft.forward.to.arrow.triangle.scurvepath.fill " )
271
- }
272
- . tag ( TabCategory . status)
274
+ FetchAppStatusSettingsView (
275
+ appStatusSettingsResponse: viewModel. appStatusSettingsResponse
276
+ )
277
+ . tabItem {
278
+ Label ( " Status " , systemImage: " point.bottomleft.forward.to.arrow.triangle.scurvepath.fill " )
279
+ }
280
+ . tag ( TabCategory . status)
273
281
}
274
282
. navigationTitle ( " kintone API " )
275
283
. task {
0 commit comments