Commit inicial: fuentes MBS ERP (Genero 6) + .gitignore + docs/SETUP_PC_MBS.md
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
{
|
||||
name: "Akeneo 1.7/2.x/3.x PIM API environment",
|
||||
values: [
|
||||
{
|
||||
enabled: true,
|
||||
key: "url",
|
||||
value: "https://your-favorite-1.7-2x-or-3x-PIM.akeneo.com",
|
||||
type: "text"
|
||||
},
|
||||
{
|
||||
enabled: true,
|
||||
key: "clientId",
|
||||
value: "client_id",
|
||||
type: "text"
|
||||
},
|
||||
{
|
||||
enabled: true,
|
||||
key: "secret",
|
||||
value: "secret",
|
||||
type: "text"
|
||||
},
|
||||
{
|
||||
enabled: true,
|
||||
key: "username",
|
||||
value: "username",
|
||||
type: "text"
|
||||
},
|
||||
{
|
||||
enabled: true,
|
||||
key: "password",
|
||||
value: "password",
|
||||
type: "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
// 20201010100925
|
||||
// https://api.akeneo.com/files/akeneo-PIM-API-environment-old.postman_environment.json
|
||||
|
||||
{
|
||||
"name": "Akeneo 1.7/2.x/3.x PIM API environment",
|
||||
"values": [
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "url",
|
||||
"value": "https://your-favorite-1.7-2x-or-3x-PIM.akeneo.com",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "clientId",
|
||||
"value": "client_id",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "secret",
|
||||
"value": "secret",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "username",
|
||||
"value": "username",
|
||||
"type": "text"
|
||||
},
|
||||
{
|
||||
"enabled": true,
|
||||
"key": "password",
|
||||
"value": "password",
|
||||
"type": "text"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
IMPORT com
|
||||
IMPORT util
|
||||
IMPORT os
|
||||
IMPORT security
|
||||
|
||||
TYPE t_sync_cmd RECORD
|
||||
oper STRING,
|
||||
data STRING
|
||||
END RECORD
|
||||
|
||||
|
||||
DEFINE url STRING
|
||||
|
||||
MAIN
|
||||
CALL conector()
|
||||
END MAIN
|
||||
|
||||
FUNCTION conector()
|
||||
DEFINE ret INTEGER,
|
||||
res,dataresponse,respuesta STRING,
|
||||
data_response RECORD
|
||||
access_token
|
||||
,expires_in
|
||||
,token_type
|
||||
,scope
|
||||
,refresh_token
|
||||
STRING
|
||||
END RECORD
|
||||
|
||||
DEFINE data_c RECORD
|
||||
username
|
||||
,password
|
||||
,grant_type
|
||||
STRING
|
||||
END RECORD,
|
||||
metodo,cmd STRING
|
||||
LET url = "https://pim.marmotech.com.do/api/oauth/v1/token"
|
||||
|
||||
LET data_c.grant_type = 'password'
|
||||
LET data_c.username = "jsoto"
|
||||
LET data_c.password = "Marmotech1234"
|
||||
|
||||
LET metodo = "POST"
|
||||
LET cmd = util.JSON.stringify(data_c)
|
||||
DISPLAY " CMD ",cmd
|
||||
CALL sync_send_command(url,cmd, metodo) RETURNING ret,res,dataresponse
|
||||
CALL util.JSON.parse(dataresponse,data_response)
|
||||
DISPLAY "json: ",data_response.access_token," - ",data_response.expires_in," - ",data_response.refresh_token," - ",
|
||||
data_response.scope," - ",data_response.token_type
|
||||
|
||||
DISPLAY "RESPONSE ",ret,"--- ",res,"---",dataresponse
|
||||
LET metodo = 'GET'
|
||||
LET url = "https://pim.marmotech.com.do"
|
||||
|
||||
#CALL send_data(url,data_response.access_token,metodo) RETURNING ret,res,respuesta
|
||||
DISPLAY "categorias ",ret ,"-",res ,"-",respuesta
|
||||
END FUNCTION
|
||||
FUNCTION send_data(xurl,xcmd,xmetodo1)
|
||||
DEFINE xret,xres,xrespuesta,xurl,xcmd,xmetodo1 STRING,
|
||||
http_re com.HTTPRequest,
|
||||
http_response com.HttpResponse
|
||||
DEFINE datahost RECORD
|
||||
host STRING
|
||||
|
||||
,authentication RECORD
|
||||
fos_oauth_server_token
|
||||
,route
|
||||
STRING
|
||||
END RECORD
|
||||
END RECORD,
|
||||
s string
|
||||
DEFINE categorias RECORD
|
||||
ref RECORD
|
||||
links
|
||||
,self
|
||||
,href STRING
|
||||
END RECORD,
|
||||
ref1 RECORD
|
||||
primero
|
||||
,href STRING
|
||||
END RECORD,
|
||||
ref2 RECORD
|
||||
anterior
|
||||
,href STRING
|
||||
END RECORD ,
|
||||
ref3 RECORD
|
||||
siguiente
|
||||
,href STRING
|
||||
END RECORD,
|
||||
ref4 RECORD
|
||||
pagina
|
||||
,almacenado STRING
|
||||
END RECORD,
|
||||
items DYNAMIC ARRAY OF RECORD
|
||||
link RECORD
|
||||
self
|
||||
,href STRING
|
||||
END RECORD,
|
||||
code
|
||||
,parent STRING
|
||||
END RECORD,
|
||||
labels DYNAMIC ARRAY OF RECORD
|
||||
en_US
|
||||
,fr_fr
|
||||
,de_DE STRING
|
||||
END RECORD
|
||||
END RECORD
|
||||
LET xcmd = 'Bearer ',xcmd
|
||||
DISPLAY "URL ",xurl
|
||||
LET datahost.host = xurl
|
||||
LET datahost.authentication.fos_oauth_server_token =xcmd
|
||||
LET datahost.authentication.route = '/api/oauth/v1/token'
|
||||
LET s = util.JSON.stringify(datahost)
|
||||
LET xurl = xurl CLIPPED,'/api/rest/v1/categories'
|
||||
TRY
|
||||
LET http_re = com.HttpRequest.Create(xurl)
|
||||
CALL http_re.setMethod(xmetodo1)
|
||||
CALL http_re.setHeader("Authorization",xcmd)
|
||||
CALL http_re.setHeader("Accept",'*/*')
|
||||
CALL http_re.doRequest()
|
||||
DISPLAY "ESTADO ", http_response.getStatusCode()
|
||||
IF http_response.getStatusCode() != 200 THEN
|
||||
|
||||
RETURN http_response.getStatusCode(), http_response.getStatusDescription(),http_response.getTextResponse()
|
||||
END IF
|
||||
|
||||
LET xrespuesta = http_response.getTextResponse()
|
||||
CATCH
|
||||
RETURN -2, SFMT("HTTP request error: STATUS=%1 (%2)",STATUS,SQLCA.SQLERRM),'ERROR'
|
||||
END TRY
|
||||
|
||||
RETURN http_response.getStatusCode(), http_response.getStatusDescription(),http_response.getTextResponse()
|
||||
END FUNCTION
|
||||
FUNCTION sync_send_command(url, cmd, xmetodo)
|
||||
|
||||
DEFINE xmetodo,url, cmd,client_id,secret,b64 STRING
|
||||
DEFINE result, tmp STRING
|
||||
DEFINE http_req com.HTTPRequest
|
||||
DEFINE http_resp com.HTTPResponse
|
||||
|
||||
|
||||
LET client_id = "6_5yt79vgp374s0gsgsggg848kwooscowwkc8ok0kog8okg8c0oc",":","yljqzqi1r808o8wog8kksok80ogwocg88w8sksk0wokgswc0c"
|
||||
LET b64 = security.Base64.FromString(client_id)
|
||||
LET b64 = 'Basic ',b64
|
||||
|
||||
TRY
|
||||
|
||||
LET http_req = com.HTTPRequest.Create(url)
|
||||
|
||||
#CALL http_req.setConnectionTimeout(40)
|
||||
#CALL http_req.setTimeout(40)
|
||||
CALL http_req.setMethod(xmetodo)
|
||||
CALL http_req.setCharset("UTF-8")
|
||||
CALL http_req.setHeader("clientId","6_5yt79vgp374s0gsgsggg848kwooscowwkc8ok0kog8okg8c0oc")
|
||||
CALL http_req.setHeader("secret","yljqzqi1r808o8wog8kksok80ogwocg88w8sksk0wokgswc0c")
|
||||
|
||||
CALL http_req.setHeader("Content-Type","application/json")
|
||||
|
||||
CALL http_req.setHeader("Authorization",b64)
|
||||
|
||||
CALL http_req.doTextRequest(cmd)
|
||||
LET http_resp=http_req.getResponse()
|
||||
IF http_resp.getStatusCode() != 200 THEN
|
||||
|
||||
RETURN http_resp.getStatusCode(), http_resp.getStatusDescription(),http_resp.getTextResponse()
|
||||
END IF
|
||||
LET tmp = http_resp.getStatusDescription()
|
||||
IF (tmp == "OK" || tmp == "no error" ) THEN
|
||||
|
||||
RETURN -1, SFMT("HTTP request status description: %1 ",tmp),http_resp.getTextResponse()
|
||||
END IF
|
||||
LET result = http_resp.getTextResponse()
|
||||
CATCH
|
||||
RETURN -2, SFMT("HTTP request error: STATUS=%1 (%2)",STATUS,SQLCA.SQLERRM)
|
||||
END TRY
|
||||
|
||||
RETURN http_resp.getStatusCode(), http_resp.getHeaderName(7), result
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION show_sync_err(msg)
|
||||
DEFINE msg STRING
|
||||
CALL fgl_winmessage(%"ERROR", msg, "exclamation")
|
||||
END FUNCTION
|
||||
@@ -0,0 +1,115 @@
|
||||
// 20201010101312
|
||||
// https://api.akeneo.com/files/your-very-first-collection.postman_collection.json
|
||||
|
||||
{
|
||||
"info": {
|
||||
"name": "Your very first collection",
|
||||
"description": "This is the collection for the very first tutorial to learn how to use the Akeneo PIM API.",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "Your very first request",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Bearer {{token}}"
|
||||
},
|
||||
{
|
||||
"key": "Cookie",
|
||||
"value": ""
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{url}}/api/rest/v1/products",
|
||||
"host": [
|
||||
"{{url}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"rest",
|
||||
"v1",
|
||||
"products"
|
||||
]
|
||||
},
|
||||
"description": "This API request asks the PIM for its 100 first products."
|
||||
},
|
||||
"response": [
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "The authentication request",
|
||||
"event": [
|
||||
{
|
||||
"listen": "prerequest",
|
||||
"script": {
|
||||
"id": "a121ed64-a205-496a-a182-c5cf3b4bb9b9",
|
||||
"exec": [
|
||||
"postman.setEnvironmentVariable(",
|
||||
" \"base64ClientIdSecret\", ",
|
||||
" btoa(postman.getEnvironmentVariable(\"clientId\") + ':' + postman.getEnvironmentVariable(\"secret\"))",
|
||||
");",
|
||||
""
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
},
|
||||
{
|
||||
"listen": "test",
|
||||
"script": {
|
||||
"id": "a44f4b34-52f5-4b3a-b57e-ea3a5cabd14c",
|
||||
"exec": [
|
||||
"var jsonData = JSON.parse(responseBody);",
|
||||
"postman.setEnvironmentVariable(\"token\", jsonData.access_token);",
|
||||
"postman.setEnvironmentVariable(\"refreshToken\", jsonData.refresh_token);"
|
||||
],
|
||||
"type": "text/javascript"
|
||||
}
|
||||
}
|
||||
],
|
||||
"request": {
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"key": "Authorization",
|
||||
"value": "Basic {{base64ClientIdSecret}}"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\n \"username\" : \"{{username}}\",\n \"password\" : \"{{password}}\",\n \"grant_type\": \"password\"\n }"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{url}}/api/oauth/v1/token",
|
||||
"host": [
|
||||
"{{url}}"
|
||||
],
|
||||
"path": [
|
||||
"api",
|
||||
"oauth",
|
||||
"v1",
|
||||
"token"
|
||||
]
|
||||
},
|
||||
"description": "It allows you to authenticate yourself thanks to the credentials you provided in the Postman environment you set up before."
|
||||
},
|
||||
"response": [
|
||||
|
||||
]
|
||||
}
|
||||
],
|
||||
"protocolProfileBehavior": {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user