Created
October 11, 2019 18:58
-
-
Save wizhippo/cb11c442b19dc33d7d3951467a34e1ca to your computer and use it in GitHub Desktop.
TramsAPI examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$result = $this->tramsAPIService->userProfileCreate([ | |
'loginName' => $loginname, | |
'loginPassword' => $password, | |
'userName' => $agent->getCommonname(), | |
'CBOEnabled' => $agent->isEnabled() ? 'Y' : 'N', | |
'CBPEnabled' => $agent->isEnabled() ? 'X' : null, | |
'CBPDefAgentProfile_LinkNo' => $profile->getProfileNo(), | |
'CBPGroupSecurity_LinkNo' => $this->getSecurityLevel($agent), | |
'agentEmail' => $agent->getEmail(), | |
'userProfEmail' => $agent->getEmail(), | |
'SMTPHostAddr' => $smtp_host, | |
'SMTPPort' => $smtp_port, | |
'SMTPLoginType' => 'D', | |
'SMTPAccountLogin' => $smtp_user, | |
'SMTPAccountPassword' => $smtp_password, | |
'SMTPSecConn' => $smtp_encryption, | |
'defSMTPMode' => 2, | |
'defEmailClient' => 'M', | |
]); | |
if ($result['resultcode'] !== 0) { | |
throw new Exception('Error: ' . $loginname . ':' . $result['resulttext']); | |
} | |
$userProfileQueryResults = $this->tramsAPIService->userProfileQueryRunQuery([ | |
'loginName' => $login, | |
'noMetadata' => true, | |
'noPermissions' => true, | |
]); | |
if (!count($userProfileQueryResults)) { | |
throw new Exception(); | |
} | |
$userProfile = $userProfileQueryResults[0]; | |
$result = $this->tramsAPIService->userProfileUpdate($userProfile, [ | |
'userName' => $agent->getCommonname(), | |
'CBOEnabled' => $agent->isEnabled() ? 'Y' : 'N', | |
'CBPEnabled' => $agent->isEnabled() ? 'X' : null, | |
'CBPDefAgentProfile_LinkNo' => $profile->getProfileNo(), | |
'CBPGroupSecurity_LinkNo' => $this->getSecurityLevel($agent), | |
'agentEmail' => $agent->getEmail(), | |
'userProfEmail' => $agent->getEmail(), | |
'SMTPHostAddr' => $smtp_host, | |
'SMTPPort' => $smtp_port, | |
'SMTPLoginType' => 'D', | |
'SMTPAccountLogin' => $smtp_user, | |
'SMTPAccountPassword' => $smtp_password, | |
'SMTPSecConn' => $smtp_encryption, | |
'defSMTPMode' => 2, | |
'defEmailClient' => 'M', | |
]); | |
if ($result !== null && $result['resultcode'] !== 0) { | |
throw new Exception('Error: ' . $result['resulttext']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment