
local Core = require "lua_iragentlink.core"
local _M = {}

---
-- index metamethod. Looks up functions in IRAgentLink's metatable
-- and adjusts the first parameter (from our wrapper table to the IRAgentLink userdata)
--
local function index_fn (t, k)
	local self = rawget(t, "__self")
	local fn = self[k]
	return function(wrapper_table, ...)
		return fn(self, ...)
	end
end

---
-- Table that holds all functions that are overridden on a IRAgentLink instance
-- These functions now how to deal with arguments supplied in a table, which is the prefered method
-- from now on.
--
local overrides = {}

function overrides.CloseTestBot (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		sessionId = assert(args.sessionId),
		command = "CloseTestBot"
	})
end

function overrides.MailCreateAndSend (self, args)
	return self:SendCommand({
		proxyType = "MAIL",
		interactionID = assert(args.interactionID),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		attention_level_id = args.attention_level_id or nil,
		agentAtVCC = assert(args.agentAtVCC),
		contact = args.contact or nil,
		from = assert(args.from),
		to = assert(args.to),
		cc = args.cc or "",
		bcc = args.bcc or "",
		subject = assert(args.subject),
		body = assert(args.body),
		attachments = args.attachments or "",
		parentInteractionId = args.parentInteractionId or nil,
		RID = args.RID or "n/a",
		command = "CreateAndSend"
	})
end

function overrides.SendIsolatedMail (self, args)
	return self:SendCommand({
		proxyType = "MAIL",
		account = assert(args.account),
		to = assert(args.to),
		cc = args.cc or "",
		bcc = args.bcc or "",
		subject = assert(args.subject),
		body = assert(args.body),
		content_type = assert(args.content_type),
		attachments = args.attachments or "",
		params = args.params or nil,
		RID = args.RID or "n/a",
		command = "SendIsolatedMessage"
	})
end

function overrides.InteractionGetFromQueue (self, args)
	local request_id = args.rid or "n/a"
	local interactionID = assert(args.id)
	local agentAtVCC = assert(args.agent)
	local interactionType = assert(args.type)
	local fromTakeNextBest = args.fromTakeNextBest or false

	return self:InteractionGetFromQueue(request_id, interactionID, agentAtVCC, interactionType, fromTakeNextBest)
end

function overrides.InteractionGetFromQueueBotInteraction (self, args)
	local request_id = args.rid or "n/a"
	local interactionID = assert(args.id)
	local agentAtVCC = assert(args.agent)
	local interactionType = assert(args.type)
	local fromTakeNextBest = args.fromTakeNextBest or false

	return self:InteractionGetFromQueueBotInteraction(request_id, interactionID, agentAtVCC, interactionType, fromTakeNextBest)
end

function overrides.InteractionReassign (self, args)
	local request_id = args.rid or "n/a"
	local interactionID = assert(args.id)
	local transferrer = assert(args.transferrer)
	local interactionType = assert(args.type)
	local target = args.target

	-- esto es de telefonia (emprolijar)
	local address = args.address
	local wrapupData = args.wrapupData

	local command = {
		command = "InteractionReassign",
		proxyType = interactionType,
		interactionID = interactionID,
		RID = request_id,
		target = target,
		transferrer = transferrer,
		wrapupData = wrapupData
	}
	if type(address) == "string" and address ~= "" then
		command.address = address
	end

	return self:SendCommand(command)
end 
 
function overrides.InteractionConference (self, args)
	local request_id = args.rid or "n/a"
	local interactionID = assert(args.id)
	local transferrer = assert(args.transferrer)
	local interactionType = assert(args.type)
	local target = args.target
	local address = args.address

	local command = {
		command = "InteractionConference",
		proxyType = interactionType,
		interactionID = interactionID,
		RID = request_id,
		target = target,
		transferrer = transferrer,
		address = address
	}

	return self:SendCommand(command)
end

function overrides.SendCustomMessage (self, args)
	local request_id = args.RID or "n/a"
	local interactionID = assert(args.interactionID)
	local proxyType = assert(args.proxyType)
	local message = assert(args.message)
	local waitForResponse = args.waitForResponse or false
	local timeout = args.timeout or nil
	
	local command = {
		command = "SendCustomMessage",
		proxyType = proxyType,
		interactionID = interactionID,
		RID = request_id,
		message = message,
		waitForResponse = waitForResponse,
	}
	return self:SendCommand(command)
