new ServiceController()

Description

Defines the controller used by all auto-generated services. In SuiteCommerce, services are responsible of implement
the REST facade while and delegate data access and logic to models (see SCModel).

Implementers should extend this class using ServiceController.extend
and implement methods ServiceController#get, ServiceController#post, ServiceController#put,
ServiceController#delete and ServiceController#patch that will handle each REST method. These methods will
end up calling ServiceController#sendContent or ServiceController#sendError

See backend_service_controller

Members


request :nlobjRequest

Description

The request made to this service


response :nlobjResponse

Description

the response object to write the data to respond by the call


method :String

Description

the REST http method currently requested


data :any

Description

the JSON object in the request body


options :ServiceControllerGeneralOptions

Description

The options which configure this service controller. If implementer use common those options will apply to all request while if they use a particular http method, like for example get, those options will apply only to get requests. Particular options override common's


name :string

Description

The name of this model. Is mandatory that al SCEventWrappers to have a name.

Details
string

Methods


sendContent( options, content )

Description

Writes the given content in the request object using the right headers, and content type

Parameters
Name Type Description
options ServiceControllerOptions
content String
Fires

sendError( e )

Description

Process given error and then writes it in the http response

Parameters
Name Type Description
e nlobjError | SCError

get() → {object}

Description

Users should implement this method for the service to support the http get operation

Returns

returns the JSON object that will end up being written in the http response


post() → {void}

Description

Users should implement this method for the service to support the http post operation and use
ServiceController#sendContent to write the response. Requested data is available in
ServiceController#data

Returns

put() → {object}

Description

Users should implement this method for the service to support the http put operation

Returns

returns the JSON object that will end up being written in the http response.
Requested data is available in ServiceController#data


delete() → {any}

Description

Users should implement this method for the service to support the http delete operation

Returns

returns the JSON object that will end up being written in the http response -
for example indicating if everything is OK or there was an error deleting the specified resources
Requested data is available in ServiceController#data


patch() → {any}

Description

Users should implement this method for the service to support the http patch operation

Returns

returns the JSON object that will end up being written in the http response