2017 © Pedro Peláez
 

library netsuite-php

NetSuite PHP API wrapper orginally built by Ryan Winchester.

image

tjsteinhaus/netsuite-php

NetSuite PHP API wrapper orginally built by Ryan Winchester.

  • Thursday, August 31, 2017
  • by tjsteinhaus
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 37 Forks
  • 0 Open issues
  • 20 Versions
  • 25 % Grown

The README.md

NetSuite PHP API Client

License Packagist, (*1)

A PHP API client package for NetSuite, pried from the NetSuite PHP Toolkit., (*2)

Adding it to your project:

Require with composer:, (*3)

V2 in Alpha, (*4)

NOTE: package name change, (*5)

composer require "tjsteinhaus/netsuite-php"

Changes in v2:

  • Changed namespaces
  • Significantly simplified NetSuiteClient
  • Added a convenience method for creating an instance using environment variables for configuration
  • Improved logging, still logs even if exception is thrown in soap call.

Quickstart:

Instantiating the NetSuiteService class:

The rest of the examples assume that you have done this., (*6)

require 'vendor/autoload.php';

use NetSuite\NetSuiteService;

$config = array(
   // required -------------------------------------
   "endpoint" => "2017_1",
   "host"     => "https://webservices.netsuite.com",
   "email"    => "jDoe@netsuite.com",
   "password" => "mySecretPwd",
   "role"     => "3",
   "account"  => "MYACCT1",
   "app_id"   => "4AD027CA-88B3-46EC-9D3E-41C6E6A325E2",
   // optional -------------------------------------
   "logging"  => true,
   "log_path" => "/var/www/myapp/logs/netsuite"
);

$service = new NetSuiteService($config);

Retreiving a customer record:

use NetSuite\Classes\GetRequest;
use NetSuite\Classes\RecordRef;

$request = new GetRequest();
$request->baseRef = new RecordRef();
$request->baseRef->internalId = "123";
$request->baseRef->type = "customer";

$getResponse = $service->get($request);

if ( ! $getResponse->readResponse->status->isSuccess) {
    echo "GET ERROR";
} else {
    $customer = $getResponse->readResponse->record;
}

Searching for customers who emails start with "j":

use NetSuite\Classes\SearchStringField;
use NetSuite\Classes\CustomerSearchBasic;
use NetSuite\Classes\SearchRequest;

$service->setSearchPreferences(false, 20);

$emailSearchField = new SearchStringField();
$emailSearchField->operator = "startsWith";
$emailSearchField->searchValue = "j";

$search = new CustomerSearchBasic();
$search->email = $emailSearchField;

$request = new SearchRequest();
$request->searchRecord = $search;

$searchResponse = $service->search($request);

if (!$searchResponse->searchResult->status->isSuccess) {
    echo "SEARCH ERROR";
} else {
    $result = $searchResponse->searchResult;
    $count = $result->totalRecords;
    $records = $result->recordList;

    echo $count . " records were found.";
}

Adding a new customer:

use NetSuite\Classes\Customer;
use NetSuite\Classes\RecordRef;
use NetSuite\Classes\AddRequest;

$customer = new Customer();
$customer->lastName = "Doe";
$customer->firstName = "John";
$customer->companyName = "ABC company";
$customer->phone = "123456789";
$customer->email = "joe.doe@abc.com";

$customer->customForm = new RecordRef();
$customer->customForm->internalId = -8;

$request = new AddRequest();
$request->record = $customer;

$addResponse = $service->add($request);

if (!$addResponse->writeResponse->status->isSuccess) {
    echo "ADD ERROR";
} else {
    echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;
}

Logging

You can set logging on or off on the fly, or override the configuration setting passed in. Please note that if you don't specify a logging directory in the config or afterwards, then you won't get logs no matter what you do., (*7)

Set a logging path, (*8)

$service->setLogPath('/path/to/logs');

Turn logging on, (*9)

$service->logRequests(true);  // Turn logging on.

Turn logging off, (*10)

$service->logRequests(false); // Turn logging off.

Token-Based Authentication

Instead of instantiating NetSuiteService with the standard credentials method, you can pass a set of credentials of the form consumerKey/consumerSecret/token/tokenSecret., (*11)

