HomeWiki
HomeWiki
  1. Import
  • Back to home
  • 2. Connectivity
  • Introduction
  • Custom Script
  • Playground
  • Database Explorer
  • Log Stream
  • Direct Communication
  • Softone
    • Getting Started
  • Datapump
    • Getting Started
    • Crons
    • Legacy Windows Support
    • SDK
      • DB
        • _executeQuery
        • _executeStoreProcedure
        • _executeInsertQuery
        • _executeInsertQueriesInTransaction
      • Import
        • _productsImport
        • _categoriesImport
        • _brandsImport
        • _attributesImport
        • _attributeSetsImport
        • _unitsImport
        • _quantityImport
        • _customersImport
        • _contactsImport
        • _callsImport
        • _eventsImport
        • _tasksImport
        • _ordersImport
        • _usersImport
        • _customerSourceTagsImport
        • _productSourceTagsImport
      • Log
        • _logDebug
        • _logInfo
        • _logWarn
        • _logError
      • Web Requests
        • _httpGetJson
        • _httpPostJson
        • _httpPutJson
        • _httpDeleteJson
        • _httpPatchJson
      • Variables
        • _saveVariable
        • _getVariable
        • _deleteVariable
      • Blob
        • _blobConnect
        • _blobExists
        • _blobGet
        • _blobFind
      • Utils
        • _encodeBase64
        • _sleep
        • _getLastSyncDate
        • _updateLastSyncDate
        • _resetLastSyncDate
  1. Import

_contactsImport

Documentation: _contactsImport Function#

The _contactsImport function is designed to import a batch of contact data into the Shopranos platform. It manages authentication, sends a POST request with the contact data to the Shopranos API, and processes the response and potential errors. The function returns a structured result indicating the outcome of the import operation.

Function Signature:#

Parameters:#

payload (Array of contacts):
Description: An array of contact objects to be sent in the POST request body. Each object should represent a contact with its relevant details. This data is used by the Shopranos platform to process the import operation.
Type: Array<Object>
Example:

Return Value:#

Returns:
A JSON object containing the result of the HTTP POST request to the Shopranos platform. The object includes:
StatusCode: The HTTP status code of the response from the Shopranos platform.
Content: The content of the response body from the Shopranos platform, typically containing success or error messages.
Type: Object
Example:

Function Workflow:#

1.
Retrieve Certificate:
The function retrieves a certificate required for authentication. If the certificate cannot be obtained, it logs an error and returns a JSON object indicating "NO CERTIFICATE".
2.
Retrieve Access Token:
It then retrieves an access token for authorization. If the token is not available or is empty, it logs an error and returns a JSON object indicating "NO TOKEN".
3.
Prepare and Send HTTP Request:
The function creates an HTTP client and configures it with the access token and base address for the Shopranos platform.
It sets the request headers, including the Authorization header with the Bearer token and x-companyid header with the company ID from the certificate.
The payload is converted to a JSON string and sent in the request body.
4.
Handle HTTP Response:
The function sends the POST request to the specified URL and checks if the response is successful. If not, it logs an error with the status code.
It reads the response content and logs it for debugging purposes.
It then constructs a JSON object with the StatusCode and Content from the response.
5.
Exception Handling:
If any exception occurs during the process, it logs the exception message and returns a JSON object with StatusCode set to "EXCEPTION" and the exception message as the Content.

Example Usage:#

Important Considerations:#

Error Handling:
Ensure proper handling of cases where the certificate or token cannot be retrieved. The function handles these errors by returning appropriate messages.
Payload Format:
The payload parameter must be an array of contact objects formatted according to the Shopranos API requirements.
Customer.Api.Features.Contacts.ContactImportDTO
ownerId
string  | null 
OwnerId
optional
accountIds
array[string] | null 
AccountIds
optional
sourceId
string  | null 
SourceId
optional
sourceOwnerId
string  | null 
SourceOwnerId
optional
sourceAccountIds
array[string] | null 
SourceAccountIds
optional
name
null  | allOf {1} 
Name
optional
object (Customer.Api.Features.Contacts.NameDTO) 
optional
email
string  | null 
Email
optional
phone
string  | null 
Phone
optional
mobilePhone
string  | null 
MobilePhone
optional
fax
string  | null 
Fax
optional
callOptOut
boolean  | null 
CallOptOut
optional
emailOptOut
boolean  | null 
EmailOptOut
optional
otherEmail
array[object (Customer.Api.Features.Contacts.EmailDTO) {3}]  | null 
OtherEmail
optional
emailAddress
string  | null 
EmailAddress
optional
type
enum<string> 
Type
optional
Allowed values:
WorkHomeOtherignore
optOut
boolean 
OptOut
optional
otherPhone
array[object (Customer.Api.Features.Contacts.PhoneDTO) {3}]  | null 
OtherPhone
optional
phoneNumber
string  | null 
PhoneNumber
optional
type
enum<string> 
Type
optional
Allowed values:
WorkHomeOtherignore
optOut
boolean 
OptOut
optional
jobTitle
string  | null 
JobTitle
optional
genderId
string  | null 
GenderId
optional
pronounceId
string  | null 
PronounceId
optional
address
null  | allOf {1} 
Address
optional
object (Customer.Api.DTOs.AddressDTO) 
optional
createdBy
string  | null 
CreatedBy
optional
lastModifiedBy
string  | null 
LastModifiedBy
optional
department
string  | null 
Department
optional
reportsTo
string  | null 
ReportsTo
optional
assistant
string  | null 
Assistant
optional
assistantPhone
string  | null 
AssistantPhone
optional
birthday
string <date-time> | null 
Birthday
optional
description
string  | null 
Description
optional
lastStayInTouchReportedDate
string <date-time> | null 
LastStayInTouchReportedDate
optional
lastStayInTouchSaveDate
string <date-time> | null 
LastStayInTouchSaveDate
optional
accountSourceTypeId
string  | null 
AccountSourceTypeId
optional
extraFields
object  | null 
ExtraFields
optional
Additional properties
integer  | number  | string  | boolean 
optional
id
string  | null 
Id
optional
Timeouts:
The HTTP client has a timeout of 120 seconds. Ensure that this is sufficient for the Shopranos platform to process the request.
By using _contactsImport, you can automate the import of contact data into the Shopranos platform, ensuring that the data is sent securely and that any issues are handled and reported appropriately.
Previous
_customersImport
Next
_callsImport
Built with