Skip to content

Commit f920e79

Browse files
ingeniumedchriszaratealecgeatches
authored
Add Salesforce D2C as a data source (#372)
* 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]>
1 parent e350711 commit f920e79

32 files changed

+881
-507
lines changed

docs/extending/block-registration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The render query is executed when the block is rendered and fetches the data tha
7070

7171
### `selection_queries`: array (optional)
7272

73-
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:
73+
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:
7474

7575
- `display_name`: A human-friendly name for the selection query.
7676
- `query` (required): An instance of `QueryInterface` that fetches the data.

inc/Config/QueryRunner/QueryRunner.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ public function execute( HttpQueryInterface $query, array $input_variables ): ar
203203
if ( ! array_key_exists( $key, $input_variables ) && isset( $schema['default_value'] ) ) {
204204
$input_variables[ $key ] = $schema['default_value'];
205205
}
206+
207+
// If the input variable is required and not provided, return an error.
208+
if ( ! array_key_exists( $key, $input_variables ) && isset( $schema['required'] ) && $schema['required'] ) {
209+
return new WP_Error( 'remote-data-blocks-missing-required-input-variable', sprintf( 'Missing required input variable: %s', $key ) );
210+
}
206211
}
207212

208213
$raw_response_data = $this->get_raw_response_data( $query, $input_variables );

inc/Integrations/SalesforceB2C/Auth/SalesforceB2CAuth.php

Lines changed: 0 additions & 247 deletions
This file was deleted.

0 commit comments

Comments
 (0)