Skip to content

added arguments to 'get_adp_data' and 'send_web_request' to accept custom headers#1

Open
Mirkoffcito wants to merge 1 commit intoheliocola:mainfrom
Mirkoffcito:refactor-get-requests
Open

added arguments to 'get_adp_data' and 'send_web_request' to accept custom headers#1
Mirkoffcito wants to merge 1 commit intoheliocola:mainfrom
Mirkoffcito:refactor-get-requests

Conversation

@Mirkoffcito
Copy link

The idea behind this PR is to be able to send custom headers for using asynchronous calls (and allowing us to get 1000 registers at a time) and also to "unmask" masked data.

As ADP documentation states, sensitive data is masked per default in the API, and to receive it unmasked, a header must be sent.

"Accept": "application/json;masked=false".

In the same way, this would allow us to make asynchronous requests, by sending the header:

"Prefer": "respond-async".

Also, something i find quite necessary and useful, is for the method to return the entire HTTP response, and not just the JSON body. I made changes so anyone can decide whether they just want to get the JSON body or the full response (this becomes necessary for example when making asynchronous calls, because you need to access to the headers, to get the redirection URL).

…ull response instead of json_body only. Also removed 'sslCaPath' from requests
Comment on lines +114 to 115
body = JSON.parse(response.body) rescue {}
raise ConnectionException, "Connection error: #{data['error']}, #{data['error_description']}" unless data["error"].nil?
Copy link
Author

Choose a reason for hiding this comment

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

@heliocola Honestly I'm a little bit bummed that I couldn't come up with something smarter here. This is just weird and has "but what if" written all over it. I'll be thinking about it, I'm sure I can come up with a better error handling (well, I just wanted to re-use what ADP gem had already)

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.

1 participant