The base configuration Personal Auto product

To generate endpoints for the Personal Auto line of business, you must:

  1. Generate an APD template from the existing product.
  2. Modify the template to align naming in the original Cloud API version of the product.
  3. From APD, install the system API code.
  4. Set the product configuration to use the installed resources.
  5. Modify the VehicleDriverExtResource class.
  6. Restart PolicyCenter.

Step 1: Generate an APD template from the existing product

First, you must generate an APD template from the existing Personal Auto product. This is done through the PolicyCenter user interface.

  1. If necessary, set Options > Preferences > Product Design Mode to Developer, and then click Update.
  2. Select Administration > Product Management > Externally Managed. This pane contains a list of products that have been installed by means other than APD.
  3. In the Installed Products pane, select "Personal Auto".
  4. In the Details pane, click Extract APD Representation. PolicyCenter generates the APD template and stores it in the <USER_HOME>/Downloads directory.

Step 2: Modify the template

The Personal Auto product predates Cloud API. Therefore, there are a small number of names in the product that do not align with Cloud API naming. You must modify the template to bring these values into alignment.

  1. Open the template generated in the previous step.
  2. Find the following tag and change it to the following value. (There is only one instance of this tag.)
    1. Original value: <TypeName>VehicleDriver</TypeName>
    2. Modified value: <TypeName>Driver</TypeName>
  3. Find the following tag and change it to the following value. (There is only one instance of this tag.)
    1. Original value: <TypeName>PersonalVehicle</TypeName>
    2. Modified value: <TypeName>Vehicle</TypeName>
  4. Save the template.

Step 3: Install the system API code

Next, you must import the modified template into Advanced Product Designer and then install the "system API code".

Note: In this step, you are installing the system API code only. Do not install the entire product. Installing the entire product could overwritten existing logic, which would result in the product behaving in unexpected ways.
  1. On the Product Management screen, click the APD Managed tab.
  2. Click Import from Template.
  3. Click Browse. Select the template to import.
  4. Click Update. APD imports the product template. Once the import is complete, the product is listed on the APD Managed tab.
  5. Select the imported template from the list.
  6. On the Details tab below the list, select Generate Product Code > System APIs > System APIs - Code. APD shows the Review Product Elements screen.
    • You may see warnings about naming conflicts for the NumAddInsured and PatternCode fields. You can ignore these warnings.
  7. Click Complete Generation. In the confirmation dialog box, click OK.

Step 4: Set the product configuration to use the installed resources

A given product can have two sets of artifacts:

  • Visualized artifacts are created when a product is imported from a template or mind map.
  • Finalized artifacts are created when a product is installed.

Calls from Cloud API can use only one set of artifacts. Every product has an Enabled for REST API flag. When a single product has both sets of artifacts, this setting determines which set to use for incoming Cloud API calls.

  • If the flag is set to Enabled, the visualized set is used.
  • If the flag is set to Disabled, the finalized set is used.

By default, this flag is set to Enabled. This means that, by default, the Personal Auto line will use the artifacts generated when the template was imported in the previous step. To make incoming calls use the original installed artifacts, you must disable this flag.

  1. If you have not done so already, set Options > Preferences > Product Design Mode to Developer, and then click Update.
  2. Navigate to the Product Management screen.
  3. Select the product. In the Details tab below the list of products, click Edit Product. PolicyCenter shows the Product Definition screen for that product.
  4. Set Enabled for REST API to Disabled.
  5. Click Save.

This setting does not take effect until PolicyCenter is restarted, which is done in the final step.

Step 5: Modify the VehicleDriverExtResource class

During system API code installation, APD generates several artifacts for the new product. For the base configuration Personal Auto product, one of these artifacts is the VehicleDriverExtResource class, located in the gw.rest.ext.pc.policyperiod.pa.v1.driver package.

The initial version of this class is empty. Guidewire recommends replacing the class with the code provided below for the following reasons.

  • The override of the finishCreate function ensures that the vehicle driver is linked to the parent PALine object. This is necessary for certain behaviors, such as some of the base configuration Personal Auto screens in the user interface.
  • The override of the applyPatchForCreate function is not required, but it is recommended to ensure there are no duplicate driver values.
package gw.rest.ext.pc.policyperiod.pa.v1.driver

uses gw.api.modules.rest.framework.v1.batch.BatchUpdateMap
uses gw.api.modules.rest.framework.v1.exceptions.LocalizedExceptionUtil
uses gw.api.modules.rest.framework.v1.json.DataEnvelope
uses gw.rest.core.pc.policyperiod.v1.JsonConstants#DATA_ATTRIBUTES
uses gw.rest.core.pc.policyperiod.v1.JsonConstants.VehicleDriver#POLICY_DRIVER

@Export
class VehicleDriverExtResource extends VehicleDriverGenResource {
  override function finishCreate(data : DataEnvelope, batchUpdateMap : BatchUpdateMap) {
    super.finishCreate(data, batchUpdateMap)

    var driver = this.Driver.PolicyDriver
    driver.PersonalAutoLine = this.Parent.Vehicle.PALine
  }

  override function applyPatchForCreate(data : DataEnvelope, batchUpdateMap : BatchUpdateMap) {
    super.applyPatchForCreate(data, batchUpdateMap)

    // Ensure there are no duplicate PolicyDriver values
    var pcr = Driver.PolicyDriver
    var duplicate = Parent.Vehicle.Drivers.firstWhere(\d -> d.PolicyDriver == pcr && d != Driver)
    if (duplicate != null) {
      throw LocalizedExceptionUtil.badInputInBody({DATA_ATTRIBUTES, POLICY_DRIVER}.join("."),
          "Rest.PolicyPeriod.V1.PolicyContactJsonValueResolver.Duplicate",
          {duplicate.PolicyDriver.AccountContactRole.AccountContact.Contact.RestId, "driver", "vehicle"})
    }
  }
}

Step 6: Restart PolicyCenter

To finish the deployment of all new resources, you must restart PolicyCenter.

Generic endpoints in Personal Auto submissions

The Personal Auto product, as designed in the base configuration, stores some auto-specific information in resources that are not LOB-specific.

For example, the following auto-specific fields exist on the PolicyContact resource and are accessed using the generic /jobs/{jobId}/contacts endpoints:

  • applicableGoodDriverDiscount
  • dateCompletedTrainingClass
  • goodDriverDiscount
  • licenseNumbr
  • licenseState
  • numberOfAccidents
  • numberOfViolations
  • policyNumberOfAccidents
  • policyNumberOfViolations
  • trainingClassType
  • yearLicensed

Therefore, when modifying a base configuration Personal Auto submission, you need to use a mix of LOB-specific endpoints and generic endpoints.

Composite request submission example

