├── .gitignore ├── README.md ├── monitoring.sh ├── production ├── documentation.html └── swagger.json ├── staging ├── documentation.html └── swagger.json └── swaggerSort.php /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Surfoo/groundspeak-api-monitoring/d85908774813eb18af102164b22d9b1a8f02868e/.gitignore -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | groundspeak-api-monitoring 2 | ========================== 3 | 4 | Backup all changes about the Groundspeak REST API. 5 | 6 | The script monitors these URLs: 7 | - **Staging** 8 | - **Documentation**: https://staging.api.groundspeak.com/documentation 9 | - **Swagger**: https://staging.api.groundspeak.com/api-docs/v1/swagger 10 | - **Production** 11 | - **Documentation**: https://api.groundspeak.com/documentation 12 | - **Swagger**: https://api.groundspeak.com/api-docs/v1/swagger 13 | 14 | Notification 15 | ============ 16 | 17 | Please "Star" this repository, and then use [hubnotify.com](http://www.hubnotify.com/) for your notifications. 18 | -------------------------------------------------------------------------------- /monitoring.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | date; 4 | 5 | cd $(dirname $0); 6 | 7 | wget -e robots=off -m -E -q -A.html "https://staging.api.groundspeak.com/documentation" -O "staging/documentation.html" 8 | wget -e robots=off -m -E -q -A.html "https://staging.api.groundspeak.com/api-docs/v1/swagger" -O "staging/swagger.json" 9 | 10 | wget -e robots=off -m -E -q -A.html "https://api.groundspeak.com/documentation" -O "production/documentation.html" 11 | wget -e robots=off -m -E -q -A.html "https://api.groundspeak.com/api-docs/v1/swagger" -O "production/swagger.json" 12 | 13 | SWAGGER_FILES=$(git ls-files -m | grep -E 'swagger.json'); 14 | php swaggerSort.php $SWAGGER_FILES 15 | 16 | if [[ $(git ls-files -m | grep -E 'staging|production' | wc -l) -gt 0 ]];then 17 | FILES=$(git ls-files -m | grep -E 'staging|production'); 18 | printf "Files found:\n%s\n\n" "$FILES"; 19 | git commit --author "Surfoo " -am "Changes detected on: 20 | $FILES" && git push; 21 | else 22 | printf 'Nothing to do.\n\n'; 23 | fi 24 | 25 | exit 0; 26 | -------------------------------------------------------------------------------- /swaggerSort.php: -------------------------------------------------------------------------------- 1 | &$content) { 11 | foreach ($keysToSort as $keyToSort) { 12 | if (isset($content['properties'][$keyToSort]) && isset($content['properties'][$keyToSort]['enum'])) { 13 | sort($content['properties'][$keyToSort]['enum']); 14 | } 15 | } 16 | } 17 | 18 | foreach ($contentFile['paths'] as $route => &$method) { 19 | if (isset($method['get']['responses']['200']['schema']['items']['enum'])) { 20 | sort($method['get']['responses']['200']['schema']['items']['enum']); 21 | } 22 | } 23 | 24 | file_put_contents($file, json_encode($contentFile, JSON_PRETTY_PRINT)); 25 | } 26 | --------------------------------------------------------------------------------