$config = array(
   // required -------------------------------------
   "endpoint"       => "2017_1",
   "host"           => "https://webservices.netsuite.com",
   "account"        => "MYACCT1",
   "consumerKey"    => "0123456789ABCDEF",
   "consumerSecret" => "0123456789ABCDEF",
   "token"          => "0123456789ABCDEF",
   "tokenSecret"    => "0123456789ABCDEF",
   // optional -------------------------------------
   "signatureAlgorithm" => 'sha256', // Defaults to 'sha256'
);

$service = new NetSuiteService($config);

Status

  • [x] Extract the ~1500 classes from their single file...
  • [x] Composer package with autoloading
  • [x] Pass config through constructor
  • [x] Optional environment variable config
  • [x] Namespacing
  • [x] Logging

License

Original work is Copyright © 2010-2015 NetSuite Inc. and provided "as is." Refer to the NetSuite Toolkit License Agreement file., (*12)

All additional work is licensed under the Apache 2.0 open source software license according to the included LICENSE file., (*13)

The Versions

31/08 2017

dev-master

9999999-dev

NetSuite PHP API wrapper orginally built by Ryan Winchester.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Ryan Winchester (fungku)
by Tyler Steinhaus

api php netsuite

31/08 2017

v2017.2

2017.2.0.0

NetSuite PHP API wrapper orginally built by Ryan Winchester.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Ryan Winchester (fungku)
by Tyler Steinhaus

api php netsuite

31/08 2017

v2017.1

2017.1.0.0

NetSuite PHP API wrapper orginally built by Ryan Winchester.

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Ryan Winchester (fungku)
by Tyler Steinhaus

api php netsuite

05/04 2017

v2016.2.0

2016.2.0.0

NetSuite PHP API wrapper

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Ryan Winchester (fungku)

api php netsuite

18/08 2016

v2016.1.2

2016.1.2.0

NetSuite PHP API wrapper

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api php netsuite

06/06 2016

v2016.1.1

2016.1.1.0

NetSuite PHP API wrapper

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api php netsuite

02/06 2016

v2016.1.0

2016.1.0.0

NetSuite PHP API wrapper

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api php netsuite

07/03 2016

v2.0.4-alpha

2.0.4.0-alpha

NetSuite PHP API wrapper

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api php netsuite

04/03 2016

v2.0.3-alpha

2.0.3.0-alpha

NetSuite PHP API wrapper

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api php netsuite

04/03 2016

v2.0.2-alpha

2.0.2.0-alpha

NetSuite PHP API wrapper

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api php netsuite

04/03 2016

v2.0.1-alpha

2.0.1.0-alpha

NetSuite PHP API wrapper

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api php netsuite

04/03 2016

v2.0.0-alpha

2.0.0.0-alpha

NetSuite PHP API wrapper

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api php netsuite

04/03 2016

v2015.2.1

2015.2.1.0

NetSuite PHP API Client with namespaces and autoloading

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api netsuite

03/03 2016

dev-develop

dev-develop

NetSuite PHP API Client with namespaces and autoloading

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *
  • ext-openssl *

 

The Development Requires

by Ryan Winchester (fungku)

api netsuite

02/03 2016

v2015.2.0

2015.2.0.0

NetSuite PHP API Client with namespaces and autoloading

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *

 

by Ryan Winchester (fungku)

api netsuite

15/05 2015

v2015.1.2

2015.1.2.0

Netsuite PHP API Client

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *

 

by Ryan Winchester (fungku)

api netsuite

14/05 2015

v2015.1.1

2015.1.1.0

Netsuite PHP API Client

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *

 

by Ryan Winchester (fungku)

api netsuite

01/05 2015

v2015.1.0

2015.1.0.0

Netsuite PHP API Client

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *

 

by Ryan Winchester (fungku)

api netsuite

01/05 2015

v2014.2.0

2014.2.0.0

Netsuite PHP API Client

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *

 

by Ryan Winchester (fungku)

api netsuite

28/01 2015

v1.1.0

1.1.0.0

Netsuite PHP API Client

  Sources   Download

Apache-2.0

The Requires

  • php >=5.3.0
  • ext-soap *
  • ext-simplexml *

 

by Ryan Winchester (fungku)

api netsuite