From 3f8b1f77d948b31a98688cfa742586a6001533e8 Mon Sep 17 00:00:00 2001 From: Kseniya Popova Date: Thu, 3 Oct 2024 15:05:14 +0200 Subject: [PATCH] EDU-2965: I300 collection updated, push notification examples from help added --- .../CommitEventEnricher.cs | 13 + .../TestInCodeDefinition.cs | 31 + .../SignalRHub/TestSignalR.cs | 60 + .../I300/OData.postman_collection.json | 1074 ++++++++--------- 4 files changed, 627 insertions(+), 551 deletions(-) create mode 100644 IntegrationDevelopment/Help/ConfiguringPushNotifications/AdditionalInformation/CommitEventEnricher.cs create mode 100644 IntegrationDevelopment/Help/ConfiguringPushNotifications/BuildInQueryDefinition/TestInCodeDefinition.cs create mode 100644 IntegrationDevelopment/Help/ConfiguringPushNotifications/SignalRHub/TestSignalR.cs diff --git a/IntegrationDevelopment/Help/ConfiguringPushNotifications/AdditionalInformation/CommitEventEnricher.cs b/IntegrationDevelopment/Help/ConfiguringPushNotifications/AdditionalInformation/CommitEventEnricher.cs new file mode 100644 index 00000000..7ee20ac1 --- /dev/null +++ b/IntegrationDevelopment/Help/ConfiguringPushNotifications/AdditionalInformation/CommitEventEnricher.cs @@ -0,0 +1,13 @@ +using PX.Common; +using PX.Data.PushNotifications; + +public class CommitEventEnricher : ICommitEventEnricher +{ + public void Enrich(IQueueEvent commitEvent) + { + var businessDate = PXContext.PXIdentity?.BusinessDate; + var userName = PXContext.PXIdentity?.IdentityName; + commitEvent.AdditionalInfo.Add(nameof(businessDate), businessDate); + commitEvent.AdditionalInfo.Add(nameof(userName), userName); + } +} diff --git a/IntegrationDevelopment/Help/ConfiguringPushNotifications/BuildInQueryDefinition/TestInCodeDefinition.cs b/IntegrationDevelopment/Help/ConfiguringPushNotifications/BuildInQueryDefinition/TestInCodeDefinition.cs new file mode 100644 index 00000000..5bccce45 --- /dev/null +++ b/IntegrationDevelopment/Help/ConfiguringPushNotifications/BuildInQueryDefinition/TestInCodeDefinition.cs @@ -0,0 +1,31 @@ +using PX.Data; +using PX.PushNotifications.UI.DAC; +using System; +using PX.Data.BQL.Fluent; +using PX.PushNotifications.Sources; + +public class TestInCodeDefinition : IInCodeNotificationDefinition +{ + public Tuple GetSourceSelect() + { + return + Tuple.Create( + SelectFrom. + LeftJoin. + On>.View + .GetCommand(), new PXDataValue[0]); + } + + public Type[] GetRestrictedFields() + { + return new[] + { + typeof(PushNotificationsHook.address), + typeof(PushNotificationsHook.type), + typeof(PushNotificationsSource.designID), + typeof(PushNotificationsSource.inCodeClass), + typeof(PushNotificationsSource.lineNbr) + }; + } +} diff --git a/IntegrationDevelopment/Help/ConfiguringPushNotifications/SignalRHub/TestSignalR.cs b/IntegrationDevelopment/Help/ConfiguringPushNotifications/SignalRHub/TestSignalR.cs new file mode 100644 index 00000000..334f3548 --- /dev/null +++ b/IntegrationDevelopment/Help/ConfiguringPushNotifications/SignalRHub/TestSignalR.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.AspNet.SignalR.Client; + +class Program +{ + static void Main(string[] args) + { + var login = "admin"; + var tenant = "Tenant"; + var password = "123"; + // Set up a Basic authentication token + var basicAuthToken = Convert.ToBase64String( + Encoding.UTF8.GetBytes(login + "@" + tenant + ":" + password)); + + //Connect to an Acumatica ERP instance + var connection = new HubConnection("http://localhost:8081/AcumaticaDB/"); + connection.Headers.Add("Authorization", "Basic " + basicAuthToken); + + //Create a proxy to hub + //Use "PushNotificationsHub" as the address of the hub + var myHub = connection.CreateHubProxy("PushNotificationsHub"); + connection.Start().ContinueWith(task => + { + if (task.IsFaulted) + { + Console.WriteLine( + "There was an error during open of the connection:{0}", + task.Exception.GetBaseException()); + } + else + { + //Instead of "TestSignalR", specify the name + //that you specified on the Push Notifications form + myHub.Invoke("Subscribe", "TestSignalR").Wait(); + } + }).Wait(); + + //Process the notifications + myHub.On("ReceiveNotification", nr => + { + Console.WriteLine("Inserted {0}", nr.Inserted.Length); + Console.WriteLine("Deleted {0}", nr.Deleted.Length); + }); + Console.Read(); + connection.Stop(); + } +} + +public class NotificationResult +{ + public object[] Inserted { get; set; } + public object[] Deleted { get; set; } + public string Query { get; set; } + public string CompanyId { get; set; } + public Guid Id { get; set; } + public long TimeStamp { get; set; } + public Dictionary AdditionalInfo { get; set; } +} diff --git a/IntegrationDevelopment/I300/OData.postman_collection.json b/IntegrationDevelopment/I300/OData.postman_collection.json index d28a47c4..50e44bb0 100644 --- a/IntegrationDevelopment/I300/OData.postman_collection.json +++ b/IntegrationDevelopment/I300/OData.postman_collection.json @@ -1,601 +1,573 @@ { "info": { - "_postman_id": "3a28c9ca-1c3f-4461-b050-56e4ef04afa3", + "_postman_id": "06a695b9-789e-42ef-953d-58bfdb4d66f1", "name": "MyBIIntegrationOData", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "1878971" }, "item": [ { - "name": "Part 1: Client Application Configuration", + "name": "Part 1: Working with Generic Inquiry-Based OData", "item": [ { - "name": "Lesson 1.1: Signing In to Acumatica ERP", - "item": [ + "name": "Activity 1.2.1: To Sign In to Acumatica ERP and Retrieve the Metadata", + "event": [ { - "name": "Example: Using Generic Inquiry-Based OData", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "pm.test(\".ASPXAUTH recieved\", function () {\r", - " pm.expect(pm.cookies.indexOf('.ASPXAUTH')).to.be.not.null;\r", - "});\r", - "pm.test(\".ASP.NET_SessionId recieved\", function () {\r", - " pm.expect(pm.cookies.indexOf('.ASP.NET_SessionId')).to.be.not.null;\r", - "});\r", - "pm.test(\"Response contains Modified Stock Items\", function () {\r", - " pm.expect(pm.response.text()).to.include(\"Modified Stock Items\");\r", - "});" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{EndpointURLGI}}/$metadata", - "host": [ - "{{EndpointURLGI}}" - ], - "path": [ - "$metadata" - ] - } - }, - "response": [] - }, - { - "name": "Example: Using DAC-Based OData", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "pm.test(\".ASPXAUTH recieved\", function () {\r", - " pm.expect(pm.cookies.indexOf('.ASPXAUTH')).to.be.not.null;\r", - "});\r", - "pm.test(\".ASP.NET_SessionId recieved\", function () {\r", - " pm.expect(pm.cookies.indexOf('.ASP.NET_SessionId')).to.be.not.null;\r", - "});\r", - "pm.test(\"Response contains Schema Namespace=\\\"PX.Api\\\"\", function () {\r", - " pm.expect(pm.response.text()).to.include(\"Schema Namespace=\\\"PX.Api\\\"\");\r", - "});" - ], - "type": "text/javascript", - "packages": {} - } - } + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "pm.test(\".ASPXAUTH recieved\", function () {\r", + " pm.expect(pm.cookies.indexOf('.ASPXAUTH')).to.be.not.null;\r", + "});\r", + "pm.test(\".ASP.NET_SessionId recieved\", function () {\r", + " pm.expect(pm.cookies.indexOf('.ASP.NET_SessionId')).to.be.not.null;\r", + "});\r", + "pm.test(\"Response contains Modified Stock Items\", function () {\r", + " pm.expect(pm.response.text()).to.include(\"Modified Stock Items\");\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{EndpointURLGI}}/$metadata", + "host": [ + "{{EndpointURLGI}}" ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{EndpointURLDAC}}/$metadata", - "host": [ - "{{EndpointURLDAC}}" - ], - "path": [ - "$metadata" - ] - } - }, - "response": [] + "path": [ + "$metadata" + ] } - ] - } - ] - }, - { - "name": "Part 2: Initial Data Retrieval", - "item": [ + }, + "response": [] + }, { - "name": "Lesson 2.1: Retrieving the List of Customers with Contacts", - "item": [ + "name": "Activity 1.3.1: To Retrieve Data by Using a Custom Generic Inquiry", + "event": [ { - "name": "Example: Using a Custom Generic Inquiry (Generic Inquiry-Based OData)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "pm.test(\"Contacts exist\", function (){\r", - " const jsonResponse = pm.response.json();\r", - " pm.expect(jsonResponse.value).to.be.not.empty;\r", - "})" - ], - "type": "text/javascript", - "packages": {} - } - } + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "pm.test(\"Contacts exist\", function (){\r", + " const jsonResponse = pm.response.json();\r", + " pm.expect(jsonResponse.value).to.be.not.empty;\r", + "})" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{EndpointURLGI}}/Customer Contacts", + "host": [ + "{{EndpointURLGI}}" ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{EndpointURLGI}}/Customer%20Contacts", - "host": [ - "{{EndpointURLGI}}" - ], - "path": [ - "Customer%20Contacts" - ] - } - }, - "response": [] - }, + "path": [ + "Customer Contacts" + ] + } + }, + "response": [] + }, + { + "name": "Activity 1.3.2: To Retrieve Data by Using a Generic Inquiry with Parameters", + "event": [ { - "name": "Example: Using GET and the $expand and $select Parameters (DAC-Based OData)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "pm.test(\"Contacts exist\", function (){\r", - " const jsonResponse = pm.response.json();\r", - " pm.expect(jsonResponse.value).to.be.not.empty;\r", - "})" - ], - "type": "text/javascript", - "packages": {} - } - } + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "pm.test(\"One item is returned\", function (){\r", + " const jsonResponse = pm.response.json();\r", + " pm.expect(jsonResponse.value).to.have.lengthOf(1);\r", + "});\r", + "pm.test(\"Response contains AALEGO500\", function () {\r", + " pm.expect(pm.response.text()).to.include(\"AALEGO500\");\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{EndpointURLGI}}/ItemAvailabilityData_WithParameters(InventoryID='AALEGO500')", + "host": [ + "{{EndpointURLGI}}" ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{EndpointURLDAC}}/PX_Objects_AR_Customer?$select=AcctCD,AcctName,CustomerClassID&$expand=ContactByDefBillContactID($select=Email,Phone1),AddressByDefAddressID($select=AddressLine1,AddressLine2,City,State,PostalCode)", - "host": [ - "{{EndpointURLDAC}}" - ], - "path": [ - "PX_Objects_AR_Customer" - ], - "query": [ - { - "key": "$select", - "value": "AcctCD,AcctName,CustomerClassID" - }, - { - "key": "$expand", - "value": "ContactByDefBillContactID($select=Email,Phone1),AddressByDefAddressID($select=AddressLine1,AddressLine2,City,State,PostalCode)" - } - ] - } - }, - "response": [] + "path": [ + "ItemAvailabilityData_WithParameters(InventoryID='AALEGO500')" + ] } - ] + }, + "response": [] }, { - "name": "Lesson 2.2: Retrieving the Quantities of Stock Items", - "item": [ + "name": "Activity 1.4.1: To Filter the Result of a Generic Inquiry", + "event": [ { - "name": "Example: Using a Generic Inquiry with Parameters (Generic Inquiry-Based OData)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "pm.test(\"Some data is retrieved\", function (){\r", - " const jsonResponse = pm.response.json();\r", - " pm.expect(jsonResponse.value).to.be.not.empty;\r", - "})" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{EndpointURLGI}}/ItemAvailabilityData_WithParameters?InventoryID=AALEGO500", - "host": [ - "{{EndpointURLGI}}" - ], - "path": [ - "ItemAvailabilityData_WithParameters" - ], - "query": [ - { - "key": "InventoryID", - "value": "AALEGO500" - } - ] - } - }, - "response": [] + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "pm.test(\"Response contains AALEGO500\", function () {\r", + " pm.expect(pm.response.text()).to.include(\"AALEGO500\");\r", + "});\r", + "pm.test(\"Response does not contain AACOMPUT01\", function () {\r", + " pm.expect(pm.response.text()).to.not.include(\"AACOMPUT01\");\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } }, { - "name": "Example: Retrieving Quantities from Tables (DAC-Based OData)", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "pm.test(\"Some data is retrieved\", function (){\r", - " const jsonResponse = pm.response.json();\r", - " pm.expect(jsonResponse.value).to.be.not.empty;\r", - "})" - ], - "type": "text/javascript", - "packages": {} - } - } + "listen": "prerequest", + "script": { + "exec": [ + "//Set current date\r", + "var moment = require('moment');\r", + "pm.environment.set('currentDate', moment().format((\"YYYY-MM-DD\")));\r", + "\r", + "//Modify stock items\r", + "var requestSignIn = {\r", + " url: pm.variables.replaceIn('{{InstanceURL}}/entity/auth/login'),\r", + " method: 'POST',\r", + " body: {\r", + " mode: 'raw',\r", + " raw: pm.variables.replaceIn(\r", + " '{ \"name\": \"{{Username}}\", \"password\": \"{{Password}}\", \"tenant\": \"{{Tenant}}\", \"branch\": \"{{Branch}}\"}')\r", + " },\r", + " header: {\r", + " 'Content-Type': 'application/json'\r", + " }\r", + "};\r", + "\r", + "pm.sendRequest(requestSignIn, (error, response) => {\r", + " if (error) {\r", + " console.log(error);\r", + " }\r", + "\r", + " pm.test('Response for sing in should be 204 to process', () => {\r", + " pm.expect(error).to.equal(null);\r", + " pm.expect(response).to.have.property('code', 204);\r", + " pm.expect(response).to.have.property('status', 'No Content');\r", + " });\r", + "\r", + "var requestAACOMPUT01 = {\r", + " url: pm.variables.replaceIn('{{InstanceURL}}/entity/Default/23.200.001/StockItem?$select=InventoryID,ItemStatus'),\r", + " method: 'PUT',\r", + " body: {\r", + " mode: 'raw',\r", + " raw: '{\"InventoryID\": {\"value\": \"AACOMPUT01\"},\"ItemStatus\": {\"value\": \"Inactive\"}}'\r", + " },\r", + " header: {\r", + " 'Content-Type': 'application/json'\r", + " }\r", + "};\r", + "pm.sendRequest(requestAACOMPUT01, (error, response) => {\r", + " if (error) {\r", + " console.log(error);\r", + " }\r", + "\r", + " pm.test('Response for AACOMPUT01 should be OK to process', () => {\r", + " pm.expect(error).to.equal(null);\r", + " pm.expect(response).to.have.property('code', 200);\r", + " pm.expect(response).to.have.property('status', 'OK');\r", + " });\r", + "\r", + "var requestAALEGO500 = {\r", + " url: pm.variables.replaceIn('{{InstanceURL}}/entity/Default/24.200.001/StockItem?$select=InventoryID,Description'),\r", + " method: 'PUT',\r", + " body: {\r", + " mode: 'raw',\r", + " raw: '{\"InventoryID\": {\"value\": \"AALEGO500\"},\"Description\": {\"value\": \"Lego, 500 piece set\"}}'\r", + " },\r", + " header: {\r", + " 'Content-Type': 'application/json'\r", + " }\r", + "};\r", + "pm.sendRequest(requestAALEGO500, (error, response) => {\r", + " if (error) {\r", + " console.log(error);\r", + " }\r", + "\r", + " pm.test('Response for AALEGO500 should be OK to process', () => {\r", + " pm.expect(error).to.equal(null);\r", + " pm.expect(response).to.have.property('code', 200);\r", + " pm.expect(response).to.have.property('status', 'OK');\r", + " });\r", + "\r", + "var requestSignOut = {\r", + " url: pm.variables.replaceIn('{{InstanceURL}}/entity/auth/logout'),\r", + " method: 'POST',\r", + " header: {\r", + " 'Content-Type': 'application/json'\r", + " }\r", + "};\r", + "\r", + "pm.sendRequest(requestSignOut, (error, response) => {\r", + " if (error) {\r", + " console.log(error);\r", + " }\r", + "\r", + " pm.test('Response for sing out should be 204 to process', () => {\r", + " pm.expect(error).to.equal(null);\r", + " pm.expect(response).to.have.property('code', 204);\r", + " pm.expect(response).to.have.property('status', 'No Content');\r", + " });\r", + "});\r", + "\r", + "});\r", + "\r", + "});\r", + "\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{EndpointURLGI}}/Modified Stock Items?$filter=ItemStatus eq 'Active' and LastModifiedOn gt {{currentDate}}", + "host": [ + "{{EndpointURLGI}}" + ], + "path": [ + "Modified Stock Items" ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{EndpointURLDAC}}/PX_Objects_IN_INSiteStatus?$select=QtyOnHand,QtyAvail&$expand=InventoryItemByInventoryID($select=InventoryCD,Descr),INSiteBySiteID($select=SiteCD)&$filter=InventoryID eq 41", - "host": [ - "{{EndpointURLDAC}}" - ], - "path": [ - "PX_Objects_IN_INSiteStatus" - ], - "query": [ - { - "key": "$select", - "value": "QtyOnHand,QtyAvail" - }, - { - "key": "$expand", - "value": "InventoryItemByInventoryID($select=InventoryCD,Descr),INSiteBySiteID($select=SiteCD)" - }, - { - "key": "$filter", - "value": "InventoryID eq 41" - } - ] + "query": [ + { + "key": "$filter", + "value": "ItemStatus eq 'Active' and LastModifiedOn gt {{currentDate}}" } - }, - "response": [] + ] } - ] + }, + "response": [] } ] }, { - "name": "Part 3: Retrieval of the Delta of Records", + "name": "Part 2: Working with DAC-Based OData", "item": [ { - "name": "Lesson 3.1: Retrieving the List of Modified Stock Items", - "item": [ + "name": "Activity 2.1.1: To Sign In to Acumatica ERP and Retrieve the Metadata", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "pm.test(\".ASPXAUTH recieved\", function () {\r", + " pm.expect(pm.cookies.indexOf('.ASPXAUTH')).to.be.not.null;\r", + "});\r", + "pm.test(\".ASP.NET_SessionId recieved\", function () {\r", + " pm.expect(pm.cookies.indexOf('.ASP.NET_SessionId')).to.be.not.null;\r", + "});\r", + "pm.test(\"Response contains Schema Namespace=\\\"PX.Api\\\"\", function () {\r", + " pm.expect(pm.response.text()).to.include(\"Schema Namespace=\\\"PX.Api\\\"\");\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{EndpointURLDAC}}/$metadata", + "host": [ + "{{EndpointURLDAC}}" + ], + "path": [ + "$metadata" + ] + } + }, + "response": [] + }, + { + "name": "Activity 2.2.1: To Retrieve Data by Using the $expand and $select Parameters", + "event": [ { - "name": "Example: Filtering the Result of a Generic Inquiry (Generic Inquiry-Based OData) | Retrieving the List of Modified Stock Items", - "event": [ + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "pm.test(\"Contacts exist\", function (){\r", + " const jsonResponse = pm.response.json();\r", + " pm.expect(jsonResponse.value).to.be.not.empty;\r", + "})" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{EndpointURLDAC}}/PX_Objects_AR_Customer?$select=AcctCD,AcctName,CustomerClassID&$expand=ContactByDefBillContactID($select=Email,Phone1),AddressByDefAddressID($select=AddressLine1,AddressLine2,City,State,PostalCode)", + "host": [ + "{{EndpointURLDAC}}" + ], + "path": [ + "PX_Objects_AR_Customer" + ], + "query": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "pm.test(\"Response contains AALEGO500\", function () {\r", - " pm.expect(pm.response.text()).to.include(\"AALEGO500\");\r", - "});\r", - "pm.test(\"Response does not contain AACOMPUT01\", function () {\r", - " pm.expect(pm.response.text()).to.not.include(\"AACOMPUT01\");\r", - "});" - ], - "type": "text/javascript", - "packages": {} - } + "key": "$select", + "value": "AcctCD,AcctName,CustomerClassID" }, { - "listen": "prerequest", - "script": { - "exec": [ - "//Set current date\r", - "var moment = require('moment');\r", - "pm.environment.set('currentDate', moment().format((\"YYYY-MM-DD\")));\r", - "\r", - "//Modify stock items\r", - "var requestSignIn = {\r", - " url: pm.variables.replaceIn('{{InstanceURL}}/entity/auth/login'),\r", - " method: 'POST',\r", - " body: {\r", - " mode: 'raw',\r", - " raw: pm.variables.replaceIn(\r", - " '{ \"name\": \"{{Username}}\", \"password\": \"{{Password}}\", \"tenant\": \"{{Tenant}}\", \"branch\": \"{{Branch}}\"}')\r", - " },\r", - " header: {\r", - " 'Content-Type': 'application/json'\r", - " }\r", - "};\r", - "\r", - "pm.sendRequest(requestSignIn, (error, response) => {\r", - " if (error) {\r", - " console.log(error);\r", - " }\r", - "\r", - " pm.test('Response for sing in should be 204 to process', () => {\r", - " pm.expect(error).to.equal(null);\r", - " pm.expect(response).to.have.property('code', 204);\r", - " pm.expect(response).to.have.property('status', 'No Content');\r", - " });\r", - "\r", - "var requestAACOMPUT01 = {\r", - " url: pm.variables.replaceIn('{{InstanceURL}}/entity/Default/23.200.001/StockItem?$select=InventoryID,ItemStatus'),\r", - " method: 'PUT',\r", - " body: {\r", - " mode: 'raw',\r", - " raw: '{\"InventoryID\": {\"value\": \"AACOMPUT01\"},\"ItemStatus\": {\"value\": \"Inactive\"}}'\r", - " },\r", - " header: {\r", - " 'Content-Type': 'application/json'\r", - " }\r", - "};\r", - "pm.sendRequest(requestAACOMPUT01, (error, response) => {\r", - " if (error) {\r", - " console.log(error);\r", - " }\r", - "\r", - " pm.test('Response for AACOMPUT01 should be OK to process', () => {\r", - " pm.expect(error).to.equal(null);\r", - " pm.expect(response).to.have.property('code', 200);\r", - " pm.expect(response).to.have.property('status', 'OK');\r", - " });\r", - "\r", - "var requestAALEGO500 = {\r", - " url: pm.variables.replaceIn('{{InstanceURL}}/entity/Default/23.200.001/StockItem?$select=InventoryID,Description'),\r", - " method: 'PUT',\r", - " body: {\r", - " mode: 'raw',\r", - " raw: '{\"InventoryID\": {\"value\": \"AALEGO500\"},\"Description\": {\"value\": \"Lego, 500 piece set\"}}'\r", - " },\r", - " header: {\r", - " 'Content-Type': 'application/json'\r", - " }\r", - "};\r", - "pm.sendRequest(requestAALEGO500, (error, response) => {\r", - " if (error) {\r", - " console.log(error);\r", - " }\r", - "\r", - " pm.test('Response for AALEGO500 should be OK to process', () => {\r", - " pm.expect(error).to.equal(null);\r", - " pm.expect(response).to.have.property('code', 200);\r", - " pm.expect(response).to.have.property('status', 'OK');\r", - " });\r", - "\r", - "var requestSignOut = {\r", - " url: pm.variables.replaceIn('{{InstanceURL}}/entity/auth/logout'),\r", - " method: 'POST',\r", - " header: {\r", - " 'Content-Type': 'application/json'\r", - " }\r", - "};\r", - "\r", - "pm.sendRequest(requestSignOut, (error, response) => {\r", - " if (error) {\r", - " console.log(error);\r", - " }\r", - "\r", - " pm.test('Response for sing out should be 204 to process', () => {\r", - " pm.expect(error).to.equal(null);\r", - " pm.expect(response).to.have.property('code', 204);\r", - " pm.expect(response).to.have.property('status', 'No Content');\r", - " });\r", - "});\r", - "\r", - "});\r", - "\r", - "});\r", - "\r", - "});" - ], - "type": "text/javascript", - "packages": {} - } + "key": "$expand", + "value": "ContactByDefBillContactID($select=Email,Phone1),AddressByDefAddressID($select=AddressLine1,AddressLine2,City,State,PostalCode)" } + ] + } + }, + "response": [] + }, + { + "name": "Activity 2.2.2: To Retrieve Data by Using the $expand, $select, and $filter Parameters", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "pm.test(\"Contacts exist\", function (){\r", + " const jsonResponse = pm.response.json();\r", + " pm.expect(jsonResponse.value).to.be.not.empty;\r", + "})" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{EndpointURLDAC}}/PX_Objects_IN_INSiteStatus?$select=QtyOnHand,QtyAvail&$expand=InventoryItemByInventoryID($select=InventoryCD,Descr),INSiteBySiteID($select=SiteCD)&$filter=InventoryID eq 41", + "host": [ + "{{EndpointURLDAC}}" ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{EndpointURLGI}}/Modified%20Stock%20Items?$filter=ItemStatus eq 'Active' and LastModifiedOn gt {{currentDate}}", - "host": [ - "{{EndpointURLGI}}" - ], - "path": [ - "Modified%20Stock%20Items" - ], - "query": [ - { - "key": "$filter", - "value": "ItemStatus eq 'Active' and LastModifiedOn gt {{currentDate}}" - } - ] + "path": [ + "PX_Objects_IN_INSiteStatus" + ], + "query": [ + { + "key": "$select", + "value": "QtyOnHand,QtyAvail" + }, + { + "key": "$expand", + "value": "InventoryItemByInventoryID($select=InventoryCD,Descr),INSiteBySiteID($select=SiteCD)" + }, + { + "key": "$filter", + "value": "InventoryID eq 41" } - }, - "response": [] + ] + } + }, + "response": [] + }, + { + "name": "Activity 2.3.1: To Filter the Requested Data", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "pm.test(\"Response contains AALEGO500\", function () {\r", + " pm.expect(pm.response.text()).to.include(\"AALEGO500\");\r", + "});\r", + "pm.test(\"Response does not contain AACOMPUT01\", function () {\r", + " pm.expect(pm.response.text()).to.not.include(\"AACOMPUT01\");\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } }, { - "name": "Example: Filtering the Requested Data (DAC-Based OData)", - "event": [ + "listen": "prerequest", + "script": { + "exec": [ + "//Set current date\r", + "var moment = require('moment');\r", + "pm.environment.set('currentDate', moment().format((\"YYYY-MM-DD\")));\r", + "\r", + "//Modify stock items\r", + "var requestSignIn = {\r", + " url: pm.variables.replaceIn('{{InstanceURL}}/entity/auth/login'),\r", + " method: 'POST',\r", + " body: {\r", + " mode: 'raw',\r", + " raw: pm.variables.replaceIn(\r", + " '{ \"name\": \"{{Username}}\", \"password\": \"{{Password}}\", \"tenant\": \"{{Tenant}}\", \"branch\": \"{{Branch}}\"}')\r", + " },\r", + " header: {\r", + " 'Content-Type': 'application/json'\r", + " }\r", + "};\r", + "\r", + "pm.sendRequest(requestSignIn, (error, response) => {\r", + " if (error) {\r", + " console.log(error);\r", + " }\r", + "\r", + " pm.test('Response for sing in should be 204 to process', () => {\r", + " pm.expect(error).to.equal(null);\r", + " pm.expect(response).to.have.property('code', 204);\r", + " pm.expect(response).to.have.property('status', 'No Content');\r", + " });\r", + "\r", + "var requestAACOMPUT01 = {\r", + " url: pm.variables.replaceIn('{{InstanceURL}}/entity/Default/24.200.001/StockItem?$select=InventoryID,ItemStatus'),\r", + " method: 'PUT',\r", + " body: {\r", + " mode: 'raw',\r", + " raw: '{\"InventoryID\": {\"value\": \"AACOMPUT01\"},\"ItemStatus\": {\"value\": \"Inactive\"}}'\r", + " },\r", + " header: {\r", + " 'Content-Type': 'application/json'\r", + " }\r", + "};\r", + "pm.sendRequest(requestAACOMPUT01, (error, response) => {\r", + " if (error) {\r", + " console.log(error);\r", + " }\r", + "\r", + " pm.test('Response for AACOMPUT01 should be OK to process', () => {\r", + " pm.expect(error).to.equal(null);\r", + " pm.expect(response).to.have.property('code', 200);\r", + " pm.expect(response).to.have.property('status', 'OK');\r", + " });\r", + "\r", + "var requestAALEGO500 = {\r", + " url: pm.variables.replaceIn('{{InstanceURL}}/entity/Default/24.200.001/StockItem?$select=InventoryID,Description'),\r", + " method: 'PUT',\r", + " body: {\r", + " mode: 'raw',\r", + " raw: '{\"InventoryID\": {\"value\": \"AALEGO500\"},\"Description\": {\"value\": \"Lego, 500 piece set.\"}}'\r", + " },\r", + " header: {\r", + " 'Content-Type': 'application/json'\r", + " }\r", + "};\r", + "pm.sendRequest(requestAALEGO500, (error, response) => {\r", + " if (error) {\r", + " console.log(error);\r", + " }\r", + "\r", + " pm.test('Response for AALEGO500 should be OK to process', () => {\r", + " pm.expect(error).to.equal(null);\r", + " pm.expect(response).to.have.property('code', 200);\r", + " pm.expect(response).to.have.property('status', 'OK');\r", + " });\r", + "\r", + "var requestSignOut = {\r", + " url: pm.variables.replaceIn('{{InstanceURL}}/entity/auth/logout'),\r", + " method: 'POST',\r", + " header: {\r", + " 'Content-Type': 'application/json'\r", + " }\r", + "};\r", + "\r", + "pm.sendRequest(requestSignOut, (error, response) => {\r", + " if (error) {\r", + " console.log(error);\r", + " }\r", + "\r", + " pm.test('Response for sing out should be 204 to process', () => {\r", + " pm.expect(error).to.equal(null);\r", + " pm.expect(response).to.have.property('code', 204);\r", + " pm.expect(response).to.have.property('status', 'No Content');\r", + " });\r", + "});\r", + "\r", + "});\r", + "\r", + "});\r", + "\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{EndpointURLDAC}}/PX_Objects_IN_InventoryItem?$select=InventoryCD,Descr,ItemStatus,LastModifiedDateTime,BaseUnit&$expand=INSiteByDfltSiteID($select=SiteCD),INItemClassByItemClassID($select=ItemClassCD),INSiteStatusCollection($select=QtyOnHand)&$filter=StkItem eq true and ItemStatus eq 'AC' and LastModifiedDateTime eq {{currentDate}}", + "host": [ + "{{EndpointURLDAC}}" + ], + "path": [ + "PX_Objects_IN_InventoryItem" + ], + "query": [ { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200\", function () {\r", - " pm.response.to.have.status(200);\r", - "});\r", - "pm.test(\"Response contains AALEGO500\", function () {\r", - " pm.expect(pm.response.text()).to.include(\"AALEGO500\");\r", - "});\r", - "pm.test(\"Response does not contain AACOMPUT01\", function () {\r", - " pm.expect(pm.response.text()).to.not.include(\"AACOMPUT01\");\r", - "});" - ], - "type": "text/javascript", - "packages": {} - } + "key": "$select", + "value": "InventoryCD,Descr,ItemStatus,LastModifiedDateTime,BaseUnit" }, { - "listen": "prerequest", - "script": { - "exec": [ - "//Set current date\r", - "var moment = require('moment');\r", - "pm.environment.set('currentDate', moment().format((\"YYYY-MM-DD\")));\r", - "\r", - "//Modify stock items\r", - "var requestSignIn = {\r", - " url: pm.variables.replaceIn('{{InstanceURL}}/entity/auth/login'),\r", - " method: 'POST',\r", - " body: {\r", - " mode: 'raw',\r", - " raw: pm.variables.replaceIn(\r", - " '{ \"name\": \"{{Username}}\", \"password\": \"{{Password}}\", \"tenant\": \"{{Tenant}}\", \"branch\": \"{{Branch}}\"}')\r", - " },\r", - " header: {\r", - " 'Content-Type': 'application/json'\r", - " }\r", - "};\r", - "\r", - "pm.sendRequest(requestSignIn, (error, response) => {\r", - " if (error) {\r", - " console.log(error);\r", - " }\r", - "\r", - " pm.test('Response for sing in should be 204 to process', () => {\r", - " pm.expect(error).to.equal(null);\r", - " pm.expect(response).to.have.property('code', 204);\r", - " pm.expect(response).to.have.property('status', 'No Content');\r", - " });\r", - "\r", - "var requestAACOMPUT01 = {\r", - " url: pm.variables.replaceIn('{{InstanceURL}}/entity/Default/23.200.001/StockItem?$select=InventoryID,ItemStatus'),\r", - " method: 'PUT',\r", - " body: {\r", - " mode: 'raw',\r", - " raw: '{\"InventoryID\": {\"value\": \"AACOMPUT01\"},\"ItemStatus\": {\"value\": \"Inactive\"}}'\r", - " },\r", - " header: {\r", - " 'Content-Type': 'application/json'\r", - " }\r", - "};\r", - "pm.sendRequest(requestAACOMPUT01, (error, response) => {\r", - " if (error) {\r", - " console.log(error);\r", - " }\r", - "\r", - " pm.test('Response for AACOMPUT01 should be OK to process', () => {\r", - " pm.expect(error).to.equal(null);\r", - " pm.expect(response).to.have.property('code', 200);\r", - " pm.expect(response).to.have.property('status', 'OK');\r", - " });\r", - "\r", - "var requestAALEGO500 = {\r", - " url: pm.variables.replaceIn('{{InstanceURL}}/entity/Default/23.200.001/StockItem?$select=InventoryID,Description'),\r", - " method: 'PUT',\r", - " body: {\r", - " mode: 'raw',\r", - " raw: '{\"InventoryID\": {\"value\": \"AALEGO500\"},\"Description\": {\"value\": \"Lego, 500 piece set\"}}'\r", - " },\r", - " header: {\r", - " 'Content-Type': 'application/json'\r", - " }\r", - "};\r", - "pm.sendRequest(requestAALEGO500, (error, response) => {\r", - " if (error) {\r", - " console.log(error);\r", - " }\r", - "\r", - " pm.test('Response for AALEGO500 should be OK to process', () => {\r", - " pm.expect(error).to.equal(null);\r", - " pm.expect(response).to.have.property('code', 200);\r", - " pm.expect(response).to.have.property('status', 'OK');\r", - " });\r", - "\r", - "var requestSignOut = {\r", - " url: pm.variables.replaceIn('{{InstanceURL}}/entity/auth/logout'),\r", - " method: 'POST',\r", - " header: {\r", - " 'Content-Type': 'application/json'\r", - " }\r", - "};\r", - "\r", - "pm.sendRequest(requestSignOut, (error, response) => {\r", - " if (error) {\r", - " console.log(error);\r", - " }\r", - "\r", - " pm.test('Response for sing out should be 204 to process', () => {\r", - " pm.expect(error).to.equal(null);\r", - " pm.expect(response).to.have.property('code', 204);\r", - " pm.expect(response).to.have.property('status', 'No Content');\r", - " });\r", - "});\r", - "\r", - "});\r", - "\r", - "});\r", - "\r", - "});" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{EndpointURLDAC}}/PX_Objects_IN_InventoryItem?$select=InventoryCD,Descr,ItemStatus,LastModifiedDateTime,BaseUnit&$expand=INSiteByDfltSiteID($select=SiteCD),INItemClassByItemClassID($select=ItemClassCD),INSiteStatusCollection($select=QtyOnHand)&$filter=StkItem eq true and ItemStatus eq 'AC' and LastModifiedDateTime eq {{currentDate}}", - "host": [ - "{{EndpointURLDAC}}" - ], - "path": [ - "PX_Objects_IN_InventoryItem" - ], - "query": [ - { - "key": "$select", - "value": "InventoryCD,Descr,ItemStatus,LastModifiedDateTime,BaseUnit" - }, - { - "key": "$expand", - "value": "INSiteByDfltSiteID($select=SiteCD),INItemClassByItemClassID($select=ItemClassCD),INSiteStatusCollection($select=QtyOnHand)" - }, - { - "key": "$filter", - "value": "StkItem eq true and ItemStatus eq 'AC' and LastModifiedDateTime eq {{currentDate}}" - } - ] + "key": "$expand", + "value": "INSiteByDfltSiteID($select=SiteCD),INItemClassByItemClassID($select=ItemClassCD),INSiteStatusCollection($select=QtyOnHand)" + }, + { + "key": "$filter", + "value": "StkItem eq true and ItemStatus eq 'AC' and LastModifiedDateTime eq {{currentDate}}" } - }, - "response": [] + ] } - ] + }, + "response": [] } ] }