Skip to content

Commit

Permalink
Allow setting dob and country from CSV (fixes #40)
Browse files Browse the repository at this point in the history
Although the CSV parser passes all named columns through to the builder,
that method only applies username, email and password. In addition,
PtcSession within the API module forcibly overrides any set values.

This applies `dob` and `country` if they're set in the CSV, and updates
the API module to use any value set in `account` VS hardcoded values.
  • Loading branch information
dshoreman authored and drallieiv committed Jun 1, 2017
1 parent 20a7ba8 commit 3eacfaa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ public class CsvHeaderConstants {
public static final String USERNAME = "username";
public static final String EMAIL = "email";
public static final String PASSWORD = "password";

public static final String DOB = "dob";
public static final String COUNTRY = "country";

private CsvHeaderConstants(){

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ public AccountData buildAccountDataFromMap(Map<String, String> fieldMap) {
account.setUsername(fieldMap.get(CsvHeaderConstants.USERNAME));
account.setPassword(fieldMap.get(CsvHeaderConstants.PASSWORD));
account.setEmail(fieldMap.get(CsvHeaderConstants.EMAIL));

if (fieldMap.containsKey(CsvHeaderConstants.DOB)) {
account.setDob(fieldMap.get(CsvHeaderConstants.DOB));
}

if (fieldMap.containsKey(CsvHeaderConstants.COUNTRY)) {
account.setCountry(fieldMap.get(CsvHeaderConstants.COUNTRY));
}

return account;
}
}
4 changes: 2 additions & 2 deletions ptc-api/src/main/java/com/kinancity/api/PtcSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ private Request buildAgeCheckRequest() {
// Http Request for age check submit
private Request buildAgeCheckSubmitRequest(AccountData account, String csrfToken) throws UnsupportedEncodingException {
RequestBody body = new FormBody.Builder()
.add("dob", "1985-01-16")
.add("country", "US")
.add("dob", account.getDob())
.add("country", account.getCountry())
.add("csrfmiddlewaretoken", csrfToken)
.build();

Expand Down

0 comments on commit 3eacfaa

Please sign in to comment.