Skip to content

Commit

Permalink
Add CLI subcommands to invoke the PA API endpoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
davepeck committed Jul 24, 2024
1 parent 61d2fcb commit d9ce1d4
Show file tree
Hide file tree
Showing 11 changed files with 1,439 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PA_API_LIVE_TESTS=False
PA_API_KEY=
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ vote check-csv <input-file.csv> [--details]

A new CSV is written to `stdout` with the same fields as the input CSV plus extras related to the registration check.

### Interact with the Pennsylvania API

The `vote` command contains a number of sub-commands for interacting directly with the [Pennsylvania state API](https://www.pa.gov/en/agencies/dos/resources/voting-and-elections-resources/pa-online-voter-registration-web-api-rfc.html).

For instance, to invoke the API's "get available languages" call:

```
> vote pa get-languages
languages=(Language(code='LANGENG', name='English'), Language(code='LANGSPN', name='Spanish'), Language(code='LANGTCN', name='Chinese'))
```

Use `vote pa --help` for details on available subcommands.

## Development

To contribute to this library, first checkout the code. Then create a new virtual environment:
Expand Down Expand Up @@ -73,3 +86,7 @@ To run a full lint/typecheck/test pass:
```bash
make check
```

## State-specific documents

We've collected state-specific documents in the [`docs`](./docs) directory and will try to keep them up-to-date as state APIs change.
278 changes: 278 additions & 0 deletions docs/pa/examples/error-values.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
<OVRLookupData>
<MessageText>
<ErrorCode>VR_WAPI_InvalidAccessKey</ErrorCode>
<ErrorText>Access Key is Invalid.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidAction</ErrorCode>
<ErrorText>Action not found.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidAPIbatch</ErrorCode>
<ErrorText>Batch value is Invalid.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRCounty</ErrorCode>
<ErrorText>Your county of residence is required.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRDL</ErrorCode>
<ErrorText> please provide valid DL or pick continuesubmit checkbox.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRDLformat</ErrorCode>
<ErrorText>Please enter a valid 8 digit PA driver's license or PennDOT ID card number.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRDOB</ErrorCode>
<ErrorText>Please input a valid birth date.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRemail</ErrorCode>
<ErrorText>The format of the email address is incorrect. Please correct and try again.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRmailingzipcode</ErrorCode>
<ErrorText>The zip code must be 5 digits or 9 digits (zip code + 4).</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRphone</ErrorCode>
<ErrorText>The phone number provided is not valid. Please enter a valid phone number.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRPreviousCounty</ErrorCode>
<ErrorText>Previous County of Registration is required for an Address Change application</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRPreviouszipcode</ErrorCode>
<ErrorText>Please enter a valid 5 digit zip code.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRSSNformat</ErrorCode>
<ErrorText>Please enter the LAST FOUR digits of your Social Security number.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRzipcode</ErrorCode>
<ErrorText>Please enter a valid 5 digit zip code.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_invalidpreviousregyear</ErrorCode>
<ErrorText>Please input valid year.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidReason</ErrorCode>
<ErrorText>Please select any one reason - New Application or Update Application , both are not allowed</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingAccessKey</ErrorCode>
<ErrorText>Please provide the access key in [sysparm_AuthKey] parameter in the link to proceed.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingAddress</ErrorCode>
<ErrorText>A complete mailing or residential address is required for your application to be submitted online. Please use the link at the top of the page to print a blank voter registration application. Please complete, sign and date it then mail it to your county voter registration office. Do not FAX your application form.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingAPIaction</ErrorCode>
<ErrorText>Please provide the GET action in [sysparm_action] parameter in the link to proceed.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingCounty</ErrorCode>
<ErrorText>Please provide the county in [sysparm_County] parameter in the link to proceed.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingLanguage</ErrorCode>
<ErrorText>Please provide the Language code in [sysparm_Language] parameter in the link to proceed.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRassistancedeclaration</ErrorCode>
<ErrorText>Please indicate assistance was provided with the completion of this form.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRcity</ErrorCode>
<ErrorText>Your city is required.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRcounty</ErrorCode>
<ErrorText>Your county of residence is required.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRdeclaration1</ErrorCode>
<ErrorText>Please confirm you have read and agree to the terms.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRDL</ErrorCode>
<ErrorText>Please supply either a PA driver's license or PennDOT ID card number, the last four digits of your SSN, or click the check box.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRfirstname</ErrorCode>
<ErrorText>Your first name is required.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRinterpreterlang</ErrorCode>
<ErrorText>Required if interpreter is checked</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRisageover18</ErrorCode>
<ErrorText>Will you be 18 years or older on or before election day? You must provide a response before continuing. </ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRisuscitizen</ErrorCode>
<ErrorText>Are you a citizen of the U.S.? You must provide a response before continuing.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRlastname</ErrorCode>
<ErrorText>Your last name is required.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVROtherParty</ErrorCode>
<ErrorText>Warning - Party is not selected. If Other is selected, the Other party text box should be completed.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRPoliticalParty</ErrorCode>
<ErrorText>Warning - Party is not selected. If Other is selected, the Other party text box should be completed.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRPreviousAddress</ErrorCode>
<ErrorText>Address of Previous Registration is required for an Address Change application</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRPreviousCity</ErrorCode>
<ErrorText>City of Previous Registration is required for an Address Change application</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRPreviousFirstName</ErrorCode>
<ErrorText>Previous First Name is required for a Name Change application</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRPreviousLastName</ErrorCode>
<ErrorText>Previous Last Name is required for a Name Change application</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRPreviousZipCode</ErrorCode>
<ErrorText>Zip of Previous Registration is required for an Address Change application</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRSSNDL</ErrorCode>
<ErrorText>Please supply either a PA driver's license or PennDOT ID card number, the last four digits of your SSN, or click the check box.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRstreetaddress</ErrorCode>
<ErrorText>Your street address is required.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRtypeofassistance</ErrorCode>
<ErrorText>Please select the type of assistance required.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRzipcode</ErrorCode>
<ErrorText>Your zip code is required</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingReason</ErrorCode>
<ErrorText>Please check at least one box.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_PennDOTServiceDown</ErrorCode>
<ErrorText>PennDOT server is down.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_RequestError</ErrorCode>
<ErrorText>WebAPi request is Invalid</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_ServiceError</ErrorCode>
<ErrorText>Signature service is down.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_SystemError</ErrorCode>
<ErrorText>We're sorry, but the system cannot verify your information and complete your application right now. Try again.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRAssistedpersonphone</ErrorCode>
<ErrorText>The phone number provided is not valid. Please enter a valid phone number.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRsecondemail</ErrorCode>
<ErrorText>The format of the email address is incorrect. Please correct and try again.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_Invalidsignaturestring</ErrorCode>
<ErrorText>Your upload was not successful. Please try again.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_Invalidsignaturetype</ErrorCode>
<ErrorText>Please choose one of the following file types: .TIFF, .JPG, .BMP and .PNG.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_Invalidsignaturesize</ErrorCode>
<ErrorText>Please upload an image file size less than 5MB.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_Invalidsignaturedimension</ErrorCode>
<ErrorText>The image size should be equal to 180 x 60 pixels.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_Invalidsignaturecontrast</ErrorCode>
<ErrorText>Your upload was not successful. Please try again.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRParty</ErrorCode>
<ErrorText>Please select a political party.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRPoliticalParty</ErrorCode>
<ErrorText>Please select a political party.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_Invalidsignatureresolution</ErrorCode>
<ErrorText>Your uploaded signature does not meet the 96.00 dpi requirements. Please upload an image file meeting or exceeding this requirement.</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRmailinballotaddr</ErrorCode>
<ErrorText>Missing MailIn Ballot Address</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRmailincity</ErrorCode>
<ErrorText>Missing MailIn City</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRmailinstate</ErrorCode>
<ErrorText>Missing MailIn State</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidOVRmailinzipcode</ErrorCode>
<ErrorText>Missing MailIn Zipcode</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRmailinlivedsince</ErrorCode>
<ErrorText>Missing MailIn lived since</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRmailindeclaration</ErrorCode>
<ErrorText>Missing MailIn Declaration</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MailinNotEligible</ErrorCode>
<ErrorText>MailIn Not Eligible</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_InvalidIsTransferPermanent</ErrorCode>
<ErrorText>The transfer permanent flag provided is not valid</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRAnnualmailinRequest</ErrorCode>
<ErrorText>Missing Annual MailIn Request</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRIsMailingCountryUSA</ErrorCode>
<ErrorText>Missing Is Mailing Country USA</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRMailBallottoDifferentAddress</ErrorCode>
<ErrorText>Missing Mail Ballot to Different Address</ErrorText>
</MessageText>
<MessageText>
<ErrorCode>VR_WAPI_MissingOVRmailingcountry</ErrorCode>
<ErrorText>Missing mailing country</ErrorText>
</MessageText>
</OVRLookupData>
49 changes: 49 additions & 0 deletions docs/pa/examples/full-voter-app-by-hand-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<APIOnlineApplicationData xmlns="OVRexternaldata">
<record>
<batch>1</batch>
<FirstName>Test</FirstName>
<MiddleName></MiddleName>
<LastName>Applicant1</LastName>
<TitleSuffix></TitleSuffix>
<united-states-citizen>1</united-states-citizen>
<eighteen-on-election-day>1</eighteen-on-election-day>
<isnewregistration>1</isnewregistration>
<name-update>0</name-update>
<address-update>0</address-update>
<ispartychange>0</ispartychange>
<isfederalvoter>0</isfederalvoter>
<voterregnumber></voterregnumber>
<DateOfBirth>1980-01-01</DateOfBirth>
<Gender>M</Gender>
<Ethnicity></Ethnicity>
<Phone></Phone>
<Email>test.applicant1@example.com</Email>
<streetaddress>123 Main St</streetaddress>
<streetaddress2></streetaddress2>
<unittype></unittype>
<unitnumber></unitnumber>
<city>Philadelphia</city>
<zipcode>19127</zipcode>
<donthavePermtOrResAddress>0</donthavePermtOrResAddress>
<mailingaddress></mailingaddress>
<mailingcity></mailingcity>
<mailingstate></mailingstate>
<mailingzipcode></mailingzipcode>
<drivers-license>12345678</drivers-license>
<ssn4></ssn4>
<signatureimage></signatureimage>
<politicalparty>D</politicalparty>
<otherpoliticalparty></otherpoliticalparty>
<needhelptovote>0</needhelptovote>
<assistancetype></assistancetype>
<preferredlanguage></preferredlanguage>
<declaration1>1</declaration1>
<assistedpersonname></assistedpersonname>
<assistedpersonAddress></assistedpersonAddress>
<assistedpersonphone />
<assistancedeclaration2 />
<county>2340</county>
<donthavebothDLandSSN>0</donthavebothDLandSSN>
<continueAppSubmit>0</continueAppSubmit>
</record>
</APIOnlineApplicationData>
Loading

0 comments on commit d9ce1d4

Please sign in to comment.