end

function overrides.InteractionRequeue (self, args)
	local command = {
		command = "InteractionRequeue",
		interactionID = assert(args.id),
		RID = args.rid or "n/a",
		proxyType = assert(args.type),
		transferrer = args.transferrer,
	}
	return self:SendCommand(command)
end

function overrides.SetCommentsAsRead (self, args)
	local request_id = args.rid or "n/a"
	local interactionID = assert(args.id)
	local agentAtVCC = assert(args.agent)

	return self:SetCommentsAsRead(request_id, interactionID, agentAtVCC)
end

function overrides.CommentInteraction (self, args)
	local request_id = args.rid or "n/a"
	local interactionID = assert(args.id)
	local agentAtVCC = assert(args.agent)
	local comment = assert(args.comment)

	return self:CommentInteraction(request_id, interactionID, agentAtVCC, comment)
end

function overrides.AddInteractionsToGroup (self, args)
	local request_id = args.rid or "n/a"
	local vcc = assert(type(args.vcc) == "string" and args.vcc)
	local groupId = assert(type(args.groupId) == "string" and args.groupId)
	local interactions = assert(type(args.interactions) == "table" and args.interactions)

	return self:AddInteractionsToGroup(request_id, interactions, groupId, vcc)
end

function overrides.RemoveInteractionsFromGroup (self, args)
	local request_id = args.rid or "n/a"
	local vcc = assert(type(args.vcc) == "string" and args.vcc)
	local groupId = assert(type(args.groupId) == "string" and args.groupId)
	local interactions = assert(type(args.interactions) == "table" and args.interactions)

	return self:RemoveInteractionsFromGroup(request_id, interactions, groupId, vcc)
end

function overrides.RemoveContactConflict (self, args)
	local interactionID = assert(args.id)
	local requestID = args.rid or "n/a"
	return self:RemoveContactConflict(interactionID, requestID)
end

function overrides.GetInteractionDetail (self, args)
	local interactionID = assert(args.id)
	local requestID = args.rid or "n/a"

	local command = {
		interactionID = assert(args.id),
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		command = "GetInteractionDetail"
	}
	return self:SendCommand(command)
end

function overrides.InteractionReopen (self, args)
	
	local command = {
		interactionID = assert(args.id),
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		agentAtVCC = assert(args.agentAtVCC),
		ignore_attention_level_membership = args.ignore_attention_level_membership,
		command = "Reopen"
	}
	return self:SendCommand(command)
end

function overrides.IsCampaignActive (self, args)
	
	local command = {
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		accountId = assert(args.accountId),
		command = "IsCampaignActive"
	}
	return self:SendCommand(command)
end

function overrides.AbortInteraction (self, args)
	
	local command = {
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		interactionID = assert(args.id),
		agentAtVCC = args.agentAtVCC or nil,
		enderSystem = args.enderSystem or nil,
		command = "AbortInteraction"
	}
	return self:SendCommand(command)
end

--- Social network posts

function overrides.PauseSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "PauseSNPost"
	})
end

function overrides.ResumeSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "ResumeSNPost"
	})
end

function overrides.CloseSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "CloseSNPost"
	})
end

function overrides.ReopenSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "ReopenSNPost"
	})
end

function overrides.DeleteSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "DeleteSNPost"
	})
end

function overrides.HideSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "HideSNPost"
	})
end

function overrides.PrivateSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "PrivateSNPost"
	})
end

function overrides.ShowSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "ShowSNPost"
	})
end

function overrides.DisableCommentsSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "DisableCommentsSNPost"
	})
end

function overrides.EnableCommentsSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "EnableCommentsSNPost"
	})
end

function overrides.NewSNPost (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		post = assert(args.post),
		user = args.user or "",
		command = "NewSNPost"
	})
end

function overrides.EditSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		post = assert(args.post),
		user = args.user or "",
		command = "EditSNPost"
	})
end

function overrides.EditSNPostProperties (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		properties = assert(args.properties),
		action = args.action,
		user = args.user or "",
		command = "EditSNPostProperties"
	})
end

function overrides.PinSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "PinSNPost"
	})
end

function overrides.UnpinSNPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		postId = assert(args.postId),
		user = args.user or "",
		command = "UnpinSNPost"
	})
end

function overrides.SearchTweets (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		conditions = assert(args.conditions),
		command = "SearchTweets"
	})
end

