WakeOnWeb/salesforce-client

WakeOnWeb Salesforce客户端

v1.0.4 2018-08-27 08:02 UTC

This package is auto-updated.

Last update: 2024-09-08 08:00:10 UTC


README

Build Status

支持的技术

- rest
    - oauth2 grant type: password.

请贡献以支持他人。

用法

use WakeOnWeb\SalesforceClient\REST;
use WakeOnWeb\SalesforceClient\ClientInterface;

$client = new REST\Client(
    new REST\Gateway('https://cs81.salesforce.com', '41.0'),
    new REST\GrantType\PasswordStrategy(
        'consumer_key',
        'consumer_secret',
        'login',
        'password',
        'security_token'
    )
);

可用的异常-------------------

  • DuplicatesDetectedException
  • EntityIsDeletedException(当尝试删除已删除的实体时)
  • NotFoundException(当找不到对象时)
  • ...

获取对象

try {
    $salesforceObject = $client->getObject( 'Account', '1337ID')); // all fields
} catch (\WakeOnWeb\SalesforceClient\Exception\NotFoundException) {
    // this object does not exist, do a specifig thing.
}

//$salesforceObject->getAttributes();
//$salesforceObject->getFields();

//$client->getObject( 'Account', '1337ID', ['Name', 'OwnerId', 'CreatedAt'] )); // specific fields

创建对象

// creation will be a SalesforceObjectCreationObject
$creation = $client->createObject( 'Account', ['name' => 'Chuck Norrs'] );
// $creation->getId();
// $creation->isSuccess();
// $creation->getErrors();
// $creation->getWarnings();

编辑对象

$client->patchObject( 'Account', '1337ID', ['name' => 'Chuck Norris'] ));

删除对象

$client->deleteObject( 'Account', '1337ID'));

SOQL

// creation will be a SalesforceObjectCreationObjectResults
$client->searchSOQL('SELECT name from Account'); // NOT_ALL by default.
$client->searchSOQL('SELECT name from Account', ClientInterface::ALL);
// $creation->getTotalSize();
// $creation->isDone();
// $creation->getRecords();

其他

$client->getAvailableResources();
$client->getAllObjects();
$client->describeObjectMetadata('Account');