Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.0 #11

Merged
merged 70 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
01fea31
Add autocomplete() + get() methods and new response classes
clnt Apr 24, 2022
6e09d0e
StyleCI fixes
clnt Apr 24, 2022
f0d56cd
Fix return type hints
clnt Apr 25, 2022
48573ff
Laravel 10 support
clnt Apr 23, 2023
089fe3f
Merge branch '1.1.0-dev' into 2.0.0-dev
clnt May 1, 2023
d75ff87
Update composer.json and CI
clnt May 1, 2023
734899f
Update gitlab-ci.yml
clnt May 1, 2023
7f5d6f6
Update gitlab-ci.yml and Dockerfile
clnt May 1, 2023
acdd2f8
Set allow_failure to true on linting job
clnt May 1, 2023
997e3e6
Add exception handler class, refactor to match instead of switch
clnt May 1, 2023
88d0eb5
Tidy up some classes, add guzzle
clnt May 1, 2023
cda8909
Merge current 2.0.0 WIP changes
clnt Jan 17, 2024
f1962e4
Update coding standards package
clnt Jan 22, 2024
728e209
Add new http client singleton with get() method
clnt Feb 8, 2024
c6e0279
Pull in new http client and drop extending base class
clnt Feb 8, 2024
40086f9
Migration linting updates
clnt Feb 8, 2024
8a966ba
Add fake api key definitions in phpunit.xml
clnt Feb 8, 2024
69fa53a
Add PHP 8.3 to CI
clnt Feb 8, 2024
3b225fb
Add ResponseFactory and example response json to unit test response c…
clnt Feb 8, 2024
aa3b873
Add coverage on respond method
clnt Feb 8, 2024
938a042
Cover construct method
clnt Feb 8, 2024
0c68dc6
Remove currently unused classes
clnt Feb 8, 2024
434e381
Rename exceptions
clnt Feb 8, 2024
e311b34
Add CachedAddressFactory and test
clnt Feb 8, 2024
6ff09b5
Update phpunit.xml to use sqlite memory database
clnt Feb 8, 2024
06371e4
Add ManagerTest
clnt Feb 12, 2024
de0e1ed
Update default php image to 8.3
clnt Feb 12, 2024
2e75f79
Update php base image to 8.3
clnt Feb 12, 2024
e88c6d1
Add test for responseToCache() method
clnt Feb 12, 2024
3f138de
Add getHttpFake() method to ResponseFactory
clnt Feb 13, 2024
ed2f63c
Add GetAddress feature test
clnt Feb 13, 2024
8114927
Add tests to cover cache responses
clnt Feb 13, 2024
961f340
Add private call() method to http Client to allow multiple methods
clnt Feb 13, 2024
3163859
Add support for autocomplete and get methods, test coverage
clnt Feb 13, 2024
46ac4a2
Add test to cover autocomplete json response
clnt Feb 13, 2024
22fc71e
Cover toArray() method on AddressCollectionResponse
clnt Feb 13, 2024
7aef0db
Cover getAddresses() and remove Arr:wrap() on SingleAddress
clnt Feb 13, 2024
4b57da2
Remove GetAddressBase
clnt Feb 13, 2024
b929616
Temporarily remove GetAddressAdmin class and facade
clnt Feb 13, 2024
76dfbc6
Add better coverage to Address response
clnt Feb 14, 2024
89a79ae
Tidy up ExpandedAddress class
clnt Feb 14, 2024
d850e36
Add ExpandedAddressTest
clnt Feb 14, 2024
78e9c37
Drop sameAs() method and update ExpandedAddressTest
clnt Feb 14, 2024
488f3ef
Update ExpandedAddressTest
clnt Feb 14, 2024
4094b84
Add AddressTest and refactor array_filter callback on toString()
clnt Feb 14, 2024
2b5894c
Cover sameAs method on Address response
clnt Feb 14, 2024
45987f5
Cover expanded addresses in AddressCollectionResponse
clnt Feb 14, 2024
7990c56
Cover storing response to cache on find
clnt Feb 14, 2024
c9459d4
Fix failing test
clnt Feb 15, 2024
07a5a57
Use (array) cast on ExpandedAddress
clnt Feb 15, 2024
bcb0bfb
Pass expand through to cache Manager
clnt Feb 15, 2024
c9e3be8
Add new test to GetAddressTest
clnt Feb 15, 2024
c617b3b
Cover expanded Manager cache response
clnt Feb 15, 2024
dc523e4
Add expanded_results config option to test
clnt Feb 15, 2024
4c152be
Add getHttpErrorFake method to ResponseFactory, add 429 error coverage
clnt Feb 15, 2024
6a4a274
Remove unrequired if statement
clnt Feb 15, 2024
ab86f74
Add test to cover 500 server error
clnt Feb 15, 2024
28441b7
Remove if statement breaking tests
clnt Feb 15, 2024
7c6c34c
Refactor exception handler test and tidy exception classes
clnt Feb 18, 2024
a4e1e31
Add is_array() check before creating expanded address
clnt Feb 19, 2024
051c35d
Add GitHub actions config
clnt Feb 22, 2024
9c5a350
Update CHANGELOG.md
clnt Feb 22, 2024
2078ae5
Update README.md
clnt Feb 22, 2024
b3ba2ea
Add type hint and return type hints
clnt Feb 22, 2024
20948b9
Fix linting step in actions config
clnt Feb 22, 2024
56627af
Update github actions config
clnt Feb 22, 2024
4aca9c2
Remove codecov bash call
clnt Feb 22, 2024
8d350e3
Fix linting
clnt Feb 22, 2024
d352bbd
Revert code coverage upload to existing method
clnt Feb 22, 2024
8558ee5
Fix composer.json
clnt Feb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG PHP_IMAGE="php:8.3"
FROM $PHP_IMAGE
ARG PHP_IMAGE

