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

_ordersImport

Documentation: _ordersImport Function#

The _ordersImport function is designed to import a batch of order data into the Shopranos platform. It manages authentication, sends a POST request with the order 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 orders):
Description: An array of order objects to be sent in the POST request body. Each object should represent an order 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 order objects formatted according to the Shopranos API requirements.
OrderDTO
id
string  | null 
optional
code
string  | null 
optional
companyId
string  | null 
optional
checkoutToken
string  | null 
optional
cartToken
string  | null 
optional
status
enum<string> 
optional
Allowed values:
DraftPlacedCancelledProcessingToBeShippedShippedPartialDeliveryFailedToDeliverDeliveredRejectedCompletedAllignore
customerId
string  | null 
optional
customerTin
string  | null 
optional
customerName
string  | null 
optional
customerCode
string  | null 
optional
currency
enum<string> 
optional
Allowed values:
aedafnallamdangaoaarsaudawgaznbambbdbdtbgnbhdbifbmdbndbobbovbrlbsdbtnbwpbynbzdcadcdfchechfchwclfclpcnycopcoucrccuccupcveczkdjfdkkdopdzdegpernetbeurfjdfkpgbpgelghsgipgmdgnfgtqgydhkdhnlhrkhtghufidrilsinriqdirriskjmdjodjpykeskgskhrkmfkpwkrwkwdkydkztlaklbplkrlrdlsllydmadmdlmgamkdmmkmntmopmrumurmvrmwkmxnmxvmyrmznnadngnnionoknprnzdomrpabpenpgkphppkrplnpygqarronrsdrubrwfsarsbdscrsdgseksgdshpsllsossrdsspstnsvcsypszlthbtjstmttndtoptryttdtwdtzsuahugxusdusnuyiuyuuywuzsvesvndvuvwstxafxagxauxbaxbbxbcxbdxcdxdrxofxpdxpfxptxsuxtsxuaxxxyerzarzmwzwlignore
discountRate
number <double>
optional
discountValue
number <double>
optional
totalAmount
number <double>
optional
netAmount
number <double>
optional
vatAmount
number <double>
optional
expenseAmount
number <double> | null 
optional
financialStatus
enum<string> 
optional
Allowed values:
PendingAuthorizedPartiallyPaidPartiallyRefundedRefundedVoided
fulfillmentStatus
enum<string> 
optional
Allowed values:
FulfilledNullPartialRestocked
billingAddress
object (AddressDTO) 
optional
address1
string  | null 
optional
>= 0 characters<= 100 characters
address2
string  | null 
optional
>= 0 characters<= 100 characters
firstName
string  | null 
optional
>= 0 characters<= 100 characters
lastName
string  | null 
optional
>= 0 characters<= 100 characters
city
string  | null 
optional
>= 0 characters<= 60 characters
state
string  | null 
optional
>= 0 characters<= 50 characters
country
string  | null 
optional
>= 0 characters<= 55 characters
countryCode
string  | null 
optional
postalCode
string  | null 
optional
>= 0 characters<= 15 characters
phoneNumber
string  | null 
optional
>= 0 characters<= 100 characters
email
string <email> | null 
optional
>= 0 characters<= 55 characters
shippingAddress
object (AddressDTO) 
optional
requiresCalculation
boolean  | null 
optional
lines
array[object (OrderLineDTO) {28}]  | null 
optional
id
string  | null 
optional
productId
string  | null 
optional
productVariantId
string  | null 
optional
productTitle
string  | null 
optional
unitId
string  | null 
optional
salesUnitId
string  | null 
optional
quantity
number <double> | null 
optional
unitQuantity
number <double>
optional
netValue
number <double>
optional
price
number <double>
optional
expenseValue
number <double> | null 
optional
priceValue1
number <double> | null 
optional
priceValue2
number <double> | null 
optional
priceValue3
number <double> | null 
optional
unitPrice
number <double>
optional
lineValue
number <double>
optional
discountValue
number <double>
optional
discountRate
number <double>
optional
vatValue
number <double>
optional
vatRate
number <double>
optional
vatCode
string  | null 
optional
sku
string  | null 
optional
dimension1Caption
string  | null 
optional
dimension2Caption
string  | null 
optional
dimension3Caption
string  | null 
optional
dimension1Value
string  | null 
optional
dimension2Value
string  | null 
optional
dimension3Value
string  | null 
optional
vatAnalysis
array[object (VatAnalysisDTO) {4}]  | null 
optional
vatRate
number <double> | null 
optional
vatAmount
number <double> | null 
optional
vatCode
string  | null 
optional
netAmount
number <double> | null 
optional
tags
array[string] | null 
optional
sourceId
string  | null 
optional
sourceTags
array[string] | null 
optional
notes
string  | null 
optional
updateDate
string <date-time> | null 
optional
insertDate
string <date-time> | null 
optional
favorite
boolean  | null 
optional
userId
string  | null 
optional
invoiceUrl
string  | null 
optional
notify
string  | null 
optional
notified
array[string] | null 
optional
customFields
array[object (OrderCustomFieldDTO) {3}]  | null 
optional
name
string  | null 
optional
value
null 
optional
translation
object (OrderCustomFieldTranslationDTO) 
optional
shippingLine
object (ShippingLineDTO) 
optional
carrierId
string  | null 
optional
carrierCode
string  | null 
optional
title
string  | null 
optional
type
enum<string> 
optional
Allowed values:
ManualAfterSalesProAcsGenikiTaxidromikiignore
netPrice
number <double> | null 
optional
totalAmount
number <double> | null 
optional
vatLines
array[object (ShippingVatDTO) {2}]  | null 
optional
giftLines
array[object (GiftLineDTO) {7}]  | null 
optional
productId
string  | null 
optional
productVariantId
string  | null 
optional
productTitle
string  | null 
optional
quantity
number <double> | null 
optional
vatCode
string  | null 
optional
imageLink
string  | null 
optional
productAlias
string  | null 
optional
expenseLines
array[object (ExpenseLineDTO) {3}]  | null 
optional
id
string  | null 
optional
netValue
number <double>
optional
vatValue
number <double>
optional
payment
object (OrderPaymentDTO) 
optional
id
string  | null 
optional
code
string  | null 
optional
provider
enum<string> 
optional
Allowed values:
OnePayEveryPayCreditPayPalDepositPayGateCardLinkEDPSJCCCODStripeKlarnaEpayNexiignore
status
enum<string> 
optional
Allowed values:
SubmittedCompletedPendingCancelledFailedErrorignore
cardType
enum<string> 
optional
Allowed values:
OtherVisaMastercardignore
paymentDate
string <date-time> | null 
optional
amount
number <double>
optional
approvalCode
string  | null 
optional
cardNumber
string  | null 
optional
postDating
integer <int32> | null 
optional
installments
integer <int32> | null 
optional
bankId
string  | null 
optional
transactionId
string  | null 
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 _ordersImport, you can automate the import of order data into the Shopranos platform, ensuring that the data is sent securely and that any issues are handled and reported appropriately.
Modified at 2024-08-23 10:39:52
Previous
_tasksImport
Next
_usersImport
Built with