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

_customersImport

Documentation: _customersImport Function#

The _customersImport function is designed to import a batch of customer data into the Shopranos platform. It handles authentication, sends a POST request with the customer 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 customers):
Description: An array of customer objects to be sent in the POST request body. Each object should represent a customer 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 customer objects formatted according to the Shopranos API requirements.
Customer.Api.Features.Customers.CustomerImportDTO
id
string  | null 
Id
optional
companyId
string  | null 
CompanyId
optional
code
string  | null 
Code
optional
name
string  | null 
Name
optional
tin
string  | null 
Tin
optional
email
string  | null 
Email
optional
phone
string  | null 
Phone
optional
priceCategoryId
string  | null 
PriceCategoryId
optional
sourceId
string  | null 
SourceId
optional
tags
array[string] | null 
Tags
optional
sourceTags
array[string] | null 
SourceTags
optional
address
null  | allOf {1} 
Address
optional
object (Customer.Api.DTOs.AddressDTO) 
optional
notes
string  | null 
Notes
optional
status
enum<string>  | enum<null> 
Status
optional
Allowed values:
ActiveInactiveStopOrderignore
branches
array[object (Customer.Api.Features.Customers.CustomerBranchDTO) {11}]  | null 
Branches
optional
id
string  | null 
Id
optional
sourceId
string  | null 
SourceId
optional
code
string  | null 
Code
optional
name
string  | null 
Name
optional
phone
string  | null 
Phone
optional
address
null  | allOf {1} 
Address
optional
vatType
enum<string>  | enum<null> 
VatType
optional
Allowed values:
ZeroRegularDiscountedignore
status
enum<string>  | enum<null> 
Status
optional
Allowed values:
ActiveInactiveStopOrderignore
contactLanguage
string  | null 
ContactLanguage
optional
paymentProviderId
string  | null 
PaymentProviderId
optional
carrierId
string  | null 
CarrierId
optional
additionalFeatures
null  | allOf {1} 
AdditionalFeatures
optional
object (Customer.Api.Features.Customers.CustomerAdditionalFeaturesDTO) 
optional
customFields
array[object (Customer.Api.Features.Customers.CustomerCustomFieldDTO) {3}]  | null 
CustomFields
optional
name
string  | null 
Name
optional
value
null 
Value
optional
translation
null  | allOf {1} 
Translation
optional
updateDate
string <date-time> | null 
UpdateDate
optional
insertDate
string <date-time> | null 
InsertDate
optional
taxOffice
string  | null 
TaxOffice
optional
contactLanguage
string  | null 
ContactLanguage
optional
vatType
enum<string>  | enum<null> 
VatType
optional
Allowed values:
ZeroRegularDiscountedignore
shopType
enum<integer> <int32> | enum<null> 
ShopType
optional
Allowed values:
012-1
logo
string  | null 
Logo
optional
paymentProviderId
string  | null 
PaymentProviderId
optional
carrierId
string  | null 
CarrierId
optional
address1
string  | null 
Address1
optional
address2
string  | null 
Address2
optional
>= 0 characters<= 100 characters
city
string  | null 
City
optional
>= 0 characters<= 60 characters
state
string  | null 
State
optional
>= 0 characters<= 50 characters
country
string  | null 
Country
optional
>= 0 characters<= 55 characters
latitude
string  | null 
Latitude
optional
longtitude
string  | null 
Longtitude
optional
countryCode
string  | null 
CountryCode
optional
postalCode
string  | null 
PostalCode
optional
>= 0 characters<= 15 characters
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 _customersImport, you can automate the import of customer data into the Shopranos platform, ensuring that the data is sent securely and that any issues are handled and reported appropriately.
Previous
_quantityImport
Next
_contactsImport
Built with