Skip to content

Get raw response from Work Histories#7

Merged
ollymarsay merged 2 commits intomainfrom
include-unprocessed-as-option-in-work-history
Oct 6, 2025
Merged

Get raw response from Work Histories#7
ollymarsay merged 2 commits intomainfrom
include-unprocessed-as-option-in-work-history

Conversation

@ollymarsay
Copy link
Copy Markdown
Collaborator

Why?

  • To update the work histories table the raw json needs to be the raw format provided by the .all method

What?

  • This addition provides a flag include_raw which is true (DEFAULT: false), returns a hash of the parsed and raw data

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for retrieving raw response data from the Work Histories API by introducing an optional include_raw parameter to the all method. When enabled, it returns both parsed and raw data in a hash structure.

  • Added include_raw parameter to the all method with default value of false
  • Modified return value to optionally include both parsed data and raw response
  • Refactored method formatting for consistency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ollymarsay
Copy link
Copy Markdown
Collaborator Author

@lienvdsteen - i expect there might be a better way to do this, which is why I have left it in PR 🙇

Copy link
Copy Markdown
Owner

@lienvdsteen lienvdsteen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need both the parsed and the raw data, feel free to merge, otherwise I would move the return up and only return the raw data. But then maybe also change the variable to something like no_parsing or whatever.

I'll make an issue to think about how we can solve this for all endpoints vs just this one.

response = get("people/#{employee_id}/work")
WorkHistoryParser.new(response).work_histories
parsed = WorkHistoryParser.new(response).work_histories
return { data: parsed, raw: response.values.first } if include_raw
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be cool to solve this for all endpoints (so you can always choose if you want it parsed or not). That said, for the sake of moving you forward, I wouldn't do that. I'll thinker about it a bit. Do you still need the parsed data as well when you need the raw? If no, then I would move the return up:

response = get("people/#{employee_id}/work")
return { raw: respone.values.first } if include_raw

parsed = ...

Main reason to do that is that the parsing does create ruby objects and technically slows calling the endpoint down + it also takes up memory.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI Bob did also release a new endpoint to access work history for multiple employees at once https://apidocs.hibob.com/reference/get_bulk-people-work
(Not sure if that's useful for you here, just wanted to share)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome; I'll move the return up and get this in for now while we think about a wider fix; the JSON schema for updates is very opinionated it seems. In this case I am updating a line in the Work table in Bob, but they have make the PATCH ability legacy, so the new method is 1) read the line 2) pass the whole line with your changes back to it... it works, but it's not as easy to work with imo.

Thanks for the note on the the bulk! For my usecase not required right now, but might be work implementing regardless

@ollymarsay ollymarsay merged commit 1690c3b into main Oct 6, 2025
1 check passed
@ollymarsay ollymarsay deleted the include-unprocessed-as-option-in-work-history branch October 6, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants