PTDirectTransferObject Class Methods
These methods are used by the PTDirectTransferObject class. The methods are listed in alphabetical order.
Syntax
SetAuth(Authorization)
Description
Use the SetAuth method to set the authorization for a request.
Note: The SetAuth method is optional. If you do not use this method, the authorization of the default search instance is used.
Parameters
Field or Control |
Definition |
---|---|
Authorization |
Specifies the authorization as a String. |
Returns
An Integer value indicating the libcurl error code.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
Local integer &ret = &PTDTObject.SetAuth("<user>:<password>");
Syntax
SetBody(Body)
Description
Use the SetBody method to set the JSON body as string for POST or PUT requests. You can use the CreateJsonBuilder function to form seamless JSON structures.
Note: For PeopleSoft application use, the attributes in the search engine are standardized with a specific suffix to support various analyzers. For example, the DESCR attribute in a search definition is created as DESCR_ORCL_ES_ENG in Elasticsearch. Related language fields should use the appropriate language code as a suffix. For example, DESCR_ORCL_ES_FRA for DESCR field in French. DirectTransfer expects the attribute name to be provided as it exists in the search engine. If not, a new field of default mapping is created in the search engine.
Parameters
Field or Control |
Definition |
---|---|
Body |
Specifies the body of a request as a String. |
Returns
An Integer value indicating the libcurl error code.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
Local JsonBuilder &jb = CreateJsonBuilder();
&jb.StartObject("");
&jb.AddProperty("FIRST_NAME", "MyFirstName");
&jb.AddProperty("LAST_NAME", "MyLastName");
&jb.EndObject("");
Local string &sBody = &jb.ToString();
Local integer &return = &PTDTObject.SetBody(&sBody);
Syntax
SetDocId(Document_ID)
Description
Use the SetDocId method to set the document ID for a document to be indexed.
Note: For PeopleSoft use, the document ID is the component URL as drilling url. A complete URL similar to the drilling URL generated through PeopleSoft Query should be provided as input. An update to an existing search document expects the same document ID to be provided in the request, otherwise the search document will be indexed as a new document.
Parameters
Field or Control |
Definition |
---|---|
Document_ID |
Specifies a document ID as a String. |
Returns
An Integer value indicating the libcurl error code.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
Local integer &return = &PTDTObject.SetDocId("1");
Syntax
SetHeader(Header)
Description
Use the SetHeader method to set the header for the cURL request.
Note: The SetHeader method is optional. The built-in functions internally handle some of the default headers such as, authentication and content type.
Parameters
Field or Control |
Definition |
---|---|
Header |
Specifies a header as a String. |
Returns
An Integer value indicating the libcurl error code.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
Local integer &ret = &PTDTObject.SetHeader("Host: myhost.com");
Syntax
SetIndex(Index_Name)
Description
Use the SetIndex method to set the name of an index.
Note: Use the database name as a suffix for the index. For example, hc_hrs_app_index_hcmdb01, where hcmdb01 is the name of the database.
Parameters
Field or Control |
Definition |
---|---|
Index_Name |
Specifies the name of the index as a String. |
Returns
An Integer value indicating the libcurl error code.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
Local integer &return = &PTDTObject.SetIndex("testindex");
Syntax
SetMethod(HTTP_Method)
Description
Use the SetMethod method to set the HTTP method (such as GET, POST, PUT and so on) for the cURL request.
Parameters
Field or Control |
Definition |
---|---|
HTTP_Method |
Specifies the HTTP method as a String. |
Returns
An Integer value indicating the libcurl error code.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
Local integer &return = &PTDTObject.SetMethod("POST");
Syntax
SetOption(Option_Name,Option_Value)
Description
Use the SetOption method to set various options such as USERPWD, MAXREDIRS, MAXFILESIZE and so on.
Note: The SetOption method is optional.
Parameters
Field or Control |
Definition |
---|---|
Option_Name |
Specifies the name of the option as a String. |
Option_Value |
Specifies the value of the option as a String. |
Returns
An Integer value indicating the libcurl error code.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
Local integer &return = &PTDTObject.SetOption("MAXREDIRS", "2");
Syntax
SetURL(URL)
Description
Use the SetURL method to set the target URL to which the request is triggered.
Note: This method is optional. If the method is not used, the target URL is set to the URL of the default search instance.
Parameters
Field or Control |
Definition |
---|---|
URL |
Specifies the URL as a String. |
Returns
An Integer value indicating the libcurl error code.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
Local integer &return = &PTDTObject.SetURL("http://host:port/");
Syntax
SyncTransfer()
Description
Use the SyncTransfer method to submit a synchronous curl transfer request.
Parameters
None.
Returns
A String value containing the curl response.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
Local string &return = &PTDTObject.SyncTransfer();
Syntax
Reset()
Description
Use the Reset method to reset the Direct Transfer object.
Parameters
None.
Returns
None.
Example
Local PTDirectTransferObject &PTDTObject = CreateDirecttransferObject();
&PTDTObject.Reset();