RUN apt-get update

RUN apt autoremove -y
RUN apt-get install libicu-dev zip -y --no-install-recommends
RUN apt-get install libmcrypt-dev -y --no-install-recommends
RUN apt-get install git unzip -y
RUN docker-php-ext-install mysqli pdo_mysql bcmath

COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

RUN apt-get install zlib1g-dev libzip-dev -y --no-install-recommends
RUN docker-php-ext-install zip

RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

ENV XDEBUG_MODE=coverage

RUN rm -rf /var/lib/apt/lists/*
80 changes: 80 additions & 0 deletions .github/workflows/.github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI

on:
push:
branches:
- master
- dev
tags:
- 1.*
- 2.*
pull_request:
branches: [ master ]

workflow_dispatch:

jobs:
phpcs:
strategy:
matrix:
version: ['8.1', '8.2', '8.3']
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.version }}
tools: composer:v2

- name: Install composer packages
run: |
php -v
composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts

- name: Execute PHP_CodeSniffer
run: |
php -v
composer phpcs

phpunit:
strategy:
matrix:
version: ['8.1', '8.2', '8.3']
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.version }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, intl, exif, iconv
coverage: xdebug

- name: Install composer packages
run: |
php -v
composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts

- name: Execute tests
run: |
php -v
./vendor/phpunit/phpunit/phpunit --version
./vendor/phpunit/phpunit/phpunit --coverage-clover=coverage.xml
export CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }}
bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload'

- name: Upload code coverage
run: |
export CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }}
bash <(curl -s https://codecov.io/bash) || echo 'Codecov failed to upload'
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ bootstrap/cache/
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/extensions.json

composer.lock
130 changes: 130 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
stages:
- docker
- build
- lint
- test

# ========= Anchors (Partials) =========
.php_base: &php_base
image: $CI_REGISTRY_IMAGE/php:8.3
tags:
- docker

.test_base: &test_base
stage: test
before_script:
- rm -rf vendor
- php -d memory_limit=-1 /usr/bin/composer require --dev phpunit/phpunit:^$PHPUNIT_VERSION
- php -d memory_limit=-1 /usr/bin/composer install
script:
- composer du
- composer test:coverage
artifacts:
when: on_failure
expire_in: 4 hours
paths:
- storage/logs/
reports:
junit: coverage/phpunit.junit.xml
coverage_report:
coverage_format: cobertura
path: coverage/cobertura.xml
coverage: /^\s*Lines:\s*\d+.\d+\%/
tags:
- docker

.docker_base: &docker_base
stage: docker
image: docker:20.10.8-alpine3.14
services:
- docker:20.10.8-dind-alpine3.14
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $CONTAINER_IMAGE:$PHP_VERSION || true
- docker build --cache-from $CONTAINER_IMAGE:$PHP_VERSION --build-arg PHP_IMAGE=php:$PHP_VERSION -t $CONTAINER_IMAGE:$PHP_VERSION ./.docker/$SERVICE_NAME
- docker push $CONTAINER_IMAGE:$PHP_VERSION
when: manual
tags:
- docker

.docker_variables: &docker_variables
CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/$SERVICE_NAME
DOCKER_DRIVER: devicemapper
DOCKER_TLS_CERTDIR: ''
GIT_STRATEGY: fetch
GIT_DEPTH: "1"

# ======================
# Docker jobs
# ======================
docker:php81:
<<: *docker_base
variables:
SERVICE_NAME: php
PHP_VERSION: "8.1"
<<: *docker_variables

docker:php82:
<<: *docker_base
variables:
SERVICE_NAME: php
PHP_VERSION: "8.2"
<<: *docker_variables

docker:php83:
<<: *docker_base
variables:
SERVICE_NAME: php
PHP_VERSION: "8.3"
<<: *docker_variables

# ======================
# Build jobs
# ======================
build:php:
<<: *php_base
stage: build
script:
- composer install
artifacts:
paths:
- vendor/
expire_in: 2 hours
cache:
paths:
- vendor
key: php

# ======================
# Lint jobs
# ======================
lint:php:
<<: *php_base
stage: lint
script:
- composer phpcs
dependencies:
- build:php
allow_failure: true

# ======================
# Test jobs
# ======================
test:php81:
<<: *test_base
image: $CI_REGISTRY_IMAGE/php:8.1
variables:
PHPUNIT_VERSION: "9.5"

test:php82:
<<: *test_base
image: $CI_REGISTRY_IMAGE/php:8.2
variables:
PHPUNIT_VERSION: "9.5"

test:php83:
<<: *test_base
image: $CI_REGISTRY_IMAGE/php:8.3
variables:
PHPUNIT_VERSION: "9.5"
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,19 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

## [1.0.2] - 14-02-2022
- Laravel 9 Support

## [1.0.3] - 06-03-2023
- Laravel 10 Support

## [2.0.0] - 22-02-2024
### Added
- Autocomplete and get endpoint support.
- Complete test coverage.

### Changed
- Refactored codebase, make use of `Http` facade to assist testing.
- Moved core HTTP logic into `Laralabs\GetAddress\Http\Client` which provides `get()` and `post()`. Can be used if wanting to experiment with new endpoints or endpoints not supported by the package.

### Removed
- Unused classes.

31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<p align="center">
<a href="https://packagist.org/packages/laralabs/get-address-io"><img src="https://poser.pugx.org/laralabs/get-address-io/version" alt="Stable Build" /></a>
<a href="https://travis-ci.org/Laralabs/get-address-io"><img src="https://travis-ci.org/Laralabs/get-address-io.svg?branch=master" alt="Build Status"></a>
<a href="https://styleci.io/repos/195806527"><img src="https://styleci.io/repos/195806527/shield?branch=master" alt="StyleCI"></a>
<a href="https://codeclimate.com/github/Laralabs/get-address-io/maintainability"><img src="https://api.codeclimate.com/v1/badges/744992b1495722bd6839/maintainability" /></a>
<a href="https://codeclimate.com/github/Laralabs/get-address-io/test_coverage"><img src="https://api.codeclimate.com/v1/badges/744992b1495722bd6839/test_coverage" /></a>
<a href="https://github.com/Laralabs/get-address-io/actions"><img src="https://github.com/clnt/scrubber/actions/workflows/.github-actions.yml/badge.svg" alt="CI Status" /></a>
<a href="https://codecov.io/gh/Laralabs/get-address-io"><img src="https://codecov.io/gh/Laralabs/get-address-io/branch/master/graph/badge.svg?token=S2VO0QHCP8"/></a>
</p>

# Laravel getAddress.io Package
Expand Down Expand Up @@ -35,22 +33,33 @@ php artisan migrate
### Usage
A helper function and facade is available, choose your preferred method.

Perform a lookup:
The facade is located at `Laralabs\GetAddress\Facades\GetAddress`

The endpoints currently supported are (support for other endpoints coming soon):
- find
- autocomplete
- get

Perform a lookup using the `find` endpoint:
```php
$results = get_address()->find($postcode, $property);
```

Perform an expanded lookup:
The `$property` argument is optional, just searching for a postcode will return all results for that postcode and also cache the data if the cache has been enabled.

Perform a looking using the `autocomplete` endpoint:
```php
$results = get_address()->expand()->find($postcode, $property);
$results = get_address()->autocomplete($searchTerm, ['top' => '20']);
```

The `$property` argument is optional, just searching for a postcode will return all results for that postcode and also cache the data if the cache has been enabled.
The second argument supports an array of parameters to send with the POST request, the example above shows setting the returned results to the maximum allowed of 20.

## :pushpin: Todo
Perform a lookup using the `get` endpoint:
```php
$results = get_address()->get($addressId);
```

- Admin Features.
- Unit Tests.
This is used with the `autocomplete` endpoint to return the full address information, the `$addressId` argument must be the ID returned from the autocomplete response.

## :speech_balloon: Support

Expand Down
Loading
Loading