-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from cultuurnet/rc-1.0
Release candidate for version 1.0
- Loading branch information
Showing
128 changed files
with
1,836 additions
and
2,540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
### Added | ||
|
||
- | ||
|
||
### Changed | ||
|
||
- | ||
|
||
### Removed | ||
|
||
- | ||
|
||
### Fixed | ||
|
||
- | ||
|
||
--- | ||
Ticket: https://jira.uitdatabank.be/browse/... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: CI | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
php-versions: ['7.1', '7.2', '7.3', '7.4'] | ||
name: PHP ${{ matrix.php-versions }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
ini-values: xdebug.mode=coverage | ||
extensions: intl | ||
tools: composer:v1 | ||
|
||
- name: Check PHP Version | ||
run: php -v | ||
|
||
- name: Validate composer.json | ||
run: composer validate | ||
|
||
- name: Install dependencies | ||
run: composer install --no-progress --no-suggest | ||
|
||
- name: Run Phing | ||
run: composer run-script phing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
vendor | ||
build | ||
coverage | ||
coverage | ||
composer.lock |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# search-v3 | ||
|
||
This PHP library allows you to integrate with publiq's Search API3. | ||
|
||
Full API documentation: https://documentatie.uitdatabank.be/content/search_api_3/latest/start.html <br /> | ||
Getting an API key: https://projectaanvraag.uitdatabank.be | ||
|
||
## Usage | ||
|
||
Set up a Guzzle client with a URL and API key for the test environment of Search API3 like this: | ||
|
||
```php | ||
$httpClient = new GuzzleHttp\Client([ | ||
'base_uri' => 'https://search-test.uitdatabank.be/', | ||
'headers' => [ | ||
'X-Api-Key' => 'YOUR_API_KEY_FOR_TEST_ENV', | ||
], | ||
]); | ||
``` | ||
|
||
Then, set up the search-v3 `SearchClient` like this: | ||
|
||
```php | ||
$searchClient = new CultuurNet\SearchV3\SearchClient( | ||
$httpClient, // HTTP client set up in the previous step | ||
new CultuurNet\SearchV3\Serializer() // Built-in serializer to deserialize the JSON responses | ||
); | ||
``` | ||
|
||
You can then perform searches like this: | ||
|
||
```php | ||
$searchQuery = new \CultuurNet\SearchV3\SearchQuery(); | ||
$events = $searchClient->searchEvents($searchQuery); // Search events | ||
$places = $searchClient->searchPlace($searchQuery); // Search places | ||
$offers = $searchClient->searchOffers($searchQuery); // Search both events + places | ||
``` | ||
|
||
The results are an instance of `\CultuurNet\SearchV3\ValueObjects\PagedCollection`, which supports the following methods: | ||
|
||
```php | ||
// Get pagination info | ||
$events->getItemsPerPage(); | ||
$events->getTotalItems(); | ||
|
||
// Get the search results, as instances of CultuurNet\SearchV3\ValueObjects\Event | ||
// and CultuurNet\SearchV3\ValueObjects\Place | ||
$events->getMember()->getItems(); | ||
|
||
// Get the facet results as an instance of CultuurNet\SearchV3\ValueObjects\FacetResults | ||
$events->getFacets(); | ||
``` | ||
|
||
To customize your search, you can configure `\CultuurNet\SearchV3\SearchQuery` like this: | ||
|
||
```php | ||
$searchQuery = new \CultuurNet\SearchV3\SearchQuery(); | ||
|
||
// Embed the JSON-LD of the search results, instead of only the ID and type. | ||
$searchQuery->setEmbed(true); | ||
|
||
// Set the number of which result to fetch first. Defaults to 0. | ||
// If the first page had a limit of 30 for example, and you want to get the results of the second page, set the start to | ||
// 30. (So the start is always the limit multiplied by the page number you want to get, starting with 0.) | ||
$searchQuery->setStart(0); | ||
|
||
// Set the max amount of results to return per page. | ||
$searchQuery->setLimit(30); | ||
|
||
// Add a sort (see SAPI3 docs for possible fields to sort on) | ||
$searchQuery->addSort('created', 'ASC'); | ||
|
||
// Remove a sort | ||
$searchQuery->removeSort('created'); | ||
|
||
// Add a search parameter (see src/Parameter for all options) | ||
$searchQuery->addParameter( | ||
new CultuurNet\SearchV3\Parameter\AudienceType( | ||
CultuurNet\SearchV3\Parameter\AudienceType::AUDIENCE_EDUCATION | ||
) | ||
); | ||
|
||
// Remove a search parameter (see src/Parameter for all options) | ||
$searchQuery->removeParameter( | ||
new CultuurNet\SearchV3\Parameter\AudienceType( | ||
CultuurNet\SearchV3\Parameter\AudienceType::AUDIENCE_EDUCATION | ||
) | ||
); | ||
``` | ||
|
||
Some parameters allow multiple options and can be added more than once: | ||
```php | ||
$searchQuery->addParameter(new CultuurNet\SearchV3\Parameter\Label('foo')); | ||
$searchQuery->addParameter(new CultuurNet\SearchV3\Parameter\Label('bar')); | ||
// Will return only results that have both labels. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.