You can test your work by executing the following composite request. This is an end-to-end test that does the following:

  1. Creates a new account.
  2. Create a Personal Auto submission for the account.
  3. Answers the question "Is the applicant currently insured" with "No - New Driver" (newdriver).
  4. Adds a line-level optional coverage (PALossOfUseCov).
  5. Adds a vehicle.
  6. Adds an optional coverage (PARentalCov) to the vehicle, and specifies the 20 dollars/day for 60 days (60/20) coverage term.
  7. Specifies contact information that is required for quoting (such as date of birth and number of accidents).
  8. Specifies vehicle driver information (percent of time the contact driver the vehicle).
  9. Sets the Anti-Lock Breaks Discount modifier to true.
  10. Quotes the job.
{
  "requests": [
    {
      "method": "post",
      "uri": "/account/v1/accounts",
      "body": {
        "data": {
          "attributes": {
            "initialAccountHolder": {
              "contactSubtype": "Person",
              "firstName": "Tamsin",
              "lastName": "Tester",
              "primaryAddress": {
                "addressLine1": "2850 S. Delaware St.",
                "city": "San Mateo",
                "postalCode": "94403",
                "state": {
                  "code": "CA"
                }
              }
            },
            "initialPrimaryLocation": {
              "addressLine1": "2850 S. Delaware St.",
              "city": "San Mateo",
              "postalCode": "94403",
              "state": {
                "code": "CA"
              }
            },
            "producerCodes": [
              {
                "id": "pc:16"
              }
            ], 
            "organizationType": {
              "code": "other" 
            }
          }
        }
      },           
      "vars": [
        {
          "name": "accountId",
          "path": "$.data.attributes.id"
        },
        {
          "name": "driverId",
          "path": "$.data.attributes.accountHolder.id"
        }
      ]
    },
    {
      "method": "post",
      "uri": "/job/v1/submissions",
      "body": {
        "data": {
          "attributes": {
            "account": {
              "id": "${accountId}"
            },
            "baseState": {
              "code": "CA"
            },
            "jobEffectiveDate": "2022-08-01",
            "producerCode": {
              "id": "pc:16"
            },
            "product": {
              "id": "PersonalAuto"
            }
          }
        }
      },
      "vars": [
        {
          "name": "jobId",
          "path": "$.data.attributes.id"
        }
      ]
    },
    {
      "method": "patch",
      "uri": "/job/v1/jobs/${jobId}/questions",
      "body": {
        "data": {
          "attributes": {
            "answers": {
              "PACurrentlyInsured": {
                  "choiceValue": {
                    "code": "newdriver"
                  }
              }
            }
          }
        }
      }
    },
    {
      "method": "post",
      "uri": "/job/v1/jobs/${jobId}/lines/PersonalAutoLine/coverages",
      "body": {
        "data": {
          "attributes": {
            "pattern": {
              "id": "PALossOfUseCov"
            }
          }
        }
      }
    },
    {
      "method": "post",
      "uri": "/job/v1/jobs/${jobId}/lines/PersonalAutoLine/vehicles",
      "body": {
        "data": {
          "attributes": {
              "make": "Toyota",
              "model": "Tercel",
              "modelYear": 2010,
              "costNew": {
                  "amount": "33000",
                  "currency": "usd"
              },
              "licenseState": {
                  "code": "CA"
              },
              "vin": "14HEW8RLGMDSP03AA"
          }
        }
      },
      "vars": [
        {
          "name": "vehicleId",
          "path": "$.data.attributes.id"
        }
      ]
    },
    {
      "method": "post",
      "uri": "/job/v1/jobs/${jobId}/lines/PersonalAutoLine/vehicles/${vehicleId}/coverages",
      "body": {
        "data": {
          "attributes": {
            "pattern": {
              "id": "PARentalCov"
            },
            "terms": {
              "PARental": {
                "choiceValue": {
                  "code": "60/20"
                }
              }
            }
          }
        }
      }
    },
    {
      "method": "patch",
      "uri": "/job/v1/jobs/${jobId}/contacts/${driverId}",
      "body": {
        "data": {
          "attributes": {
              "dateOfBirth": "1980-10-10",
              "licenseNumber": "CA7732839",
              "licenseState": {
                  "code": "CA"
              },
              "numberOfAccidents": {
                  "code": "0"
              },
              "numberOfViolations": {
                  "code": "0"
              },
              "policyNumberOfAccidents": {
                  "code": "0"
              },
              "policyNumberOfViolations": {
                  "code": "0"
              }
          }
        }
      }
    },  
    {
      "method": "post",
      "uri": "/job/v1/jobs/${jobId}/lines/PersonalAutoLine/vehicles/${vehicleId}/drivers",
      "body": {
        "data": {
          "attributes": {
              "percentageDriven": 100,
              "policyDriver": {
                  "id": "${driverId}"
              }
          }
        }
      }
    },
    {
      "method": "patch",
      "uri": "/job/v1/jobs/${jobId}/lines/PersonalAutoLine/vehicles/${vehicleId}/modifiers/PAAntiLockBrakes",
      "body": {
        "data": {
          "attributes": {
            "booleanModifier": true
          }
        }
      }
    },
    {
      "method": "post",
      "uri": "/job/v1/jobs/${jobId}/quote"
    }
  ]
}