function overrides.GetInstagramPost (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		permalink = assert(args.permalink),
		command = "GetPost"
	})
end

function overrides.GetInstagramMedia (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		url = assert(args.url),
		command = "GetMedia"
	})
end

function overrides.CreateFromSearch (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		message = assert(args.message),
		command = "CreateFromSearch"
	})
end

function overrides.RegisterUnregisterWebhookPages (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		account = assert(args.account),
		accessToken = assert(args.accessToken),
		registerPages = assert(args.registerPages),
		unregisterPages = assert(args.unregisterPages),
		command = "RegisterUnregisterWebhookPages"
	})
end

function overrides.RegisterAccountWebhook (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		account = assert(args.account),
		old = args.old or nil,
		command = "RegisterAccountWebhook"
	})
end

function overrides.UnregisterAccountWebhook (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		account = assert(args.account),
		command = "UnregisterAccountWebhook"
	})
end

function overrides.CleanMessengerConfiguration (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		account = assert(args.account),
		accessToken = assert(args.accessToken),
		pages = assert(args.pages),
		command = "CleanMessengerConfiguration"
	})
end

function overrides.FBCreatePrivateMessage (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "FACEBOOK",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		message = assert(args.message),
		command = "CreatePrivateMessage"
	})
end

function overrides.FBPrivateReply (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "FACEBOOK",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		object = assert(args.object),
		index = assert(args.index),
		message = assert(args.message),
		command = "PrivateReply"
	})
end

function overrides.FBCommentPost (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "FACEBOOK",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		postId = assert(args.postId),
		commentId = args.commentId or "",
		message = assert(args.message),
		command = "CommentPost"
	})
end

function overrides.CloseInactiveProcessFlowInteractions (self, args)
	return self:SendCommand({
		proxyType = args.proxyType,
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		command = "CloseInactiveProcessFlowInteractions"
	})
end

function overrides.CloseInactiveQueuedInteractions (self, args)
	return self:SendCommand({
		proxyType = args.proxyType,
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		otherInfo = args.otherInfo or {},
		command = "CloseInactiveQueuedInteractions"
	})
end

function overrides.SMSSendInteractionMessage (self, args)
	return self:SendCommand({
		proxyType = "SMS",
		interactionID = assert(args.interactionID),
		message = assert(args.message),
		agentAtVCC = assert(args.agentAtVCC),
		command = "SendInteractionMessage"
	})
end

function overrides.SMSCreateAndSendInteractionMessage (self, args)
	return self:SendCommand({
		proxyType = "SMS",
		interactionID = assert(args.interactionID),
		parentInteractionId = args.parentInteractionId,
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		attention_level_id = args.attention_level_id or nil,
		phoneNumber = assert(args.phoneNumber),
		contactID = args.contactID,
		message = assert(args.message),
		agentAtVCC = assert(args.agentAtVCC),
		command = "CreateAndSendInteractionMessage"
	})
end

function overrides.SMSForward (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "SMS",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		address = assert(args.address),
		messages = assert(args.messages),
		command = "Forward"
	})
end

function overrides.RCSSendInteractionMessage (self, args)
	return self:SendCommand({
		proxyType = "RCS",
		interactionID = assert(args.interactionID),
		message = assert(args.message),
		agentAtVCC = assert(args.agentAtVCC),
		command = "SendInteractionMessage"
	})
end

function overrides.RCSCreateAndSendInteractionMessage (self, args)
	return self:SendCommand({
		proxyType = "RCS",
		interactionID = assert(args.interactionID),
		parentInteractionId = args.parentInteractionId,
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		attention_level_id = args.attention_level_id or nil,
		phoneNumber = assert(args.phoneNumber),
		contactID = args.contactID,
		message = assert(args.message),
		agentAtVCC = assert(args.agentAtVCC),
		command = "CreateAndSendInteractionMessage"
	})
end

function overrides.RCSForward (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "RCS",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		address = assert(args.address),
		messages = assert(args.messages),
		command = "Forward"
	})
end

function overrides.WhatsappSendInteractionMessage (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		interactionID = assert(args.interactionID),
		message = assert(args.message),
		agentAtVCC = assert(args.agentAtVCC),
		command = "SendInteractionMessage"
	})
end

function overrides.WhatsappSendInternalMessage (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		interactionID = assert(args.interactionID),
		message = assert(args.message),
		agentAtVCC = assert(args.agentAtVCC),
		command = "SendInternalMessage"
	})
