Skip to content

Commit

Permalink
feat(ecom-config): first step of integration defining initial config
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgnreis authored Jan 30, 2024
1 parent 2771845 commit 18bf3db
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 56 deletions.
4 changes: 2 additions & 2 deletions ecomplus-market.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app": {
"title": "",
"short_description": "",
"title": "Horus Erp",
"short_description": "HORUS - Sistema integrado de gestão para o mercado editorial",
"category": "tools"
}
}
187 changes: 133 additions & 54 deletions functions/ecom.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

const app = {
app_id: 112106,
title: 'My Awesome E-Com Plus App',
slug: 'my-awesome-app',
title: 'Horus ERP',
slug: 'horus-erp',
type: 'external',
state: 'active',
authentication: true,
Expand Down Expand Up @@ -54,37 +54,37 @@ const app = {
'POST' // Create procedures to receive webhooks
],
products: [
// 'GET', // Read products with public and private fields
// 'POST', // Create products
// 'PATCH', // Edit products
'GET', // Read products with public and private fields
'POST', // Create products
'PATCH', // Edit products
// 'PUT', // Overwrite products
// 'DELETE', // Delete products
],
brands: [
// 'GET', // List/read brands with public and private fields
// 'POST', // Create brands
// 'PATCH', // Edit brands
'GET', // List/read brands with public and private fields
'POST', // Create brands
'PATCH', // Edit brands
// 'PUT', // Overwrite brands
// 'DELETE', // Delete brands
],
categories: [
// 'GET', // List/read categories with public and private fields
// 'POST', // Create categories
// 'PATCH', // Edit categories
'GET', // List/read categories with public and private fields
'POST', // Create categories
'PATCH', // Edit categories
// 'PUT', // Overwrite categories
// 'DELETE', // Delete categories
],
customers: [
// 'GET', // List/read customers
// 'POST', // Create customers
// 'PATCH', // Edit customers
'GET', // List/read customers
'POST', // Create customers
'PATCH', // Edit customers
// 'PUT', // Overwrite customers
// 'DELETE', // Delete customers
],
orders: [
// 'GET', // List/read orders with public and private fields
// 'POST', // Create orders
// 'PATCH', // Edit orders
'GET', // List/read orders with public and private fields
'POST', // Create orders
'PATCH', // Edit orders
// 'PUT', // Overwrite orders
// 'DELETE', // Delete orders
],
Expand All @@ -100,13 +100,13 @@ const app = {
* Prefer using 'fulfillments' and 'payment_history' subresources to manipulate update order status.
*/
'orders/fulfillments': [
// 'GET', // List/read order fulfillment and tracking events
// 'POST', // Create fulfillment event with new status
'GET', // List/read order fulfillment and tracking events
'POST', // Create fulfillment event with new status
// 'DELETE', // Delete fulfillment event
],
'orders/payments_history': [
// 'GET', // List/read order payments history events
// 'POST', // Create payments history entry with new status
'GET', // List/read order payments history events
'POST', // Create payments history entry with new status
// 'DELETE', // Delete payments history entry
],

Expand All @@ -116,19 +116,19 @@ const app = {
*/
'products/quantity': [
// 'GET', // Read product available quantity
// 'PUT', // Set product stock quantity
'PUT', // Set product stock quantity
],
'products/variations/quantity': [
// 'GET', // Read variaton available quantity
// 'PUT', // Set variation stock quantity
'PUT', // Set variation stock quantity
],
'products/price': [
// 'GET', // Read product current sale price
// 'PUT', // Set product sale price
'PUT', // Set product sale price
],
'products/variations/price': [
// 'GET', // Read variation current sale price
// 'PUT', // Set variation sale price
'PUT', // Set variation sale price
],

/**
Expand All @@ -140,35 +140,114 @@ const app = {
admin_settings: {
/**
* JSON schema based fields to be configured by merchant and saved to app `data` / `hidden_data`, such as:
webhook_uri: {
**/
base_url: {
schema: {
type: 'string',
maxLength: 255,
format: 'uri',
title: 'Notifications URI',
description: 'Unique notifications URI available on your Custom App dashboard'
title: 'Url base para endpoint de conexão (seu local)',
description: 'Solicite ao suporte do erp por base url'
},
hide: true
},
token: {
schema: {
type: 'string',
maxLength: 50,
title: 'App token'
},
hide: true
},
opt_in: {
schema: {
type: 'boolean',
default: false,
title: 'Some config option'
},
hide: false
},
*/
username: {
schema: {
type: 'string',
maxLength: 255,
title: 'Usuário',
description: 'Usuário para acesso a API'
}
},
password: {
schema: {
type: 'string',
maxLength: 255,
title: 'Senha',
description: 'Senha para acesso a API'
},
hide: true
},
new_orders: {
schema: {
type: 'boolean',
default: true,
title: 'Exportar novos pedidos',
description: 'Criar novos pedidos automaticamente'
}
},
approved_order_only: {
schema: {
type: 'boolean',
default: false,
title: 'Apenas pedidos aprovados',
description: 'Criar pedidos após aprovação'
}
},
update_quantity: {
schema: {
type: 'boolean',
defaut: false,
title: 'Atualização de estoque',
description: 'Atualizar estoque automaticamente na E-com'
},
hide: true
},
update_product: {
schema: {
type: 'boolean',
default: false,
title: 'Sobrescrever produto',
description: 'Atualizar cadastro (não apenas estoque) de produtos importados já existentes na plataforma'
},
hide: true
},
update_price: {
schema: {
type: 'boolean',
default: false,
title: 'Atualização de preço',
description: 'Atualizar preço automaticamente na E-com'
}
},
importation: {
schema: {
title: 'Importação manual',
description: 'Fila a importar do erp, serão removidos automaticamente após importação',
type: 'object',
properties: {
products: {
title: 'Produtos a importar',
type: 'array',
items: {
type: 'string',
title: 'ID do produto no erp',
description: 'ID do produto no erp que você deseja importar para a E-com'
}
}
}
},
hide: false
},
exportation: {
schema: {
title: 'Exportação manual',
description: 'Fila a exportar para o erp, serão removidos automaticamente após exportação',
type: 'object',
properties: {
orders: {
title: 'Pedidos a exportar',
type: 'array',
items: {
type: 'string',
pattern: '^[a-f0-9]{24}$',
title: 'ID do pedido'
}
}
}
},
hide: false
}
}
}

Expand All @@ -181,7 +260,7 @@ const procedures = []

/**
* Uncomment and edit code above to configure `triggers` and receive respective `webhooks`:
**/
const { baseUri } = require('./__env')

procedures.push({
Expand All @@ -206,26 +285,26 @@ procedures.push({
},

// Receive notifications when products/variations stock quantity changes:
{
/* {
resource: 'products',
field: 'quantity',
},
{
resource: 'products',
subresource: 'variations',
field: 'quantity'
},
}, */

// Receive notifications when cart is edited:
{
/* {
resource: 'carts',
action: 'change',
},
}, */

// Receive notifications when customer is deleted:
{
resource: 'customers',
action: 'delete',
action: 'create',
},

// Feel free to create custom combinations with any Store API resource, subresource, action and field.
Expand All @@ -242,7 +321,7 @@ procedures.push({
}
]
})
/*
* You may also edit `routes/ecom/webhook.js` to treat notifications properly.
*/

Expand Down

0 comments on commit 18bf3db

Please sign in to comment.