Skip to content

Commit

Permalink
Merge pull request #16 from fullcontact/badge
Browse files Browse the repository at this point in the history
badge: fc module
  • Loading branch information
Ken Michie authored Feb 9, 2024
2 parents fd2b50f + 7fa2a06 commit 7f35542
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 55 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
go-version: '1.20'

- name: Build
run: go build -v ./...
working-directory: fc
run: go build -v .

- name: Test
run: go test -v ./...
working-directory: fc
run: go test -v .
158 changes: 105 additions & 53 deletions fc/fullcontact.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fullcontact
import (
"bytes"
"encoding/json"
"io"
"io/ioutil"
"net/http"
"time"
Expand Down Expand Up @@ -141,8 +142,11 @@ func sendToChannel(ch chan *APIResponse, response *http.Response, url string, er
return
}

/* FullContact V3 Person Enrich API, takes an PersonRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact V3 Person Enrich API, takes an PersonRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) PersonEnrich(personRequest *PersonRequest) chan *APIResponse {
ch := make(chan *APIResponse)

Expand All @@ -166,8 +170,11 @@ func (fcClient *fullContactClient) PersonEnrich(personRequest *PersonRequest) ch
return ch
}

/* FullContact V3 Company Enrich API, takes an CompanyRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact V3 Company Enrich API, takes an CompanyRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) CompanyEnrich(companyRequest *CompanyRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if companyRequest == nil {
Expand All @@ -190,9 +197,12 @@ func (fcClient *fullContactClient) CompanyEnrich(companyRequest *CompanyRequest)
return ch
}

/* Resolve
/*
Resolve
FullContact Resolve API - IdentityMap, takes an ResolveRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) IdentityMap(resolveRequest *ResolveRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if resolveRequest == nil {
Expand All @@ -207,9 +217,12 @@ func (fcClient *fullContactClient) IdentityMap(resolveRequest *ResolveRequest) c
return fcClient.resolveRequest(ch, resolveRequest, identityMapUrl)
}

/* Resolve
/*
Resolve
FullContact Resolve API - IdentityResolve, takes an ResolveRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) IdentityResolve(resolveRequest *ResolveRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if resolveRequest == nil {
Expand All @@ -224,9 +237,12 @@ func (fcClient *fullContactClient) IdentityResolve(resolveRequest *ResolveReques
return fcClient.resolveRequest(ch, resolveRequest, identityResolveUrl)
}

/* Resolve
/*
Resolve
FullContact Resolve API - IdentityMapResolve, takes an ResolveRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) IdentityMapResolve(resolveRequest *ResolveRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if resolveRequest == nil {
Expand All @@ -241,9 +257,12 @@ func (fcClient *fullContactClient) IdentityMapResolve(resolveRequest *ResolveReq
return fcClient.resolveRequest(ch, resolveRequest, identityMapResolveUrl)
}

/* Resolve
/*
Resolve
FullContact Resolve API - IdentityResolve with Tags in response, takes an ResolveRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) IdentityResolveWithTags(resolveRequest *ResolveRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if resolveRequest == nil {
Expand All @@ -258,9 +277,12 @@ func (fcClient *fullContactClient) IdentityResolveWithTags(resolveRequest *Resol
return fcClient.resolveRequest(ch, resolveRequest, identityResolveWithTagsUrl)
}

/* Resolve
/*
Resolve
FullContact Resolve API - IdentityDelete, takes an ResolveRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) IdentityDelete(resolveRequest *ResolveRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if resolveRequest == nil {
Expand All @@ -286,8 +308,11 @@ func (fcClient *fullContactClient) resolveRequest(ch chan *APIResponse, resolveR
return ch
}

/* FullContact API for adding/creating tags for any recordId in your PIC, takes a TagsRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact API for adding/creating tags for any recordId in your PIC, takes a TagsRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) TagsCreate(tagsRequest *TagsRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if tagsRequest == nil {
Expand All @@ -305,8 +330,11 @@ func (fcClient *fullContactClient) TagsCreate(tagsRequest *TagsRequest) chan *AP
return ch
}

/* FullContact API for getting all tags for any recordId in your PIC, takes a 'recordId' and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact API for getting all tags for any recordId in your PIC, takes a 'recordId' and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) TagsGet(recordId string) chan *APIResponse {
ch := make(chan *APIResponse)
if !isPopulated(recordId) {
Expand All @@ -320,8 +348,11 @@ func (fcClient *fullContactClient) TagsGet(recordId string) chan *APIResponse {
return ch
}

/* FullContact API for deleting any tag(s) for any recordId in your PIC, takes a TagsRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact API for deleting any tag(s) for any recordId in your PIC, takes a TagsRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) TagsDelete(tagsRequest *TagsRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if tagsRequest == nil {
Expand All @@ -339,8 +370,11 @@ func (fcClient *fullContactClient) TagsDelete(tagsRequest *TagsRequest) chan *AP
return ch
}

/* FullContact API for creating Audience based on tags from your PIC, takes a AudienceRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact API for creating Audience based on tags from your PIC, takes a AudienceRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) AudienceCreate(audienceRequest *AudienceRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if audienceRequest == nil {
Expand All @@ -358,8 +392,11 @@ func (fcClient *fullContactClient) AudienceCreate(audienceRequest *AudienceReque
return ch
}

/* FullContact API for downloading Audience created using 'AudienceCreate', takes a requestId and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact API for downloading Audience created using 'AudienceCreate', takes a requestId and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) AudienceDownload(requestId string) chan *APIResponse {
ch := make(chan *APIResponse)
if !isPopulated(requestId) {
Expand All @@ -373,9 +410,12 @@ func (fcClient *fullContactClient) AudienceDownload(requestId string) chan *APIR
return ch
}

/* Permission
/*
Permission
FullContact Permission API - PermissionCreate, takes an PermissionRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) PermissionCreate(permissionRequest *PermissionRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if permissionRequest == nil {
Expand All @@ -398,26 +438,38 @@ func (fcClient *fullContactClient) PermissionCreate(permissionRequest *Permissio
return ch
}

/* FullContact Permission API - PermissionDelete, takes an PermissionRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact Permission API - PermissionDelete, takes an PermissionRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) PermissionDelete(multifieldRequest *MultifieldRequest) chan *APIResponse {
return fcClient.validateAndSendMultiFieldRequestAsync(permissionDeleteUrl, multifieldRequest)
}

/* FullContact Permission API - PermissionFind, takes an PermissionRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact Permission API - PermissionFind, takes an PermissionRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) PermissionFind(multifieldRequest *MultifieldRequest) chan *APIResponse {
return fcClient.validateAndSendMultiFieldRequestAsync(permissionFindUrl, multifieldRequest)
}

/* FullContact Permission API - PermissionCurrent, takes an PermissionRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact Permission API - PermissionCurrent, takes an PermissionRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) PermissionCurrent(multifieldRequest *MultifieldRequest) chan *APIResponse {
return fcClient.validateAndSendMultiFieldRequestAsync(permissionCurrentUrl, multifieldRequest)
}

/* FullContact Permission API - PermissionVerify, takes an PermissionRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request */
/*
FullContact Permission API - PermissionVerify, takes an PermissionRequest and returns a channel of type APIResponse.
Request is converted to JSON and sends a Asynchronous request
*/
func (fcClient *fullContactClient) PermissionVerify(permissionRequest *PermissionRequest) chan *APIResponse {
ch := make(chan *APIResponse)
if permissionRequest == nil {
Expand Down Expand Up @@ -471,11 +523,11 @@ func (fcClient *fullContactClient) VerifyActivity(multifieldRequest *MultifieldR
}

/*
This function will perform the `MultifieldRequest` validations and if
there are no errors then it'll be marshalled and a `MultifieldRequest` will be
made to the specified `url`
This function will perform the `MultifieldRequest` validations and if
there are no errors then it'll be marshalled and a `MultifieldRequest` will be
made to the specified `url`
Returns a channel frm which the request response can be obtained
Returns a channel frm which the request response can be obtained
*/
func (fcClient *fullContactClient) validateAndSendMultiFieldRequestAsync(url string, multifieldRequest *MultifieldRequest) chan *APIResponse {
ch := make(chan *APIResponse)
Expand Down Expand Up @@ -531,7 +583,7 @@ func setCompanyResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -556,7 +608,7 @@ func setResolveResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -581,7 +633,7 @@ func setResolveResponseWithTags(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -606,7 +658,7 @@ func setTagsResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -632,7 +684,7 @@ func setAudienceResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -656,12 +708,12 @@ func setAudienceResponse(apiResponse *APIResponse) {
}

func setPermissionCreateResponse(apiResponse *APIResponse) {
_, err := ioutil.ReadAll(apiResponse.RawHttpResponse.Body)
bodyBytes, err := ioutil.ReadAll(apiResponse.RawHttpResponse.Body)
defer apiResponse.RawHttpResponse.Body.Close()

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -672,12 +724,12 @@ func setPermissionCreateResponse(apiResponse *APIResponse) {
}

func setPermissionDeleteResponse(apiResponse *APIResponse) {
_, err := ioutil.ReadAll(apiResponse.RawHttpResponse.Body)
bodyBytes, err := ioutil.ReadAll(apiResponse.RawHttpResponse.Body)
defer apiResponse.RawHttpResponse.Body.Close()

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -693,7 +745,7 @@ func setPermissionFindResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -718,7 +770,7 @@ func setPermissionVerifyResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -743,7 +795,7 @@ func setPermissionCurrentResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -768,7 +820,7 @@ func setVerfiySignalsResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -793,7 +845,7 @@ func setVerfiyMatchResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand All @@ -818,7 +870,7 @@ func setVerfiyActivityResponse(apiResponse *APIResponse) {

// Reset the buffer so that it can be re-read by the caller.
apiResponse.RawHttpResponse.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

if err != nil {
apiResponse.Err = err
return
Expand Down

0 comments on commit 7f35542

Please sign in to comment.