承接 pipetic/salesforce 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pipetic/salesforce

Composer 安装命令:

composer require pipetic/salesforce

包简介

Salesforce adapter for the Pipetic platform. Provides OAuth 2.0 authentication and ETL data sync for multi-tenant SaaS applications.

README 文档

README

Salesforce adapter for the Pipetic platform. Provides OAuth 2.0 authentication and ETL data synchronisation between multi-tenant SaaS applications and Salesforce.

Requirements

  • PHP ≥ 8.0
  • Composer

Installation

composer require pipetic/salesforce

Configuration

Add your Salesforce OAuth credentials to your application configuration:

// config/services.php (Laravel) or equivalent
'salesforce' => [
    'oauth' => [
        'client_id'     => env('SALESFORCE_CLIENT_ID'),
        'client_secret' => env('SALESFORCE_CLIENT_SECRET'),
        'redirect_uri'  => env('SALESFORCE_REDIRECT_URI'),
    ],
],

Usage

OAuth 2.0 Authentication

use Pipetic\Salesforce\Client\Actions\SalesforceCreateClientDataNode;

// 1. Create a client bound to a DataNode (stores the access token)
$client = SalesforceCreateClientDataNode::run($dataNode);

// 2. Redirect the user to Salesforce login
$authorizationUrl = $client->getAuthenticator()->getAuthorizationUrl();
header('Location: ' . $authorizationUrl);

// 3. Exchange the authorization code for an access token (in your callback route)
$client->authenticate(['code' => $_GET['code']]);

Querying Records (SOQL)

$response = $client->query()->query('SELECT Id, Name FROM Account LIMIT 10');

foreach ($response->getRecords() as $record) {
    echo $record['Name'] . PHP_EOL;
}

// Paginate through large result sets
while (!$response->isDone()) {
    $response = $client->query()->nextPage($response->getNextRecordsUrl());
    foreach ($response->getRecords() as $record) {
        // process record
    }
}

CRUD on SObjects

$sobjects = $client->sobjects();

// Create a record
$result = $sobjects->create('Account', ['Name' => 'Acme Corp', 'Phone' => '555-1234']);
$newId = $result['id'];

// Read a record
$account = $sobjects->get('Account', $newId);

// Update a record
$sobjects->update('Account', $newId, ['Phone' => '555-5678']);

// Delete a record
$sobjects->delete('Account', $newId);

Token Introspection

$accessToken = $client->getAccessToken();
$response = $client->oauth2Introspect()->inspect($accessToken);

if ($response->getActive()) {
    echo 'Token is active, user: ' . $response->getUsername();
}

Architecture

src/
├── Abstract/Behaviours/       # Reusable traits (HasAccessToken, HasDataNode, HasOauthConfig)
├── Authentication/            # OAuth2 authentication & token storage
│   └── Token/                 # TokenRepositoryInterface + DataNode implementation
├── Client/                    # SalesforceClient + composable behaviours
│   ├── Actions/               # Factory actions (CreateClientBase, CreateClientDataNode)
│   └── Behaviours/            # HasAuthenticatorTrait, HasConfiguration, HasEndpoints
├── Config/                    # OauthConfig, ClientConfiguration
└── Endpoints/
    ├── Base/                  # AbstractEndpoint
    ├── Oauth2/Introspect/     # Token introspection endpoint
    └── SObjects/              # CRUD + SOQL query endpoints (ETL)

Testing

composer install
vendor/bin/phpunit

License

MIT

统计信息

  • 总下载量: 50
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固