vendasta/accountgroup

There is no license information available for the latest version (1.1.0) of this package.

Vendasta account group library for PHP

1.1.0 2020-07-21 18:21 UTC

This package is auto-updated.

Last update: 2021-09-21 21:23:47 UTC


README

Account group php sdk

Description

This is Vendasta's official PHP SDK for API integration of account-groups. This is used to create a business.

Requirements

Installation

Install the requirements from above, then:

composer require vendasta/account-group-php-sdk

Authentication

To authenticate your SDK calls, you must provision a service account from within the Vendasta platform.

This feature is currently in alpha, therefore your service account credentials file will be provided to you manually.

You must put this file on your server, and set an environment variable to it's path:

export VENDASTA_APPLICATION_CREDENTIALS=<path to credentials.json>

Client Initialization

It is highly recommended that you use a singleton client instance. Each client initilization will open it's own connection, therefore using a singleton results in reusing a connection, saving time and resources.

Set an environment variable for the production environment:

export PRODUCTION_ENVIRONMENT=<DEMO or PROD> 

To instantiate the client:

$environment = getenv("PRODUCTION_ENVIRONMENT");
if ($environment == null) {
    $environment = "DEMO";
}

$client = new Vendasta\AccountGroup\V1\AccountGroupServiceClient($environment);

Notice that the production environment will be set to DEMO if it is not specified.

Creating account groups

$createReq = new Vendasta\AccountGroup\V1\CreateAccountGroupRequest();
$location = new Vendasta\AccountGroup\V1\AccountGroupLocation();
$location->setCompanyName("<business_name>");
$location->setAddress("<address>");
$location->setCity("<city>>");
$location->setState("<state>");
$location->setCountry("<country>");
$location->setZip("<zip>");
$workNumber = array("<phone_number>");
$location->setWorkNumber($workNumber);

$createReq->setAccountGroupNap($location);

$createReq->setPartnerId("<partner_id>");
$resp = $client->Create($createReq);