public class

NetSuiteCloudConnector

extends Object
java.lang.Object
   ↳ org.mule.module.netsuite.NetSuiteCloudConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

The NetSuite cloud connector facade, based on a NetSuiteClient

Summary

Constants
String SUITETALK_LIVE_ADDRESS
Fields
private NetSuiteClient<List<Object>, RuntimeException, Void> client The Netsuite client to use.
private String connectionId The login email of both NetSuite UI and SuiteTalk
private static List<String> customKey
private String defaultEndpoint Service endpoint
    Supports:
  • Live: https://webservices.netsuite.com/services/NetSuitePort_2012_2
  • Sandbox: https://webservices.sandbox.netsuite.com/services/NetSuitePort_2012_2
Defaults to Live
Public Constructors
NetSuiteCloudConnector()
Public Methods
RecordRef addFile(Map<String, Object> attributes, Object content, String fileName, String folderId, RecordIdType folderIdType)
Creates a new file record.
List<RecordRef> addList(String recordType, List<Map<String, Object>> records)
Used to add one or more records into the system
RecordRef addRecord(String recordType, Map<String, Object> attributes)
Creates a new record.
List<RecordRef> addRecordObjects(RecordTypeEnum recordType, List<? extends Record> records)
Creates new records Example:
AsyncStatusResult asyncFindRecords(SearchRecordTypeEnum recordType, String expression)
Searches for all records that match the given filtering expression, asynchronously.
AttachResponse attachRecord(RecordTypeEnum sourceRecordType, String sourceId, RecordIdType sourceIdType, RecordTypeEnum destinationRecordType, String destinationId, RecordIdType destinationIdType, RecordTypeEnum contanctRecordType, String contanctId, RecordIdType contanctIdType)
Attaches a source record - that is, the attachment - to another destination one, optionally specifying a contact for the attachment.
AsyncStatusResult checkAsyncStatus(String jobId)
Answers the status of an asynchronous Web services submission.
void connect(String email, String password, String endpoint, String account, String roleId)
Connection Management connect method
String connectionId()
List<RecordRef> deleteList(RecordTypeEnum recordType, List<Map<String, Object>> records)
Used to delete one or more records in the system.
DeleteResponse deleteRecord(RecordTypeEnum recordType, String id, RecordIdType idType)
Deletes a record.
DetachResponse detachRecord(RecordTypeEnum sourceRecordType, String sourceId, RecordIdType sourceIdType, RecordTypeEnum destinationRecordType, String destinationId, RecordIdType destinationIdType)
Detaches a source record - that is, the attachment - from a destination record.
void disconnect()
Connection Management disconnect method
Record findFirstRecord(SearchRecordTypeEnum recordType, String expression)
Answers the first records that match the given filtering expression.
List<Record> findRecords(SearchRecordTypeEnum recordType, String expression)
Answers all records that match the given filtering expression.
Object getAsyncFindFirstResult(String jobId)
Answers the the first result of an asynchronous asyncFind.
List<Record> getAsyncFindResult(String jobId)
Answers the results of an asynchronous web services submission.
List<BudgetExchangeRate> getBudgetExchangeRates(String periodId, RecordIdType periodIdType, String fromSubsidiaryId, RecordIdType fromSubsidiaryIdType, String toSubsidiaryId, RecordIdType toSubsidiaryIdType)
Answers the list of budget exchange rates Example:
NetSuiteClient<List<Object>, RuntimeException, Void> getClient()
List<ConsolidatedExchangeRate> getConsolidatedExchangeRates(String periodId, RecordIdType periodIdType, String fromSubsidiaryId, RecordIdType fromSubsidiaryIdType, String toSubsidiaryId, RecordIdType toSubsidiaryIdType)
Answers the list of consolidated exchange rates Example:
List<CustomizationRef> getCustomizationIds(GetCustomizationTypeEnum type, boolean includeInactives)
Answers the ids of available customizations for a given record type.
String getDefaultEndpoint()
List<DeletedRecord> getDeletedRecords(RecordTypeEnum type, String whenExpression, Date date1, Date date2, SearchDateFieldOperatorEnum operator)
Answers a list of deleted records of a given record type that match a given date expression.
List<ItemAvailability> getItemAvailabilities(RecordTypeEnum recordType, String id, RecordIdType idType, Date ifModifiedSince)
Answers the availability for a given record reference.
MetaData getMetaData(MetaDataKey key)
List<MetaDataKey> getMetaDataKeys()
Record getRecord(RecordTypeEnum recordType, String id, RecordIdType idType)
Answers a record given its id Example:
List<Record> getRecords(GetAllRecordType type)
Answers all the record of a given type Example:
List<RecordRef> getSavedSearch(RecordTypeEnum type)
Retrieves a list of existing saved searches for the given record type.
Date getServerTime()
Answers the server time, resulting in more accurate and reliable sync'ing of data than using using local client time.
Object initialize(InitializeTypeEnum type, RecordTypeEnum recordType, String id, RecordIdType idType)
Populates fields on transaction line items with values from a related record, in a similar way empty text boxes are prepopulated within the Netsuite UI Example:
boolean isConnected()
List<SearchRow> savedFindRecords(SearchRecordTypeEnum recordType, String searchId)
Answers all records of a given type for a saved search, given its search id.
void setClient(NetSuiteClient<?, ?, ?> client)
void setDefaultEndpoint(String defaultEndpoint)
void updateCustomFieldsRecord(RecordTypeEnum recordType, CustomFieldRefTypeEnum customFieldType, String id, RecordIdType idType, Map<String, Object> customFields)
Updates existing record's custom fields Example:
UpdateInviteeStatusResponse updateInviteeStatus(String eventId, RecordIdType eventIdType, CalendarEventAttendeeResponseEnum status)
Sets a new invitation status for a given event.
List<RecordRef> updateList(String recordType, List<Map<String, Object>> records)
Used to update one or more existing records in the system by providing new values for the fields to be updated for each record.
RecordRef updateRecord(String recordType, String id, RecordIdType idType, Map<String, Object> attributes)
Updates an existing record.
List<RecordRef> upsertList(String recordType, List<Map<String, Object>> records)
The upsertList operation is used to add or update one or more instances of a record type in NetSuite.
RecordRef upsertRecord(String recordType, String externalId, Map<String, Object> attributes)
The upsert operation is used to add a new instance or to update an instance of a record in NetSuite.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

