定制 idci/sam-client-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

idci/sam-client-bundle

最新稳定版本:v1.1.8

Composer 安装命令:

composer require idci/sam-client-bundle

包简介

Symfony bundle that provides an api client for SAM app (SAVInsight)

README 文档

README

Symfony bundle that provides an api client for SAM app (SAVInsight)

Installation

Install this bundle using composer :

composer require idci/sam-client-bundle

Configuration

Create an Eightpoint Guzzle HTTP client

In the file config/packages/eight_points_guzzle.yaml, create a SAM API client :

eight_points_guzzle:
    clients:
        sam_api:
            base_url: 'https://sam-staging.savinsight.com/api/' # PROD = 'https://sam.savinsight.com/api/'

Configure a cache pool

Create a dedicated SAM cache, or use any of your existing pools :

In the file config/services.yaml, register your cache pool :

# Redis example
app.cache.adapter.redis.sam:
    parent: 'cache.adapter.redis'
    tags:
        - { name: 'cache.pool', namespace: 'SAM' }

In the file config/packages/cache.yaml, define your cache pool :

framework:
    cache:
        # ...
        pools:
            cache.sam:
                public: true

Configure sam-client-bundle

In config/packages/, create a idci_sam_client.yaml file :

idci_sam_client:
    guzzle_http_client_service_alias: 'eight_points_guzzle.client.sam_api'
    cache_pool_service_alias: 'cache.sam'
    client_id: '%env(string:IDCI_SAM_CLIENT_ID)%'
    client_secret: '%env(string:IDCI_SAM_CLIENT_SECRET)%'
    mode: '%env(string:IDCI_SAM_MODE)%'

Required parameters:

  • guzzle_http_client_service_alias : The guzzle HTTP client alias
  • client_id : The SAM client ID
  • client_secret : The SAM client secret
  • mode: live or staging

Then, add these environment variable in your .env file :

###> idci/sam-client-bundle ###
IDCI_SAM_CLIENT_ID=Y2xpZW50X2lk...
IDCI_SAM_CLIENT_SECRET=Y2xpZW50X3NlY3JldA==...
IDCI_SAM_MODE=live
###< idci/sam-client-bundle ###

To retrieve more informations about SAM API, go to https://sam-staging.savinsight.com/swagger/index.html.

Usage

Activity methods

Create activity

use IDCI\Bundle\SAMClientBundle\Client\SAMApiClient;
...
$this->samApiClient->createActivity(20000, [
    'date' => new \DateTime,
    'employeeCode' => 'JeanDupont',
]);

$this->samApiClient->createActivityByInternalNumber('internalNumber', [
    'date' => new \DateTime,
    'employeeCode' => 'JeanDupont',
]);

$this->samApiClient->createActivityByExternalId('externalId', [
    'date' => new \DateTime,
    'employeeCode' => 'JeanDupont',
]);
option name type
date DateTimeInterface, string, null
employeeCode string, null

Update activity

use IDCI\Bundle\SAMClientBundle\Client\SAMApiClient;
use IDCI\Bundle\SAMClientBundle\Client\Model\Enum\UpdateActivityInputState;
...
$this->samApiClient->updateActivity(20000, 'A020', [
    'status' => UpdateActivityInputState::Paused,
    'date' => new \DateTime,
    'employeeCode' => 'JeanDupont',
]);

$this->samApiClient->createActivityByInternalNumber('internalNumber', 'A020', [
    'status' => UpdateActivityInputState::Paused,
    'date' => new \DateTime,
    'employeeCode' => 'JeanDupont',
]);

$this->samApiClient->createActivityByExternalId('externalId', 'A020', [
    'status' => UpdateActivityInputState::Paused,
    'date' => new \DateTime,
    'employeeCode' => 'JeanDupont',
]);
option name type
status UpdateActivityInputState
date DateTimeInterface, string, null
employeeCode string, null

Diagnostic methods

Create diagnostic

use IDCI\Bundle\SAMClientBundle\Client\SAMApiClient;
use IDCI\Bundle\SAMClientBundle\Client\Model\Enum\CreateDiagnosticInputWatchStateProductState;
...
$this->samApiClient->createDiagnotic(20000, [
    'date' => new \DateTime,
    'watchStates' => [
        [
            'toPrint' => false,
            'internalComment' => 'Fermoir cassé',
            'materialReference' => 'xxxxxx',
            'productState' => CreateDiagnosticInputWatchStateProductState::Broken,
        ],
    ],
    'operations' => [
        [
            'toPrint' => false,
            'internalComment' => 'Remplacement fermoir',
            'materialReference' => 'xxxxxx',
            'mandatory' => true,
            'main' => false,
            'quantity' => 1.00,
        ],
    ],
]);