end

function overrides.WhatsappCreateAndSendInteractionMessage (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		interactionID = assert(args.interactionID),
		parentInteractionId = args.parentInteractionId,
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		attention_level_id = args.attention_level_id or nil,
		address = assert(args.address),
		contactID = args.contactID,
		message = assert(args.message),
		agentAtVCC = assert(args.agentAtVCC),
		command = "CreateAndSendInteractionMessage"
	})
end

function overrides.WhatsappForward (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		address = assert(args.address),
		messages = assert(args.messages),
		command = "Forward"
	})
end

function overrides.WhatsappAuthenticate (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		data = args.data or {},
		command = "WhatsappAuthenticate"
	})
end

function overrides.WhatsappGetPhoneStatus (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		phoneId = assert(args.phoneId),
		command = "WhatsappGetPhoneStatus"
	})
end

function overrides.WhatsappRegisterPhone (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		phoneId = assert(args.phoneId),
		pin = assert(args.pin),
		command = "WhatsappRegisterPhone"
	})
end

function overrides.WhatsappDeregisterPhone (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		phoneId = assert(args.phoneId),
		command = "WhatsappDeregisterPhone"
	})
end

function overrides.WhatsappRequestCode (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		phoneId = assert(args.phoneId),
		method = assert(args.method),
		language = assert(args.language),
		command = "WhatsappRequestCode"
	})
end

function overrides.WhatsappVerifyCode (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		phoneId = assert(args.phoneId),
		pin = assert(args.pin),
		command = "WhatsappVerifyCode"
	})
end

function overrides.WhatsappMigratePhone (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		fromWaba = assert(args.fromWaba),
		toWaba = assert(args.toWaba),
		fullPhoneNumber = assert(args.fullPhoneNumber),
		command = "WhatsappMigratePhone"
	})
end

function overrides.WhatsappLockActivationCode (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		code = assert(args.code),
		command = "WhatsappLockActivationCode"
	})
end

function overrides.WhatsappUnlockActivationCode (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		code = assert(args.code),
		command = "WhatsappUnlockActivationCode"
	})
end

function overrides.WhatsappGetMessageTemplates (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		wabaId = assert(args.wabaId),
		command = "WhatsappGetMessageTemplates"
	})
end

function overrides.WhatsappSetMessageTemplates (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		installationId = assert(args.installationId),
		wabaId = assert(args.wabaId),
		data = assert(args.data),
		command = "WhatsappSetMessageTemplates"
	})
end

function overrides.WhatsappDelMessageTemplates (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		wabaId = assert(args.wabaId),
		templateName = assert(args.templateName),
		installationId = assert(args.installationId),
		command = "WhatsappDelMessageTemplates"
	})
end

function overrides.WhatsappGetCloudApiPublicRepositoryFileUrl (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		fileId = assert(args.fileId),
		fileName = assert(args.fileName),
		command = "WhatsappGetCloudApiPublicRepositoryFileUrl"
	})
end

function overrides.WhatsappSetCloudApiPublicRepositoryFileUrl (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		fileId = assert(args.fileId),
		usedById = assert(args.usedById),
		command = "WhatsappSetCloudApiPublicRepositoryFileUrl"
	})
end

function overrides.WhatsappDelCloudApiPublicRepositoryFileUrl (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		fileId = assert(args.fileId),
		usedById = assert(args.usedById),
		command = "WhatsappDelCloudApiPublicRepositoryFileUrl"
	})
end

function overrides.WhatsappGetAccountLimitData (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		command = "WhatsappGetAccountLimitData"
	})
end

function overrides.TwitterSendDirectMessage (self, args)
	return self:SendCommand({
		proxyType = "TWITTER",
		interactionID = assert(args.interactionID),
		campaignAtVCC = assert(args.campaignAtVCC),
		agentAtVCC = assert(args.agentAtVCC),
		account = assert(args.account),
		targetUser = assert(args.targetUser),
		targetUserId = assert(args.targetUserId),
		message = assert(args.message),
		RID = args.RID or "n/a",
		command = "SendDirectMessage"
	})
end

function overrides.TwitterSendDirectMessageFromTweet (self, args)
	return self:SendCommand({
		proxyType = "TWITTER",
		interactionID = assert(args.interactionID),
		campaignAtVCC = assert(args.campaignAtVCC),
		agentAtVCC = assert(args.agentAtVCC),
		account = assert(args.account),
		targetUser = assert(args.targetUser),
		targetUserId = assert(args.targetUserId),
		message = assert(args.message),
		tweet = assert(args.tweet),
		RID = args.RID or "n/a",
		command = "SendDirectMessageFromTweet"
	})