private static final String SUITETALK_LIVE_ADDRESS

Constant Value: "https://webservices.na1.netsuite.com/services/NetSuitePort_2012_2"

Fields

private NetSuiteClient<List<Object>, RuntimeException, Void> client

The Netsuite client to use. Mainly for mocking purposes

private String connectionId

The login email of both NetSuite UI and SuiteTalk

private static List<String> customKey

private String defaultEndpoint

Service endpoint

    Supports:
  • Live: https://webservices.netsuite.com/services/NetSuitePort_2012_2
  • Sandbox: https://webservices.sandbox.netsuite.com/services/NetSuitePort_2012_2
Defaults to Live

Public Constructors

public NetSuiteCloudConnector ()

Public Methods

public RecordRef addFile (Map<String, Object> attributes, Object content, String fileName, String folderId, RecordIdType folderIdType)

Creates a new file record. This Processor is similar to addRecord, but is customized for simplifying local content passing.

Parameters
attributes The additional file attributes
content The content of the file record to add. It can be of type String, byte array, File or InputStream. If it is an input stream, this Processors also closes it.
fileName The name of the remote file
folderId The id of the folder record where to add this file
folderIdType The id type of the folder record
Returns
  • the RecordRef of the new record
Throws
IOException if the content cannot be parsed to byte[]

