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

184366331 Contify: subscribe_to_webhook returns :ok on error responses. #8

Conversation

crova
Copy link
Contributor

@crova crova commented Feb 1, 2023

Comment

Let me know if you see any issues.

Manually tested with a couple of Enaia's existing webhooks and the returned response looked like what you specified:

{:error,
 %ContifyAPI.Model.Error{
   code: 100,
   fields: "",
   message: "Internal Error. Please check if you are providing all necessary details."
 }}

Cheers.

@crova
Copy link
Contributor Author

crova commented Feb 1, 2023

Update:
There is an open issue within Tesla about tests not supporting the use of the timeout middleware.
After talking with Ricardo, we came to the conclusion that skipping the middleware while on test env would be a good idea.

Let me know if you see any issues.

Cheers.

Comment on lines 108 to 129
if Mix.env() == :test do
[
{Tesla.Middleware.BaseUrl, base_url},
{Tesla.Middleware.Headers, [{"user-agent", user_agent}]},
{Tesla.Middleware.Headers, [{"APPSECRET", app_secret}]},
{Tesla.Middleware.Headers, [{"APPID", app_id}]},
{Tesla.Middleware.EncodeJson, engine: json_engine}
| middleware
]
else
timeout = Application.get_env(:contify, :timeout, @default_timeout)

[
{Tesla.Middleware.BaseUrl, base_url},
{Tesla.Middleware.Headers, [{"user-agent", user_agent}]},
{Tesla.Middleware.Headers, [{"APPSECRET", app_secret}]},
{Tesla.Middleware.Headers, [{"APPID", app_id}]},
{Tesla.Middleware.Timeout, timeout: timeout},
{Tesla.Middleware.EncodeJson, engine: json_engine}
| middleware
]
end
Copy link
Contributor

Choose a reason for hiding this comment

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

hey @crova I think it would be best here to check if timeout is 0 and if so skip the Timeout Middleware.
And then put Application.put_env(:contify, :timeout, 0) on the test_helpers.exs? so that it gets configured as 0 before the test suite starts (I think)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback @imricardoramos, I'll make the change and see how that goes.

@crova
Copy link
Contributor Author

crova commented Feb 1, 2023

@imricardoramos , does this look better?

@crova crova requested a review from imricardoramos February 1, 2023 14:58
@imricardoramos
Copy link
Contributor

@imricardoramos , does this look better?

yep, looks good. Does it work though?

@neilberkman
Copy link
Collaborator

yep, looks good. Does it work though?

Verified that it works 👍

@neilberkman neilberkman merged commit 5071ee1 into main Feb 1, 2023
@neilberkman neilberkman deleted the 184366331-contify-subscribe-to-webhook-returns-ok-on-error-responses branch February 1, 2023 16:57
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