Purchase Unit Mockup
```
protocol Patchable: Encodable {
func getPatchValue(referenceId: String?) -> String
}
@objc(PPCIntent)
enum Intent: Int, Patchable {
case capture
case authorize
var rawText: String {
switch self {
case .capture:
return "CAPTURE"
case .authorize:
return "AUTHORIZE"
}
func getPatchValue(referenceId: String?) -> String{
return "purchaseUnit[]/asdfjadsf;adsf"
}
}
func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(rawText)
}
}
@objc(PPCAmountObj)
class AmountObj: NSObject, Patchable, Encodable {
var currencyCode: String
var value: String
init(cc: String, value: String) {
currency_code = cc
self.value = value
}
}
func patch(op: String, value: Patchable) {
let patchString = value.getPatchValue(referenceId: nil)
}
```
```
public class PatchOrderRequest: NSObject, Encodable {
private enum CodingKeys: String, CodingKey {
case op
case path
case value
case from
}
let op: PatchOp
let path: String?
let value: Patchable?
let from: String?
public init(
op: PatchOp,
path: String? = nil,
value: Patchable? = nil,
from: String? = nil
) {
self.op = op
self.path = path
self.value = value
self.from = from
}
deinit { }
}
```
```
public func patch<Value: Encodable>(op: Operation, value: Value)
func patch(operation: Operation, value: String)
```