public List<RecordRef> addList (String recordType, List<Map<String, Object>> records)

Used to add one or more records into the system

Parameters
recordType The type of record to add
records The records with their attributes, as a string-object map
Returns
  • A list of record references for the added records

public RecordRef addRecord (String recordType, Map<String, Object> attributes)

Creates a new record. Example:

Parameters
recordType The type of record to add
attributes The record attributes, as a string-object map
Returns
  • the RecordRef of the new record

public List<RecordRef> addRecordObjects (RecordTypeEnum recordType, List<? extends Record> records)

Creates new records Example:

Parameters
recordType The type of record to add
records The Records object
Returns
  • the RecordRef of the new record

public AsyncStatusResult asyncFindRecords (SearchRecordTypeEnum recordType, String expression)

Searches for all records that match the given filtering expression, asynchronously. If no expression is specified, all records of the given type are retrieved Filtering expressions support both basic and joined syntax, that is, using in the filters attributes of both the target entity and the target entity associations. Advanced search is not supported. Search expressions are in the form operator(attribute, arguments...) for basic search, and operator(join.attribute, arguments...) for joined search, where operator is any of the string, long, double, and text operators supported by SuiteTalk - MultiSelect operators are not supported - plus the isTrue/isFalse boolean operators, and arguments are zero up to three operands that depend on the operator used. Examples:

Parameters
recordType The type of record to search
expression The filtering expression, in the form operator(attribute, arguments...) for basic search, and operator(join.attribute, arguments...) for joined search, where operator is any of the string, long, double, and text operators supported by SuiteTalk - MultiSelect operators are not supported - plus the isTrue/isFalse boolean operators, and arguments are zero up to three operands that depend on the operator used. Multiple filters can be combined using multiple predicates separated by commas.
Returns
  • the AsyncStatusResult of the query

public AttachResponse attachRecord (RecordTypeEnum sourceRecordType, String sourceId, RecordIdType sourceIdType, RecordTypeEnum destinationRecordType, String destinationId, RecordIdType destinationIdType, RecordTypeEnum contanctRecordType, String contanctId, RecordIdType contanctIdType)

Attaches a source record - that is, the attachment - to another destination one, optionally specifying a contact for the attachment. Not all record type are supported as source, destination or contact. Please consult NetSuite documentation. Example:

Parameters
sourceRecordType The type of the target record to be attached
sourceId The id of the target record to be attached
sourceIdType The id type of the record to be attached
destinationRecordType The type of the record to be attached to
destinationId The id of the record to be attached to
destinationIdType The id type of the record to be attached to
contanctRecordType The record type of the optional contact record
contanctId The id of the optional contact record
contanctIdType The id type of the optional contact record
Returns
  • AttachResponse information including the WriteResponse object.

public AsyncStatusResult checkAsyncStatus (String jobId)

Answers the status of an asynchronous Web services submission. When a jobId is submitted, the status, percent complete, and estimated remaining duration are returned. Example:

Parameters
jobId The id of the job whose status to check
Returns
  • the AsyncStatusResult for the given job

public void connect (String email, String password, String endpoint, String account, String roleId)

Connection Management connect method

Parameters
email The login email of both NetSuite UI and SuiteTalk
password The login password of both the NetSuite UI and SuiteTalk
endpoint Service endpoint
account SuiteTalk -NetSuite WebService - account id. It looks like TSTDRVXXXXXX
roleId The id of the role used to login in SuiteTalk, which determines the Processor privileges
Throws
ConnectionException

public String connectionId ()

Returns
  • the session id

public List<RecordRef> deleteList (RecordTypeEnum recordType, List<Map<String, Object>> records)

Used to delete one or more records in the system. The records to be deleted are identified through the provided unique identifiers.

Parameters
recordType The type of record to add
records The records with their attributes, as a string-object map
Returns
  • A list of Record references for the deleted records

