PHP SDKのサンプルコード - 変数の操作

変数グループ
変数グループの取得
              
              
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
use zcrmsdk\crm\setup\org\ZCRMOrganization;
use zcrmsdk\crm\crud\ZCRMVariable;
use zcrmsdk\crm\crud\ZCRMVariableGroup;
    require 'vendor/autoload.php';
    class VariableGroup{
        public function __construct()
        {
            $configuration = array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
            ZCRMRestClient::initialize($configuration);
        }
 public static function getVariableGroup(){
        $variable_group_ins=ZCRMVariableGroup::getInstance();//to get the rest client
        $variable_group_ins->setId("3524033000000231001");
        $variable_group_instance = $variable_group_ins->getVariableGroup()->getData();
        echo $variable_group_instance->getId();
        echo $variable_group_instance->getName();
        echo $variable_group_instance->getApiName();
        echo $variable_group_instance->getDisplayLabel();
        echo $variable_group_instance->getDescription();
    }
}
$obj =new VariableGroup();
$obj->getVariableGroup();

 
変数
変数の取得
              
              
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
use zcrmsdk\crm\setup\org\ZCRMOrganization;
use zcrmsdk\crm\crud\ZCRMVariable;
use zcrmsdk\crm\crud\ZCRMVariableGroup;
    require 'vendor/autoload.php';
    class Variable{
        public function __construct()
        {
            $configuration = array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
            ZCRMRestClient::initialize($configuration);
        }
    public static function getVariableofgroup(){
        $variable_ins=ZCRMVariable::getInstance();//to get the rest client
        ZCRMVariable::getDescription();
        $variable_ins->setId("3524033000003124006");
        $group_id = "3524033000000231001";
        $variable_instance = $variable_ins->getVariable($group_id)->getData();
        echo $variable_instance->getId();
        echo $variable_instance->getName();
        echo $variable_instance->getApiName();
        echo $variable_instance->getType();
        echo $variable_instance->getValue();
        foreach( $variable_instance->getVariableGroup() as $variable_group){
            echo $variable_group->getId();
            echo $variable_group->getName();
        }
        echo $variable_instance->getDescription();
    }
}
$obj =new Variable();
$obj->getVariableofgroup();
 
変数の更新
              
              
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
use zcrmsdk\crm\setup\org\ZCRMOrganization;
use zcrmsdk\crm\crud\ZCRMVariable;
use zcrmsdk\crm\crud\ZCRMVariableGroup;
require 'vendor/autoload.php';

    class Variable{
        public function __construct()
        {
            $configuration = array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
            ZCRMRestClient::initialize($configuration);
        }
    public static function updateVariable(){
        try{
            $variable_ins=ZCRMVariable::getInstance();//to get the rest client
            $variable_ins->setId("3524033000002999002");
            $variable_ins->setValue("3");
            $variable_ins->setDescription("automated sdk");
            $responseIn=$variable_ins->updateVariable();
                echo "HTTP Status Code:" . $responseIn->getHttpStatusCode(); // To get http response code
                echo "Status:" . $responseIn->getStatus(); // To get response status
                echo "Message:" . $responseIn->getMessage(); // To get response message
                echo "Code:" . $responseIn->getCode(); // To get status code
                echo "Details:" . json_encode($responseIn->getDetails());
        }
        catch (ZCRMException $ex) {
            echo $ex->getMessage(); // To get ZCRMException error message
            echo $ex->getExceptionCode(); // To get ZCRMException error code
            echo $ex->getFile(); // To get the file name that throws the Exception
        }
    }
}
$obj =new Variable();
$obj->updateVariable();
 
変数の削除
              
              
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
use zcrmsdk\crm\setup\org\ZCRMOrganization;
use zcrmsdk\crm\crud\ZCRMVariable;
use zcrmsdk\crm\crud\ZCRMVariableGroup;
require 'vendor/autoload.php';
    class Variable{
        public function __construct()
        {
            $configuration = array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
            ZCRMRestClient::initialize($configuration);
        }

    public static function deleteVariable(){
        try{
            $variable_ins=ZCRMVariable::getInstance();//to get the rest client
            $variable_ins->setId("3524033000002999002");
            $variable_ins->setValue("3");
            $variable_ins->setDescription("automated sdk");
            $responseIn=$variable_ins->deleteVariable();
            echo "HTTP Status Code:" . $responseIn->getHttpStatusCode(); // To get http response code
            echo "Status:" . $responseIn->getStatus(); // To get response status
            echo "Message:" . $responseIn->getMessage(); // To get response message
            echo "Code:" . $responseIn->getCode(); // To get status code
            echo "Details:" . json_encode($responseIn->getDetails());
        }
        catch (ZCRMException $ex) {
            echo $ex->getMessage(); // To get ZCRMException error message
            echo $ex->getExceptionCode(); // To get ZCRMException error code
            echo $ex->getFile(); // To get the file name that throws the Exception
        }
    }
}
$obj =new Org();
$obj->deleteVariable();