Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdef committed Sep 4, 2024
1 parent 53ef1a7 commit 94f8a03
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 48 deletions.
16 changes: 8 additions & 8 deletions example/airtable/elden-ring-map/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ function register_airtable_elden_ring_map_block() {
}

$maps_config = [
'friendly_name' => $block_name . ' (Maps)',
'uid' => 'appqI3sJ9R2NcML8Y/tblS3OYo8tZOg04CP',
'endpoint' => 'https://api.airtable.com/v0/appqI3sJ9R2NcML8Y/tblS3OYo8tZOg04CP',
'friendly_name' => $block_name . ' (Maps)',
'uid' => 'appqI3sJ9R2NcML8Y/tblS3OYo8tZOg04CP',
'endpoint' => 'https://api.airtable.com/v0/appqI3sJ9R2NcML8Y/tblS3OYo8tZOg04CP',
'request_headers' => [
'Authorization' => "Bearer {$access_token}",
'Content-Type' => 'application/json',
],
];

$locations_config = [
'friendly_name' => $block_name . ' (Locations)',
'uid' => 'appqI3sJ9R2NcML8Y/tblc82R9msH4Yh6ZX',
'endpoint' => 'https://api.airtable.com/v0/appqI3sJ9R2NcML8Y/tblS3OYo8tZOg04CP',
'friendly_name' => $block_name . ' (Locations)',
'uid' => 'appqI3sJ9R2NcML8Y/tblc82R9msH4Yh6ZX',
'endpoint' => 'https://api.airtable.com/v0/appqI3sJ9R2NcML8Y/tblS3OYo8tZOg04CP',
'request_headers' => [
'Authorization' => "Bearer {$access_token}",
'Content-Type' => 'application/json',
],
];

$list_locations_query = new AirtableEldenRingListLocationsQuery( new HttpDatasource( $locations_config ) );
$list_maps_query = new AirtableEldenRingListMapsQuery( new HttpDatasource( $maps_config ) );
$list_locations_query = new AirtableEldenRingListLocationsQuery( new HttpDatasource( $locations_config ) );
$list_maps_query = new AirtableEldenRingListMapsQuery( new HttpDatasource( $maps_config ) );

ConfigurationLoader::register_block( $block_name, $list_locations_query );
ConfigurationLoader::register_list_query( $block_name, $list_maps_query );
Expand Down
6 changes: 3 additions & 3 deletions example/airtable/events/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ function register_airtable_events_block() {
}

