iOS SDK Samples - Tags Operations
Get All Tags
// module is the object of geModuleDelegate
$module.getTags { ( result ) in
switch result
{
case .success(let tags, let response) :
print ("ResponseJSON : \( response.responseJSON )")
case .failure(let error) :
print ( "Throws exception : \(error)" )
}
}
Create Tags
let invoice = ZCRMSDKUtil.getModuleDelegate(apiName: "Leads").newTag(name: "Invoice")
//module is the object of getModuleDelegate()
$module.createTags(tags: [invoice]) { ( result ) in
switch result
{
case .success(let tags, let response) :
print ("ResponseJSON : \( response.responseJSON )")
case .failure(let error) :
print ( "Throws exception : \(error)" )
}
}
Get Record Count of a Specific Tag
// tag is the object of newTag
$tag.getRecordCount { ( result ) in
switch result
{
case .success(let tags, let response) :
print ("ResponseJSON : \( response.responseJSON )")
case .failure(let error) :
print ( "Throws exception : \(error)" )
}
}
Merge Tags
// tag and mergeWith are the objects of newTag
$tag.merge(withTag: mergeWith) { ( result ) in
switch result
{
case .success(let tags, let response) :
print ("ResponseJSON : \( response.responseJSON )")
case .failure(let error) :
print ( "Throws exception : \(error)" )
}
}
Update a Tag
// module is the object of getModuleDelegate
// tag is the object of getTags method
$tag.update{ ( result ) in
switch result
{
case .success(let tags, let response) :
print ("ResponseJSON : \( response.responseJSON )")
case .failure(let error) :
print ( "Throws exception : \(error)" )
}
}
Update Tags
// module is the object of getModuleDelegate
// tag is the object of getTags()
$tag.name = "Testing"
$tag.update{ ( result ) in
switch result
{
case .success(let tags, let response) :
print ("ResponseJSON : \( response.responseJSON )")
case .failure(let error) :
print ( "Throws exception : \(error)" )
}
}
Delete Tags
//tag is the object of getTags
$tag.delete { ( result ) in
switch result
{
case .success(let response) :
print ("ResponseJSON : \( response.responseJSON )")
case .failure(let error) :
print ( "Throws exception : \(error)" )
}
}
Add Tags to Records
// record is the object of getRecordDelegate
// email and priority are the objects of newTag method
/*- Parameters:
- tags : The list of tags to be added
- overWrite : To overwrite the tag or not*/
$record.addTags(tags: ["email", "priority"], overWrite : true){(result ) in
switch result
{
case .success( let tags, let response ) :
print ("ResponseJSON : \( response.responseJSON )")
case .failure( let error ) :
print("Throws exception : \(error)")
}
}
Remove Tags from Records
// record is the object of getRecordDelegate
let tags : [ String ] = trydefModRecordDetails.getValue(key: "tagNames")
$record.removeTags(tags: tags) { ( result ) in
switch result
{
case .success(let tags, let response) :
print ("ResponseJSON : \( response.responseJSON )")
case .failure(let error) :
print ( "Throws exception : \(error)" )
}
}