Neste artigo, iremos explicar os ajustes que precisam ser feitos na request quando não é possível converter o elemento "actions" em coleção, na API V3.
Exemplo:
curl --location 'https://apiv3.ideris.com.br/order' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJDdXN0b21lcklkIjoiMjExODAiLCJNYXN0ZXJVc2VySWQiOiI0MTY5NSIsIlByaXZhdGVLZXlJZCI6IjEyMyIsIkxvY2FsVXNlcklkIjoiMyIsIkFwcGxpY2F0aW9uSWQiOiIzOCIsIm5iZiI6MTY4MjU5MTcxNSwiZXhwIjoxNjgyNjIwNTE1LCJpYXQiOjE2ODI1OTE3MTV9.jKqwZuj57VwHwHrkISQwHppFPEOi_8t2aG91xC8S718' \
--header 'Content-Type: application/json' \
--header 'Cookie: AWSALB=TY0QPs8kCDO19hRWC9lNvdYcVP5aVF4PzuiS4udzdZXCp0wmGnvr8DVoAXsi1r71+iTHRsjMSiBGy3u0K1BXPjPOGnLpw40yFBZX3qAHLbJTKO7qPvyJlZ1Xn4DC; AWSALBCORS=TY0QPs8kCDO19hRWC9lNvdYcVP5aVF4PzuiS4udzdZXCp0wmGnvr8DVoAXsi1r71+iTHRsjMSiBGy3u0K1BXPjPOGnLpw40yFBZX3qAHLbJTKO7qPvyJlZ1Xn4DC' \
--data-raw '{
"document" :
{
"type" : "cpf","value" : "00000000000"
},
"phone" :
{
"areaCode" : "99", "number" : "999999999","extension" : null,"verified" : null
},
"phoneAlternative" :
{
"areaCode" : "", "number" : "", "extension" : null, "verified" : null
},
"customer" :
{
"firstName" : "Cliente Ambiente", "lastName" : "Teste", "nickname" : "Cliente Ambiente", "email" : "cliente@email.com", "code" : "999999"
},
"deliveryOptions" :
{
"name" : "Transportadora - Transportadora", "cost" : 0, "listCost" : 0, "estimatedDeliveryTime" : "2023-03-20", "estimatedScheduleTime" : null, "estimatedHandlingTime" : null,
"estimatedDeliveryExtended" : null, "estimatedDeliveryLimit" : null, "estimatedDeliveryFinal" : null
},
"country" :
{
"name" : "Brasil", "abbreviation" : "BR"
},
"state" :
{
"name" : "SC", "abbreviation" : "SC"
},
"city" :
{
"name" : "Florianópolis", "abbreviation" : "Florianópolis"
},
"district" :
{
"name" : "Centro", "abbreviation" : "Centro"
},
"address" : {
"street" : "Rua Test", "number" : "100", "zipCode" : "88888888", "receiverName" : "Cliente Ambiente Teste", "receiverPhone" : "99999999999", "comment" : "Apto 123456"
},
"delivery" :
{
"created" : null, "firstPrinted" : null, "shipmentType" : "Transportadora", "cost" : 0, "mode" : "Transportadora", "shipmentMode" : null, "siteId" : null, "code" : null, "statusDescription" : null,
"trackingCode" : null, "trackingMethod" : null, "subStatusDescription" : null
},
"statusId" : 1010, "orderId" : xxxxxxxx,
"order" :
{
"authenticationId" : xxxxxxxxx, "sendCorreio" : null, "expedition" : null, "picking" : null, "closed" : null, "created" : null, "expiration" : null, "delivery" : null, "lastUpdated" : null, "paidAmount" : 0, "totalAmount" : 90,
"totalAmountWithShipping" : 90, "paymentType" : "credit", "notification" : 0, "origin" : "conectala", "statusId" : 1010, "statusDescription" : "aprovado", "statusDetail" : "aprovado", "code" : "517003850", "packId" : null, "intermediaryName" : "Empresa BLA BLA BLA", "intermediaryCnpj" : "0000000000099"
},
"values" :
{
"transportCustomer" : 0, "transportSeller" : 0, "transportMarketplace" : 0, "discount" : 0, "fee" : 0, "payment" : 0, "marketplaceValue" : 0
},
"actions" :
{
"action": "", "value": ""
},
"payments" :
{
"approved" : "2023-04-26", "created" : "2023-04-26T12:45:52.659Z", "lastModified" : "2023-04-26T12:45:52.659Z", "couponAmount" : null, "installmentAmount" : 90, "overpaidAmount" : null,
"shippingCost" : 0, "totalPaidAmount" : 90, "transactionAmount" : null, "activationUri" : null, "authorizationCode" : null, "cardId" : null, "code" : null, "couponId" : null, "deferredPeriod" : null,
"installments" : null, "issuerId" : null, "operationType" : null, "orderCode" : 517003850, "payerId" : null, "methodId" : null, "type" : null, "siteId" : null, "status" : null, "statusCode" : null, "statusDetail" : null,
"transactionOrderId" : null
},
"items" : [
{
"item" :
{
"unitPrice" : 90, "quantity" : 1
},
"itemProduct" :
{
"categoryId" : null, "title" : "Teste da van", "sellerCustomField" : null, "variationId" : "", "condition" : null, "code" : "16", "permalink" : null, "type" : null, "image" : null, "freeShipping" : null
},
"itemProductAttributes" : []
}
]
}
Veja as regras a seguir:
- Seguindo a documentação (Swagger), "actions" espera uma coleção de elementos. então é necessário colocar os colchetes [] para dizer que vai receber coleção.
- actions, payments, items e itemProductAttributes esperam os colchetes porque podem possuir mais de um elemento.
- Dentro de payments alguns campos são decimal como couponAmount, overpaidAmount, transactionAmount ou seja valor igual ou maior que zero.
Veja a documentação:
Exemplo acima:
Caso ainda haja dúvidas quanto a este processo, não deixe de abrir um chat com nossa equipe de suporte, clicando no lado esquerdo do seu painel, na opção "Abrir Ticket."
Sua opinião é muito importante para nós! Clique aqui para avaliar o artigo que acabou de ler!
Até a próxima!