iOS SDK Samples - CRM Variables Operations

Get Variables' Data
          
          
ZCRMSDKUtil.getVariables { ( result ) in
            switch result
            {
      case .success(let variables, let response) :
        print ("ResponseJSON : \( response.responseJSON )")
      case .failure(let error) :
         print ( "Throws exception : \(error)" )
            }
}
 
Get a Variable's Data using Variable ID and Group ID
          
          
ZCRMSDKUtil.getVariable(variableId: 123456543, variableGroupId: 12345654) { ( result ) in
            switch result
            {
            case .success(let variable, let response) :
             print ("ResponseJSON : \( response.responseJSON )")
            case .failure(let error) :
             print ( "Throws exception : \(error)" )
            }
        }
 
Get a Variable's Data using Variable API Name and Group ID
          
          
ZCRMSDKUtil.getVariable(variableAPIName: "testing", variableGroupId: 12345654) { ( result ) in
            switch result
            {
            case .success(let variable, let response) :
             print ("ResponseJSON : \( response.responseJSON )")
            case .failure(let error) :
             print ( "Throws exception : \(error)" )
            }
}
 
Get a Variable's Data using Variable ID and Group API Name
          
          
ZCRMSDKUtil.getVariable(variableId: 234565432, variableGroupAPIName: "testing") { ( result ) in
            switch result
            {
            case .success(let variable, let response) :
             print ("ResponseJSON : \( response.responseJSON )")
            case .failure(let error) :
             print ( "Throws exception : \(error)" )
            }
}
 
Get a Variable's Data using Variable API Name and Group API Name
          
          
ZCRMSDKUtil.getVariable(variableAPIName: "test", variableGroupAPIName: "testing") { ( result ) in
            switch result
            {
            case .success(let variable, let response) :
             print ("ResponseJSON : \( response.responseJSON )")
            case .failure(let error) :
             print ( "Throws exception : \(error)" )
            }
}
 
Get All Variable Groups
          
          
ZCRMSDKUtil.getVariableGroups { ( result ) in
 switch result
 {

		case .success(let variable, let response) :
      print ("ResponseJSON : \( response.responseJSON )")
      case .failure(let error) :
      print ( "Throws exception : \(error)" )
            }
}
 
Get a Variable Group by its API Name
          
          
ZCRMSDKUtil.getVariableGroup( apiName : "testing" ) { ( result ) in
 switch result
 {
	     case .success(let variable, let response) :
      print ("ResponseJSON : \( response.responseJSON )")
      case .failure(let error) :
      print ( "Throws exception : \(error)" )
            }
}
 
Get a Variable Group by its ID
          
          
ZCRMSDKUtil.getVariableGroup( id : 78830812 ) { ( result ) in

 switch result
 {
		case .success(let variable, let response) :
      print ("ResponseJSON : \( response.responseJSON )")
      case .failure(let error) :
      print ( "Throws exception : \(error)" )
            }
}
 
Create Variables
          
          
// variable is the object of getVariableGroup()
/* - Parameter 
		-type: datatype of the variable*/
         let vname1 = ZCRMSDKUtil.newVariable (name : "ID", apiName : "id", type : .singleLine, variableGroup : variable)
		  let vname2 = ZCRMSDKUtil.newVariable (name : "Telephone", apiName : "telephone", type : .number, variableGroup : variable)
        let vnames = [vname1, vname2]
        ZCRMSDKUtil.createVariables(variables: vnames) { ( result ) in
       switch result
       {
       case .success(let variable, let response) :
       print ("ResponseJSON : \( response.responseJSON )")
       case .failure(let error) :
       print ( "Throws exception : \(error)" )
       }
      }
 
Update Variables
          
          
// variable is the object of getVariable()
     $variable.name = "Invoice"
     $variable.apiName = "invoice"
     $variable.type = "Integer"
     ZCRMSDKUtil.updateVariables(variables: [variable]) { ( result ) in
      switch result
      {
       case .success (let variable, let response) :
       print ("ResponseJSON : \( response.responseJSON )")
       case .failure(let error) :
       print ( "Throws exception : \(error)" )
       }
     }
 
Delete Variables
          
          
ZCRMSDKUtil.deleteVariables(ids: [12xxx543, 234xxx432, 234xxx543]) { ( result ) in
            switch result
            {
            case .success (let response) :
                  print ("ResponseJSON : \( response.responseJSON )")
             case .failure(let error) :
                  print ( "Throws exception : \(error)" )
            }
        }