enum Operations: Int {
 case update
 case add
 case replace 

 etc
}

enum Paths {
 case amount
 
 func pathValue(referenceId: String = "default") -> String {
    switch self {
     case amount:
         return "purchaseUnits[]/referenceId=\(referenceId ?? "default")/amount"
     case intent: 
         return "intent"
    }
 }
 
 var acceptedOperations: [Operations] {
  switch self {
    case amount:
        return [.update]
  }
 }
}

let request = PatchOrderRequest(operation: .add, path: .amount)

  func patch(operation: Operation, path: Paths, value: Encodable) throws {
     guard path.acceptedOperations.contains(operation) else {
       throw <unacceptable operation error>
     }
 }
 
 
 1. Path Enum -> correct path format
 2. Path value with allowed / disallowed operations
​patch(operation: .update, value: AmountObject) 
​
​AmountObject: Patchable {
​    pathValue: Path
​}
​
​protocol Patchable: Encodable {
​    var pathValue: Path 
​}
​
​func patch<T: Patchable>(operation: Operation, value: T)