end

function overrides.TwitterLikeObject (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "TWITTER",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		objectId = assert(args.objectId),
		like = args.like,
		command = "LikeObject"
	})
end

function overrides.SendAttachment (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		interactionID = assert(args.interactionID),
		campaignAtVCC = assert(args.campaignAtVCC),
		agentAtVCC = assert(args.agentAtVCC),
		displayName = args.displayName or nil,
		account = assert(args.account),
		data = assert(args.data),
		file = assert(args.file),
		RID = args.RID or "n/a",
		command = "SendAttachment"
	})
end

function overrides.SendSharedFile (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		interactionID = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		displayName = args.displayName or nil,
		message = assert(args.message),
		RID = args.RID or "n/a",
		command = "SendSharedFile"
	})
end

function overrides.CanRetrieveInteractionFile (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		interactionID = assert(args.interactionID),
		id = assert(args.id),
		command = "CanRetrieveInteractionFile"
	})
end

function overrides.CanAddInteractionFile (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		interactionID = assert(args.interactionID),
		command = "CanAddInteractionFile"
	})
end

function overrides.AddInteractionFile (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		interactionID = assert(args.interactionID),
		data = assert(args.data),
		file = assert(args.file),
		RID = args.RID or "n/a",
		command = "AddInteractionFile"
	})
end

function overrides.InstagramCreatePrivateMessage (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "INSTAGRAM",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		message = assert(args.message),
		command = "CreatePrivateMessage"
	})
end

function overrides.InstagramPrivateReply (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "INSTAGRAM",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		object = assert(args.object),
		index = assert(args.index),
		message = assert(args.message),
		command = "PrivateReply"
	})
end

function overrides.InstagramCommentPost (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "INSTAGRAM",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionId),
		agentAtVCC = assert(args.agentAtVCC),
		postId = assert(args.postId),
		commentId = assert(args.commentId),
		message = assert(args.message),
		command = "CommentPost"
	})
end

function overrides.InstagramLikeObject (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "INSTAGRAM",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		objectId = assert(args.objectId),
		like = args.like,
		command = "LikeObject"
	})
end

function overrides.InstagramLikeMessage (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "INSTAGRAM",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		recipientId = assert(args.recipientId),
		messageId = assert(args.messageId),
		page = assert(args.page),
		like = args.like,
		command = "LikeMessage"
	})
end

function overrides.YoutubeCreatePrivateMessage (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "YOUTUBE",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		message = assert(args.message),
		command = "CreatePrivateMessage"
	})
end

function overrides.YoutubeCommentPost (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "YOUTUBE",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionId),
		agentAtVCC = assert(args.agentAtVCC),
		postId = assert(args.postId),
		commentId = assert(args.commentId),
		message = assert(args.message),
		command = "CommentPost"
	})
end

function overrides.YoutubeLikeObject (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "YOUTUBE",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionID),
		agentAtVCC = assert(args.agentAtVCC),
		objectId = assert(args.objectId),
		like = args.like,
		command = "LikeObject"
	})
end

function overrides.AppstoreCommentPost (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "APPSTORE",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionId),
		agentAtVCC = assert(args.agentAtVCC),
		postId = assert(args.postId),
		commentId = assert(args.commentId),
		message = assert(args.message),
		command = "CommentPost"
	})
end

function overrides.GoogleplayCommentPost (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = "GOOGLEPLAY",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		interactionId = assert(args.interactionId),
		agentAtVCC = assert(args.agentAtVCC),
		postId = assert(args.postId),
		commentId = assert(args.commentId),
		message = assert(args.message),
		command = "CommentPost"
	})
end

--- Batch management

function overrides.PauseOutgoingBatch (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		batchId = assert(args.batchId),
		user = args.user or "",
		command = "PauseOutgoingBatch"
	})
end

function overrides.ResumeOutgoingBatch (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		batchId = assert(args.batchId),
		user = args.user or "",
		command = "ResumeOutgoingBatch"
	})
end

function overrides.CloseOutgoingBatch (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		batchId = assert(args.batchId),
		user = args.user or "",
		command = "CloseOutgoingBatch"
	})
