Keystone Online Customer Portal REST API

From KeystoneIntranet
Jump to navigation Jump to search

Overview

The Keystone REST Server exposes a REST API which is used by the Keystone Online Customer Portal website.

See: Keystone_REST_Server_(KServer) for more on KServer.

Example URIs:

http://127.0.0.1:8211/rest/kOLcpapi/v1/connection

Connection Test API

ROOT: /rest/kOLcpapi/v1

connection

connection

tests connection with the server
{
    "kOLcpapi/v1": {
        "request_status": {
            "status": "200",
            "msg": "Keystone Online Customer Portal REST Server."
        }
    }
}

API v1

ROOT: /rest/kdiapi/v1

Keystone Contact Functions

ContactInfo

ContactInfo/{Id}

returns Keystone contact information for specified contact Id
{
    "ContactInfo": [
        {
            "CustId": "ALLEN",
            "Name": "Allen Construction",
            "Email": "Banders@anywhere.com"
        }
    ]
}

ContactList

ContactList/{CustId}

returns list of active Keystone contacts that have web portal access for specified CustId
{
    "ContactList": [
        {
            "Id": 1,
            "Email": "Janders@anywhere.com"
        },
        {
            "Id": 2,
            "Email": "Banders@anywhere.com"
        }
    ]
}

ContactLookup

ContactLookup/{Email}

returns Keystone contact information for specified email address
{
    "ContactLookup": [
        {
            "Id": 2,
            "CustId": "ALLEN",
            "Name": "Allen Construction"
        }
    ]
}

Customer Portal Functions

CustomerInvoices

CustomerInvoices/{ContactId}/{AgingDateLo1}/{AgingDateLo2}/{AgingDateHi2}/{AgingDateLo3}/{AgingDateHi3}/{AgingDateLo4}/{AgingDateHi4}/{AgingDateHi5}
?AgeByDate=0|1 (0=Invoice Date, 1=Due Date)
?IncPaid=N|Y (N=Open Invoices only, Y=All Invoices)

returns invoices and aging for customer associated with the specified ContactId
uses monthly aging based on today's date if aging dates not specified
{
    "CustomerAging": [
        {
            "Aging1": 0,
            "Aging2": 0,
            "Aging3": 0,
            "Aging4": 0,
            "Aging5": 203410.79
        }
    ],
    "CustomerInvoices": [
        {
            "CustId": "ALLEN",
            "InvoiceNo": 19502,
            "InvoiceType": "I",
            "InvoiceDate": "2009-05-09T00:00:00.000Z",
            "DueDate": "2009-05-09T00:00:00.000Z",
            "JobId": "ECHO VALLEY",
            "DebitAmt": 1300,
            "CreditAmt": 869.5,
            "InvoiceKey": "4759K35",
            "UMTotals": [
                {
                    "ProdUM": "CY",
                    "QtyTotal": 20
                }
            ]
        },
        {
            "CustId": "ALLEN",
            "InvoiceNo": 19503,
            "InvoiceType": "I",
            "InvoiceDate": "2009-05-09T00:00:00.000Z",
            "DueDate": "2009-05-09T00:00:00.000Z",
            "JobId": "ECHO VALLEY",
            "DebitAmt": 14700,
            "CreditAmt": 0,
            "InvoiceKey": "4759K38",
            "UMTotals": [
                {
                    "ProdUM": "CY",
                    "QtyTotal": 220
                }
            ]
        }
    ]
}

CustomerJobs

CustomerJobs/{ContactId}

returns list of open jobs for customer associated with the specified ContactId
{
    "CustomerJobs": [
        {
            "JobId": "108 NORTHSIDE"
        },
        {
            "JobId": "ECCO VALLEY"
        },
        {
            "JobId": "ECHO VALLEY"
        },
        {
            "JobId": "MEIJER"
        },
        {
            "JobId": "PARK-N-RIDE"
        },
        {
            "JobId": "VALE DO ECO"
        }
    ]
}

InvoiceHistory

InvoiceHistory/{Id}

