@@ -66,19 +66,18 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
66
66
67
67
self . resultLabel. text = " "
68
68
69
- let recordAmount : StudyplusRecordAmount = StudyplusRecordAmount ( amount: 10 )
70
- let record : StudyplusRecord = StudyplusRecord ( duration: duration,
71
- recordedAt: Date ( ) ,
72
- amount: recordAmount,
73
- comment: " Today, I studied like anything. " )
74
-
75
- Studyplus . shared. post ( studyRecord: record, success: {
76
-
77
- self . resultLabel. text = " Success to post your studyRecord to Studyplus App "
78
-
79
- } , failure: { error in
80
-
81
- self . resultLabel. text = " Error Code: \( error. code ( ) ) , Message: \( error. message ( ) ) "
69
+ let record = StudyplusRecord ( duration: Int ( duration) ,
70
+ amount: 10 ,
71
+ comment: " Today, I studied like anything. " ,
72
+ recordDatetime: Date ( ) )
73
+
74
+ Studyplus . shared. post ( record, completion: { result in
75
+ switch result {
76
+ case . failure( let error) :
77
+ self . resultLabel. text = " Error Code: \( error) "
78
+ case . success:
79
+ self . resultLabel. text = " Success to post your studyRecord to Studyplus App "
80
+ }
82
81
} )
83
82
}
84
83
@@ -96,9 +95,9 @@ class ViewController: UIViewController, StudyplusLoginDelegate {
96
95
updateIsConnected ( )
97
96
}
98
97
99
- func studyplusDidFailToLogin( error: StudyplusError ) {
98
+ func studyplusDidFailToLogin( error: StudyplusLoginError ) {
100
99
print ( " -- Called studyplusDidFailToLogin -- " )
101
- resultLabel. text = " Error Code: \( error. code ( ) ) , Message: \( error . message ( ) ) "
100
+ resultLabel. text = " Error Code: \( error) "
102
101
updateIsConnected ( )
103
102
}
104
103
0 commit comments