$this->samApiClient->createDiagnosticByInternalNumber('internalNumber', [
    'date' => new \DateTime,
    'watchStates' => [
        [
            'toPrint' => false,
            'internalComment' => 'Fermoir cassé',
            'materialReference' => 'xxxxxx',
            'productState' => CreateDiagnosticInputWatchStateProductState::Broken,
        ],
    ],
    'operations' => [
        [
            'toPrint' => false,
            'internalComment' => 'Remplacement fermoir',
            'materialReference' => 'xxxxxx',
            'mandatory' => true,
            'main' => false,
            'quantity' => 1.00,
        ],
    ],
]);

$this->samApiClient->createDiagnosticByExternalId('externalId', [
    'date' => new \DateTime,
    'watchStates' => [
        [
            'toPrint' => false,
            'internalComment' => 'Fermoir cassé',
            'materialReference' => 'xxxxxx',
            'productState' => CreateDiagnosticInputWatchStateProductState::Broken,
        ],
    ],
    'operations' => [
        [
            'toPrint' => false,
            'internalComment' => 'Remplacement fermoir',
            'materialReference' => 'xxxxxx',
            'mandatory' => true,
            'main' => false,
            'quantity' => 1.00,
        ],
    ],
]);
option name type
date DateTimeInterface, string, null
watchStates array, null
operations array, null

Business deal methods

Create business deal

use IDCI\Bundle\SAMClientBundle\Client\SAMApiClient;
...
$this->samApiClient->createBusinessDeal([
    'externalId' => 'externalRef',
    'partnerReference' => 'FR center',
    'brandReference' => 'Brand 002',
    'partnerSiteReference' => 'xxxxx',
    'initialRequestorPartnerSiteReference' => 'xxxxx',
    'initialRequestorPartnerReference' => 'xxxxx',
    'invoicingCode' => '001',
    'internalNumber' => 'internalRef',
    'productNature' => 'Watch',
    'productReference' => 'xxxxx',
    'productSerialNumber' => 'xxxxx'
    'batchReference' => 'xxxxx',
    'movementSerialNumberReference' => 'xxxxx',
    'movementReference' => 'xxxxx',
    'interventionCode' => 'INV',
    'progress' => [
        'receptionDate' => new \DateTime,
        'estimateDate' => null,
        'expectedDeliveryDate' => null,
        'workStartDate' => null,
        'workEndDate' => null,
        'deliveryDate' => null,
        'numberDaysWaitingParts' => 2,
    ],
    'accessCode' => 'trackingCode',
    'quickService' => true,
    'interventionInvoicingCode' => '000',
]);
option name type
externalId* string
partnerReference* string
brandReference* string
partnerSiteReference string, null
initialRequestorPartnerSiteReference string, null
initialRequestorPartnerReference string, null
invoicingCode string, null
internalNumber string, null
productNature string, null
productReference string, null
productSerialNumber string, null
batchReference string, null
movementSerialNumberReference string, null
movementReference string, null
interventionCode string, null
progress BusinessDealProgress, array
accessCode string, null
quickService bool, null
interventionInvoicingCode string, null

Get business deal

use IDCI\Bundle\SAMClientBundle\Client\SAMApiClient;
...
$this->samApiClient->getBusinessDeal(20000);

$this->samApiClient->getBusinessDealByInternalNumber('internalNumber');

$this->samApiClient->getBusinessDealByExternalId('externalId');

$this->samApiClient->getBusinessDealsModifiedSince('2024-12-01');

Update business deal

use IDCI\Bundle\SAMClientBundle\Client\SAMApiClient;
use IDCI\Bundle\SAMClientBundle\Client\Model\Enum\JsonPatchDocumentOperation;
...
$this->samApiClient->updateBusinessDeal(20000, [
    'jsonPatchDocuments' => [
        [
            'op' => JsonPatchDocumentOperation::Add,
            'path' => '',
            'value' => 'new value',
            'from' => '',
        ],
    ],
]);

$this->samApiClient->updateBusinessDealByInternalNumber('internalNumber', [
    'jsonPatchDocuments' => [
        [
            'op' => JsonPatchDocumentOperation::Add,
            'path' => '',
            'value' => 'new value',
            'from' => '',
        ],
    ],
]);

$this->samApiClient->updateBusinessDealByExternalId('externalId', [
    'jsonPatchDocuments' => [
        [
            'op' => JsonPatchDocumentOperation::Add,
            'path' => '',
            'value' => 'new value',
            'from' => '',
        ],
    ],
]);
option name type
jsonPatchDocuments array

Delete business deal

use IDCI\Bundle\SAMClientBundle\Client\SAMApiClient;
...
$this->samApiClient->deleteBusinessDeal(20000);

$this->samApiClient->deleteBusinessDealByInternalNumber('internalNumber');

$this->samApiClient->deleteBusinessDealByExternalId('externalId');

Support

If needed, you can contact Maëva.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: CECILL-C
  • 更新时间: 2025-01-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固