public DeleteResponse deleteRecord (RecordTypeEnum recordType, String id, RecordIdType idType)

Deletes a record. Not all records can be deleted. Please consult NetSuite documentation Example:

Parameters
recordType The type of the record to delete
id The id of the record to delete
idType The type of id of the record to delete
Returns
  • deleted record response

public DetachResponse detachRecord (RecordTypeEnum sourceRecordType, String sourceId, RecordIdType sourceIdType, RecordTypeEnum destinationRecordType, String destinationId, RecordIdType destinationIdType)

Detaches a source record - that is, the attachment - from a destination record. Example:

Parameters
sourceRecordType The type of the target record to be detached
sourceId The id of the target record to be detached
sourceIdType The id type of the record to be detached
destinationRecordType The type of the record to be detached to
destinationId The id of the record to be detached to
destinationIdType The id type of the record to be detached to
Returns
  • DetachResponse object

public void disconnect ()

Connection Management disconnect method

Throws
ConnectionException exception
Exception

public Record findFirstRecord (SearchRecordTypeEnum recordType, String expression)

Answers the first records that match the given filtering expression. If no expression is specified, the empty expression is used, which retrieves all records of the given type. Returns null if no element can be retrieved Filtering expressions support both basic and joined syntax, that is, using in the filters attributes of both the target entity and the target entity associations. Advanced search is not supported. Search expressions are in the form operator(attribute, arguments...) for basic search, and operator(join.attribute, arguments...) for joined search, where operator is any of the string, long, double, and text operators supported by SuiteTalk - MultiSelect operators are not supported - plus the isTrue/isFalse boolean operators, and arguments are zero up to three operands that depend on the operator used. Examples:

Parameters
recordType The type of record to search
expression The filtering expression Multiple filters can be combined using multiple predicates separated by commas.
Returns
  • the first record that match the given filtering expression

public List<Record> findRecords (SearchRecordTypeEnum recordType, String expression)

Answers all records that match the given filtering expression. If no expression is specified, the empty expression is used, which retrieves all records of the given type. Filtering expressions support both basic and joined syntax, that is, using in the filters attributes of both the target entity and the target entity associations. Advanced search is not supported. Search expressions are in the form operator(attribute, arguments...) for basic search, and operator(join.attribute, arguments...) for joined search, where operator is any of the string, long, double, and text operators supported by SuiteTalk - MultiSelect operators are not supported - plus the isTrue/isFalse boolean operators, and arguments are zero up to three operands that depend on the operator used. Examples:

Parameters
recordType The type of record to search
expression The filtering expression Multiple filters can be combined using multiple predicates separated by commas.
Returns

public Object getAsyncFindFirstResult (String jobId)

Answers the the first result of an asynchronous asyncFind. Throws a NoSuchElement exception if there are no results. This Processor can be executed Processor up to 20 times within a 30 day time period to retrieve the results of an asynchronous job. Example:

Parameters
jobId The id of the job
Returns
  • the first Record

public List<Record> getAsyncFindResult (String jobId)

Answers the results of an asynchronous web services submission. This Processor can be executed Processor up to 20 times within a 30 day time period to retrieve the results of an asynchronous job. Example:

Parameters
jobId The id of the job
Returns
  • An iterable with the Records found

public List<BudgetExchangeRate> getBudgetExchangeRates (String periodId, RecordIdType periodIdType, String fromSubsidiaryId, RecordIdType fromSubsidiaryIdType, String toSubsidiaryId, RecordIdType toSubsidiaryIdType)

Answers the list of budget exchange rates Example:

Parameters
periodId The id of the period
periodIdType The period id type
fromSubsidiaryId The id of the staring subsidiary
fromSubsidiaryIdType The starting subsidiary id type
toSubsidiaryId The the id of the optional ending subsidiary
toSubsidiaryIdType The id type of the optional ending subsidiary
Returns
  • a list of BudgetExchangeRate's

