Skip to content

Commit 2300f22

Browse files
committed
Added totalCount to FetchRecordsResponse
1 parent c68dd93 commit 2300f22

File tree

3 files changed

+61
-29
lines changed

3 files changed

+61
-29
lines changed

Sources/KintoneAPI/Decodable/FetchRecordsResponse.swift

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77

88
public struct FetchRecordsResponse: Decodable, Sendable {
99
public var records: [Record.Read]
10+
public var totalCount: Int?
1011
}

Sources/KintoneAPI/KintoneAPI.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,14 @@ public struct KintoneAPI: Sendable {
131131
public func fetchRecords(
132132
appID: Int,
133133
fields: [String]? = nil,
134-
query: String? = nil
134+
query: String? = nil,
135+
totalCount: Bool? = nil
135136
) async throws -> FetchRecordsResponse {
136137
var queryItems = [URLQueryItem]()
137138
queryItems.appendQueryItem(name: "app", value: appID.description)
138139
queryItems.appendQueryItem(name: "fields", value: fields?.arrayString)
139140
queryItems.appendQueryItem(name: "query", value: query)
141+
queryItems.appendQueryItem(name: "totalCount", value: totalCount?.description)
140142
let request = makeRequest(httpMethod: .get, endpoint: .records, queryItems: queryItems)
141143
let (data, response) = try await dataRequestHandler(request)
142144
try check(response: response)

Tests/KintoneAPITests/DecodableTests/FetchRecordsResponseTests.swift

+57-28
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ struct FetchRecordsResponseTests {
88
func response_records_empty() throws {
99
let input = """
1010
{
11-
"records" : []
11+
"records" : [],
12+
"totalCount" : null
1213
}
1314
"""
1415
let data = try #require(input.data(using: .utf8))
@@ -31,7 +32,8 @@ struct FetchRecordsResponseTests {
3132
"value" : "1"
3233
}
3334
}
34-
]
35+
],
36+
"totalCount" : 1
3537
}
3638
"""
3739
let data = try #require(input.data(using: .utf8))
@@ -41,6 +43,7 @@ struct FetchRecordsResponseTests {
4143
#expect(record.identity.id == 1)
4244
#expect(record.identity.revision == 1)
4345
#expect(record.fields.isEmpty)
46+
#expect(actual.totalCount == 1)
4447
}
4548

4649
@Test
@@ -62,7 +65,8 @@ struct FetchRecordsResponseTests {
6265
"value" : "0"
6366
}
6467
}
65-
]
68+
],
69+
"totalCount" : 1
6670
}
6771
"""
6872
let data = try #require(input.data(using: .utf8))
@@ -100,7 +104,8 @@ struct FetchRecordsResponseTests {
100104
"value" : ["dummy0", "dummy1"]
101105
}
102106
}
103-
]
107+
],
108+
"totalCount" : 1
104109
}
105110
"""
106111
let data = try #require(input.data(using: .utf8))
@@ -138,7 +143,8 @@ struct FetchRecordsResponseTests {
138143
"value" : ["dummy0", "dummy1"]
139144
}
140145
}
141-
]
146+
],
147+
"totalCount" : 1
142148
}
143149
"""
144150
let data = try #require(input.data(using: .utf8))
@@ -176,7 +182,8 @@ struct FetchRecordsResponseTests {
176182
"value" : "0001-01-01T00:00:00Z"
177183
}
178184
}
179-
]
185+
],
186+
"totalCount" : 1
180187
}
181188
"""
182189
let data = try #require(input.data(using: .utf8))
@@ -217,7 +224,8 @@ struct FetchRecordsResponseTests {
217224
}
218225
}
219226
}
220-
]
227+
],
228+
"totalCount" : 1
221229
}
222230
"""
223231
let data = try #require(input.data(using: .utf8))
@@ -259,7 +267,8 @@ struct FetchRecordsResponseTests {
259267
"value" : \(dateProperty.value)
260268
}
261269
}
262-
]
270+
],
271+
"totalCount" : 1
263272
}
264273
"""
265274
let data = try #require(input.data(using: .utf8))
@@ -300,7 +309,8 @@ struct FetchRecordsResponseTests {
300309
"value" : \(dateTimeProperty.value)
301310
}
302311
}
303-
]
312+
],
313+
"totalCount" : 1
304314
}
305315
"""
306316
let data = try #require(input.data(using: .utf8))
@@ -341,7 +351,8 @@ struct FetchRecordsResponseTests {
341351
"value" : \(dropDownProperty.value)
342352
}
343353
}
344-
]
354+
],
355+
"totalCount" : 1
345356
}
346357
"""
347358
let data = try #require(input.data(using: .utf8))
@@ -386,7 +397,8 @@ struct FetchRecordsResponseTests {
386397
]
387398
}
388399
}
389-
]
400+
],
401+
"totalCount" : 1
390402
}
391403
"""
392404
let data = try #require(input.data(using: .utf8))
@@ -434,7 +446,8 @@ struct FetchRecordsResponseTests {
434446
]
435447
}
436448
}
437-
]
449+
],
450+
"totalCount" : 1
438451
}
439452
"""
440453
let data = try #require(input.data(using: .utf8))
@@ -476,7 +489,8 @@ struct FetchRecordsResponseTests {
476489
"value" : "dummy"
477490
}
478491
}
479-
]
492+
],
493+
"totalCount" : 1
480494
}
481495
"""
482496
let data = try #require(input.data(using: .utf8))
@@ -517,7 +531,8 @@ struct FetchRecordsResponseTests {
517531
}
518532
}
519533
}
520-
]
534+
],
535+
"totalCount" : 1
521536
}
522537
"""
523538
let data = try #require(input.data(using: .utf8))
@@ -556,7 +571,8 @@ struct FetchRecordsResponseTests {
556571
"value" : "dummy\\ndummy"
557572
}
558573
}
559-
]
574+
],
575+
"totalCount" : 1
560576
}
561577
"""
562578
let data = try #require(input.data(using: .utf8))
@@ -594,7 +610,8 @@ struct FetchRecordsResponseTests {
594610
"value" : ["dummy0", "dummy1"]
595611
}
596612
}
597-
]
613+
],
614+
"totalCount" : 1
598615
}
599616
"""
600617
let data = try #require(input.data(using: .utf8))
@@ -632,7 +649,8 @@ struct FetchRecordsResponseTests {
632649
"value" : "123.456"
633650
}
634651
}
635-
]
652+
],
653+
"totalCount" : 1
636654
}
637655
"""
638656
let data = try #require(input.data(using: .utf8))
@@ -675,7 +693,8 @@ struct FetchRecordsResponseTests {
675693
]
676694
}
677695
}
678-
]
696+
],
697+
"totalCount" : 1
679698
}
680699
"""
681700
let data = try #require(input.data(using: .utf8))
@@ -720,7 +739,8 @@ struct FetchRecordsResponseTests {
720739
"value" : \(radioButtonProperty.value)
721740
}
722741
}
723-
]
742+
],
743+
"totalCount" : 1
724744
}
725745
"""
726746
let data = try #require(input.data(using: .utf8))
@@ -758,7 +778,8 @@ struct FetchRecordsResponseTests {
758778
"value" : "DUMMY-1"
759779
}
760780
}
761-
]
781+
],
782+
"totalCount" : 1
762783
}
763784
"""
764785
let data = try #require(input.data(using: .utf8))
@@ -796,7 +817,8 @@ struct FetchRecordsResponseTests {
796817
"value" : "<h1>dummy</h1>"
797818
}
798819
}
799-
]
820+
],
821+
"totalCount" : 1
800822
}
801823
"""
802824
let data = try #require(input.data(using: .utf8))
@@ -834,7 +856,8 @@ struct FetchRecordsResponseTests {
834856
"value" : "dummy"
835857
}
836858
}
837-
]
859+
],
860+
"totalCount" : 1
838861
}
839862
"""
840863
let data = try #require(input.data(using: .utf8))
@@ -872,7 +895,8 @@ struct FetchRecordsResponseTests {
872895
"value" : "dummy"
873896
}
874897
}
875-
]
898+
],
899+
"totalCount" : 1
876900
}
877901
"""
878902
let data = try #require(input.data(using: .utf8))
@@ -915,7 +939,8 @@ struct FetchRecordsResponseTests {
915939
]
916940
}
917941
}
918-
]
942+
],
943+
"totalCount" : 1
919944
}
920945
"""
921946
let data = try #require(input.data(using: .utf8))
@@ -965,7 +990,8 @@ struct FetchRecordsResponseTests {
965990
]
966991
}
967992
}
968-
]
993+
],
994+
"totalCount" : 1
969995
}
970996
"""
971997
let data = try #require(input.data(using: .utf8))
@@ -1022,7 +1048,8 @@ struct FetchRecordsResponseTests {
10221048
"value" : \(timeProperty.value)
10231049
}
10241050
}
1025-
]
1051+
],
1052+
"totalCount" : 1
10261053
}
10271054
"""
10281055
let data = try #require(input.data(using: .utf8))
@@ -1060,7 +1087,8 @@ struct FetchRecordsResponseTests {
10601087
"value" : "0001-01-01T00:00:00Z"
10611088
}
10621089
}
1063-
]
1090+
],
1091+
"totalCount" : 1
10641092
}
10651093
"""
10661094
let data = try #require(input.data(using: .utf8))
@@ -1103,7 +1131,8 @@ struct FetchRecordsResponseTests {
11031131
]
11041132
}
11051133
}
1106-
]
1134+
],
1135+
"totalCount" : 1
11071136
}
11081137
"""
11091138
let data = try #require(input.data(using: .utf8))

0 commit comments

Comments
 (0)