Problem/Motivation

Gotta start somewhere...

We need to create an initial (and bare bones) ApiClient class that we can extend and build upon. This might end up being taken care of or started by way of https://www.drupal.org/project/api_client/issues/3365959 but this issue can at least be used to validate the requirements for that implementation.

Proposed resolution

The ApiClient class will take the following arguments:
* baseUrl (string)
* options (object)

To start, options will have one property, apiPrefix (string)

The class will also implement an async fetch method, that to start will just be an interface to the default fetch.

It should be possible to both create an instance of the ApiClient class, and also extend it.

Remaining tasks

* Implement the ApiClient class
* Define necessary types
* Document the current ApiClient class inline.
* Add test coverage.

API changes

The ApiClient class will be created.

Issue fork api_client-3374181

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

brianperry created an issue. See original summary.

brianperry’s picture

Issue summary: View changes
coby.sher’s picture

To @jayhuskins point here: https://www.drupal.org/project/api_client/issues/3365506#comment-15098435

how can we implement this with support for localization right away?

Would that part be handled by the consumer of this library by passing in the locale to each request?

Should we require a default language like DrupalState did?

Or is the localization better handled in the JsonAPIClient instead of this base class?

brianperry’s picture

Status: Active » Needs work

This is mostly addressed by our initial project scaffolding, but I think likely needs more complete tests and possibly improved documentation.

brianperry’s picture

Assigned: Unassigned » brianperry

brianperry’s picture

Opened a draft MR with additional test coverage. Still need to take a quick look to see if anything else needs to be documented.

brianperry’s picture

Assigned: brianperry » Unassigned
Status: Needs work » Needs review
coby.sher’s picture

Status: Needs review » Reviewed & tested by the community
brianperry’s picture

Status: Reviewed & tested by the community » Fixed

Merged. Marking as fixed. Not sure what the deal is with the merge train failing here. Will have to keep an eye on that.

Status: Fixed » Closed (fixed)

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