Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Parsing of HTTPX::ErrorResponse and Add Hooks for Advanced Logging #25

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

obahareth
Copy link
Contributor

There are usecases when users of the SDK need to perform custom logic before the request is sent or response is parsed, so they can add context to exception monitoring platforms.

This change also adds the following two hooks:

  • Client#before_submitting_request
  • Client#before_parsing_response

These hooks can be used like so:

client = ZATCA::Client.new(username: "user", password: "pass", verbose: true)

client.before_submitting_request = proc do |method, url, body, headers|
  # method is a symbol
  # url is a string
  # body and headers are hashes
end

client.before_parsing_response = proc do |response|
  # Response is an instance of HTTPX::Response or HTTPX::ErrorResponse
end

There are usecases when users of the SDK need to perform custom logic before the request is sent or response is parsed, so they can add context to exception monitoring platforms.

This change also adds the following two hooks:
- `Client#before_submitting_request`
- `Client#before_parsing_response`
@obahareth obahareth merged commit 2cddf57 into main Dec 27, 2023
6 checks passed
@obahareth obahareth deleted the feature/logging-hooks branch December 27, 2023 15:18
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