Edit a Switch

There may be a time when your user doesn't have all the information they need at the time they are first performing a switch, or perhaps they run out of time in the middle. At any point in the process you can save a partially completed switch to be completed later. In this document we will cover just how to do this.

First you will need to get a list of switches and present it to the user so that they can pick which switch they would like to edit. Here is the API call which will return this information:

API Endpoint: Switches

METHOD ENDPOINT
GET /customers/{customerKey}/switches

Example Response Object

{
  "apiVersion": "3.0.1",
  "context": "testing",
  "id": 12345,
  "data": {
    "kind": "switch",
    "currentItemCount": 2,
    "items": [
      {
        "index": 1,
        "type": "Deposit",
        "name": "Acme Trucking",
        "status": "Submitted",
        "actions": [
          "Cancel"
        ]
      },
      {
        "index": 2,
        "type": "Payment",
        "name": "Xcel Energy",
        "status": "Ready",
        "actions": [
          "HTTP-PUT",
          "Cancel",
          "Submit"
        ]
      }
    ]
  }
}

Now that you have a list of switches to present to the customer, you may want to show them a screen like the one below:

Create Customer

If your user sees a switch in the list above which they want to continue to work on or edit, then you will need to make the following API call in order to get the details of that switch and continue to gather information for that switch:

METHOD ENDPOINT
GET /customers/{customerKey}/switches/{switchIndex}

Parameter reference

PARAMETER DESCRIPTION
context
string
The context value to be returned in the response. This is supplied initially by your app and is returned from the API in the response so that responses can be correlated with requests in JSON-P and batch situations. (This is not required)
customerKey
string
A valid customerKey for the customer you are searching for.
switchIndex
string
The index of the switch (unique within a customer).

Example Response Object

{
  "apiVersion": "3.0.1",
  "context": "testing",
  "id": 1290,
  "data": {
    "kind": "switch",
    "item": {
      "index": 1,
      "type": "deposit",
      "targetId": 678313,
      "name": "Acme Inc.",
      "accountholderIndex": 0,
      "values": {
        "accounts": [
          {
            "index": 0
          }
        ],
        "fields": {}
      },
      "ux": {
        "accounts": {
          "limit": 1,
          "maxChecking": 1,
          "maxSavings": 1,
          "choices": [
            {
              "index": "0",
              "label": "Checking *3904"
            },
            {
              "index": "1",
              "label": "Savings *3289"
            }
          ],
          "fields": []
        },
        "fields": [
          {
            "key": "Custom_Net or Amount (in dollars)",
            "label": "Net or Amount (in dollars)",
            "type": "textbox",
            "required": false
          },
          {
            "key": "Custom_or Percentage of Pay (1 - 100)",
            "label": "Percentage of Pay (1 - 100)",
            "type": "textbox",
            "required": false
          },
          {
            "key": "Custom_Depositor's Full Mailing Address",
            "label": "Depositor's Full Mailing Address",
            "type": "textbox",
            "required": true
          },
          {
            "key": "Custom_Employee ID",
            "label": "Employee ID",
            "type": "textbox",
            "required": false
          },
          {
            "key": "Custom_Last 4 of SSN",
            "label": "Last 4 of SSN",
            "type": "textbox",
            "required": true
          }
        ]
      },
      "metadata": {
        "employee_id": "jsmith",
        "branch": "21"
      },
      "state": {
        "status": "Incomplete",
        "validation": {
          "accounts": [],
          "fields": [
            "Custom_Last 4 of SSN is required",
            "Custom_Depositor's Full Mailing Address is required"
          ],
          "overall": []
        },
        "actions": [
          "HTTP-PUT",
          "Cancel"
        ]
      }
    }
  }
}

Now you need to continue to continue gathering and submitting information for the switch. What you do now will depend on where the customer left off. Based on the data that comes back from the call above you will know where to continue from. It will be one of the steps in the "Creating a Switch" guide in this documentation. Please refer to the "Creating a Switch" guide for more information on how to tell which step you should take the user to and what UI to present them with.