Skip to content

Commit 55b5469

Browse files
author
Maika Akedo
committed
add duration range property, add duration checker at post StudyplusRecord method
1 parent 76a53ec commit 55b5469

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

StudyplusSDK/Studyplus.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ final public class Studyplus {
152152
/// - failure: callback when failure to post the studyRecord
153153
public func post(studyRecord: StudyplusRecord, success: @escaping () -> Void, failure: @escaping (_ error: StudyplusError) -> Void) {
154154

155+
guard StudyplusRecord.durationRange ~= studyRecord.duration else {
156+
failure(.postRecordFailed)
157+
return
158+
}
159+
155160
if !self.isConnected() {
156161
failure(.notConnected)
157162
return

StudyplusSDK/StudyplusRecord.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ private extension Date {
6969
Studyplusに投稿する一件の勉強記録を表現するクラスです。
7070
*/
7171
public struct StudyplusRecord {
72+
73+
static let durationRange = 0...(24 * 60 * 60)
7274

7375
/**
7476
The seconds of the learning.
@@ -102,6 +104,8 @@ public struct StudyplusRecord {
102104
///
103105
/// - Parameters:
104106
/// - duration: Specify the seconds of the learning. 勉強した時間(秒数)を指定してください。
107+
/// - min: 0
108+
/// - max: 86400 (24h)
105109
/// - recordedAt: Time the learning is ended. 学習を終えた日時。
106110
/// - amount: The amount of learning. 学習量。
107111
/// - comment: Studyplus timeline comment. Studyplusのタイムライン上で表示されるコメント。
@@ -120,6 +124,8 @@ public struct StudyplusRecord {
120124
///
121125
/// - Parameters:
122126
/// - duration: Specify the seconds of the learning. 勉強した時間(秒数)を指定してください。
127+
/// - min: 0
128+
/// - max: 86400 (24h)
123129
/// - recordedAt: Time the learning is ended. 学習を終えた日時。
124130
/// - amount: The amount of learning. 学習量。
125131
/// - comment: Studyplus timeline comment. Studyplusのタイムライン上で表示されるコメント。

0 commit comments

Comments
 (0)