Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Add last changed API #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lawrence-c
Copy link

Resolves #50.

Not sure if there is a better way of converting converting the request payload to stop it from percent encoding the ISO timestamp...

# Convert payload to stop percent encoding the URL for requests
payload_str = "&".join("%s=%s" % (k,v) for k,v in payload.items())

r = requests.get(url, timeout=self.timeout, headers=self.headers, params=payload_str, auth=(self.api_key, ''))
Copy link

Choose a reason for hiding this comment

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

Why don't you pass params=payload instead of building the string. Compare https://requests.readthedocs.io/en/master/user/quickstart/#passing-parameters-in-urls


```

Note: Last change timestamps are a newer feature in BambooHR, and they only started recording these dates from June 5th, 2011.
Copy link

Choose a reason for hiding this comment

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

2011 is quite some time ago. I think it's fine to drop this info from the README 😉

@horida
Copy link

horida commented Jun 18, 2020

Hi @lawrence-c

Thanks for your contribution and sorry for responding sooo late.

One little request: could you add a test for the new API call?

Cheers!

@lawrence-c
Copy link
Author

Hey @horida,

Thanks for the review, however I don't have access to a BambooHR system anymore, so don't think I'd be able to do anymore changes to this MR.

Please feel free to take over this MR however :)

@horida
Copy link

horida commented Jul 3, 2020

Tested in sandbox account. It's working fine.

Thanks @lawrence-c for implementing this.

@horida
Copy link

horida commented Jul 3, 2020

@smeggingsmegger could you please merge this PR. Thanks

r = requests.get(url, timeout=self.timeout, headers=self.headers, params=payload_str, auth=(self.api_key, ''))
r.raise_for_status()

last_changed = r.json()
Copy link

Choose a reason for hiding this comment

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

possible crash bug if r.text is not json parsable, e.g., timeout.

Copy link

Choose a reason for hiding this comment

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

Yes, but I'd open a different issue for to improve the code because this affects all API methods. @vahedq could you open an new issue with this? And if you have a fix at hand, a PR would be highly appreciated 😬

Nevertheless, it is expected that BambooHR answers with a JSON, so not critical.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Last changed information
3 participants