public NetSuiteClient<List<Object>, RuntimeException, Void> getClient ()

public List<ConsolidatedExchangeRate> getConsolidatedExchangeRates (String periodId, RecordIdType periodIdType, String fromSubsidiaryId, RecordIdType fromSubsidiaryIdType, String toSubsidiaryId, RecordIdType toSubsidiaryIdType)

Answers the list of consolidated exchange rates Example:

Parameters
periodId The id of the period
periodIdType The period id type
fromSubsidiaryId The id of the staring subsidiary
fromSubsidiaryIdType The starting subsidiary id type
toSubsidiaryId The the id of the optional ending subsidiary
toSubsidiaryIdType The id type of the optional ending subsidiary
Returns
  • a list of ConsolidatedExchangeRate's

public List<CustomizationRef> getCustomizationIds (GetCustomizationTypeEnum type, boolean includeInactives)

Answers the ids of available customizations for a given record type. Example:

Parameters
type The target record type
includeInactives If inactive customizations should also be returned
Returns
  • a list of CustomizationRef's

public String getDefaultEndpoint ()

public List<DeletedRecord> getDeletedRecords (RecordTypeEnum type, String whenExpression, Date date1, Date date2, SearchDateFieldOperatorEnum operator)

Answers a list of deleted records of a given record type that match a given date expression. This Processors accepts two different date expression passing styles: string oriented, and object oriented. If whenExpression is specified, it is parsed and used as date expression. Otherwise, a date expression is build from date1, date2 and operator parameters. The first style is more appropriate when the date expression can be harcdoded, while the second style is better when client code already has date objects. However, predefined search values like thisWeek, tomorrow or today can only be used with the first, string oriented, style. String oriented date expressions are in the form Processor( searchValue, arguments...), where Processor is any of the NetSuite supported date Processors, arguments are one or two operands for the given operator, and searchValue is some of the supported predefined search value as defined by NetSuite or any of the following expressions: isoDate( anIsoDate ), isoDateRante( anIsoDate, anotherIsoDate ) , dateTime( aQuotedDateTime, aQuoatedJavaDateFormat ), dateTimeRange( aQuotedDateTime, anotherQuotedDateTime, aQuoatedJavaDateFormat ). Supported predefined search values are: today, thisWeek, thisBusinessWeek, thisMonth,thisYear, yesterday, twoDaysAgo, lastWeek, lastMonth, threeMonthAgo,tomorrow, nextMonth , nextWeek Examples using both string and object oriented styles:

Parameters
type The type of the target deleted record to retrieve
whenExpression A predicate-style date filtering expression
date1 The first date to use
date2 The second date to use
operator The date operator
Returns
  • the list of DeletedRecord's that match the given date filtering expression

public List<ItemAvailability> getItemAvailabilities (RecordTypeEnum recordType, String id, RecordIdType idType, Date ifModifiedSince)

Answers the availability for a given record reference. If the Multi-Location Inventory feature is enabled, this Processor returns results for all locations. For locations that do not have any items available, only location IDs and names are listed in results. Example:

Parameters
recordType The target record type
id The target record id
idType The id type of the given record id
ifModifiedSince An optional modified since date. If set, only items with quantity available changes recorded as of the specified date are returned.
Returns
  • A list of ItemAvailability's

public MetaData getMetaData (MetaDataKey key)

Parameters
key
Throws
Exception

public List<MetaDataKey> getMetaDataKeys ()

Throws
Exception

public Record getRecord (RecordTypeEnum recordType, String id, RecordIdType idType)

Answers a record given its id Example:

Parameters
recordType The target record type
id The target record id
idType The id type of the given record id
Returns

public List<Record> getRecords (GetAllRecordType type)

Answers all the record of a given type Example:

Parameters
type The target record type
Returns
  • the list of Record's

public List<RecordRef> getSavedSearch (RecordTypeEnum type)

Retrieves a list of existing saved searches for the given record type. Example:

