Skip to content

Commit

Permalink
parse associations data generically
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwas Shashidhar committed Dec 7, 2021
1 parent a20ad09 commit 7d0cab7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ func (b *bullhornClient) validateEntity(name string) error {
return fmt.Errorf("unsupported entity %s", name)
}

func (b *bullhornClient) parseResponseForEntity(name string, data interface{}) (interface{}, error) {
func (b *bullhornClient) parseResponseForEntity(name string, data interface{}, associations []string) (interface{},
error) {
if len(associations) > 0 {
var resp interface{}
err := b.B.ParseResponse(data, &resp)
if err != nil {
return nil, err
}
return resp, nil
}
switch name {
case "Candidate":
var candidate Candidate
Expand Down Expand Up @@ -160,7 +169,7 @@ func (b *bullhornClient) GetEntity(name string, id int, options QueryOptions) (*
return rr, nil, errors.New(bhErr.Message)
}
dataMap := cr.Data.(map[string]interface{})
responseData, err := b.parseResponseForEntity(name, dataMap["data"])
responseData, err := b.parseResponseForEntity(name, dataMap["data"], options.Associations)
if err != nil {
return rr, nil, err
}
Expand Down

0 comments on commit 7d0cab7

Please sign in to comment.