Is there a way to modify the arguments property so that I can use a [String : Any]?
No, Any
isn’t Encodable
, this only works with types that conform to the Encodable
protocol. The dictionary for an argument was just an example. Your arguments can be separated into multiple properties of your cloud struct
:
struct Cloud: ParseCloud {
typealias ReturnType = EmailType
var functionJobName: String
var argument1: String // Required parameter to your cloud function, `argument1` should match the name of your cloud function parameter.
var argument2: Int? // Optional parameter to your cloud function, `argument2` should match the name of your cloud function parameter.
// You can have as many parameters as your cloud function has
}
Can I have the arguments be a struct that is Encodable?
If you want something similar to Any
, you can add the AnyCodable package via SPM and use type AnyEncodable
. See more here and here. So it may look like:
struct Cloud: ParseCloud {
typealias ReturnType = EmailType
var functionJobName: String
var argument1: String // Required parameter to your cloud function, `argument1` should match the name of your cloud function parameter.
var argument2: Int? // Optional parameter to your cloud function, `argument2` should match the name of your cloud function parameter.
var argument3: AnyEncodable // Required parameter to your cloud function, `argument3` should match the name of your cloud function parameter.
// You can have as many parameters as your cloud function has
}
You can also do this with a mixed dictionary. Though I prefer the aforementioned methods as opposed to putting everything in a dictionary:
struct Cloud: ParseCloud {
typealias ReturnType = EmailType
var functionJobName: String
var arguments: [String: AnyEncodable]
}