TF-2384 Create TwakeCore in ios folder to handle network jmap request to server
Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit d8a330b987860f133b7e56b4aa67669c9d3c8f20)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import Foundation
|
||||
|
||||
class JmapConstants {
|
||||
static let EMAIL_GET_METHOD_NAME = "Email/get"
|
||||
static let EMAIL_CHANGES_METHOD_NAME = "Email/changes"
|
||||
|
||||
static let CREATED_REFERENCE_PATH = "/created/*"
|
||||
|
||||
static let JMAP_CORE_CAPABILITY = "urn:ietf:params:jmap:core"
|
||||
static let JMAP_MAIL_CAPABILITY = "urn:ietf:params:jmap:mail"
|
||||
|
||||
static let EMAIL_PUSH_NOTIFICATION_PROPERTIES = [
|
||||
"id",
|
||||
"subject",
|
||||
"preview",
|
||||
"from"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import Foundation
|
||||
|
||||
class JmapRequestGenerator {
|
||||
static let shared: JmapRequestGenerator = JmapRequestGenerator()
|
||||
|
||||
func createEmailChangesRequest(accountId: String, sinceState: String) -> JmapRequestObject? {
|
||||
return JmapRequestObject(
|
||||
using: [
|
||||
JmapConstants.JMAP_CORE_CAPABILITY,
|
||||
JmapConstants.JMAP_MAIL_CAPABILITY
|
||||
],
|
||||
methodCalls: [
|
||||
[
|
||||
RequestInvocation.string(JmapConstants.EMAIL_CHANGES_METHOD_NAME),
|
||||
RequestInvocation.methodRequest(
|
||||
MethodRequest(
|
||||
accountId: accountId,
|
||||
sinceState: sinceState,
|
||||
ids: nil,
|
||||
properties: nil
|
||||
)
|
||||
),
|
||||
RequestInvocation.string("c0"),
|
||||
],
|
||||
[
|
||||
RequestInvocation.string(JmapConstants.EMAIL_GET_METHOD_NAME),
|
||||
RequestInvocation.methodRequest(
|
||||
MethodRequest(
|
||||
accountId: accountId,
|
||||
sinceState: nil,
|
||||
ids: ResultReference(
|
||||
resultOf: "c0",
|
||||
name: JmapConstants.EMAIL_CHANGES_METHOD_NAME,
|
||||
path: JmapConstants.CREATED_REFERENCE_PATH
|
||||
),
|
||||
properties: JmapConstants.EMAIL_PUSH_NOTIFICATION_PROPERTIES
|
||||
)
|
||||
),
|
||||
RequestInvocation.string("c1"),
|
||||
]
|
||||
]
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user