end

function overrides.ReopenOutgoingBatch (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		batchId = assert(args.batchId),
		user = args.user or "",
		command = "ReopenOutgoingBatch"
	})
end

function overrides.DeleteOutgoingBatch (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		batchId = assert(args.batchId),
		user = args.user or "",
		command = "DeleteOutgoingBatch"
	})
end

function overrides.NewOutgoingBatch (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		batch = assert(args.batch),
		user = args.user or "",
		apiRequest = args.apiRequest or "",
		command = "NewOutgoingBatch"
	})
end

function overrides.EditOutgoingBatch (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		batchId = assert(args.batchId),
		batch = assert(args.batch),
		user = args.user or "",
		command = "EditOutgoingBatch"
	})
end

function overrides.EditOutgoingBatchProperties (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		batchId = assert(args.batchId),
		properties = assert(args.properties),
		action = args.action,
		user = args.user or "",
		command = "EditOutgoingBatchProperties"
	})
end

function overrides.PinOutgoingBatch (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		batchId = assert(args.batchId),
		user = args.user or "",
		command = "PinOutgoingBatch"
	})
end

function overrides.UnpinOutgoingBatch (self, args)
	return self:SendCommand({
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		batchId = assert(args.batchId),
		user = args.user or "",
		command = "UnpinOutgoingBatch"
	})
end

function overrides.AddAddressToOutgoingBatch (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		batchId = assert(args.batchId),
		address = assert(args.address),
		message = args.message,
		data = args.data,
		user = args.user or "",
		apiRequest = args.apiRequest or "",
		command = "AddAddressToOutgoingBatch"
	})
end

function overrides.AddAddressesToOutgoingBatch (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		batchId = assert(args.batchId),
		addresses = assert(args.addresses),
		user = args.user or "",
		apiRequest = args.apiRequest or "",
		command = "AddAddressesToOutgoingBatch"
	})
end

function overrides.GetTemplateMessageOptions (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		page = args.page or "",
		cache = args.cache or false,
		command = "GetTemplateMessageOptions"
	})
end

function overrides.SetTemplateMessageOptions (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		options = assert(args.options),
		page = args.page or "",
		command = "SetTemplateMessageOptions"
	})
end

function overrides.RequestAvatar (self, args)
	return self:SendCommand({
		fake_event_id = args.fake_event_id or "n/a",
		RID = args.rid or "n/a",
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		userId = assert(args.userId),
		page = args.page or "",
		returnPicture = args.returnPicture and true or false,
		command = "RequestAvatar"
	})
end

function overrides.WhatsappListGroups (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		cache = args.cache and true or false,
		command = "ListGroups"
	})
end

function overrides.WhatsappGetGroup (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		cache = args.cache and true or false,
		command = "GetGroup"
	})
end

function overrides.WhatsappCreateGroup (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		group = assert(args.group),
		command = "CreateGroup"
	})
end

function overrides.WhatsappUpdateGroup (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		group = assert(args.group),
		command = "UpdateGroup"
	})
end

function overrides.WhatsappCreateGroupInviteLink (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		command = "CreateGroupInviteLink"
	})
end

function overrides.WhatsappDeleteGroupInviteLink (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		command = "DeleteGroupInviteLink"
	})
end

function overrides.WhatsappRemoveGroupParticipants (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		participants = assert(args.participants),
		command = "RemoveGroupParticipants"
	})
end

function overrides.WhatsappLeaveGroup (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		command = "LeaveGroup"
	})
end

function overrides.WhatsappSetGroupIcon (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		contentType = assert(args.contentType),
		content = assert(args.content),
		command = "SetGroupIcon"
	})
end

function overrides.WhatsappGetGroupIcon (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		command = "GetGroupIcon"
	})
end

function overrides.WhatsappDeleteGroupIcon (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		command = "DeleteGroupIcon"
	})
end

function overrides.WhatsappAddGroupAdmins (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		admins = assert(args.admins),
		command = "AddGroupAdmins"
	})
end

function overrides.WhatsappRemoveGroupAdmins (self, args)
	return self:SendCommand({
		proxyType = "WHATSAPP",
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		groupId = assert(args.groupId),
		admins = assert(args.admins),
		command = "RemoveGroupAdmins"
	})
end