Parameters
type The target record type
Returns
  • the list of RecordRedf's

public Date getServerTime ()

Answers the server time, resulting in more accurate and reliable sync'ing of data than using using local client time. Example:

Returns
  • the server time, as a Date

public Object initialize (InitializeTypeEnum type, RecordTypeEnum recordType, String id, RecordIdType idType)

Populates fields on transaction line items with values from a related record, in a similar way empty text boxes are prepopulated within the Netsuite UI Example:

Parameters
type The type of record whose defaults values are used to populate the target record
recordType The target record type
id The target record id
idType The id type of the given record id
Returns
  • the initialized Record

public boolean isConnected ()

public List<SearchRow> savedFindRecords (SearchRecordTypeEnum recordType, String searchId)

Answers all records of a given type for a saved search, given its search id. Examples:

Parameters
recordType The type of record to search
searchId The id of the save search
Returns
  • An iterable with the Records found

public void setClient (NetSuiteClient<?, ?, ?> client)

Parameters
client

public void setDefaultEndpoint (String defaultEndpoint)

Parameters
defaultEndpoint

public void updateCustomFieldsRecord (RecordTypeEnum recordType, CustomFieldRefTypeEnum customFieldType, String id, RecordIdType idType, Map<String, Object> customFields)

Updates existing record's custom fields Example:

Parameters
recordType The target record type to update
customFieldType The type of custom field
id The target record id
idType The id type of the given record id
customFields The custom fields as a map, where the key is the internalId

public UpdateInviteeStatusResponse updateInviteeStatus (String eventId, RecordIdType eventIdType, CalendarEventAttendeeResponseEnum status)

Sets a new invitation status for a given event. Example: Example:

Parameters
eventId The target event id
eventIdType The id type of the given eventId
status The new status to set
Returns
  • UpdateInviteeStatus response object

public List<RecordRef> updateList (String recordType, List<Map<String, Object>> records)

Used to update one or more existing records in the system by providing new values for the fields to be updated for each record. The records to be updated are identified through the provided unique identifiers.

Parameters
recordType The type of record to add
records The records with their attributes, as a string-object map
Returns
  • A list with the record references for the updated records

public RecordRef updateRecord (String recordType, String id, RecordIdType idType, Map<String, Object> attributes)

Updates an existing record. Example:

Parameters
recordType The target record type to update
id The target record id
idType The id type of the given record id
attributes The record attributes, as a string-object map
Returns
  • The Record reference for the updated record
Throws
Exception

public List<RecordRef> upsertList (String recordType, List<Map<String, Object>> records)

The upsertList operation is used to add or update one or more instances of a record type in NetSuite. The upsertList operation is similar to both the addList and updateList operations, but upsert can be run without first determining whether records exist in NetSuite. Records are identified by their external ID and their record type. If a record of the specified type with a matching external ID exists in the system, it is updated. If it does not exist, a new record is created. Because external ID is mandatory for this operation, upsertList is supported only for records that support the external ID field. Also, this operation prohibits the passing of internal ID values.

Parameters
recordType The target record type to update
records The record attributes, as a string-object map
Returns
  • A list with the references to the upserted records

public RecordRef upsertRecord (String recordType, String externalId, Map<String, Object> attributes)

The upsert operation is used to add a new instance or to update an instance of a record in NetSuite. It is similar to the upsertList operation, which allows users to add or update more than one record at a time. The upsert operation is similar to both the add and update operations, but upsert can be run without first determining whether a record exists in NetSuite. A record is identified by its external ID and its record type. If a record of the specified type with a matching external ID exists in the system, it is updated. If it does not exist, a new record is created. Because external ID is mandatory for this operation, upsert is supported only for records that support the external ID field. Also, this operation prohibits the passing of internal ID values.

Parameters
recordType The target record type to update
externalId The target record id
attributes The record attributes, as a string-object map
Returns