Giter VIP home page Giter VIP logo

salesforce-bundle's Introduction

Salesforce-bundle

Symfony bundle for Salesforce REST client which is base on username,password authentication

###Package instalation with composer

$ composer require genesis-global/salesforce-bundle

Enable bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new GenesisGlobal\Salesforce\SalesforceBundle\SalesforceBundle(),
        );

        // ...
    }

    // ...
}

Required configuration:

salesforce:
    authentication:
        endpoint: "https://login.salesforce.com/"
        client_id: "id"
        client_secret: "secret"
        username: "name"
        password: "pass",
        security_token: '22s2sd233e3'
    rest:
        version: "v35.0"
        endpoint: "https://yourinstance.salesforce.com"
        

Use in controller:

CREATE RECORD

// custom class which implements SobjectInterface
$case = new Sobject();
$case->setName('Case');
$case->setContent(['someField' => 'someValue']);

$result = $this->get('salesforce.service')->create($case);  

// get salesforce id
$id = $result->getId();

UPDATE RECORD

try {
    $this->get('salesforce.service')->update('Account', '001D000000INjVe', [ 'someField' => 'someValue' ]);
    
} catch (UpdateSobjectException $e) {
    
    // update failed
    echo $e->getMessage();
}

UPSERT RECORD

// account object
$account = new \stdClass();
$account->Current_Balance__c = '21023';
$account->Current_Count_of_Deposit__c = 0;
$account->Number_of_Active_Days__c = 12;
 
// account sObject ready to send to salesforce
$accountSobject = new Sobject();
$accountSobject->setName('Account');
$accountSobject->setContent($account);

$result = $this->get('salesforce.service')->upsert($sObject, 'Player_Account__c', '123132');

GET METADATA

$metaData = $this->get('salesforce.service')->getMetaDataForSobject('Account');

salesforce-bundle's People

Contributors

coderaf avatar bullb avatar clamburger avatar a1tem avatar lixing-zhang avatar melyouz avatar rjakubiak avatar siliconmind avatar harmstyler avatar timwsuqld avatar

Watchers

Diego Aguiar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.