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

PassengerAPI | Fix updating language #187

Merged
merged 1 commit into from Feb 7, 2023
Merged

PassengerAPI | Fix updating language #187

merged 1 commit into from Feb 7, 2023

Conversation

phylor
Copy link
Collaborator

@phylor phylor commented Feb 6, 2023

Currently, the Passenger#update_language endpoint doesn't work as expected.

What should happen:

  1. Call my_passenger_client.update_language('fr')
  2. ioki-ruby calls PATCH /api/passenger/user/language and sets the Accept-Language header to fr. That header is used to set the language. There is no body or path parameters.

What actually happens:

  1. ioki-ruby is initialized with a Ioki::Configuration. At that point the language is taken from the configuration and an HTTP adapter is initialized as config.http_adapter with that language.
  2. Call my_passenger_client.update_language('fr')
  3. The method sets config.language to the new language and then makes the HTTP request
  4. However, the new config has no effect, because the HTTP adapter has been initialised with the initial configuration.

So we have to re-initialize the HTTP adapter, so that the new language takes effect and is sent as the HTTP header.

The HTTP adapter is initialized when the configuration is initialized. When changing the language later, the client still uses the old values. We therefore have to reinitialize the HTTP adapter when the config is changed.
@phylor phylor marked this pull request as ready for review February 6, 2023 16:46
@phylor phylor requested a review from tom-ioki February 6, 2023 16:46
Copy link
Contributor

@tom-ioki tom-ioki left a comment

Choose a reason for hiding this comment

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

That sounds annoying to debug. Nice fix 👍 Thanks

@phylor phylor merged commit 888a81d into main Feb 7, 2023
@phylor phylor deleted the fix/update-language branch February 7, 2023 10:28
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.

None yet

2 participants