Problem/Motivation

I'm creating an integration with an API-endpoint that can receive a json-payload in any structure. Meaning that the keys or properties depend on uri-variables. See https://developers.home-assistant.io/docs/api/rest/ (POST /api/services/{domain}/{service}) for more details. I'm aware of the json- and body-location types, but they both don't really apply.

Proposed resolution

There are 2 possible solutions:

  1. I add a new location type, Serializer and Deserializer and use those to create a new GuzzleClient in a decorated version of the Drupal\http_client_manager\HttpClient-class. This would remain private, in a separate module;
  2. Via a fork of this module, I create a new plugin type for locations, register the existing ones via a deriver regular plugin classes, create a new one for this specific need (can be discussed whether it should be part of this module) and use the plugin manager when creating new instances of the default Serializer and Deserializer.

Remaining tasks

Decide on the path to take, to see if solution 2 would bring value to this module.

API changes

A new plugin type would be introduced.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lammensj created an issue. See original summary.

lammensj’s picture

Issue summary: View changes
lammensj’s picture

Issue summary: View changes
lammensj’s picture

Issue summary: View changes
lammensj’s picture

Status: Active » Needs review

I've created the mentioned plugin manager and added plugins for the existing locations that are already part of the Guzzle-package. Let me know what you think :)

aronne’s picture

Hi @lammensj,
I took a look at your work and I really love what you've done.
I would avoid putting this implementation into a separate module, I prefer the 2nd option.
Tho we must be 100% sure this new implementation doesn't break already existing service descriptions so if you could add some tests it would be great!

lammensj’s picture

@aronne, glad you approve!
I've added some unit-tests for the specific plugins that are included, based on the same unit tests as for the guzzle-service package itself: see https://github.com/guzzle/guzzle-services/tree/1.4.0/tests/RequestLocation. I've also updated the HttpClient-test by prophezing the plugin manager and injecting it. Is this sufficient?

aronne’s picture

Hi @lammensj,
great job again, thank you.
Could you please open a MR or upload a patch so that we can go online with your feature?

Regards,
aronne

lammensj’s picture

PR for the general functionality is created.
What's your take on the additional RequestLocation-plugin for body-payloads without a key? Do you think it should be/can be included in this module or something a developer now might create itself?
Example: https://gist.github.com/lammensj/dca48a5bb9d8b659e1a79e8aaf380d4b

aronne’s picture

Hi @lammensj,
I think you could add it directly in this module.

lammensj’s picture

@aronne, I've added the extra plugin and a test to the PR.

  • lammensj authored 28c2e80a on 3.x
    Issue #3397521 by lammensj: Locations as plugin
    
aronne’s picture

Status: Needs review » Fixed

Hi @lammensj,
thank you for the great job you've done with this implementation.
I'm gonna create a new release soon.

Kind regards,
aronne

  • lammensj authored c73d8903 on 9.3.x
    Issue #3397521 by lammensj: Locations as plugin
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.