Wednesday, September 30, 2009

(tongue set firmly in cheek)

I happened upon Dana Merrick’s blog entry with a ruby script that retrieves an order status from dominos. In the spirit of “anything you can do I can do better” i threw this Psh equivalent together and submitted it to PoshCode.org. It’s phenomenally simple. It makes a request to the Dominos SOAP order status service and selects and displays the order status nodes if they exist.

function Get-DominosOrderStatus($pn) {
  [xml]$content = (new-object System.Net.WebClient).DownloadString(
    "http://trkweb.dominos.com/orderstorage/GetTrackerData?Phone=$pn");
  $statii = select-xml -xml @($content) `
    -Namespace @{dominos="http://www.dominos.com/message/"} `
    -XPath descendant::dominos:OrderStatus
  if($statii.Count -gt 0) { $statii | %{ $_.Node } }
  else { "No orders" }
}

Sample Output:

Version               : 1.3
OrderAsOfTime         : 2008-06-04T16:40:48
StoreAsOfTime         : 2008-06-04T16:44:55
StoreID               : 3189
OrderID               : 2008-06-04#73694
Phone                 : 3145551234
ServiceMethod         : Delivery
AdvancedOrderTime     :
OrderDescription      : 2 Small(10") Hand Tossed Pizza

OrderTakeCompleteTime : 2008-06-04T16:27:52
TakeTimeSecs          : 0
CsrID                 : Power
CsrName               :
OrderSourceCode       : Web
OrderStatus           : Out the Door
StartTime             : 2008-06-04T16:27:52
MakeTimeSecs          : 237
OvenTime              : 2008-06-04T16:31:49
OvenTimeSecs          : 360
RackTime              : 2008-06-04T16:37:49
RackTimeSecs          : 179
RouteTime             : 2008-06-04T16:40:48
DriverID              : 0818
DriverName            : Edna
OrderDeliveryTimeSecs :
DeliveryTime          :
OrderKey              : 1dRprcnzmWxaOXvlzj06OlFdzuexcIC/
ManagerID             : 5560
ManagerName           : Danillo

#text : Out the Door

You can download it here: http://bitbucket.org/xcud/powershell-snippets/src/tip/Get-DominosOrderStatus.psm1

Notes