Skip to content

Commit

Permalink
Merge pull request #6 from fullcontact/add-request-parameters-enrich
Browse files Browse the repository at this point in the history
Add request parameters enrich
  • Loading branch information
prakhar-j authored Aug 16, 2021
2 parents cb796f8 + 69b7118 commit 5dbba76
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 36 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ such as:
- `LiNonId`: _string_
- `PartnerId`: _string_
- `Placekey`: _string_
- `ExpandedInterests`: _bool_
- `VerifiedPhysical`: _bool_
- `MaxMaids`: _int_


```go
Expand Down
2 changes: 2 additions & 0 deletions fc/fullcontact.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func sendToChannel(ch chan *APIResponse, response *http.Response, url string, er
setResolveResponseWithTags(apiResponse)
case tagsCreateUrl, tagsGetUrl, tagsDeleteUrl:
setTagsResponse(apiResponse)
case emailVerificationUrl:
setEmailVerificationResponse(apiResponse)
case audienceCreateUrl, audienceDownloadUrl:
setAudienceResponse(apiResponse)
case permissionCreateUrl:
Expand Down
2 changes: 1 addition & 1 deletion fc/household.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type LocationInfo struct {
DesignatedMarketArea string `json:"designatedMarketArea"`
CoreBasedStatisticalArea string `json:"coreBasedStatisticalArea"`
NielsenCountySize string `json:"nielsenCountySize"`
CongressionalDistrict int `json:"congressionalDistrict"`
CongressionalDistrict string `json:"congressionalDistrict"`
NumericCountyCode int `json:"numericCountyCode"`
SeasonalAddress bool `json:"seasonalAddress"`
}
Expand Down
32 changes: 17 additions & 15 deletions fc/person.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ package fullcontact
/* This contains all the Person centric response models for the Person Enrich API */

type PersonResp struct {
FullName string `json:"fullName"`
Email string `json:"email"`
Phone string `json:"phone"`
AgeRange string `json:"ageRange"`
Gender string `json:"gender"`
Location string `json:"location"`
Title string `json:"title"`
Organization string `json:"organization"`
Twitter string `json:"twitter"`
Linkedin string `json:"linkedin"`
Bio string `json:"bio"`
Avatar string `json:"avatar"`
Website string `json:"website"`
Details *Details `json:"details"`
Updated string `json:"updated"`
FullName string `json:"fullName"`
Email string `json:"email"`
Phone string `json:"phone"`
AgeRange string `json:"ageRange"`
Gender string `json:"gender"`
Location string `json:"location"`
Title string `json:"title"`
Organization string `json:"organization"`
Twitter string `json:"twitter"`
Linkedin string `json:"linkedin"`
Bio string `json:"bio"`
Avatar string `json:"avatar"`
Website string `json:"website"`
Details *Details `json:"details"`
Epsilon map[string]string `json:"epsilon"`
VerifiedPhysical bool `json:"verifiedPhysical"`
Updated string `json:"updated"`
}

type Details struct {
Expand Down
53 changes: 37 additions & 16 deletions fc/person_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ package fullcontact
type PersonRequestOption func(pr *PersonRequest)

type PersonRequest struct {
Emails []string `json:"emails,omitempty"`
Phones []string `json:"phones,omitempty"`
DataFilter []string `json:"dataFilter,omitempty"`
Maid []string `json:"maids,omitempty"`
Location *Location `json:"location,omitempty"`
Name *PersonName `json:"name,omitempty"`
Profiles []*Profile `json:"profiles,omitempty"`
WebhookUrl string `json:"webhookUrl,omitempty"`
RecordId string `json:"recordId,omitempty"`
PersonId string `json:"personId,omitempty"`
PartnerId string `json:"partnerId,omitempty"`
LiNonId string `json:"li_nonid,omitempty"`
Confidence string `json:"confidence,omitempty"`
Infer bool `json:"infer,omitempty"`
Placekey string `json:"placekey,omitempty"`
Emails []string `json:"emails,omitempty"`
Phones []string `json:"phones,omitempty"`
DataFilter []string `json:"dataFilter,omitempty"`
Maid []string `json:"maids,omitempty"`
Location *Location `json:"location,omitempty"`
Name *PersonName `json:"name,omitempty"`
Profiles []*Profile `json:"profiles,omitempty"`
WebhookUrl string `json:"webhookUrl,omitempty"`
RecordId string `json:"recordId,omitempty"`
PersonId string `json:"personId,omitempty"`
PartnerId string `json:"partnerId,omitempty"`
LiNonId string `json:"li_nonid,omitempty"`
Confidence string `json:"confidence,omitempty"`
Infer bool `json:"infer,omitempty"`
Placekey string `json:"placekey,omitempty"`
VerifiedPhysical bool `json:"verifiedPhysical,omitempty"`
ExpandedInterests bool `json:"expandedInterests,omitempty"`
MaxMaids int `json:"maxMaids,omitempty"`
}

func NewPersonRequest(option ...PersonRequestOption) (*PersonRequest, error) {
Expand Down Expand Up @@ -48,7 +51,7 @@ func validatePersonRequest(pr *PersonRequest) error {
return NewFullContactError("Confidence value can only be 'LOW', 'MED', 'HIGH', 'MAX'")
}
if !pr.isQueryable() {
if (pr.Location == nil && pr.Name == nil && !isPopulated(pr.Placekey)) || (isPopulated(pr.Placekey) && pr.Name != nil ){
if (pr.Location == nil && pr.Name == nil && !isPopulated(pr.Placekey)) || (isPopulated(pr.Placekey) && pr.Name != nil) {
return nil
} else if pr.Location != nil && pr.Name != nil {
// Validating Location fields
Expand Down Expand Up @@ -223,3 +226,21 @@ func WithPlacekey(placekey string) PersonRequestOption {
pr.Placekey = placekey
}
}

func WithExpandedInterests(expandedInterests bool) PersonRequestOption {
return func(pr *PersonRequest) {
pr.ExpandedInterests = expandedInterests
}
}

func WithVerifiedPhysical(verifiedPhysical bool) PersonRequestOption {
return func(pr *PersonRequest) {
pr.VerifiedPhysical = verifiedPhysical
}
}

func WithMaxMaids(maxMaids int) PersonRequestOption {
return func(pr *PersonRequest) {
pr.MaxMaids = maxMaids
}
}
8 changes: 6 additions & 2 deletions fc/person_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func TestMarshallNewPersonRequest(t *testing.T) {
assert.NoError(t, err)
profile2, err := NewProfile(WithUrl("https://twitter.com/mcreedytest"))
assert.NoError(t, err)
requestJson := "{\"emails\":[\"marianrd97@outlook.com\",\"test1@gmail.com\",\"test2@outlook.com\"],\"phones\":[\"123-4567890\"],\"dataFilter\":[\"individual\",\"social\"],\"maids\":[\"abcd-123-abcd-1234-abcdlkjhasdfgh\",\"1234-snbk-lkldiemvmruixp-2kdp-vdm\"],\"location\":{\"addressLine1\":\"123/23\",\"addressLine2\":\"Some Street\",\"city\":\"Denver\",\"region\":\"Denver\",\"regionCode\":\"123123\",\"postalCode\":\"23124\"},\"name\":{\"given\":\"Marian\",\"family\":\"Reed\",\"full\":\"Marian C Reed\"},\"profiles\":[{\"url\":\"https://twitter.com/mcreedy\"},{\"url\":\"https://twitter.com/mcreedytest\"}],\"webhookUrl\":\"http://www.fullcontact.com/hook\",\"recordId\":\"customer123\",\"personId\":\"VS1OPPPPvxHcCNPezUbvYBCDEAOdSj5AI0adsA2bLmh12345\",\"confidence\":\"HIGH\"}"
requestJson := "{\"emails\":[\"marianrd97@outlook.com\",\"test1@gmail.com\",\"test2@outlook.com\"],\"phones\":[\"123-4567890\"],\"dataFilter\":[\"individual\",\"social\"],\"maids\":[\"abcd-123-abcd-1234-abcdlkjhasdfgh\",\"1234-snbk-lkldiemvmruixp-2kdp-vdm\"],\"location\":{\"addressLine1\":\"123/23\",\"addressLine2\":\"Some Street\",\"city\":\"Denver\",\"region\":\"Denver\",\"regionCode\":\"123123\",\"postalCode\":\"23124\"},\"name\":{\"given\":\"Marian\",\"family\":\"Reed\",\"full\":\"Marian C Reed\"},\"profiles\":[{\"url\":\"https://twitter.com/mcreedy\"},{\"url\":\"https://twitter.com/mcreedytest\"}],\"webhookUrl\":\"http://www.fullcontact.com/hook\",\"recordId\":\"customer123\",\"personId\":\"VS1OPPPPvxHcCNPezUbvYBCDEAOdSj5AI0adsA2bLmh12345\",\"confidence\":\"HIGH\",\"verifiedPhysical\":true,\"expandedInterests\":true,\"maxMaids\":5}"
pr, err := NewPersonRequest(
WithName(NewPersonName(WithFull("Marian C Reed"), WithFamily("Reed"), WithGiven("Marian"))),
WithEmail("marianrd97@outlook.com"),
Expand All @@ -35,7 +35,11 @@ func TestMarshallNewPersonRequest(t *testing.T) {
WithMaid("1234-snbk-lkldiemvmruixp-2kdp-vdm"),
WithWebhookUrl("http://www.fullcontact.com/hook"),
WithRecordId("customer123"),
WithPersonId("VS1OPPPPvxHcCNPezUbvYBCDEAOdSj5AI0adsA2bLmh12345"))
WithPersonId("VS1OPPPPvxHcCNPezUbvYBCDEAOdSj5AI0adsA2bLmh12345"),
WithVerifiedPhysical(true),
WithMaxMaids(5),
WithExpandedInterests(true),
)
assert.NoError(t, err)
reqBytes, err := json.Marshal(pr)
assert.NoError(t, err)
Expand Down
Loading

0 comments on commit 5dbba76

Please sign in to comment.