returns invoice history (tickets and payments) for the specified Id (where Id is <session#>K<trans#>)

LoadGpsLocation

LoadGpsLocation/{Id}

returns load gps location information for the specified Id (where Id is <session#>K<trans#>K<load#>)

OrdReqJobInfo

OrdReqJobInfo/{ContactId}/{JobId}

returns job information and job products for specified JobId for customer associated with the specified ContactId
{
    "OrdReqJobInfo": [
        {
            "latitude": 40.0097883,
            "longitude": -83.0683519,
            "slump": 3,
            "spacing": 45,
            "shipTo1": "ECHO VALLEY Estates",
            "shipTo2": "345 W Adams St",
            "shipTo3": "Columbus,OH 43221",
            "delvInst1": "I 70 W to Exit 24 turn left",
            "delvInst2": "Go 6 miles to Brewister St",
            "delvInst3": "Turn Rt .75 mile on left",
            "products": [
                {
                    "prodId": "2510-05",
                    "prodDesc": "2500 PSI w/ 57 Stone",
                    "prodUM": "CY",
                    "prodType": "M",
                    "jobProd": true
                },
                {
                    "prodId": "FUEL-05",
                    "prodDesc": "Fuel Charge",
                    "prodUM": "EA",
                    "prodType": "D",
                    "jobProd": true
                }
            ]
        }
    ]
}

OrdReqJobs

OrdReqJobs/{ContactId}

returns list of active jobs for customer associated with the specified ContactId
{
    "OrdReqJobs": [
        { "JobId": "WALMART" },
        { "JobId": "ECHO VALLEY" },
        { "JobId": "I95 BRIDGE" }
    ]
}

OrderRequest [POST]

OrderRequest

submits an order request to Keystone
Request Content:
[
  {
    "customerId": "ALL100",
    "jobId": "WALMART",
    "delvDt": "2022-02-23T09:00Z",
    "spacing": 100,
    "slump": 3.5,
    "customerPo": "12345",
    "phoneNumber": "4135551212",
    "willCall": true,
    "latitude": 40.004076385875194,
    "longitude": -82.86115726470949, 
    "shipTo1": "Ship To Line 1",
    "shipTo2": "Ship To Line 2",
    "shipTo3": "Ship To Line 3",
    "shipTo4": "Ship To Line 4",
    "delvInst1": "Delivery Instruction Line 1",
    "delvInst2": "Delivery Instruction Line 2",
    "delvInst3": "Delivery Instruction Line 3",
    "delvInst4": "Delivery Instruction Line 4",
    "dispatchNotes": "a place for the user to put miscellaneous notes for the dispatcher",
    "products": [
      // mix product (prodType M) first
      {
        "jobProd": true,
        "prodId": "3010-01",
        "prodType": "M",
        "qtyOrd": 50,
        "loadSize": 10
      },
      // additives (prodType X) second
      {
        "jobProd": true,
        "prodId": "F-01",
        "prodType": "X"
      },
      // addons (all other prodType including NULL) last
      {
        "jobProd": false,
        "prodId": "REBAR-01",
        "prodType": "Z",
        "qtyOrd": 25
      },
      {
        "jobProd": false,
        "prodId": "GLOVES",
        "qtyOrd": 4
      }
    ]
  }
]

ScheduleOrders

ScheduleOrders/{ContactId}/{BegSchedDT}/{EndSchedDT}/{ActiveCarryHrs}/{UndelvCarryHrs}/{NTLLookAheadHrs}/{OrdselRangeHrs}
?IncComplete=true|false
?SlsId={SlsId}
?PlantId={PlantId}

returns schedule order information for customer associated with the specified ContactId
includes completed orders if IncComplete is true
restrict to salesperson SlsId if specified
restrict to plant PlantId if specified
{
    "ScheduleOrders": [
        {
            "OrderId": "2732",
            "TgtDepartDt": "2019-07-28T16:59:00.000Z",
            "CustId": "ALLEN",
            "CustName": "Allen Construction",
            "ProdId": "3010-01",
            "ProdDesc": "3000 PSI w/ 1\" Stone",
            "LdsActive": 0,
            "LdsCompleted": 0,
            "QtyOrd": 20,
            "QtyDel": 0,
            "OrderKey": "17491K1",
            "OrderStatus": "O",
            "DeliveryDt": "2019-07-28T17:15:00.000Z",
            "WillCall": false,
            "Plus": false,
            "Completed": false
        },
        {
            "OrderId": "2733",
            "TgtDepartDt": "2019-07-28T18:34:00.000Z",
            "CustId": "ALLEN",
            "CustName": "Allen Construction",
            "ProdId": "2510-01",
            "ProdDesc": "2500 PSI w/ 57 Stone",
            "LdsActive": 0,
            "LdsCompleted": 0,
            "QtyOrd": 15,
            "QtyDel": 0,
            "OrderKey": "17491K5",
            "OrderStatus": "O",
            "DeliveryDt": "2019-07-28T19:00:00.000Z",
            "WillCall": false,
            "Plus": false,
            "Completed": false
        }
    ],
    "Totals": [
        {
            "LdsOrd": 7,
            "LdsDel": 0,
            "LdsRem": 7,
            "LdsWc": 0,
            "QtyOrd": 35,
            "QtyDel": 0,
            "QtyRem": 35,
            "QtyWc": 0
        }
    ]
}

ScheduleOrderLoads

ScheduleOrderLoads/{Id}
?IncComplete=true|false

returns schedule order load information (active & completed loads) for the specified Id (where Id is <session#>K<trans#>)
includes completed orders if IncComplete is true

Ticket

Ticket/{Id}

returns ticket, products and batch weights information for the specified Id (where Id is <session#>K<trans#>)

Payment Processor Functions

CustomerPayments [POST]

CustomerPayments/{Id}

handles the payment processor "capture" process (where Id is the payment processor identifier, currently "1" for CardConnect)

PPSettlement [POST]

PPSettlement/{Id}

handles the payment processor "settlement" process (where Id is the payment processor identifier, currently "1" for CardConnect)
Request Content:
[
    {
        "respproc": "RPCT",
        "hostbatch": "0000000136",
        "refundtotal": "0.00",
        "batchid": "128",
        "chargetotal": "136784.68",
        "hoststat": "GB",
        "merchid": "830000000058",
        "txns": [
            {
                "setlamount": "1231.00",
                "setlstat": "Y",
                "salesdoc": "3862",
                "retref": "033326134033"
            },
            {
                "setlamount": "120.00",
                "setlstat": "Y",
                "salesdoc": "3862",
                "retref": "033765135734"
            },
            {
                "setlamount": "123123.00",
                "setlstat": "Y",
                "salesdoc": "3862",
                "retref": "033168137483"
            },
            {
                "setlamount": "9.00",
                "setlstat": "Y",
                "salesdoc": "4787",
                "retref": "033229740140"
            },
            {
                "setlamount": "19.33",
                "setlstat": "Y",
                "salesdoc": "4787",
                "retref": "033371047518"
            },
            {
                "setlamount": "26.50",
                "setlstat": "Y",
                "salesdoc": "4787",
                "retref": "033472747941"
            },
            {
                "setlamount": "13.85",
                "setlstat": "Y",
                "salesdoc": "4787",
                "retref": "033049148127"
            },
            {
                "setlamount": "12121.00",
                "setlstat": "Y",
                "salesdoc": "3862",
                "retref": "033753750784"
            },
            {
                "setlamount": "121.00",
                "setlstat": "Y",
                "salesdoc": "3862",
                "retref": "033472152392"
            }
        ]
    },
    {
        "respproc": "RPCT",
        "hostbatch": "0000000136",
        "refundtotal": "0.00",
        "batchid": "129",
        "chargetotal": "5.00",
        "hoststat": "GB",
        "merchid": "830000000058",
        "txns": [
            {
                "setlamount": "5.00",
                "setlstat": "Y",
                "salesdoc": "129879",
                "retref": "033124734715"
            }
        ]
    }
]