Skip to content

Commit

Permalink
Add Salesforce D2C as a data source (#372)
Browse files Browse the repository at this point in the history
* Replace Salesforce b2c with d2c

* Fix a missing product_id field

* Skip empty search queries, and map the name correctly

* Use the constant instead of the hardcoded value

* Use null coalescing

Co-authored-by: Chris Zarate <[email protected]>

* Safety when returning the token

Co-authored-by: Chris Zarate <[email protected]>

* Remove the unnecessary memo

* Attempt to only fire the fetch for required variables

* Got the search and productId queries working

* Fix the search and productId lookups

* Add support for token expiry

* Strengthen the empty query checks

* Simplify the search query check, fix the expiry time and add more comments

* Add an additional layer of checks for subsequent fetches

* Fix the search functionality, and ensure missing required variables don't fire queries

* Refactor the salesforce setup screen to be a lot more user friendly

* Move the auth call to the server and simplify the setup page

* Fix the docblock and the unsafe use of wp_remote_get

* Center-align "Salesforce D2C" text in "Connect New" menu

* Add error state and fix bugs in useRemoteData

* Fix type error: Names are optional

* Separate logic for initial fetch and refetch

* Fix comment

* PR Feedback

* Add more validation for the domain of the salesforce url

---------

Co-authored-by: Chris Zarate <[email protected]>
Co-authored-by: Alec Geatches <[email protected]>
  • Loading branch information
3 people authored Feb 21, 2025
1 parent e350711 commit f920e79
Show file tree
Hide file tree
Showing 32 changed files with 881 additions and 507 deletions.
2 changes: 1 addition & 1 deletion docs/extending/block-registration.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ The render query is executed when the block is rendered and fetches the data tha

### `selection_queries`: array (optional)

Selection queries are used by content creators to select or curate remote data in the block editor. For example, you may wish to provide a list of products to users and allow them to select one to incled, or you may want to allow a user to search for a specific item. Selection queries are an array of objects with the following properties:
Selection queries are used by content creators to select or curate remote data in the block editor. For example, you may wish to provide a list of products to users and allow them to select one to include in their post, or you may want to allow a user to search for a specific item. Selection queries are an array of objects with the following properties:

- `display_name`: A human-friendly name for the selection query.
- `query` (required): An instance of `QueryInterface` that fetches the data.
Expand Down
5 changes: 5 additions & 0 deletions inc/Config/QueryRunner/QueryRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ public function execute( HttpQueryInterface $query, array $input_variables ): ar
if ( ! array_key_exists( $key, $input_variables ) && isset( $schema['default_value'] ) ) {
$input_variables[ $key ] = $schema['default_value'];
}

// If the input variable is required and not provided, return an error.
if ( ! array_key_exists( $key, $input_variables ) && isset( $schema['required'] ) && $schema['required'] ) {
return new WP_Error( 'remote-data-blocks-missing-required-input-variable', sprintf( 'Missing required input variable: %s', $key ) );
}
}

$raw_response_data = $this->get_raw_response_data( $query, $input_variables );
Expand Down
247 changes: 0 additions & 247 deletions inc/Integrations/SalesforceB2C/Auth/SalesforceB2CAuth.php

This file was deleted.

Loading

0 comments on commit f920e79

Please sign in to comment.