function overrides.NewWebContact (self, args)
	return self:SendCommand({
		proxyType = "WEBCONTACT",
		campaignAtVCC = args.campaignAtVCC or nil,
		account_id = args.account or nil,
		token = args.token or nil,
		interactionID = assert(args.interactionID),
		data = assert(args.data),
		RID = args.RID or "n/a",
		command = "NewWebContact"
	})
end

function overrides.NewMail (self, args)
	return self:SendCommand({
		emailId = assert(args.interactionID),
		account = assert(args.account),
		campaignAtVCC = assert(args.campaignAtVCC),
		head = assert(args.head),
		body = assert(args.body),
		proxyType = "MAIL",
		RID = args.RID or "n/a",
		isSpam = false,
		command = "NewEMailFromAPI",
		attachments = assert(args.attachments)
	})
end		

function overrides.NewWhatsappFromAPI (self, args)
	return self:SendCommand({
		interactionID = assert(args.interactionID),
		account = assert(args.account),
		campaignAtVCC = assert(args.campaignAtVCC),
		name = assert(args.name),
		address = assert(args.address),
		text = assert(args.text),
		proxyType = "WHATSAPP",
		RID = args.RID or "n/a",
		command = "NewWhatsappFromAPI",
		attachments = assert(args.attachments),
		timestamp = assert(args.timestamp)
	})
end		
		
function overrides.MakeAppointment (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		campaignAtVCC = assert(args.campaignAtVCC),
		account = assert(args.account),
		agentAtVCC = assert(args.agentAtVCC),
		interactionID = args.interactionID or nil,
		addressTable = args.addressTable or nil,
		fromDate = args.fromDate or nil,
		RID = args.RID or "n/a",
		command = "MakeAppointment"
	})
end

function overrides.TakeAppointment (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		agentAtVCC = assert(args.agentAtVCC),
		interactionID = assert(args.interactionID),
		RID = args.RID or "n/a",
		command = "TakeAppointment"
	})
end

function overrides.FireProcessTimeoutEvent (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		id = assert(args.interactionID),
		command = "FireProcessTimeoutEvent"
	})
end

function overrides.StartMonitor (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		agentAtVCC = assert(args.agentAtVCC),
		interactionID = assert(args.interactionID),
		data = args.data or nil,
		RID = args.RID or "n/a",
		command = "StartMonitor"
	})
end

function overrides.SwitchConversation (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		agentAtVCC = assert(args.agentAtVCC),
		interactionID = assert(args.interactionID),
		RID = args.RID or "n/a",
		command = "SwitchConversation"
	})
end

function overrides.UnswitchConversation (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		agentAtVCC = assert(args.agentAtVCC),
		interactionID = assert(args.interactionID),
		RID = args.RID or "n/a",
		command = "UnswitchConversation"
	})
end

function overrides.AgentVideoChange (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		agentAtVCC = assert(args.agentAtVCC),
		interactionID = assert(args.interactionID),
		change = assert(args.change),
		RID = args.RID or "n/a",
		command = "AgentVideoChange"
	})
end

function overrides.GetIRNodes (self)
	return self:SendCommand({
		proxyType = "AGENT",
		command = "GetIRNodes"
	})
end

function overrides.DialerPreviewCancel (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		interactionID = assert(args.interactionID),
		command = "DialerPreviewCancel"
	})
end

function overrides.DialerPreviewConfirm (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		interactionID = assert(args.interactionID),
		command = "DialerPreviewConfirm"
	})
end

--dialer

function overrides.AssignedPeerTimeout (self, args)
	return self:SendCommand({
		proxyType = assert(args.proxyType),
		VCC = assert(args.VCC),
		interactionID = assert(args.interactionID),
		command = "AssignedPeerTimeout"
	})
end

---
-- Set our wrappers on the instance of IRAgentLink.
-- Eventually this could be moved to C++ (or not)
--
local function SetOverrides (instance)

	for name, fun in pairs(overrides) do

		instance[name] = function (self, args, ...)
			if type(args) == "string" then
				-- old style invocation
				return self.__self[name](self.__self, "n/a", args, ...)
			else
				-- new style invocation, args is a table (if not, let it crash)
				return fun(self.__self, args)
			end
		end
	end

	return instance
end

---
-- Wrapped IRAgentLink constructor
--
_M.IRAgentLink = function (cluster_id)

	local irlink = Core.IRAgentLink(cluster_id)

	local link = setmetatable({ __self = irlink }, { __index = index_fn })

	return SetOverrides(link)
end

return _M
