cs445 - Spring 2015

Project - Command Line Interface


The general format of a command is:

$ java vin command [ command_options [ arguments ] ]

where vin is the name of the project, command is one the several things the software can do, command_options are options for the various commands available, and arguments are the various values that go with the command options.

In the examples below we use brackets "[ ]", parentheses "( )", pipes "|" and ellipsis "..." to describe optional, required, mutually exclusive, and repeating elements.

Commands

subscriber

$ java vin subscriber add -n <name> -e <email> -a <address> -c <city> -s <state> -z <zip> -h <phone> [ -f <facebook> ] [ -t <twitter> ]

The command adds a new subscriber and returns a JSON response that includes the ID of the subscriber newly created, plus an array of validation errors.

Example Response


  {
    "uid": 345,
    "errors": []
  }


Here is another example


  {
      "uid": null,
      "errors": [
          {
              "code": 1008,
              "message": "State must be provided"
          },
          {
              "code": 1003,
              "message": "invalid email address"
          }
      ]
  }


Here is a list of error codes that can be included in the response, together with the corresponding messages:

  • 1000 - Name must be provided
  • 1001 - Bad name
  • 1002 - Email address must be provided
  • 1003 - Invalid email address
  • 1004 - Address must be provided
  • 1005 - Bad address
  • 1006 - City must be provided
  • 1007 - Bad city
  • 1008 - State must be provided
  • 1009 - We may not ship to this state
  • 1010 - ZIP code must be provided
  • 1011 - Bad ZIP code
  • 1012 - Phone number must be provided
  • 1013 - Invalid ID
  • 1014 - An account with this email address exists
  • 1015 - File name must be provided
  • 1016 - File not found


$ java vin subscriber modify -uid <ID> [ -n <name> ] [ -e <email> ] [ -a <address> ] [ -c <city> ] [ -s <state> ] [ -z <zip> ] [ -h phone ] [ -f <facebook> ] [ -t <twitter> ]

The command will update the information for the subscriber identified by ID with what's provided in the command line. If no arguments are provided, then no change is made. The response is JSON that includes the ID and an array of validation errors.

Example Response


  {
    "uid": 345,
    "errors": []
  }



$ java pn subscriber view -uid <ID>

The command will print detailed information about the subscriber <ID>. This includes subscriber information such as name, address, etc.

Example Response


  {
    "uid": 345,
    "date_created": "20150117",
    "type": "AR",
    "dow": "Friday",
    "tod": "AM",
    "name": "Jane Doe",
    "email": "jane.doe@example.com",
    "phone": "123-456-7890",
    "address": {
      "street": "123 Main ST, STE A",
      "city": "Anytown",
      "state": "Anystate",
      "zip": "12345"
    },
    "facebook": "",
    "twitter": ""   
  }



$ java pn subscriber load -f <file>

The command creates a new subscriber using information from the JSON file, and returns JSON that includes the ID of the newly created account and an array of errors.

Example Response


  {
    "uid": 346,
    "errors": []
  }


Here is another example


  {
      "uid": null,
      "errors": [
          {
              "code": 1014,
              "message": "An account with this email address exists"
          }
      ]
  }



$ java vin subscriber search -uid <ID> [ -k <query_string> ]

Returns an array of wine IDs, array of note IDs, and shipments IDs that contain the query_string, if provided, for the user identified by ID.

Example Response


  {
      "uid": 345,
      "wines": [
          {
              "wid": 123,
              "label_name": "The Mission"
          },
          {
              "wid": 124,
              "label_name": "Joseph Phelps Cabernet Sauvignon 2012"
          }
      ],
      "notes": [],
      "shipments": [
          {
              "sid": 145,
              "selection_month": "Mar/2015"
          }
      ]
  }



shipments

$ java vin shipments view -uid <UID> [ -sid <SID> ]

Returns an array of shipments for the subscriber identified by <UID>. For each shipment return the status, e.g. "delivered", "cancelled", "returned", "pending". If the shipment identified by <SID> is provided, then return specific information about that shipment.

Example Response - <SID> not provided


  {
      "uid": 345,
      "shipments": [
          {
              "sid": 131,
              "selection_month": "Jan/2015",
              "status": "delivered"
          },
          {
              "sid": 139,
              "selection_month": "Feb/2015",
              "status": "cancelled"
          },
          {
              "sid": 145,
              "selection_month": "Mar/2015",
              "status": "delivered"
          }
      ]
  }


Example Response - <SID> provided


  {
    "uid": 345,
    "sid": 139,
    "selection_month": "Feb/2015",
    "status": "cancelled",
    "date": "13-Feb-2015",
    "type": "AR",
    "wines": [
        {
            "id": 123,
            "label_name": "The Mission"
        },
        {
            "id": 124,
            "label_name": "Joseph Phelps Cabernet Sauvignon 2012"
        },
        {
            "id": 125,
            "label_name": "Round Pond Estate Rutherford"
        },
        {
            "id": 126,
            "label_name": "Dona Paula Black Label"
        },
        {
            "id": 127,
            "label_name": "Schug Sonoma Coast Pinot Noir"
        },
        {
            "id": 128,
            "label_name": "Caymus Special Selection Cabernet Sauvignon "
        }
    ]
  }


$ java vin shipments modify -uid <UID> -sid <SID> -dow <DOW> -tod <TOD>

Modifies the delivery detail for shipment <SID> for subscriber <UID>. The new day-of-week and time-of-day will be <DOW> and <TOD> respectively

Example Response

  
  {
    "uid": 345,
    "sid": 145,
    "delivery_day": "Tue",
    "time_of_day": "AM",
    "errors": []
  }
  

$ java vin shipments view -uid <UID> [ -sid <SID> ]

Returns .

Example Response - <SID> not provided


$Id: command-line.html,v 1.2 2015/04/24 05:32:48 virgil Exp $