chibenwa commented on code in PR #1277:
URL: https://github.com/apache/james-project/pull/1277#discussion_r1009213854


##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/QuotaSerializer.scala:
##########
@@ -42,6 +43,23 @@ object QuotaSerializer {
   private implicit val stateWrites: Writes[UuidState] = 
Json.valueWrites[UuidState]
 
   private implicit val resourceTypeWrite: Writes[ResourceType] = resourceType 
=> JsString(resourceType.asString())
+  private implicit val scopeReads: Reads[Scope] = {
+    case JsString("account") => json.JsSuccess(AccountScope)
+    case _ => JsError(s"Expecting a JsString to represent a scope property")
+  }
+
+  private implicit val optionReads: Reads[QuotaName] = 
Json.valueReads[QuotaName]
+
+  private implicit val resourceTypeReads: Reads[ResourceType] = {
+    case JsString("count") => json.JsSuccess(CountResourceType)
+    case JsString("octets") => json.JsSuccess(OctetsResourceType)
+    case _ => JsError(s"Expecting a JsString to represent a resourceType 
property")
+  }
+  private implicit val dataTypeReads: Reads[DataType] = {
+    case JsString("Mail") => json.JsSuccess(MailDataType)
+    case _ => JsError(s"Expecting a JsString to represent a dataType property")
+  }

Review Comment:
   Idem
   
   
   ```suggestion
     private implicit val dataTypeReads: Reads[DataType] = {
       case JsString("Mail") => json.JsSuccess(MailDataType)
        case JsTring(any) => JsError(s"Unexpected value $any, only 'Mail' are 
managed")
       case _ => JsError(s"Expecting a JsString to represent a dataType 
property")
     }
   ```



##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/QuotaSerializer.scala:
##########
@@ -42,6 +43,23 @@ object QuotaSerializer {
   private implicit val stateWrites: Writes[UuidState] = 
Json.valueWrites[UuidState]
 
   private implicit val resourceTypeWrite: Writes[ResourceType] = resourceType 
=> JsString(resourceType.asString())
+  private implicit val scopeReads: Reads[Scope] = {
+    case JsString("account") => json.JsSuccess(AccountScope)
+    case _ => JsError(s"Expecting a JsString to represent a scope property")
+  }
+
+  private implicit val optionReads: Reads[QuotaName] = 
Json.valueReads[QuotaName]
+
+  private implicit val resourceTypeReads: Reads[ResourceType] = {
+    case JsString("count") => json.JsSuccess(CountResourceType)
+    case JsString("octets") => json.JsSuccess(OctetsResourceType)
+    case _ => JsError(s"Expecting a JsString to represent a resourceType 
property")
+  }

Review Comment:
   Idem 
   
   ```suggestion
     private implicit val resourceTypeReads: Reads[ResourceType] = {
       case JsString("count") => json.JsSuccess(CountResourceType)
       case JsString("octets") => json.JsSuccess(OctetsResourceType)
       case JsTring(any) => JsError(s"Unexpected value $any, only 'count' and 
'octets' are managed")
       case _ => JsError(s"Expecting a JsString to represent a resourceType 
property")
     }
   ```



##########
server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/json/QuotaSerializer.scala:
##########
@@ -42,6 +43,23 @@ object QuotaSerializer {
   private implicit val stateWrites: Writes[UuidState] = 
Json.valueWrites[UuidState]
 
   private implicit val resourceTypeWrite: Writes[ResourceType] = resourceType 
=> JsString(resourceType.asString())
+  private implicit val scopeReads: Reads[Scope] = {
+    case JsString("account") => json.JsSuccess(AccountScope)
+    case _ => JsError(s"Expecting a JsString to represent a scope property")

Review Comment:
   We caan refine error handling here.
   
   If I pass a wrong JsString it returns me "please send me a JsString" while 
it should say "Oops, I do not manage this value"
   
   ```suggestion
       case JsString("account") => json.JsSuccess(AccountScope)
       case JsTring(any) => JsError(s"Unexpected value $any, only 'account' is 
managed")
       case _ => JsError(s"Expecting a JsString to represent a scope property")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to