akeneo-salesforce/salesforce-api

A library for interacting with the Salesforce REST API and managing the OAuth flow

2.0.7 2017-12-15 16:03 UTC

This package is not auto-updated.

Last update: 2024-10-26 20:37:39 UTC


README

Warning : Work in progess

###Aim

Call The SalesForce API (v37.0 at this time) in order to call API functionnalities easily. The main advantage is that you don't have to be preoccuped by the token, the library maintains it. Also, you are authentificated correctly to make a CLI application.

Install

$ composer require akeneo-salesforce/salesforce-api

Documentation

Usage

The client
$client = new Akeneo\SalesForce\Connector\SalesForceClient(
    $myUsername,
    $myPassword,
    $myClientId,
    $myClientSecret,
    $myLoginUrl,
    new GuzzleHttp\Client(),
    new Akeneo\SalesForce\Authentification\AccessTokenGenerator()
);

Usage in Symfony

This bundle can be easily integrated to a Symfony2 project, you just have to declare two services:

First declare your parameters in your parameters.yml

  • sales_force.username
  • sales_force.password
  • sales_force.client_id
  • sales_force.client_secret
  • sales_force.login_url (For example: 'https://login.salesforce.com/')
services:
    akeneo_sales_force.authentification.token_generator:
        class: Akeneo\SalesForce\Authentification\AccessTokenGenerator

    akeneo_sales_force.connector.client:
        class: Akeneo\SalesForce\Connector\SalesForceClient
        arguments:
            - "%sales_force.username%"
            - "%sales_force.password%"
            - "%sales_force.client_id%"
            - "%sales_force.client_secret%"
            - "%sales_force.login_url%"
            - "@guzzle.client"
            - "@akeneo_sales_force.authentification.token_generator"

And then use your client service like any other service.

Make a query

A QueryBuilder is given to make SOQL query.

See available functionnalities into the class itself.

Example

$queryBuilder = new Akeneo\SalesForce\Query\QueryBuilder();

$queryBuilder
            ->select('Id')
            ->from('Account')
            ->where($queryBuilder->getNotEqualCondition('Name', ':nameId'))
            ->setParameter('nameId', 'AccountPlop')
        ;

$client->search($queryBuilder->getQuery());

Next

More

This library is made with <3 by Akeneo

Do not hesitate to contribute.

Maintained by Anaƫl CHARDAN.