$config = [
'friendly_name' => $block_name,
'uid' => 'appVQ2PAl95wQSo9S/tblyGtuxblLtmoqMI',
'endpoint' => 'https://api.airtable.com/v0/appVQ2PAl95wQSo9S/tblyGtuxblLtmoqMI',
'friendly_name' => $block_name,
'uid' => 'appVQ2PAl95wQSo9S/tblyGtuxblLtmoqMI',
'endpoint' => 'https://api.airtable.com/v0/appVQ2PAl95wQSo9S/tblyGtuxblLtmoqMI',
'request_headers' => [
'Authorization' => "Bearer {$access_token}",
'Content-Type' => 'application/json',
Expand Down
6 changes: 3 additions & 3 deletions example/rest-api/art-institute/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

function register_aic_block() {
$config = [
'friendly_name' => 'Art Institute of Chicago',
'uid' => 'aic_artworks',
'endpoint' => 'https://api.artic.edu/api/v1/artworks',
'friendly_name' => 'Art Institute of Chicago',
'uid' => 'aic_artworks',
'endpoint' => 'https://api.artic.edu/api/v1/artworks',
'request_headers' => [
'Content-Type' => 'application/json',
],
Expand Down
8 changes: 4 additions & 4 deletions example/rest-api/zip-code/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

function register_zipcode_block() {
$config = [
'friendly_name' => 'zippopotam.us',
'uid' => 'zippopotamus',
'endpoint' => 'https://api.zippopotam.us/us/90210',
'friendly_name' => 'zippopotam.us',
'uid' => 'zippopotamus',
'endpoint' => 'https://api.zippopotam.us/us/90210',
'request_headers' => [
'Content-Type' => 'application/json',
],
];

$zipcode_query = new GetZipCodeQuery( new HttpDatasource( $config ) );
$zipcode_query = new GetZipCodeQuery( new HttpDatasource( $config ) );

ConfigurationLoader::register_block( 'Zip Code', $zipcode_query );
}
Expand Down
10 changes: 5 additions & 5 deletions example/shopify/register.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ function register_shopify_block() {
}

$config = [
'friendly_name' => $block_name,
'uid' => 'stoph-test',
'endpoint' => 'https://stoph-test.myshopify.com/api/2024-04/graphql.json',
'friendly_name' => $block_name,
'uid' => 'stoph-test',
'endpoint' => 'https://stoph-test.myshopify.com/api/2024-04/graphql.json',
'request_headers' => [
'Content-Type' => 'application/json',
'X-Shopify-Storefront-Access-Token' => $access_token,
],
'image_url' => plugins_url( '../../assets/shopify_logo_black.png', __FILE__ ),
'image_url' => plugins_url( '../../assets/shopify_logo_black.png', __FILE__ ),
];

$block_pattern = file_get_contents( __DIR__ . '/inc/patterns/product-teaser.html' );
Expand Down Expand Up @@ -77,4 +77,4 @@ function register_blocks_for_shopify_data_source( array $config, string $block_p
ConfigurationLoader::register_query( $block_name, new ShopifyRemoveFromCartMutation( $shopify_datasource ) );

ConfigurationLoader::register_block_pattern( $block_name, 'remote-data-blocks/shopify-product-teaser', $block_pattern, [ 'title' => 'Shopify Product Teaser' ] );
}
}
2 changes: 1 addition & 1 deletion inc/config/http-datasource/http-datasource.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ public function get_request_headers(): array {
public function get_image_url(): ?string {
return $this->config['image_url'] ?? null;
}
}
}
42 changes: 21 additions & 21 deletions inc/rest/datasource-crud/datasource-crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ private static function validate_airtable_source( $source ) {
}

return [
'uuid' => $source->uuid,
'token' => sanitize_text_field( $source->token ),
'service' => 'airtable',
'base' => $source->base,
'table' => $source->table,
'slug' => sanitize_text_field( $source->slug ),
'uuid' => $source->uuid,
'token' => sanitize_text_field( $source->token ),
'service' => 'airtable',
'base' => $source->base,
'table' => $source->table,
'slug' => sanitize_text_field( $source->slug ),
// quick hack to transform data to our experimental format
'friendly_name' => sanitize_text_field( $source->slug ),
'uid' => hash( 'sha256', $source->slug ),
'endpoint' => 'https://api.airtable.com/v0/' . $source->base['id'] . '/' . $source->table['id'],
'friendly_name' => sanitize_text_field( $source->slug ),
'uid' => hash( 'sha256', $source->slug ),
'endpoint' => 'https://api.airtable.com/v0/' . $source->base['id'] . '/' . $source->table['id'],
'request_headers' => [
'Authorization' => 'Bearer ' . $source->token,
'Content-Type' => 'application/json',
'Content-Type' => 'application/json',
],
'image_url' => null,
'image_url' => null,
];
}

Expand All @@ -115,20 +115,20 @@ public static function validate_shopify_source( $source ) {
}

return [
'uuid' => $source->uuid,
'token' => sanitize_text_field( $source->token ),
'service' => 'shopify',
'store' => sanitize_text_field( $source->store ),
'slug' => sanitize_text_field( $source->slug ),
'uuid' => $source->uuid,
'token' => sanitize_text_field( $source->token ),
'service' => 'shopify',
'store' => sanitize_text_field( $source->store ),
'slug' => sanitize_text_field( $source->slug ),
// quick hack totransform data to our experimental format
'friendly_name' => sanitize_text_field( $source->slug ),
'uid' => hash( 'sha256', $source->slug ),
'endpoint' => 'https://' . $source->store . '.myshopify.com/api/2024-04/graphql.json',
'friendly_name' => sanitize_text_field( $source->slug ),
'uid' => hash( 'sha256', $source->slug ),
'endpoint' => 'https://' . $source->store . '.myshopify.com/api/2024-04/graphql.json',
'request_headers' => [
'Content-Type' => 'application/json',
'Content-Type' => 'application/json',
'X-Shopify-Storefront-Access-Token' => $source->token,
],
'image_url' => plugins_url( '../../assets/shopify_logo_black.png', __FILE__ ),
'image_url' => plugins_url( '../../assets/shopify_logo_black.png', __FILE__ ),
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/inc/config/QueryRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp(): void {

$this->http_datasource = new HttpDatasource( [
'endpoint' => 'https://api.example.com',
'headers' => [ 'Content-Type' => 'application/json' ],
'headers' => [ 'Content-Type' => 'application/json' ],
] );

$this->query_context = new class($this->http_datasource) implements HttpQueryContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function testIsRegisteredBlockReturnsFalseWhenNoConfigurations() {
public function testIsRegisteredBlockReturnsTrueForRegisteredBlock() {
$http_datasource = new HttpDatasource( [
'endpoint' => 'https://api.example.com',
'headers' => [ 'Content-Type' => 'application/json' ],
'headers' => [ 'Content-Type' => 'application/json' ],
] );
ConfigurationLoader::register_block( 'some_slick_block', new QueryContext( $http_datasource ) );
$this->assertTrue( ConfigurationLoader::is_registered_block( 'remote-data-blocks/some_slick_block' ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestQueryContext extends QueryContext {
public function __construct( private QueryRunnerInterface $mock_qr ) {
parent::__construct( new HttpDatasource( [
'endpoint' => 'https://api.example.com',
'headers' => [ 'Content-Type' => 'application/json' ],
'headers' => [ 'Content-Type' => 'application/json' ],
] ) );
}

Expand Down

0 comments on commit 94f8a03

Please sign in to comment.