diff --git a/README.md b/README.md index d6a00ae..771f634 100644 --- a/README.md +++ b/README.md @@ -39,18 +39,23 @@ cd platformsh-github-authenticator composer install ``` -#### Configure the environment -Define the following values in your environment: +Note: This repository contains a copy of +[lp-digital/github-event-parser](https://packagist.org/packages/lp-digital/github-event-parser) +v0.8.3, as the repo has disappeared from GitHub. + +#### Configure the environment + +Define the following values in your environment: 1. `GITHUB_USERNAME`: The username of the GitHub user which will be used to represent the application. 2. `GITHUB_SECRET`: A [personal access token](https://github.blog/2013-05-16-personal-api-tokens/) for the GitHub user. The token must have the following scopes: `repo` and `read:org`. 3. `GITHUB_WEBHOOK_SECRET`: [A shared secret between GitHub and the application](https://developer.github.com/webhooks/securing/#setting-your-secret-token). 4. `GITHUB_ORGANIZATION`: The name of the GitHub organisation which users must be a member of to have pull request environments enabled. 5. `GITHUB_TEAM`: The name of the GitHub organisation tram which users must be a member of to have pull request environments enabled. -6. `PLATFORMSH_API_TOKEN`: The [Platform.sh API token](Platform.sh API) to use to access the Platform.sh API. +6. `PLATFORMSH_API_TOKEN`: The [Platform.sh API token](Platform.sh API) to use to access the Platform.sh API. 7. `PLATFORMSH_PROJECT`: The id of the Platform.sh project to use when publishing pull request environments. When you go to the project console the id is the trailing part of the url: `https://console.platform.sh/[organization]/[project_id]`. -8. `GIT_REPO_URL`: The url for the project repository on Platform.sh. +8. `GIT_REPO_URL`: The url for the project repository on Platform.sh. 9. `GIT_PRIVATE_KEY`: The SSH private key to use when synchronizing commits from pull requests to Platform.sh. The corresponding [public key must be added to the Platform.sh user](https://docs.platform.sh/development/ssh.html#add-the-ssh-key-to-your-platform-account) which will be used to perform the synchronization. These can be defined as environment variables or by creating an [`.env.local` file](https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables) in the root of the checkout which contains the environment variables. @@ -91,18 +96,18 @@ git push origin platformsh-test Then open a pull request from the branch against the default branch for the repository. The user opening the pull request should be member of the organisation and team configured in the environment. -Now the `continuous-integration/platformsh` should appear in the list of status checks for the pull request displaying the status of the deployment to Platform.sh. +Now the `continuous-integration/platformsh` should appear in the list of status checks for the pull request displaying the status of the deployment to Platform.sh. ## Architecture The architecture of the system is based on the application: - + 1. Responding to GitHub webhooks 2. Using the GitHub API to determine group membership and update pull requests 3. Using Platform.sh API and project git repository to manage environments - + The process is described in the following diagram: - + ![Architecture](/docs/architecture.svg) A key element in the application is the fact that it will push code from the project pull request branch to a corresponding branch in the project Platform.sh repository. The Platform.sh git implementation will then automatically create an environment for the branch. @@ -117,7 +122,7 @@ docker-compose up In this setup [ngrok](https://ngrok.com/) is used to expose the application externally. The url for the application can be identified by accessing the ngrok user interface. -In this setup the url for the webhook will be `https://[unique-id].ngrok.io/webhook`. +In this setup the url for the webhook will be `https://[unique-id].ngrok.io/webhook`. ## Unit tests @@ -138,7 +143,7 @@ To use these features then complete the following steps: 1. [Create an AWS key/secret pair](https://bref.sh/docs/installation/aws-keys.html) 2. Add [your AWS key and secret used to setup the application](https://bref.sh/docs/installation/aws-keys.html) as [GitHub secrets for the repository](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables). - + 3. Add the [environment variable values](#configure-the-environment) to the [Amazon SSM parameter store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html). If you have the [AWS cli](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) installed this can be achieved through the following commands: diff --git a/composer.json b/composer.json index 8537b17..0f4b665 100644 --- a/composer.json +++ b/composer.json @@ -13,11 +13,11 @@ "ext-iconv": "*", "bref/bref": "^0.5.5", "bref/symfony-messenger-sns": "^0.2.0", + "composer/package-versions-deprecated": "^1.11", "cpliakas/git-wrapper": "^2.2", "cweagans/composer-patches": "^1.6", "enqueue/fs": "^0.9.12", "knplabs/github-api": "^2.11", - "lp-digital/github-event-parser": "^0.8.3", "php-http/guzzle6-adapter": "^1.1", "php-http/logger-plugin": "^1.1", "platformsh/client": "^2.1", @@ -52,7 +52,8 @@ }, "autoload": { "psr-4": { - "App\\": "src/" + "App\\": "src/", + "Lpdigital\\Github\\": "lp-digital/github-event-parser/" } }, "autoload-dev": { diff --git a/composer.lock b/composer.lock index 53d4712..13db3cf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b151f030ce85fad482b1cce0f523ec5e", + "content-hash": "d5c65ed8d107107e09afbd58385c5dd0", "packages": [ { "name": "aws/aws-sdk-php", @@ -306,6 +306,79 @@ ], "time": "2019-01-31T20:38:55+00:00" }, + { + "name": "composer/package-versions-deprecated", + "version": "1.11.99", + "source": { + "type": "git", + "url": "https://github.com/composer/package-versions-deprecated.git", + "reference": "c8c9aa8a14cc3d3bec86d0a8c3fa52ea79936855" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/package-versions-deprecated/zipball/c8c9aa8a14cc3d3bec86d0a8c3fa52ea79936855", + "reference": "c8c9aa8a14cc3d3bec86d0a8c3fa52ea79936855", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1.0 || ^2.0", + "php": "^7 || ^8" + }, + "replace": { + "ocramius/package-versions": "1.11.99" + }, + "require-dev": { + "composer/composer": "^1.9.3 || ^2.0@dev", + "ext-zip": "^1.13", + "phpunit/phpunit": "^6.5 || ^7" + }, + "type": "composer-plugin", + "extra": { + "class": "PackageVersions\\Installer", + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "PackageVersions\\": "src/PackageVersions" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be" + } + ], + "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "support": { + "issues": "https://github.com/composer/package-versions-deprecated/issues", + "source": "https://github.com/composer/package-versions-deprecated/tree/master" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2020-08-25T05:50:16+00:00" + }, { "name": "cpliakas/git-wrapper", "version": "v2.2.0", @@ -372,24 +445,24 @@ }, { "name": "cweagans/composer-patches", - "version": "1.6.7", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/cweagans/composer-patches.git", - "reference": "2e6f72a2ad8d59cd7e2b729f218bf42adb14f590" + "reference": "ae02121445ad75f4eaff800cc532b5e6233e2ddf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweagans/composer-patches/zipball/2e6f72a2ad8d59cd7e2b729f218bf42adb14f590", - "reference": "2e6f72a2ad8d59cd7e2b729f218bf42adb14f590", + "url": "https://api.github.com/repos/cweagans/composer-patches/zipball/ae02121445ad75f4eaff800cc532b5e6233e2ddf", + "reference": "ae02121445ad75f4eaff800cc532b5e6233e2ddf", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0", + "composer-plugin-api": "^1.0 || ^2.0", "php": ">=5.3.0" }, "require-dev": { - "composer/composer": "~1.0", + "composer/composer": "~1.0 || ~2.0", "phpunit/phpunit": "~4.6" }, "type": "composer-plugin", @@ -412,7 +485,11 @@ } ], "description": "Provides a way to patch Composer packages.", - "time": "2019-08-29T20:11:49+00:00" + "support": { + "issues": "https://github.com/cweagans/composer-patches/issues", + "source": "https://github.com/cweagans/composer-patches/tree/1.7.0" + }, + "time": "2020-09-30T17:56:20+00:00" }, { "name": "doctrine/annotations", @@ -1725,57 +1802,6 @@ ], "time": "2018-11-22T18:33:57+00:00" }, - { - "name": "lp-digital/github-event-parser", - "version": "v0.8.3", - "source": { - "type": "git", - "url": "https://github.com/Lp-digital/github-event-parser.git", - "reference": "2a57cd8ab1cf7e12fb680fd61afd1e9725db708c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Lp-digital/github-event-parser/zipball/2a57cd8ab1cf7e12fb680fd61afd1e9725db708c", - "reference": "2a57cd8ab1cf7e12fb680fd61afd1e9725db708c", - "shasum": "" - }, - "require": { - "php": ">=5.4" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "~1.11", - "phpunit/phpunit": "~4.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Lpdigital\\Github\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-3.0+" - ], - "authors": [ - { - "name": "Mickaël Andrieu", - "email": "mickael.andrieu@lp-digital.fr" - } - ], - "description": "PHP library to get a readable representation of events dispatched by Github API v3", - "homepage": "https://github.com/Lp-digital/github-event-parser", - "keywords": [ - "event", - "github", - "json parser" - ], - "time": "2017-04-19T20:00:10+00:00" - }, { "name": "makasim/temp-file", "version": "0.2.0", @@ -4089,32 +4115,32 @@ }, { "name": "symfony/flex", - "version": "v1.4.6", + "version": "v1.9.10", "source": { "type": "git", "url": "https://github.com/symfony/flex.git", - "reference": "133e649fdf08aeb8741be1ba955ccbe5cd17c696" + "reference": "7335ec033995aa34133e621627333368f260b626" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/flex/zipball/133e649fdf08aeb8741be1ba955ccbe5cd17c696", - "reference": "133e649fdf08aeb8741be1ba955ccbe5cd17c696", + "url": "https://api.github.com/repos/symfony/flex/zipball/7335ec033995aa34133e621627333368f260b626", + "reference": "7335ec033995aa34133e621627333368f260b626", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0", - "php": "^7.0" + "composer-plugin-api": "^1.0|^2.0", + "php": ">=7.1" }, "require-dev": { - "composer/composer": "^1.0.2", - "symfony/dotenv": "^3.4|^4.0", - "symfony/phpunit-bridge": "^3.4.19|^4.1.8", - "symfony/process": "^2.7|^3.0|^4.0" + "composer/composer": "^1.0.2|^2.0", + "symfony/dotenv": "^4.4|^5.0", + "symfony/phpunit-bridge": "^4.4|^5.0", + "symfony/process": "^3.4|^4.4|^5.0" }, "type": "composer-plugin", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-main": "1.9-dev" }, "class": "Symfony\\Flex\\Flex" }, @@ -4134,7 +4160,25 @@ } ], "description": "Composer plugin for Symfony", - "time": "2019-09-19T14:55:57+00:00" + "support": { + "issues": "https://github.com/symfony/flex/issues", + "source": "https://github.com/symfony/flex/tree/v1.9.10" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-14T17:41:54+00:00" }, { "name": "symfony/framework-bundle", @@ -6145,82 +6189,32 @@ ], "time": "2019-09-01T07:51:21+00:00" }, - { - "name": "ocramius/package-versions", - "version": "1.5.1", - "source": { - "type": "git", - "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "1d32342b8c1eb27353c8887c366147b4c2da673c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/1d32342b8c1eb27353c8887c366147b4c2da673c", - "reference": "1d32342b8c1eb27353c8887c366147b4c2da673c", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0.0", - "php": "^7.3.0" - }, - "require-dev": { - "composer/composer": "^1.8.6", - "doctrine/coding-standard": "^6.0.0", - "ext-zip": "*", - "infection/infection": "^0.13.4", - "phpunit/phpunit": "^8.2.5", - "vimeo/psalm": "^3.4.9" - }, - "type": "composer-plugin", - "extra": { - "class": "PackageVersions\\Installer", - "branch-alias": { - "dev-master": "1.6.x-dev" - } - }, - "autoload": { - "psr-4": { - "PackageVersions\\": "src/PackageVersions" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com" - } - ], - "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2019-07-17T15:49:50+00:00" - }, { "name": "phpstan/extension-installer", - "version": "1.0.2", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/phpstan/extension-installer.git", - "reference": "b9f4c4e9fe93373a102c982bda5b8e57f901ce33" + "reference": "5c2da3846819f951385cb6a25d3277051481c48a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/b9f4c4e9fe93373a102c982bda5b8e57f901ce33", - "reference": "b9f4c4e9fe93373a102c982bda5b8e57f901ce33", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/5c2da3846819f951385cb6a25d3277051481c48a", + "reference": "5c2da3846819f951385cb6a25d3277051481c48a", "shasum": "" }, "require": { - "composer-plugin-api": "^1.1", - "php": "^7.1", + "composer-plugin-api": "^1.1 || ^2.0", + "php": "^7.1 || ^8.0", "phpstan/phpstan": ">=0.11.6" }, "require-dev": { "composer/composer": "^1.8", "consistence/coding-standard": "^3.8", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", - "jakub-onderka/php-parallel-lint": "^1.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "ergebnis/composer-normalize": "^2.0.2", "phing/phing": "^2.16", + "php-parallel-lint/php-parallel-lint": "^1.2.0", "phpstan/phpstan-strict-rules": "^0.11", "slevomat/coding-standard": "^5.0.4" }, @@ -6238,7 +6232,11 @@ "MIT" ], "description": "Composer plugin for automatic installation of PHPStan extensions", - "time": "2019-09-13T19:07:11+00:00" + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.0.5" + }, + "time": "2020-08-30T12:06:42+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -6801,5 +6799,6 @@ "ext-ctype": "*", "ext-iconv": "*" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "2.0.0" } diff --git a/lp-digital/.DS_Store b/lp-digital/.DS_Store new file mode 100644 index 0000000..4c1247f Binary files /dev/null and b/lp-digital/.DS_Store differ diff --git a/lp-digital/._.DS_Store b/lp-digital/._.DS_Store new file mode 100644 index 0000000..a5b28df Binary files /dev/null and b/lp-digital/._.DS_Store differ diff --git a/lp-digital/github-event-parser/.DS_Store b/lp-digital/github-event-parser/.DS_Store new file mode 100644 index 0000000..5a57635 Binary files /dev/null and b/lp-digital/github-event-parser/.DS_Store differ diff --git a/lp-digital/github-event-parser/._.DS_Store b/lp-digital/github-event-parser/._.DS_Store new file mode 100644 index 0000000..a5b28df Binary files /dev/null and b/lp-digital/github-event-parser/._.DS_Store differ diff --git a/lp-digital/github-event-parser/.gitignore b/lp-digital/github-event-parser/.gitignore new file mode 100644 index 0000000..3fcc880 --- /dev/null +++ b/lp-digital/github-event-parser/.gitignore @@ -0,0 +1,5 @@ +.phpintel/* +vendor +composer.phar +composer.lock +phpunit.xml diff --git a/lp-digital/github-event-parser/.scrutinizer.yml b/lp-digital/github-event-parser/.scrutinizer.yml new file mode 100644 index 0000000..d0452ac --- /dev/null +++ b/lp-digital/github-event-parser/.scrutinizer.yml @@ -0,0 +1,4 @@ +tools: + external_code_coverage: true + php_pdepend: true + sensiolabs_security_checker: true diff --git a/lp-digital/github-event-parser/.travis.yml b/lp-digital/github-event-parser/.travis.yml new file mode 100644 index 0000000..91b92b3 --- /dev/null +++ b/lp-digital/github-event-parser/.travis.yml @@ -0,0 +1,29 @@ +language: php + +sudo: false + +php: + - 5.6 + - 7.0 + - 7.1 + +cache: + directories: + - $HOME/.composer/cache + - vendor + +before_install: + - composer self-update + +before_script: + - composer install --no-interaction + +script: + - phpunit --coverage-clover=coverage.clover + +after_script: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover coverage.clover + +notifications: + email: false diff --git a/lp-digital/github-event-parser/Entity/.DS_Store b/lp-digital/github-event-parser/Entity/.DS_Store new file mode 100644 index 0000000..f842fe2 Binary files /dev/null and b/lp-digital/github-event-parser/Entity/.DS_Store differ diff --git a/lp-digital/github-event-parser/Entity/._.DS_Store b/lp-digital/github-event-parser/Entity/._.DS_Store new file mode 100644 index 0000000..a5b28df Binary files /dev/null and b/lp-digital/github-event-parser/Entity/._.DS_Store differ diff --git a/lp-digital/github-event-parser/Entity/Comment.php b/lp-digital/github-event-parser/Entity/Comment.php new file mode 100644 index 0000000..17fe1a7 --- /dev/null +++ b/lp-digital/github-event-parser/Entity/Comment.php @@ -0,0 +1,191 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class Comment +{ + private $url; + private $htmlUrl; + private $id; + + /** + * @var User + */ + private $user; + private $position; + private $line; + private $path; + private $commitId; + private $createdAt; + private $updatedAt; + private $body; + + public static function createFromData(array $data) + { + return new static($data); + } + + public function __construct($data) + { + $this->url = $data['url']; + $this->htmlUrl = $data['html_url']; + $this->id = $data['id']; + $this->user = User::createFromData($data['user']); + $this->position = isset($data['position']) ?: null; + $this->line = isset($data['line']) ?: null; + $this->path = isset($data['path']) ?: null; + $this->commitId = isset($data['commit_id']) ?: null; + $this->createdAt = $data['created_at']; + $this->updatedAt = $data['updated_at']; + $this->body = $data['body']; + } + + /** + * Gets the value of url. + * + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + + /** + * Gets the value of htmlUrl. + * + * @return mixed + */ + public function getHtmlUrl() + { + return $this->htmlUrl; + } + + /** + * Gets the value of id. + * + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * Gets the value of user. + * + * @return Lpdigital\Github\Entity\User + */ + public function getUser() + { + return $this->user; + } + + /** + * Gets the author of comment. + * + * @return string + */ + public function getUserLogin() + { + return $this->user->getLogin(); + } + + /** + * Gets the value of position. + * + * @return mixed + */ + public function getPosition() + { + return $this->position; + } + + /** + * Gets the value of line. + * + * @return mixed + */ + public function getLine() + { + return $this->line; + } + + /** + * Gets the value of path. + * + * @return mixed + */ + public function getPath() + { + return $this->path; + } + + /** + * Gets the value of commitId. + * + * @return mixed + */ + public function getCommitId() + { + return $this->commitId; + } + + /** + * Gets the value of createdAt. + * + * @return mixed + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Gets the value of updatedAt. + * + * @return mixed + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Gets the value of body. + * + * @return mixed + */ + public function getBody() + { + return $this->body; + } + + /** + * Get an human readable description of Comment object: the comment. + * + * @return string the comment + */ + public function __toString() + { + return $this->body; + } +} diff --git a/lp-digital/github-event-parser/Entity/Commit.php b/lp-digital/github-event-parser/Entity/Commit.php new file mode 100644 index 0000000..6f0b4a8 --- /dev/null +++ b/lp-digital/github-event-parser/Entity/Commit.php @@ -0,0 +1,96 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +/** + * Partial representation of Commit GitHub API. + * + * @doc https://developer.github.com/v3/git/commits/ + */ +class Commit +{ + private $sha; + private $url; + + /** + * @var CommitUser + */ + private $author; + + /** + * @var CommitUser + */ + private $committer; + private $message; + private $tree; + + public static function createFromData(array $data) + { + return new static($data); + } + + public function __construct($data) + { + $this->url = $data['url']; + $this->author = CommitUser::createFromData($data['author']); + $this->committer = CommitUser::createFromData($data['committer']); + $this->message = $data['message']; + $this->tree = $data['tree']; + } + + public function setSha($sha) + { + $this->sha = $sha; + + return $this; + } + + public function getSha() + { + return $this->sha; + } + + public function getUrl() + { + return $this->url; + } + + public function getAuthor() + { + return $this->author; + } + + public function getCommitter() + { + return $this->committer; + } + + public function getMessage() + { + return $this->message; + } + + public function getTree() + { + return $this->tree; + } +} diff --git a/lp-digital/github-event-parser/Entity/CommitUser.php b/lp-digital/github-event-parser/Entity/CommitUser.php new file mode 100644 index 0000000..53a9090 --- /dev/null +++ b/lp-digital/github-event-parser/Entity/CommitUser.php @@ -0,0 +1,64 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class CommitUser +{ + private $date; + private $name; + private $email; + + public static function createFromData($data) + { + return new static($data); + } + + public function __construct($data) + { + $this->date = new \DateTime($data['date']); + $this->name = $data['name']; + $this->email = $data['email']; + } + + public function getDate() + { + return $this->date; + } + + public function getName() + { + return $this->name; + } + + public function getEmail() + { + return $this->email; + } + + /* Get an human readable description of CommitUser object. + * + * @return string the commit author/committer + */ + public function __toString() + { + return $this->name.' ('.$this->email.')'; + } +} diff --git a/lp-digital/github-event-parser/Entity/Deployment.php b/lp-digital/github-event-parser/Entity/Deployment.php new file mode 100644 index 0000000..819a784 --- /dev/null +++ b/lp-digital/github-event-parser/Entity/Deployment.php @@ -0,0 +1,195 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class Deployment +{ + private $url; + private $id; + private $sha; + private $ref; + private $task; + private $payload; + private $environment; + private $description; + + /** + * @var User + */ + private $creator; + private $createdAt; + private $updatedAt; + private $statusesUrl; + private $repositoryUrl; + + public static function createFromData(array $data) + { + return new static($data); + } + + public function __construct($data) + { + $this->url = $data['url']; + $this->id = $data['id']; + $this->sha = $data['sha']; + $this->ref = $data['ref']; + $this->task = $data['task']; + $this->payload = $data['payload']; + $this->environment = $data['environment']; + $this->description = $data['description']; + $this->creator = User::createFromData($data['creator']); + $this->createdAt = $data['created_at']; + $this->updatedAt = $data['updated_at']; + $this->statusesUrl = $data['statuses_url']; + $this->repositoryUrl = $data['repository_url']; + } + + /** + * Gets the value of url. + * + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + + /** + * Gets the value of id. + * + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * Gets the value of sha. + * + * @return mixed + */ + public function getSha() + { + return $this->sha; + } + + /** + * Gets the value of ref. + * + * @return mixed + */ + public function getRef() + { + return $this->ref; + } + + /** + * Gets the value of task. + * + * @return mixed + */ + public function getTask() + { + return $this->task; + } + + /** + * Gets the value of payload. + * + * @return mixed + */ + public function getPayload() + { + return $this->payload; + } + + /** + * Gets the value of environment. + * + * @return mixed + */ + public function getEnvironment() + { + return $this->environment; + } + + /** + * Gets the value of description. + * + * @return mixed + */ + public function getDescription() + { + return $this->description; + } + + /** + * Gets the value of creator. + * + * @return mixed + */ + public function getCreator() + { + return $this->creator; + } + + /** + * Gets the value of createdAt. + * + * @return mixed + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Gets the value of updatedAt. + * + * @return mixed + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Gets the value of statusesUrl. + * + * @return mixed + */ + public function getStatusesUrl() + { + return $this->statusesUrl; + } + + /** + * Gets the value of repositoryUrl. + * + * @return mixed + */ + public function getRepositoryUrl() + { + return $this->repositoryUrl; + } +} diff --git a/lp-digital/github-event-parser/Entity/Integration.php b/lp-digital/github-event-parser/Entity/Integration.php new file mode 100644 index 0000000..72c2a62 --- /dev/null +++ b/lp-digital/github-event-parser/Entity/Integration.php @@ -0,0 +1,109 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class Integration +{ + /** + * @var int + */ + private $installationId; + + /** + * @var User + */ + private $account; + + /** + * @var string + */ + private $accessTokenUrl; + + /** + * @var string + */ + private $repositoriesUrl; + + /** + * @var string + */ + private $htmlUrl; + + /** + * @param array $data + * + * @return self + */ + public static function createFromData(array $data) + { + return new static($data); + } + + public function __construct(array $data) + { + $this->installationId = $data['id']; + $this->account = isset($data['account']) ? User::createFromData($data['account']) : null; + $this->accessTokenUrl = isset($data['access_tokens_url']) ? $data['access_tokens_url'] : null; + $this->repositoriesUrl = isset($data['repositories_url']) ? $data['repositories_url'] : null; + $this->htmlUrl = isset($data['html_url']) ? $data['html_url'] : null; + } + + /** + * @return int + */ + public function getInstallationId() + { + return $this->installationId; + } + + /** + * @return User + */ + public function getAccount() + { + return $this->account; + } + + /** + * @return string + */ + public function getAccessTokenUrl() + { + return $this->accessTokenUrl; + } + + /** + * @return string + */ + public function getRepositoriesUrl() + { + return $this->repositoriesUrl; + } + + /** + * @return string + */ + public function getHtmlUrl() + { + return $this->htmlUrl; + } +} diff --git a/lp-digital/github-event-parser/Entity/Issue.php b/lp-digital/github-event-parser/Entity/Issue.php new file mode 100644 index 0000000..be9e6d2 --- /dev/null +++ b/lp-digital/github-event-parser/Entity/Issue.php @@ -0,0 +1,288 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class Issue +{ + private $url; + private $labelsUrl; + private $commentsUrl; + private $eventsUrl; + private $htmlUrl; + private $id; + private $number; + private $title; + + /** + * @var User + */ + private $user; + private $labels; + private $state; + private $isLocked; + + /** + * @var User|null + */ + private $assignee; + private $milestone; + private $commentsCount; + private $createdAt; + private $updatedAt; + private $closedAt; + private $body; + + public static function createFromData(array $data) + { + return new static($data); + } + + public function __construct($data) + { + $this->url = $data['url']; + $this->labelsUrl = $data['labels_url']; + $this->commentsUrl = $data['comments_url']; + $this->eventsUrl = $data['events_url']; + $this->htmlUrl = $data['html_url']; + $this->id = $data['id']; + $this->number = $data['number']; + $this->title = $data['title']; + $this->user = User::createFromData($data['user']); + $this->labels = $this->buildLabels($data['labels']); + $this->state = $data['state']; + $this->isLocked = $data['locked']; + $this->assignee = isset($data['assignee']) ? User::createFromData($data['assignee']) : null; + $this->milestone = isset($data['milestone']) ?: null; + $this->commentsCount = $data['comments']; + $this->createdAt = $data['created_at']; + $this->updatedAt = $data['updated_at']; + $this->closedAt = $data['closed_at']; + $this->body = $data['body']; + } + + /** + * Gets the value of url. + * + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + + /** + * Gets the value of labelsUrl. + * + * @return mixed + */ + public function getLabelsUrl() + { + return $this->labelsUrl; + } + + /** + * Gets the value of commentsUrl. + * + * @return mixed + */ + public function getCommentsUrl() + { + return $this->commentsUrl; + } + + /** + * Gets the value of eventsUrl. + * + * @return mixed + */ + public function getEventsUrl() + { + return $this->eventsUrl; + } + + /** + * Gets the value of htmlUrl. + * + * @return mixed + */ + public function getHtmlUrl() + { + return $this->htmlUrl; + } + + /** + * Gets the value of id. + * + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * Gets the value of number. + * + * @return mixed + */ + public function getNumber() + { + return $this->number; + } + + /** + * Gets the value of title. + * + * @return mixed + */ + public function getTitle() + { + return $this->title; + } + + /** + * Gets the value of user. + * + * @return mixed + */ + public function getUser() + { + return $this->user; + } + + /** + * Gets the value of labels. + * + * @return mixed + */ + public function getLabels() + { + return $this->labels; + } + + /** + * Gets the value of state. + * + * @return mixed + */ + public function getState() + { + return $this->state; + } + + /** + * Gets the value of isLocked. + * + * @return mixed + */ + public function isLocked() + { + return $this->isLocked; + } + + /** + * Gets the value of assignee. + * + * @return mixed + */ + public function getAssignee() + { + return $this->assignee; + } + + /** + * Gets the value of milestone. + * + * @return mixed + */ + public function getMilestone() + { + return $this->milestone; + } + + /** + * Gets the value of commentsCount. + * + * @return mixed + */ + public function getCommentsCount() + { + return $this->commentsCount; + } + + /** + * Gets the value of createdAt. + * + * @return mixed + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Gets the value of updatedAt. + * + * @return mixed + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Gets the value of closedAt. + * + * @return mixed + */ + public function getClosedAt() + { + return $this->closedAt; + } + + /** + * Gets the value of body. + * + * @return mixed + */ + public function getBody() + { + return $this->body; + } + + /** + * Set the Label collection from an array. + * + * @param array $labels an array of labels + * + * @return Label[] the collection of labels + */ + private function buildLabels($labels) + { + $collection = []; + foreach ($labels as $label) { + $collection[] = Label::createFromData($label); + } + + return $collection; + } +} diff --git a/lp-digital/github-event-parser/Entity/Label.php b/lp-digital/github-event-parser/Entity/Label.php new file mode 100644 index 0000000..5a7b36c --- /dev/null +++ b/lp-digital/github-event-parser/Entity/Label.php @@ -0,0 +1,71 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class Label +{ + private $url; + private $name; + private $color; + + public static function createFromData(array $data) + { + return new static($data); + } + + public function __construct($data) + { + $this->url = $data['url']; + $this->name = $data['name']; + $this->color = $data['color']; + } + + /** + * Gets the value of url. + * + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + + /** + * Gets the value of name. + * + * @return mixed + */ + public function getName() + { + return $this->name; + } + + /** + * Gets the value of color. + * + * @return mixed + */ + public function getColor() + { + return $this->color; + } +} diff --git a/lp-digital/github-event-parser/Entity/Page.php b/lp-digital/github-event-parser/Entity/Page.php new file mode 100644 index 0000000..9cb8230 --- /dev/null +++ b/lp-digital/github-event-parser/Entity/Page.php @@ -0,0 +1,97 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class Page +{ + private $pageName; + private $title; + private $summary; + private $action; + private $sha; + private $htmlUrl; + + public static function createFromData(array $data) + { + return new static($data); + } + + public function __construct($data) + { + $this->pageName = $data['page_name']; + $this->title = $data['title']; + $this->summary = $data['summary']; + $this->action = $data['action']; + $this->sha = $data['sha']; + $this->htmlUrl = $data['html_url']; + } + + /** + * @return string + */ + public function getPageName() + { + return $this->pageName; + } + + /** + * @return string + */ + public function getTitle() + { + return $this->title; + } + + /** + * @return string + */ + public function getSummary() + { + return $this->summary; + } + + /** + * Action value can be one of ['created', 'edited']. + * + * @return string + */ + public function getAction() + { + return $this->action; + } + + /** + * @return string + */ + public function getSha() + { + return $this->sha; + } + + /** + * @return string + */ + public function getHtmlUrl() + { + return $this->htmlUrl; + } +} diff --git a/lp-digital/github-event-parser/Entity/PullRequest.php b/lp-digital/github-event-parser/Entity/PullRequest.php new file mode 100644 index 0000000..feea4c9 --- /dev/null +++ b/lp-digital/github-event-parser/Entity/PullRequest.php @@ -0,0 +1,972 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +use Lpdigital\Github\Exception\UserAgentNotFoundException; +use Lpdigital\Github\Exception\AllowUrlFileOpenException; + +class PullRequest +{ + private $url; + private $id; + private $htmlUrl; + private $diffUrl; + private $issueUrl; + private $number; + private $state; + private $isLocked; + private $title; + + /** + * @var User + */ + private $user; + private $body; + private $createdAt; + private $updatedAt; + private $closedAt; + private $mergedAt; + private $mergeCommitSha; + + /** + * @var User|null + */ + private $assignee; + private $milestone; + private $commitsUrl; + private $reviewCommentUrl; + private $reviewCommentsUrl; + private $statusesUrl; + private $isMerged; + private $isMergeable; + private $mergeableState; + + /** + * @var User|null + */ + private $mergedBy; + private $commentsCount; + private $reviewCommentsCount; + private $commitsCount; + private $additions; + private $deletions; + private $changedFiles; + private $commitSha; + private $base; + private $head; + + public static function createFromData(array $data) + { + return new static($data); + } + + public function __construct($data) + { + $this->url = $data['url']; + $this->id = $data['id']; + $this->htmlUrl = $data['html_url']; + $diffUrl = isset($data['diff_url']) ? $data['diff_url'] : null; + $diffUrlFromPR = isset($data['pull_request']['diff_url']) ? $data['pull_request']['diff_url'] : null; + $this->diffUrl = !is_null($diffUrl) ? $diffUrl : $diffUrlFromPR; + $this->issueUrl = isset($data['issue_url']) ? $data['issue_url'] : null; + $this->number = $data['number']; + $this->state = $data['state']; + $this->isLocked = $data['locked']; + $this->title = $data['title']; + $this->user = User::createFromData($data['user']); + $this->body = $data['body']; + $this->createdAt = $data['created_at']; + $this->updatedAt = isset($data['updated_at']) ? $data['updated_at'] : null; + $this->closedAt = $data['closed_at']; + $this->mergedAt = isset($data['merged_at']) ? $data['merged_at'] : null; + $this->mergeCommitSha = isset($data['merge_commit_sha']) ? $data['merge_commit_sha'] : null; + $this->assignee = isset($data['assignee']) ? User::createFromData($data['assignee']) : null; + $this->milestone = $data['milestone']; + $this->commitsUrl = isset($data['commits_url']) ? $data['commits_url'] : null; + $this->reviewCommentUrl = isset($data['review_comment_url']) ? $data['review_comment_url'] : null; + $this->reviewCommentsUrl = isset($data['review_comments_url']) ? $data['review_comments_url'] : null; + $this->statusesUrl = isset($data['statuses_url']) ? $data['statuses_url'] : null; + $this->isMerged = isset($data['merged']) ? $data['merged'] : null; + $this->isMergeable = isset($data['mergeable']) ? $data['mergeable'] : null; + $this->mergeableState = isset($data['mergeable_state']) ? $data['mergeable_state'] : false; + $this->mergedBy = isset($data['merged_by']) ? User::createFromData($data['merged_by']) : null; + $this->commentsCount = isset($data['comments']) ? $data['comments'] : null; + $this->reviewCommentsCount = isset($data['review_comments']) ? $data['review_comments'] : null; + $this->commitSha = isset($data['head']['sha']) ? $data['head']['sha'] : null; + $this->base = isset($data['base']) ? $data['base'] : null; + $this->head = isset($data['head']) ? $data['head'] : null; + } + + /** + * Gets the value of url. + * + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + + /** + * Sets the value of url. + * + * @param mixed $url the url + * + * @return self + */ + public function setUrl($url) + { + $this->url = $url; + + return $this; + } + + /** + * Gets the value of id. + * + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * Sets the value of id. + * + * @param mixed $id the id + * + * @return self + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * Gets the value of htmlUrl. + * + * @return mixed + */ + public function getHtmlUrl() + { + return $this->htmlUrl; + } + + /** + * Sets the value of htmlUrl. + * + * @param mixed $htmlUrl the html url + * + * @return self + */ + public function setHtmlUrl($htmlUrl) + { + $this->htmlUrl = $htmlUrl; + + return $this; + } + + /** + * Gets the value of diffUrl. + * + * @return mixed + */ + public function getDiffUrl() + { + return $this->diffUrl; + } + + /** + * Sets the value of diffUrl. + * + * @param mixed $diffUrl the diff url + * + * @return self + */ + public function setDiffUrl($diffUrl) + { + $this->diffUrl = $diffUrl; + + return $this; + } + + /** + * Gets the value of issueUrl. + * + * @return mixed + */ + public function getIssueUrl() + { + return $this->issueUrl; + } + + /** + * Sets the value of issueUrl. + * + * @param mixed $issueUrl the issue url + * + * @return self + */ + public function setIssueUrl($issueUrl) + { + $this->issueUrl = $issueUrl; + + return $this; + } + + /** + * Gets the value of number. + * + * @return mixed + */ + public function getNumber() + { + return $this->number; + } + + /** + * Sets the value of number. + * + * @param mixed $number the number + * + * @return self + */ + public function setNumber($number) + { + $this->number = $number; + + return $this; + } + + /** + * Gets the value of state. + * + * @return mixed + */ + public function getState() + { + return $this->state; + } + + /** + * Sets the value of state. + * + * @param mixed $state the state + * + * @return self + */ + public function setState($state) + { + $this->state = $state; + + return $this; + } + + /** + * Gets the value of locked. + * + * @return bool + */ + public function isLocked() + { + return (bool) $this->islocked; + } + + /** + * Sets the value of locked. + * + * @param mixed $locked the locked + * + * @return self + */ + public function setLocked($locked) + { + $this->isLocked = $locked; + + return $this; + } + + /** + * Gets the value of title. + * + * @return mixed + */ + public function getTitle() + { + return $this->title; + } + + /** + * Sets the value of title. + * + * @param mixed $title the title + * + * @return self + */ + public function setTitle($title) + { + $this->title = $title; + + return $this; + } + + /** + * Gets the value of user. + * + * @return mixed + */ + public function getUser() + { + return $this->user; + } + + /** + * Sets the value of user. + * + * @param mixed $user the user + * + * @return self + */ + public function setUser($user) + { + $this->user = $user; + + return $this; + } + + /** + * Gets the value of body. + * + * @return mixed + */ + public function getBody() + { + return $this->body; + } + + /** + * Sets the value of body. + * + * @param mixed $body the body + * + * @return self + */ + public function setBody($body) + { + $this->body = $body; + + return $this; + } + + /** + * Gets the value of createdAt. + * + * @return mixed + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Sets the value of createdAt. + * + * @param mixed $createdAt the created at + * + * @return self + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Gets the value of updatedAt. + * + * @return mixed + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Sets the value of updatedAt. + * + * @param mixed $updatedAt the updated at + * + * @return self + */ + public function setUpdatedAt($updatedAt) + { + $this->updatedAt = $updatedAt; + + return $this; + } + + /** + * Gets the value of closedAt. + * + * @return mixed + */ + public function getClosedAt() + { + return $this->closedAt; + } + + /** + * Sets the value of closedAt. + * + * @param mixed $closedAt the closed at + * + * @return self + */ + public function setClosedAt($closedAt) + { + $this->closedAt = $closedAt; + + return $this; + } + + /** + * Gets the value of mergedAt. + * + * @return mixed + */ + public function getMergedAt() + { + return $this->mergedAt; + } + + /** + * Sets the value of mergedAt. + * + * @param mixed $mergedAt the merged at + * + * @return self + */ + public function setMergedAt($mergedAt) + { + $this->mergedAt = $mergedAt; + + return $this; + } + + /** + * Gets the value of mergeCommitSha. + * + * @return mixed + */ + public function getMergeCommitSha() + { + return $this->mergeCommitSha; + } + + /** + * Sets the value of mergeCommitSha. + * + * @param mixed $mergeCommitSha the merge commit sha + * + * @return self + */ + public function setMergeCommitSha($mergeCommitSha) + { + $this->mergeCommitSha = $mergeCommitSha; + + return $this; + } + + /** + * Gets the value of assignee. + * + * @return mixed + */ + public function getAssignee() + { + return $this->assignee; + } + + /** + * Sets the value of assignee. + * + * @param mixed $assignee the assignee + * + * @return self + */ + public function setAssignee($assignee) + { + $this->assignee = $assignee; + + return $this; + } + + /** + * Gets the value of milestone. + * + * @return mixed + */ + public function getMilestone() + { + return $this->milestone; + } + + /** + * Sets the value of milestone. + * + * @param mixed $milestone the milestone + * + * @return self + */ + public function setMilestone($milestone) + { + $this->milestone = $milestone; + + return $this; + } + + /** + * Gets the value of commitsUrl. + * + * @return mixed + */ + public function getCommitsUrl() + { + return $this->commitsUrl; + } + + /** + * Sets the value of commitsUrl. + * + * @param mixed $commitsUrl the commits url + * + * @return self + */ + public function setCommitsUrl($commitsUrl) + { + $this->commitsUrl = $commitsUrl; + + return $this; + } + + /** + * Gets the value of reviewCommentUrl. + * + * @return mixed + */ + public function getReviewCommentUrl() + { + return $this->reviewCommentUrl; + } + + /** + * Sets the value of reviewCommentUrl. + * + * @param mixed $reviewCommentUrl the review comment url + * + * @return self + */ + public function setReviewCommentUrl($reviewCommentUrl) + { + $this->reviewCommentUrl = $reviewCommentUrl; + + return $this; + } + + /** + * Gets the value of reviewCommentsUrl. + * + * @return mixed + */ + public function getReviewCommentsUrl() + { + return $this->reviewCommentsUrl; + } + + /** + * Sets the value of reviewCommentsUrl. + * + * @param mixed $reviewCommentsUrl the review comments url + * + * @return self + */ + public function setReviewCommentsUrl($reviewCommentsUrl) + { + $this->reviewCommentsUrl = $reviewCommentsUrl; + + return $this; + } + + /** + * Gets the value of statusesUrl. + * + * @return mixed + */ + public function getStatusesUrl() + { + return $this->statusesUrl; + } + + /** + * Sets the value of statusesUrl. + * + * @param mixed $statusesUrl the statuses url + * + * @return self + */ + public function setStatusesUrl($statusesUrl) + { + $this->statusesUrl = $statusesUrl; + + return $this; + } + + /** + * Gets the value of merged. + * + * @return bool + */ + public function isMerged() + { + return (bool) $this->isMerged; + } + + /** + * Sets the value of merged. + * + * @param mixed $merged the merged + * + * @return self + */ + public function setMerged($merged) + { + $this->isMerged = $merged; + + return $this; + } + + /** + * Gets the value of mergeable. + * + * @return bool + */ + public function isMergeable() + { + return (bool) $this->isMergeable; + } + + /** + * Sets the value of mergeable. + * + * @param mixed $mergeable the mergeable + * + * @return self + */ + public function setMergeable($mergeable) + { + $this->isMergeable = $mergeable; + + return $this; + } + + /** + * Gets the value of mergeableState. + * + * @return mixed + */ + public function getMergeableState() + { + return $this->mergeableState; + } + + /** + * Sets the value of mergeableState. + * + * @param mixed $mergeableState the mergeable state + * + * @return self + */ + public function setMergeableState($mergeableState) + { + $this->mergeableState = $mergeableState; + + return $this; + } + + /** + * Gets the value of mergedBy. + * + * @return mixed + */ + public function getMergedBy() + { + return $this->mergedBy; + } + + /** + * Sets the value of mergedBy. + * + * @param mixed $mergedBy the merged by + * + * @return self + */ + public function setMergedBy($mergedBy) + { + $this->mergedBy = $mergedBy; + + return $this; + } + + /** + * Gets the count of comments. + * + * @return mixed + */ + public function getCommentsCount() + { + return $this->commentsCount; + } + + /** + * Sets the count of comments. + * + * @param mixed $comments the comments + * + * @return self + */ + public function setCommentsCount($comments) + { + $this->commentsCount = $comments; + + return $this; + } + + /** + * Gets the count of reviewComments. + * + * @return mixed + */ + public function getReviewCommentsCount() + { + return $this->reviewCommentsCount; + } + + /** + * Sets the count of reviewComments. + * + * @param mixed $reviewComments the review comments + * + * @return self + */ + public function setReviewCommentsCount($reviewComments) + { + $this->reviewCommentsCount = $reviewComments; + + return $this; + } + + /** + * Gets the count of commits. + * + * @return mixed + */ + public function getCommitsCount() + { + return $this->commitsCount; + } + + /** + * Sets the value of commits. + * + * @param mixed $commits the commits + * + * @return self + */ + public function setCommitsCount($commits) + { + $this->commitsCount = $commits; + + return $this; + } + + /** + * Gets the value of additions. + * + * @return mixed + */ + public function getAdditions() + { + return $this->additions; + } + + /** + * Sets the value of additions. + * + * @param mixed $additions the additions + * + * @return self + */ + public function setAdditions($additions) + { + $this->additions = $additions; + + return $this; + } + + /** + * Gets the value of deletions. + * + * @return mixed + */ + public function getDeletions() + { + return $this->deletions; + } + + /** + * Sets the value of deletions. + * + * @param mixed $deletions the deletions + * + * @return self + */ + public function setDeletions($deletions) + { + $this->deletions = $deletions; + + return $this; + } + + /** + * Gets the value of changedFiles. + * + * @return mixed + */ + public function getChangedFiles() + { + return $this->changedFiles; + } + + /** + * Sets the value of changedFiles. + * + * @param mixed $changedFiles the changed files + * + * @return self + */ + public function setChangedFiles($changedFiles) + { + $this->changedFiles = $changedFiles; + + return $this; + } + + /** + * Gets the value of commit. + * + * @return mixed + */ + public function getCommitSha() + { + return $this->commitSha; + } + + /** + * Get the commits. + * + * @return Commit[] + */ + public function getCommits() + { + if ('' === ini_get('user_agent')) { + throw new UserAgentNotFoundException(); + } + + if (!ini_get('allow_url_fopen')) { + throw new AllowUrlFileOpenException(); + } + + $jsonResponse = $this->getFileContent($this->getCommitsUrl(), ini_get('user_agent')); + $response = json_decode($jsonResponse, true); + + foreach ($response as $commitArray) { + $commit = Commit::createFromData($commitArray['commit']) + ->setSha($commitArray['sha']) + ; + + $commits[] = $commit; + } + + return $commits; + } + + /** + * Some helpers. + */ + public function isClosed() + { + return 'closed' === $this->state; + } + + /* + * Get the HEAD information. + * + * @return array + */ + public function getHead() + { + return $this->head; + } + + /** + * Get the BASE information. + * + * @return array + */ + public function getBase() + { + return $this->base; + } + + /** + * A better file_get_contents + */ + private function getFileContent($url, $userAgent) + { + $opts = [ + 'http' => [ + 'method' => 'GET', + 'header' => [ + 'User-Agent: '. $userAgent + ] + ] + ]; + + $context = stream_context_create($opts); + + return file_get_contents($url, false, $context); + } +} diff --git a/lp-digital/github-event-parser/Entity/Release.php b/lp-digital/github-event-parser/Entity/Release.php new file mode 100644 index 0000000..204962a --- /dev/null +++ b/lp-digital/github-event-parser/Entity/Release.php @@ -0,0 +1,229 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class Release +{ + private $url; + private $assetsUrl; + private $uploadUrl; + private $htmlUrl; + private $id; + private $tagName; + private $targetCommitish; + private $name; + private $isDraft; + private $author; + private $isPreRelease; + private $createdAt; + private $publishedAt; + private $assets; + private $tarballUrl; + private $zipballUrl; + private $body; + private $repository; + private $sender; + + public static function createFromData(array $data, Repository $repository, User $sender) + { + return new static($data, $repository, $sender); + } + + public function __construct(array $data, Repository $repository, User $sender) + { + $this->url = $data['url']; + $this->assetsUrl = $data['assets_url']; + $this->uploadUrl = $data['upload_url']; + $this->htmlUrl = $data['html_url']; + $this->id = $data['id']; + $this->tagName = $data['tag_name']; + $this->targetCommitish = $data['target_commitish']; + $this->name = $data['name']; + $this->isDraft = $data['draft']; + $this->author = User::createFromData($data['author']); + $this->isPreRelease = $data['prerelease']; + $this->createdAt = $data['created_at']; + $this->publishedAt = $data['published_at']; + $this->assets = $data['assets']; + $this->tarballUrl = $data['tarball_url']; + $this->zipballUrl = $data['zipball_url']; + $this->body = $data['body']; + $this->repository = $repository; + $this->sender = $sender; + } + + /** + * @return mixed + */ + public function getAssetsUrl() + { + return $this->assetsUrl; + } + + /** + * @return mixed + */ + public function getUploadUrl() + { + return $this->uploadUrl; + } + + /** + * @return mixed + */ + public function getHtmlUrl() + { + return $this->htmlUrl; + } + + /** + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * @return mixed + */ + public function getTagName() + { + return $this->tagName; + } + + /** + * @return mixed + */ + public function getTargetCommitish() + { + return $this->targetCommitish; + } + + /** + * @return mixed + */ + public function isDraft() + { + return $this->isDraft; + } + + /** + * @return mixed + */ + public function getAuthor() + { + return $this->author; + } + + /** + * @return mixed + */ + public function isPreRelease() + { + return $this->isPreRelease; + } + + /** + * @return mixed + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * @return mixed + */ + public function getPublishedAt() + { + return $this->publishedAt; + } + + /** + * @return mixed + */ + public function getAssets() + { + return $this->assets; + } + + /** + * @return mixed + */ + public function getTarballUrl() + { + return $this->tarballUrl; + } + + /** + * @return mixed + */ + public function getZipballUrl() + { + return $this->zipballUrl; + } + + /** + * @return mixed + */ + public function getBody() + { + return $this->body; + } + + /** + * @return mixed + */ + public function getRepository() + { + return $this->repository; + } + + /** + * @return mixed + */ + public function getSender() + { + return $this->sender; + } + + /** + * Gets the value of url. + * + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + + /** + * Gets the value of name. + * + * @return mixed + */ + public function getName() + { + return $this->name; + } +} diff --git a/lp-digital/github-event-parser/Entity/Repository.php b/lp-digital/github-event-parser/Entity/Repository.php new file mode 100644 index 0000000..55307dd --- /dev/null +++ b/lp-digital/github-event-parser/Entity/Repository.php @@ -0,0 +1,831 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class Repository +{ + private $id; + private $name; + private $fullName; + + /** + * @var User + */ + private $owner; + private $isPrivate; + private $htmlUrl; + private $description; + private $isFork; + private $url; + private $forksUrl; + private $keysUrl; + private $collaboratorsUrl; + private $teamsUrl; + private $hooksUrl; + private $issueEventsUrl; + private $eventsUrl; + private $assigneesUrl; + private $branchesUrl; + private $tagsUrl; + private $blobsUrl; + private $gitTagsUrl; + private $gitRefsUrl; + private $treesUrl; + private $statusesUrl; + private $languagesUrl; + private $stargazersUrl; + private $contributorsUrl; + private $subscribersUrl; + private $subscriptionUrl; + private $commitsUrl; + private $gitCommitsUrl; + private $commentsUrl; + private $issueCommentUrl; + private $contentsUrl; + private $compareUrl; + private $mergesUrl; + private $archiveUrl; + private $downloadsUrl; + private $issuesUrl; + private $pullsUrl; + private $milestonesUrl; + private $notificationsUrl; + private $labelsUrl; + private $releasesUrl; + private $createdAt; + private $updatedAt; + private $pushedAt; + private $gitUrl; + private $sshUrl; + private $cloneUrl; + private $svnUrl; + private $homepage; + private $size; + private $stargazersCount; + private $watchersCount; + private $language; + private $hasIssues; + private $hasDownloads; + private $hasWiki; + private $hasPages; + private $forksCount; + private $mirrorUrl; + private $openIssues; + private $watchers; + private $defaultBranch; + private $isPublic; + + public static function createFromData(array $data) + { + return new static($data); + } + + public function __construct($data) + { + $this->id = $data['id']; + $this->name = $data['name']; + $this->fullName = $data['full_name']; + $this->owner = User::createFromData($data['owner']); + $this->isPrivate = $data['private']; + $this->htmlUrl = $data['html_url']; + $this->description = $data['description']; + $this->isFork = $data['fork']; + $this->url = $data['url']; + $this->forksUrl = $data['forks_url']; + $this->keysUrl = $data['keys_url']; + $this->collaboratorsUrl = $data['collaborators_url']; + $this->teamsUrl = $data['teams_url']; + $this->hooksUrl = $data['hooks_url']; + $this->issueEventsUrl = $data['issue_events_url']; + $this->eventsUrl = $data['events_url']; + $this->assigneesUrl = $data['assignees_url']; + $this->branchesUrl = $data['branches_url']; + $this->tagsUrl = $data['tags_url']; + $this->blobsUrl = $data['blobs_url']; + $this->gitTagsUrl = $data['git_tags_url']; + $this->gitRefsUrl = $data['git_refs_url']; + $this->treesUrl = $data['trees_url']; + $this->statusesUrl = $data['statuses_url']; + $this->languagesUrl = $data['languages_url']; + $this->stargazersUrl = $data['stargazers_url']; + $this->contributorsUrl = $data['contributors_url']; + $this->subscribersUrl = $data['subscribers_url']; + $this->subscriptionUrl = $data['subscription_url']; + $this->commitsUrl = $data['commits_url']; + $this->gitCommitsUrl = $data['git_commits_url']; + $this->commentsUrl = $data['comments_url']; + $this->issueCommentUrl = $data['issue_comment_url']; + $this->contentsUrl = $data['contents_url']; + $this->compareUrl = $data['compare_url']; + $this->mergesUrl = $data['merges_url']; + $this->archiveUrl = $data['archive_url']; + $this->downloadsUrl = $data['downloads_url']; + $this->issuesUrl = $data['issues_url']; + $this->pullsUrl = $data['pulls_url']; + $this->milestonesUrl = $data['milestones_url']; + $this->notificationsUrl = $data['notifications_url']; + $this->labelsUrl = $data['labels_url']; + $this->releasesUrl = $data['releases_url']; + $this->createdAt = $data['created_at']; + $this->updatedAt = $data['updated_at']; + $this->pushedAt = $data['pushed_at']; + $this->gitUrl = $data['git_url']; + $this->sshUrl = $data['ssh_url']; + $this->cloneUrl = $data['clone_url']; + $this->svnUrl = $data['svn_url']; + $this->homepage = $data['homepage']; + $this->size = $data['size']; + $this->stargazersCount = $data['stargazers_count']; + $this->watchersCount = $data['watchers_count']; + $this->language = $data['language']; + $this->hasIssues = $data['has_issues']; + $this->hasDownloads = $data['has_downloads']; + $this->hasWiki = $data['has_wiki']; + $this->hasPages = $data['has_pages']; + $this->forksCount = $data['forks_count']; + $this->mirrorUrl = $data['mirror_url']; + $this->openIssues = $data['open_issues']; + $this->watchers = $data['watchers']; + $this->defaultBranch = $data['default_branch']; + $this->isPublic = isset($data['public']) ?: null; + } + + /** + * Gets the value of id. + * + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * Gets the value of name. + * + * @return mixed + */ + public function getName() + { + return $this->name; + } + + /** + * Gets the value of fullName. + * + * @return mixed + */ + public function getFullName() + { + return $this->fullName; + } + + /** + * Gets the value of owner. + * + * @return User + */ + public function getOwner() + { + return $this->owner; + } + + /** + * Gets the value of isPrivate. + * + * @return mixed + */ + public function isPrivate() + { + return $this->isPrivate; + } + + /** + * Gets the value of htmlUrl. + * + * @return mixed + */ + public function getHtmlUrl() + { + return $this->htmlUrl; + } + + /** + * Gets the value of description. + * + * @return mixed + */ + public function getDescription() + { + return $this->description; + } + + /** + * Gets the value of isFork. + * + * @return mixed + */ + public function isFork() + { + return $this->isFork; + } + + /** + * Gets the value of url. + * + * @return mixed + */ + public function getUrl() + { + return $this->url; + } + + /** + * Gets the value of forksUrl. + * + * @return mixed + */ + public function getForksUrl() + { + return $this->forksUrl; + } + + /** + * Gets the value of keysUrl. + * + * @return mixed + */ + public function getKeysUrl() + { + return $this->keysUrl; + } + + /** + * Gets the value of collaboratorsUrl. + * + * @return mixed + */ + public function getCollaboratorsUrl() + { + return $this->collaboratorsUrl; + } + + /** + * Gets the value of teamsUrl. + * + * @return mixed + */ + public function getTeamsUrl() + { + return $this->teamsUrl; + } + + /** + * Gets the value of hooksUrl. + * + * @return mixed + */ + public function getHooksUrl() + { + return $this->hooksUrl; + } + + /** + * Gets the value of issueEventsUrl. + * + * @return mixed + */ + public function getIssueEventsUrl() + { + return $this->issueEventsUrl; + } + + /** + * Gets the value of eventsUrl. + * + * @return mixed + */ + public function getEventsUrl() + { + return $this->eventsUrl; + } + + /** + * Gets the value of assigneesUrl. + * + * @return mixed + */ + public function getAssigneesUrl() + { + return $this->assigneesUrl; + } + + /** + * Gets the value of branchesUrl. + * + * @return mixed + */ + public function getBranchesUrl() + { + return $this->branchesUrl; + } + + /** + * Gets the value of tagsUrl. + * + * @return mixed + */ + public function getTagsUrl() + { + return $this->tagsUrl; + } + + /** + * Gets the value of blobsUrl. + * + * @return mixed + */ + public function getBlobsUrl() + { + return $this->blobsUrl; + } + + /** + * Gets the value of gitTagsUrl. + * + * @return mixed + */ + public function getGitTagsUrl() + { + return $this->gitTagsUrl; + } + + /** + * Gets the value of gitRefsUrl. + * + * @return mixed + */ + public function getGitRefsUrl() + { + return $this->gitRefsUrl; + } + + /** + * Gets the value of treesUrl. + * + * @return mixed + */ + public function getTreesUrl() + { + return $this->treesUrl; + } + + /** + * Gets the value of statusesUrl. + * + * @return mixed + */ + public function getStatusesUrl() + { + return $this->statusesUrl; + } + + /** + * Gets the value of languagesUrl. + * + * @return mixed + */ + public function getLanguagesUrl() + { + return $this->languagesUrl; + } + + /** + * Gets the value of stargazersUrl. + * + * @return mixed + */ + public function getStargazersUrl() + { + return $this->stargazersUrl; + } + + /** + * Gets the value of contributorsUrl. + * + * @return mixed + */ + public function getContributorsUrl() + { + return $this->contributorsUrl; + } + + /** + * Gets the value of subscribersUrl. + * + * @return mixed + */ + public function getSubscribersUrl() + { + return $this->subscribersUrl; + } + + /** + * Gets the value of subscriptionUrl. + * + * @return mixed + */ + public function getSubscriptionUrl() + { + return $this->subscriptionUrl; + } + + /** + * Gets the value of commitsUrl. + * + * @return mixed + */ + public function getCommitsUrl() + { + return $this->commitsUrl; + } + + /** + * Gets the value of gitCommitsUrl. + * + * @return mixed + */ + public function getGitCommitsUrl() + { + return $this->gitCommitsUrl; + } + + /** + * Gets the value of commentsUrl. + * + * @return mixed + */ + public function getCommentsUrl() + { + return $this->commentsUrl; + } + + /** + * Gets the value of issueCommentUrl. + * + * @return mixed + */ + public function getIssueCommentUrl() + { + return $this->issueCommentUrl; + } + + /** + * Gets the value of contentsUrl. + * + * @return mixed + */ + public function getContentsUrl() + { + return $this->contentsUrl; + } + + /** + * Gets the value of compareUrl. + * + * @return mixed + */ + public function getCompareUrl() + { + return $this->compareUrl; + } + + /** + * Gets the value of mergesUrl. + * + * @return mixed + */ + public function getMergesUrl() + { + return $this->mergesUrl; + } + + /** + * Gets the value of archiveUrl. + * + * @return mixed + */ + public function getArchiveUrl() + { + return $this->archiveUrl; + } + + /** + * Gets the value of downloadsUrl. + * + * @return mixed + */ + public function getDownloadsUrl() + { + return $this->downloadsUrl; + } + + /** + * Gets the value of issuesUrl. + * + * @return mixed + */ + public function getIssuesUrl() + { + return $this->issuesUrl; + } + + /** + * Gets the value of pullsUrl. + * + * @return mixed + */ + public function getPullsUrl() + { + return $this->pullsUrl; + } + + /** + * Gets the value of milestonesUrl. + * + * @return mixed + */ + public function getMilestonesUrl() + { + return $this->milestonesUrl; + } + + /** + * Gets the value of notificationsUrl. + * + * @return mixed + */ + public function getNotificationsUrl() + { + return $this->notificationsUrl; + } + + /** + * Gets the value of labelsUrl. + * + * @return mixed + */ + public function getLabelsUrl() + { + return $this->labelsUrl; + } + + /** + * Gets the value of releasesUrl. + * + * @return mixed + */ + public function getReleasesUrl() + { + return $this->releasesUrl; + } + + /** + * Gets the value of createdAt. + * + * @return mixed + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Gets the value of updatedAt. + * + * @return mixed + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Gets the value of pushedAt. + * + * @return mixed + */ + public function getPushedAt() + { + return $this->pushedAt; + } + + /** + * Gets the value of gitUrl. + * + * @return mixed + */ + public function getGitUrl() + { + return $this->gitUrl; + } + + /** + * Gets the value of sshUrl. + * + * @return mixed + */ + public function getSshUrl() + { + return $this->sshUrl; + } + + /** + * Gets the value of cloneUrl. + * + * @return mixed + */ + public function getCloneUrl() + { + return $this->cloneUrl; + } + + /** + * Gets the value of svnUrl. + * + * @return mixed + */ + public function getSvnUrl() + { + return $this->svnUrl; + } + + /** + * Gets the value of homepage. + * + * @return mixed + */ + public function getHomepage() + { + return $this->homepage; + } + + /** + * Gets the value of size. + * + * @return mixed + */ + public function getSize() + { + return $this->size; + } + + /** + * Gets the value of stargazersCount. + * + * @return mixed + */ + public function getStargazersCount() + { + return $this->stargazersCount; + } + + /** + * Gets the value of watchersCount. + * + * @return mixed + */ + public function getWatchersCount() + { + return $this->watchersCount; + } + + /** + * Gets the value of language. + * + * @return mixed + */ + public function getLanguage() + { + return $this->language; + } + + /** + * Gets the value of hasIssues. + * + * @return mixed + */ + public function getHasIssues() + { + return $this->hasIssues; + } + + /** + * Gets the value of hasDownloads. + * + * @return mixed + */ + public function getHasDownloads() + { + return $this->hasDownloads; + } + + /** + * Gets the value of hasWiki. + * + * @return mixed + */ + public function getHasWiki() + { + return $this->hasWiki; + } + + /** + * Gets the value of hasPages. + * + * @return mixed + */ + public function getHasPages() + { + return $this->hasPages; + } + + /** + * Gets the value of forksCount. + * + * @return mixed + */ + public function getForksCount() + { + return $this->forksCount; + } + + /** + * Gets the value of mirrorUrl. + * + * @return mixed + */ + public function getMirrorUrl() + { + return $this->mirrorUrl; + } + + /** + * Gets the value of openIssues. + * + * @return mixed + */ + public function getOpenIssues() + { + return $this->openIssues; + } + + /** + * Gets the value of watchers. + * + * @return mixed + */ + public function getWatchers() + { + return $this->watchers; + } + + /** + * Gets the value of defaultBranch. + * + * @return mixed + */ + public function getDefaultBranch() + { + return $this->defaultBranch; + } + + /** + * Gets the value of isPublic. + * + * @return mixed + */ + public function isPublic() + { + return $this->isPublic; + } +} diff --git a/lp-digital/github-event-parser/Entity/User.php b/lp-digital/github-event-parser/Entity/User.php new file mode 100644 index 0000000..484bed4 --- /dev/null +++ b/lp-digital/github-event-parser/Entity/User.php @@ -0,0 +1,243 @@ +. + */ + +namespace Lpdigital\Github\Entity; + +class User +{ + private $login; + private $id; + private $avatarUrl; + private $gravatarId; + private $apiUrl; + private $htmlUrl; + private $followersUrl; + private $followingUrl; + private $gistsUrl; + private $starredUrl; + private $subscriptionsUrl; + private $organizationsUrl; + private $repositoriesUrl; + private $eventsUrl; + private $receivedEventsUrl; + private $type; + private $siteAdmin; + + public static function createFromData(array $data) + { + if (isset($data['login'], $data['id'])) { + return new static($data); + } + + return $data['name']; + } + + public function __construct($data) + { + $this->login = $data['login']; + $this->id = $data['id']; + $this->avatarUrl = $data['avatar_url']; + $this->gravatarId = $data['gravatar_id']; + $this->apiUrl = $data['url']; + $this->htmlUrl = $data['html_url']; + $this->followersUrl = $data['followers_url']; + $this->followingUrl = $data['following_url']; + $this->gistsUrl = $data['gists_url']; + $this->starredUrl = $data['starred_url']; + $this->subscriptionsUrl = $data['subscriptions_url']; + $this->organizationsUrl = $data['organizations_url']; + $this->repositoriesUrl = $data['repos_url']; + $this->eventsUrl = $data['events_url']; + $this->receivedEventsUrl = $data['received_events_url']; + $this->type = $data['type']; + $this->siteAdmin = $data['site_admin']; + } + + /** + * Gets the value of login. + * + * @return mixed + */ + public function getLogin() + { + return $this->login; + } + + /** + * Gets the value of id. + * + * @return mixed + */ + public function getId() + { + return $this->id; + } + + /** + * Gets the value of avatarUrl. + * + * @return mixed + */ + public function getAvatarUrl() + { + return $this->avatarUrl; + } + + /** + * Gets the value of gravatarId. + * + * @return mixed + */ + public function getGravatarId() + { + return $this->gravatarId; + } + + /** + * Gets the value of apiUrl. + * + * @return mixed + */ + public function getApiUrl() + { + return $this->apiUrl; + } + + /** + * Gets the value of htmlUrl. + * + * @return mixed + */ + public function getHtmlUrl() + { + return $this->htmlUrl; + } + + /** + * Gets the value of followersUrl. + * + * @return mixed + */ + public function getFollowersUrl() + { + return $this->followersUrl; + } + + /** + * Gets the value of followingUrl. + * + * @return mixed + */ + public function getFollowingUrl() + { + return $this->followingUrl; + } + + /** + * Gets the value of gistsUrl. + * + * @return mixed + */ + public function getGistsUrl() + { + return $this->gistsUrl; + } + + /** + * Gets the value of starredUrl. + * + * @return mixed + */ + public function getStarredUrl() + { + return $this->starredUrl; + } + + /** + * Gets the value of organizationsUrl. + * + * @return mixed + */ + public function getOrganizationsUrl() + { + return $this->organizationsUrl; + } + + /** + * Gets the value of subscriptionsUrl. + * + * @return mixed + */ + public function getSubscriptionsUrl() + { + return $this->subscriptionsUrl; + } + + /** + * Gets the value of repositoriesUrl. + * + * @return mixed + */ + public function getRepositoriesUrl() + { + return $this->repositoriesUrl; + } + + /** + * Gets the value of eventsUrl. + * + * @return mixed + */ + public function getEventsUrl() + { + return $this->eventsUrl; + } + + /** + * Gets the value of receivedEventsUrl. + * + * @return mixed + */ + public function getReceivedEventsUrl() + { + return $this->receivedEventsUrl; + } + + /** + * Gets the value of type. + * + * @return mixed + */ + public function getType() + { + return $this->type; + } + + /** + * Gets the value of siteAdmin. + * + * @return mixed + */ + public function getSiteAdmin() + { + return $this->siteAdmin; + } +} diff --git a/lp-digital/github-event-parser/EventType/AbstractEventType.php b/lp-digital/github-event-parser/EventType/AbstractEventType.php new file mode 100644 index 0000000..f5d2e78 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/AbstractEventType.php @@ -0,0 +1,70 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\Integration; + +abstract class AbstractEventType implements GithubEventInterface +{ + /** + * @var array + */ + private $data; + + /** + * @var Integration|null + */ + public $integration; + + public function getPayload() + { + return $this->data; + } + + public static function fields() + { + return []; + } + + public static function name() + { + return get_called_class(); + } + + public static function isValid($data) + { + foreach (static::fields() as $field) { + if ((isset($data[$field]) || array_key_exists($field, $data)) === false) { + return false; + } + } + + return true; + } + + public function createFromData($data) + { + $this->data = $data; + + $this->integration = isset($data['installation']) ? Integration::createFromData($data['installation']) : null; + } +} diff --git a/lp-digital/github-event-parser/EventType/ActionableEventInterface.php b/lp-digital/github-event-parser/EventType/ActionableEventInterface.php new file mode 100644 index 0000000..a690a34 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/ActionableEventInterface.php @@ -0,0 +1,34 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +/** + * Made the event actionable + * Made the system aware that this event have an action. + */ +interface ActionableEventInterface +{ + /** + * @return string action name + */ + public function getAction(); +} diff --git a/lp-digital/github-event-parser/EventType/DeploymentStatusEvent.php b/lp-digital/github-event-parser/EventType/DeploymentStatusEvent.php new file mode 100644 index 0000000..9522f74 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/DeploymentStatusEvent.php @@ -0,0 +1,58 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\Deployment; +use Lpdigital\Github\Entity\User; + +class DeploymentStatusEvent extends RepositoryAwareEventType +{ + /** + * @var Deployment + */ + public $deployment; + + /** + * @var User + */ + public $sender; + + public static function name() + { + return 'DeploymentStatusEvent'; + } + + public static function fields() + { + return ['deployment_status', 'deployment', 'repository']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->deployment = Deployment::createFromData($data['deployment']); + $this->sender = User::createFromData($data['sender']); + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/ForkEvent.php b/lp-digital/github-event-parser/EventType/ForkEvent.php new file mode 100644 index 0000000..8e0c90d --- /dev/null +++ b/lp-digital/github-event-parser/EventType/ForkEvent.php @@ -0,0 +1,64 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\Repository; +use Lpdigital\Github\Entity\User; + +class ForkEvent extends RepositoryAwareEventType +{ + /** + * @var Repository + */ + public $forkedRepository; + + /** + * @var User + */ + public $owner; + + /** + * @var User + */ + public $forker; + + public static function name() + { + return 'ForkEvent'; + } + + public static function fields() + { + return ['forkee']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->forkedRepository = Repository::createFromData($data['forkee']); + $this->owner = $this->forkedRepository->getOwner(); + $this->forker = $this->repository->getOwner(); + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/GithubEventInterface.php b/lp-digital/github-event-parser/EventType/GithubEventInterface.php new file mode 100644 index 0000000..335a63e --- /dev/null +++ b/lp-digital/github-event-parser/EventType/GithubEventInterface.php @@ -0,0 +1,54 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +interface GithubEventInterface +{ + /** + * @return array list of fields that need to be present to define the event + */ + public static function fields(); + + /** + * @return string name event + */ + public static function name(); + + /** + * @param $data array data of the event + * + * @return bool validation rule + */ + public static function isValid($data); + + /** + * @param $data array data of the event + * + * @return GithubEventInterface + */ + public function createFromData($data); + + /** + * @return array data of the event + */ + public function getPayload(); +} diff --git a/lp-digital/github-event-parser/EventType/GollumEvent.php b/lp-digital/github-event-parser/EventType/GollumEvent.php new file mode 100644 index 0000000..4e0d252 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/GollumEvent.php @@ -0,0 +1,68 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\Page; +use Lpdigital\Github\Entity\User; + +class GollumEvent extends RepositoryAwareEventType +{ + /** + * @var array + */ + public $pages; + + /** + * @var User + */ + public $sender; + + public static function name() + { + return 'GollumEvent'; + } + + public static function fields() + { + return ['pages']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->sender = User::createFromData($data['sender']); + $this->pages = $this->parsePages($data['pages']); + + return $this; + } + + private function parsePages(array $arrayPages) + { + $pages = []; + foreach ($arrayPages as $pageEntry) { + $pages[] = Page::createFromData($pageEntry); + } + + return $pages; + } +} diff --git a/lp-digital/github-event-parser/EventType/IntegrationInstallationEvent.php b/lp-digital/github-event-parser/EventType/IntegrationInstallationEvent.php new file mode 100644 index 0000000..7899706 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/IntegrationInstallationEvent.php @@ -0,0 +1,65 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\User; + +class IntegrationInstallationEvent extends AbstractEventType implements ActionableEventInterface +{ + /** + * @var string + */ + public $action; + + /** + * @var User + */ + public $sender; + + /** + * {@inheritdoc} + */ + public function getAction() + { + return $this->action; + } + + public static function name() + { + return 'IntegrationInstallationEvent'; + } + + public static function fields() + { + return ['action', 'installation']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->action = $data['action']; + $this->sender = User::createFromData($data['sender']); + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/IntegrationInstallationRepositoriesEvent.php b/lp-digital/github-event-parser/EventType/IntegrationInstallationRepositoriesEvent.php new file mode 100644 index 0000000..88ecadd --- /dev/null +++ b/lp-digital/github-event-parser/EventType/IntegrationInstallationRepositoriesEvent.php @@ -0,0 +1,81 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\User; + +class IntegrationInstallationRepositoriesEvent extends AbstractEventType implements ActionableEventInterface +{ + public $action; + + /** + * @var User + */ + public $sender; + + /** + * @var string + */ + public $repositorySelection; + + /** + * @var array + */ + public $repositoryAdded; + + /** + * @var array + */ + public $repositoryRemoved; + + /** + * @return string action name + */ + public function getAction() + { + return $this->action; + } + + public static function name() + { + return 'IntegrationInstallationRepositoriesEvent'; + } + + public static function fields() + { + return ['action', 'installation', 'repository_selection', 'repositories_added', 'repositories_removed']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->action = $data['action']; + $this->sender = User::createFromData($data['sender']); + + $this->repositorySelection = $data['repository_selection']; + $this->repositoryAdded = $data['repositories_added']; + $this->repositoryRemoved = $data['repositories_removed']; + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/IssueCommentEvent.php b/lp-digital/github-event-parser/EventType/IssueCommentEvent.php new file mode 100644 index 0000000..f423f43 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/IssueCommentEvent.php @@ -0,0 +1,73 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\Comment; +use Lpdigital\Github\Entity\Issue; +use Lpdigital\Github\Entity\User; + +class IssueCommentEvent extends RepositoryAwareEventType implements ActionableEventInterface +{ + public $action; + + /** + * @var Issue + */ + public $issue; + + /** + * @var User + */ + public $user; + + /** + * @var Comment + */ + public $comment; + + public function getAction() + { + return $this->action; + } + + public static function name() + { + return 'IssueCommentEvent'; + } + + public static function fields() + { + return ['action', 'issue', 'comment']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->action = $data['action']; + $this->issue = Issue::createFromData($data['issue']); + $this->comment = Comment::createFromData($data['comment']); + $this->user = $this->comment->getUser(); + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/IssuesEvent.php b/lp-digital/github-event-parser/EventType/IssuesEvent.php new file mode 100644 index 0000000..ddc0bf0 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/IssuesEvent.php @@ -0,0 +1,116 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\Issue; +use Lpdigital\Github\Entity\Label; +use Lpdigital\Github\Entity\Repository; +use Lpdigital\Github\Entity\User; + +class IssuesEvent extends RepositoryAwareEventType implements ActionableEventInterface +{ + public $action; + + /** + * @var User|null + */ + public $assignee; + + /** + * @var Issue + */ + public $issue; + + /** + * @var Label|null + */ + public $label; + + /** + * @var User + */ + public $sender; + + public function getAction() + { + return $this->action; + } + + public static function name() + { + return 'IssuesEvent'; + } + + public static function fields() + { + return ['action', 'issue']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->action = $data['action']; + $this->assignee = isset($data['assignee']) ? User::createFromData($data['assignee']) : null; + $this->label = isset($data['label']) ? Label::createFromData($data['label']) : null; + $this->issue = Issue::createFromData($data['issue']); + $this->repository = Repository::createFromData($data['repository']); + $this->sender = User::createFromData($data['sender']); + + return $this; + } + + public function isAssigned() + { + return 'assigned' === $this->action; + } + + public function isUnassigned() + { + return 'unassigned' === $this->action; + } + + public function isLabeled() + { + return 'labeled' === $this->action; + } + + public function isUnlabeled() + { + return 'unlabeled' === $this->action; + } + + public function isOpened() + { + return 'opened' === $this->action; + } + + public function isClosed() + { + return 'closed' === $this->action; + } + + public function isReopened() + { + return 'reopened' === $this->action; + } +} diff --git a/lp-digital/github-event-parser/EventType/PullRequestEvent.php b/lp-digital/github-event-parser/EventType/PullRequestEvent.php new file mode 100644 index 0000000..aceae54 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/PullRequestEvent.php @@ -0,0 +1,70 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\PullRequest; +use Lpdigital\Github\Entity\Repository; +use Lpdigital\Github\Entity\User; + +class PullRequestEvent extends RepositoryAwareEventType implements ActionableEventInterface +{ + public $action; + public $number; + + /** + * @var PullRequest + */ + public $pullRequest; + + /** + * @var User + */ + public $sender; + + public function getAction() + { + return $this->action; + } + + public static function name() + { + return 'PullRequestEvent'; + } + + public static function fields() + { + return ['action', 'number', 'pull_request']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->action = $data['action']; + $this->number = $data['number']; + $this->pullRequest = PullRequest::createFromData($data['pull_request']); + $this->repository = Repository::createFromData($data['repository']); + $this->sender = User::createFromData($data['sender']); + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/PullRequestReviewCommentEvent.php b/lp-digital/github-event-parser/EventType/PullRequestReviewCommentEvent.php new file mode 100644 index 0000000..19107b9 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/PullRequestReviewCommentEvent.php @@ -0,0 +1,84 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\Comment; +use Lpdigital\Github\Entity\PullRequest; +use Lpdigital\Github\Entity\User; + +class PullRequestReviewCommentEvent extends RepositoryAwareEventType implements ActionableEventInterface +{ + public $action; + + /** + * @var Comment + */ + public $comment; + + /** + * @var PullRequest + */ + public $pullRequest; + + /** + * @var User + */ + public $sender; + + public function getAction() + { + return $this->action; + } + + public static function name() + { + return 'PullRequestReviewCommentEvent'; + } + + public static function fields() + { + return ['action', 'comment', 'pull_request']; + } + + public static function isValid($data) + { + if (parent::isValid($data)) { + if ($data['action'] === 'created') { + return true; + } + } + + return false; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->action = $data['action']; + $this->comment = Comment::createFromData($data['comment']); + $this->pullRequest = PullRequest::createFromData($data['pull_request']); + $this->sender = User::createFromData($data['comment']['user']); + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/PushEvent.php b/lp-digital/github-event-parser/EventType/PushEvent.php new file mode 100644 index 0000000..50aa167 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/PushEvent.php @@ -0,0 +1,66 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\User; + +class PushEvent extends RepositoryAwareEventType +{ + public $before; + public $commits; + public $distinctSize; + public $head; + public $pusher; + public $ref; + + /** + * @var User + */ + public $sender; + public $size; + + public static function name() + { + return 'PushEvent'; + } + + public static function fields() + { + return ['ref', 'head', 'before', 'commits']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->before = $data['before']; + $this->commits = $data['commits']; + $this->distinctSize = $data['distinct_size']; + $this->head = $data['head']; + $this->pusher = $data['pusher']['name']; + $this->ref = $data['ref']; + $this->sender = User::createFromData($data['sender']); + $this->size = $data['size']; + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/ReleaseEvent.php b/lp-digital/github-event-parser/EventType/ReleaseEvent.php new file mode 100644 index 0000000..a9af10c --- /dev/null +++ b/lp-digital/github-event-parser/EventType/ReleaseEvent.php @@ -0,0 +1,65 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\Release; +use Lpdigital\Github\Entity\User; + +class ReleaseEvent extends RepositoryAwareEventType implements ActionableEventInterface +{ + public $action; + + /** + * @var Release + */ + public $release; + + public function getAction() + { + return $this->action; + } + + public static function name() + { + return 'ReleaseEvent'; + } + + public static function fields() + { + return ['action', 'release', 'sender', 'repository']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->action = $data['action']; + $sender = User::createFromData($data['sender']); + $this->release = Release::createFromData( + $data['release'], + $this->repository, + $sender + ); + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/RepositoryAwareEventType.php b/lp-digital/github-event-parser/EventType/RepositoryAwareEventType.php new file mode 100644 index 0000000..b31452a --- /dev/null +++ b/lp-digital/github-event-parser/EventType/RepositoryAwareEventType.php @@ -0,0 +1,52 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\Repository; +use Lpdigital\Github\Exception\RepositoryNotFoundException; + +abstract class RepositoryAwareEventType extends AbstractEventType +{ + /** + * @var Repository + */ + public $repository; + + /** + * @return Repository + */ + public function getRepository() + { + return $this->repository; + } + + public function createFromData($data) + { + parent::createFromData($data); + + try { + $this->repository = Repository::createFromData($data['repository']); + } catch (\Exception $e) { + throw new RepositoryNotFoundException($e->getMessage()); + } + } +} diff --git a/lp-digital/github-event-parser/EventType/StatusEvent.php b/lp-digital/github-event-parser/EventType/StatusEvent.php new file mode 100644 index 0000000..e3e3d61 --- /dev/null +++ b/lp-digital/github-event-parser/EventType/StatusEvent.php @@ -0,0 +1,62 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\User; + +class StatusEvent extends RepositoryAwareEventType +{ + public $branches; + + /** + * @var User + */ + public $committer; + public $description; + public $sha; + public $state; + public $targetUrl; + + public static function name() + { + return 'StatusEvent'; + } + + public static function fields() + { + return ['sha', 'state', 'description', 'target_url', 'branches']; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->branches = $data['branches']; + $this->committer = User::createFromData($data['commit']['committer']); + $this->description = $data['description']; + $this->sha = $data['sha']; + $this->state = $data['state']; + $this->targetUrl = $data['target_url']; + + return $this; + } +} diff --git a/lp-digital/github-event-parser/EventType/WatchEvent.php b/lp-digital/github-event-parser/EventType/WatchEvent.php new file mode 100644 index 0000000..3b7c18b --- /dev/null +++ b/lp-digital/github-event-parser/EventType/WatchEvent.php @@ -0,0 +1,68 @@ +. + */ + +namespace Lpdigital\Github\EventType; + +use Lpdigital\Github\Entity\User; + +class WatchEvent extends RepositoryAwareEventType implements ActionableEventInterface +{ + public $action; + + /** + * @var User + */ + public $user; + + public function getAction() + { + return $this->action; + } + + public static function name() + { + return 'WatchEvent'; + } + + public static function fields() + { + return ['action']; + } + + public static function isValid($data) + { + if (array_key_exists('action', $data) && $data['action'] === 'started') { + return true; + } + + return false; + } + + public function createFromData($data) + { + parent::createFromData($data); + + $this->action = $data['action']; + $this->user = User::createFromData($data['sender']); + + return $this; + } +} diff --git a/lp-digital/github-event-parser/Exception/AllowUrlFileOpenException.php b/lp-digital/github-event-parser/Exception/AllowUrlFileOpenException.php new file mode 100644 index 0000000..48316bf --- /dev/null +++ b/lp-digital/github-event-parser/Exception/AllowUrlFileOpenException.php @@ -0,0 +1,34 @@ +. + */ + +namespace Lpdigital\Github\Exception; + +class AllowUrlFileOpenException extends InvalidPhpConfigurationException +{ + public function __construct() + { + parent::__construct( + 'You need to set "allow_url_fopen" option in PHP configuration.', + 0, + null + ); + } +} diff --git a/lp-digital/github-event-parser/Exception/EventNotFoundException.php b/lp-digital/github-event-parser/Exception/EventNotFoundException.php new file mode 100644 index 0000000..11964dd --- /dev/null +++ b/lp-digital/github-event-parser/Exception/EventNotFoundException.php @@ -0,0 +1,32 @@ +. + */ + +namespace Lpdigital\Github\Exception; + +use Exception; + +class EventNotFoundException extends Exception +{ + public function __construct() + { + parent::__construct('Not event can be related to this data.', 0, null); + } +} diff --git a/lp-digital/github-event-parser/Exception/InvalidPhpConfigurationException.php b/lp-digital/github-event-parser/Exception/InvalidPhpConfigurationException.php new file mode 100644 index 0000000..1a15e3b --- /dev/null +++ b/lp-digital/github-event-parser/Exception/InvalidPhpConfigurationException.php @@ -0,0 +1,28 @@ +. + */ + +namespace Lpdigital\Github\Exception; + +use Exception; + +abstract class InvalidPhpConfigurationException extends Exception +{ +} diff --git a/lp-digital/github-event-parser/Exception/RepositoryNotFoundException.php b/lp-digital/github-event-parser/Exception/RepositoryNotFoundException.php new file mode 100644 index 0000000..46a598a --- /dev/null +++ b/lp-digital/github-event-parser/Exception/RepositoryNotFoundException.php @@ -0,0 +1,34 @@ +. + */ + +namespace Lpdigital\Github\Exception; + +use Exception; + +class RepositoryNotFoundException extends Exception +{ + public function __construct($errorMessage) + { + $exceptionMessage = sprintf("A repository can't be extracted from data: %s", $errorMessage); + + parent::__construct($exceptionMessage, 0, null); + } +} diff --git a/lp-digital/github-event-parser/Exception/UserAgentNotFoundException.php b/lp-digital/github-event-parser/Exception/UserAgentNotFoundException.php new file mode 100644 index 0000000..5e6fd0c --- /dev/null +++ b/lp-digital/github-event-parser/Exception/UserAgentNotFoundException.php @@ -0,0 +1,30 @@ +. + */ + +namespace Lpdigital\Github\Exception; + +class UserAgentNotFoundException extends InvalidPhpConfigurationException +{ + public function __construct() + { + parent::__construct('You need to set user agent to execute this query.', 0, null); + } +} diff --git a/lp-digital/github-event-parser/LICENCE b/lp-digital/github-event-parser/LICENCE new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/lp-digital/github-event-parser/LICENCE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/lp-digital/github-event-parser/Parser/WebhookResolver.php b/lp-digital/github-event-parser/Parser/WebhookResolver.php new file mode 100644 index 0000000..6d84a45 --- /dev/null +++ b/lp-digital/github-event-parser/Parser/WebhookResolver.php @@ -0,0 +1,76 @@ +. + */ + +namespace Lpdigital\Github\Parser; + +use Lpdigital\Github\Exception\EventNotFoundException; + +class WebhookResolver +{ + public function resolve(array $data) + { + foreach ($this->eventsType() as $eventType) { + if ($eventType['class']::isValid($data)) { + return (new $eventType['class']())->createFromData($data); + } + } + + throw new EventNotFoundException(); + } + + public function eventsType() + { + $classes = [ + 'Lpdigital\Github\EventType\IssuesEvent', + 'Lpdigital\Github\EventType\IssueCommentEvent', + 'Lpdigital\Github\EventType\ForkEvent', + 'Lpdigital\Github\EventType\DeploymentStatusEvent', + 'Lpdigital\Github\EventType\GollumEvent', + 'Lpdigital\Github\EventType\IntegrationInstallationEvent', + 'Lpdigital\Github\EventType\IntegrationInstallationRepositoriesEvent', + 'Lpdigital\Github\EventType\PullRequestEvent', + 'Lpdigital\Github\EventType\PullRequestReviewCommentEvent', + 'Lpdigital\Github\EventType\PushEvent', + 'Lpdigital\Github\EventType\ReleaseEvent', + 'Lpdigital\Github\EventType\StatusEvent', + 'Lpdigital\Github\EventType\WatchEvent', + ]; + + $eventTypes = []; + + foreach ($classes as $className) { + $name = $className::name(); + $fields = $className::fields(); + + $eventTypes[$name] = ['class' => $className, 'priority' => count($fields)]; + } + + usort($eventTypes, function ($a, $b) { + if ($a['priority'] == $b['priority']) { + return 0; + } + + return ($a['priority'] < $b['priority']) ? 1 : -1; + }); + + return $eventTypes; + } +} diff --git a/lp-digital/github-event-parser/README.md b/lp-digital/github-event-parser/README.md new file mode 100644 index 0000000..d5d6ca5 --- /dev/null +++ b/lp-digital/github-event-parser/README.md @@ -0,0 +1,230 @@ +Github event parser library +============================ + +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/4bb32121-6a01-4b8c-9044-8a77e52dfa2c/mini.png)](https://insight.sensiolabs.com/projects/4bb32121-6a01-4b8c-9044-8a77e52dfa2c) + +This is a naive PHP library to provide readable representations of json responses from [Github Events Api v3](https://developer.github.com/v3/activity/events/types/). + +Thanks to the Github webhooks, any administrator of a repository can access and listen theses events returned into json responses. + +The only aim of this library is to parse theses responses, and create simple POPO (Plain Old PHP Object) easy to manipulate, extends or even persist in a database. + +A lot of usages are available since you can listen all events: +* make statistics on your repositories +* do some tasks after a successful deployment +* send a "thanks" email for each validated contribution +* and so on ... + +## Installation + +```bash +$ composer require "lp-digital/github-event-parser" +``` + +## PHP requirements + +The library may access to GitHub API to retrieve additional information. +Your PHP configuration may have `allow_url_fopen` and a valid `user_agent` enabled, or +some informations won't be retrieved. + +You can use ``InvalidPhpConfigurationException`` to catch the exception: + +```php +getCommits(); // use the GitHub API when called. +} catch(\Lpdigital\Github\Exception\InvalidPhpConfigurationException $e) { + // ... +} +``` + +## How to resolve a json response from Github ? + +Once your webhook is set up, you should receive POST responses from github each time an event is dispatched by the platform. + +For instance, let's consider you have a simple `github-hook.php` file and have installed your dependency through composer: +```php +resolve($decodedJson); // ex: an instance of `IssueCommentEvent` + echo($event::name()); // IssueCommentEvent + + /* ... do your own business */ +``` + + +## EventTypes + +> Note that this library is not complete, so only few events are available for now. But, it's realy easy to implement the missing. If you need them, please make a pull request! + +### IssueCommentEvent + +> Dispatched when someone comment an issue + +You can retrieve the issue, the user and the related comment from this event. + +```php +issue; // instance of Lpdigital/Entity/Issue +$issueCommentEvent->user; // instance of Lpdigital/Entity/User +$issueCommentEvent->comment; // instance of Lpdigital/Entity/Comment +``` + +### IssuesEvent + +> Dispatched when an issue is assigned, unassigned, labeled, unlabeled, opened, closed, or reopened. + +You can retrieve the action, the repository and the sender from this event. When available, you can also get assignee and label. + +```php +action; // Can be one of "assigned", "unassigned", "labeled", "unlabeled", "opened", "closed", or "reopened". +$issuesEvent->assignee; // optional: the assignee of the issue(Lpdigital/Entity/User) +$issuesEvent->issue; // instance of Lpdigital/Entity/Issue +$issuesEvent->label; // optional: the label of the issue(Lpdigital/Entity/Label) +$issuesEvent->repository; // instance of Lpdigital/Entity/Repository +$issuesEvent->sender; // instance of Lpdigital/Entity/User +``` + +### ForkEvent + +> Dispatched when someone fork the repository + +You can retrieve the forked repository, the owner, the new repository and the "forker". + +```php +forkedRepository; // instance of Lpdigital/Entity/Repository +$forkEvent->owner; // instance of Lpdigital/Entity/User +$forkEvent->repository; // instance of Lpdigital/Entity/Repository +$forkEvent->forker; // instance of Lpdigital/Entity/User +``` + +### DeploymentStatusEvent + +> Dispatched when a deployement's status changes + +You can retrieve the deployment, the sender and the related repository. + +```php +deployment; // instance of Lpdigital/Entity/Deployment +$deploymentStatusEvent->sender; // instance of Lpdigital/Entity/User +$deploymentStatusEvent->repository; // instance of Lpdigital/Entity/Repository +``` + +### PullRequestEvent + +> Dispatched when a pull request is assigned, unassigned, labeled, unlabeled, opened, closed, reopened, or synchronized. + +```php +$pullRequestEvent->pullRequest; // instance of Lpdigital/Entity/PullRequest +$pullRequest->action; +/** + * Can be one of “assigned”, “unassigned”, “labeled”, “unlabeled”, “opened”, “closed”, or “reopened”, or “synchronize”. + * If the action is “closed” and the merged key is false, the pull request was closed with unmerged commits. + * If the action is “closed” and the merged key is true, the pull request was merged. + */ +$pullRequest->number; // the pull request number +$pullRequest->repository; // instance of Lpdigital/Entity/Repository +``` + +### PushEvent + +> Dispatched when a repository branch is pushed to. In addition to branch pushes, webhook push events are also triggered when repository tags are pushed. + +```php +$pushEvent->ref // the full Git ref that was pushed ex: refs/heads/master +$pushEvent->head // the SHA of the most recent commit on ref after the push +$pushEvent->before // the SHA of the most recent commit on ref before the push +$pushEvent->size // the number of commits in the push +$pushEvent->commits // an array of objects that describe the pushed commits +``` + +### StatusEvent + +> Dispatched when the status of a Git commit changes. + Events of this type are not visible in timelines, they are only used to trigger hooks. + +You can retrieve the sha, the status, the committer and the related repository. More others +informations are available. + +```php +sha; // something like "9049f1265b7d61be4a8904a9a27120d2064dab3b" +$statusEvent->status; // Can be one of "success", "failure" or "error". +$statusEvent->commiter; // instance of Lpdigital/Entity/User +$statusEvent->repository; // instance of Lpdigital/Entity/Repository +``` + +### WatchEvent + +> The WatchEvent is related to starring a repository, not watching. See this [API blog post](https://developer.github.com/changes/2012-09-05-watcher-api/) for an explanation. + The event’s actor is the user who starred a repository, and the event’s repository is the repository that was starred. + +```php +action; // "started" +$watchEvent->user // instance of Lpdigital\Entity\User +$watchEvent->repository // instance of Lpdigital\Entity\Repository +``` + +### PullRequestReviewCommentEvent + +> Dispatched when a comment is created on a portion of the unified diff of a pull request. + +```php +action // "created" +$pullRequestReviewCommentEvent->comment // instance of Lpdigital\Entity\Comment +$pullRequestReviewCommentEvent->pullRequest // instance of Lpdigital\Entity\PullRequest +$pullRequestReviewCommentEvent->repository // instance of Lpdigital\Entity\Repository +$pullRequestReviewCommentEvent->sender // instance of Lpdigital\Entity\User +``` + +### GollumEvent + +> Dispatched when a Wiki page is created or updated. + +```php +pages // an array of Lpdigital\Entity\Page objects +$gollumEvent->repository // instance of Lpdigital\Entity\Repository +$gollumEvent->sender // instance of Lpdigital\Entity\User +``` + +## Entities + +Each object from Github API have his PHP class. +* Comment +* Commit (and CommitUser) +* Deployment +* Issue +* Label +* Page (*Wiki*) +* PullRequest +* Release +* Repository +* User + +## ROADMAP + +* Add all missing events +* Add doctrine mapping file for doctrine/dbal + +## Contribute + +**All features are tested, and all contributions need to be tested in order to be accepted.** + +Features from roadmap and bug fixes are prioritized. Fork the repository, create a feature branch and then launch the testsuite: + +```bash +$ phpunit +``` + +Thank you for help, let us know if you use this library ;) diff --git a/lp-digital/github-event-parser/Tests/Parser/WebhookResolverTest.php b/lp-digital/github-event-parser/Tests/Parser/WebhookResolverTest.php new file mode 100644 index 0000000..94dc95d --- /dev/null +++ b/lp-digital/github-event-parser/Tests/Parser/WebhookResolverTest.php @@ -0,0 +1,270 @@ +. + */ + +namespace Tests\Parser; + +use Lpdigital\Github\Parser\WebhookResolver; + +class WebhookResolverTest extends \PHPUnit_Framework_TestCase +{ + /** @var $userAgent string */ + public static $userAgent; + + /** @var $resolver \Lpdigital\Github\Parser\WebhookResolver */ + private $resolver; + + /** @var $jsonDataFolder string */ + private $jsonDataFolder; + + public static function setUpBeforeClass() + { + self::$userAgent = 'MyClient/1.0.0'; + } + + public function setUp() + { + ini_set('user_agent', self::$userAgent); + $this->resolver = new WebhookResolver(); + $this->jsonDataFolder = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'json-data'.DIRECTORY_SEPARATOR; + } + + public function tearDown() + { + $this->resolver = null; + } + + public function testResolveIssuesEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'issue_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\IssuesEvent", $event); + + $this->assertEquals('opened', $event->action); + $this->assertEquals('Spelling error in the README file', $event->issue->getTitle()); + $this->assertEquals('35129377', $event->repository->getId()); + } + + public function testResolveIssueCommitEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'issue_commit_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\IssueCommentEvent", $event); + + $this->assertEquals('Spelling error in the README file', $event->issue->getTitle()); + $this->assertEquals('baxterthehacker', $event->user->getLogin()); + $this->assertEquals("You are totally right! I'll get this fixed right away.", $event->comment->getBody()); + } + + public function testResolveForkEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'fork_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\ForkEvent", $event); + + $this->assertEquals('baxterandthehackers/public-repo', $event->forkedRepository->getFullName()); + $this->assertEquals('7649605', $event->owner->getId()); + $this->assertEquals('https://api.github.com/repos/baxterthehacker/public-repo', $event->repository->getUrl()); + } + + public function testResolveDeploymentStatusEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'deployment_status_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\DeploymentStatusEvent", $event); + + $this->assertEquals('production', $event->deployment->getEnvironment()); + $this->assertEquals('public-repo', $event->repository->getName()); + $this->assertEquals('User', $event->sender->getType()); + } + + public function testResolvePullRequestEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'pull_request_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\PullRequestEvent", $event); + + $this->assertEquals('Update the README with new information', $event->pullRequest->getTitle()); + $this->assertEquals('opened', $event->action); + $this->assertEquals('1', $event->number); + $this->assertEquals('baxterthehacker', $event->sender->getLogin()); + $this->assertInstanceOf('Lpdigital\Github\Entity\Repository', $event->repository); + } + + public function testResolveStatusEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'status_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\StatusEvent", $event); + + $this->assertEquals('baxterthehacker', $event->committer->getLogin()); + $this->assertEquals('public-repo', $event->repository->getName()); + $this->assertEquals('success', $event->state); + $this->assertEquals('9049f1265b7d61be4a8904a9a27120d2064dab3b', $event->sha); + } + + public function testResolveReleaseEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'release_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\ReleaseEvent", $event); + + $this->assertInstanceOf("Lpdigital\Github\Entity\Release", $event->release); + $this->assertEquals('published', $event->action); + $this->assertEquals('https://api.github.com/repos/baxterthehacker/public-repo/releases/1261438', $event->release->getUrl()); + $this->assertEquals('https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1', $event->release->getHtmlUrl()); + } + + public function testResolveWatchEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'watch_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\WatchEvent", $event); + $this->assertInstanceOf("Lpdigital\Github\Entity\Repository", $event->repository); + $this->assertInstanceOf("Lpdigital\Github\Entity\User", $event->user); + + $this->assertEquals('started', $event->action); + } + + public function testResolvePullRequestReviewCommentEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'pull_request_review_comment_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\PullRequestReviewCommentEvent", $event); + $this->assertInstanceOf("Lpdigital\Github\Entity\Repository", $event->repository); + $this->assertInstanceOf("Lpdigital\Github\Entity\User", $event->sender); + $this->assertInstanceOf("Lpdigital\Github\Entity\Comment", $event->comment); + } + + public function testResolveGollumEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'gollum_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\GollumEvent", $event); + $this->assertInstanceOf("Lpdigital\Github\Entity\Repository", $event->repository); + $this->assertInstanceOf("Lpdigital\Github\Entity\User", $event->sender); + $this->assertInternalType('array', $event->pages); + $this->assertCount(2, $event->pages); + + $this->assertInstanceOf("Lpdigital\Github\Entity\Page", current($event->pages)); + $this->assertInstanceOf("Lpdigital\Github\Entity\Page", next($event->pages)); + + $this->assertEquals('Home', $event->pages[0]->getTitle()); + $this->assertEquals('Home2', $event->pages[1]->getTitle()); + } + + public function testPushEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'push_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\PushEvent", $event); + } + + public function testResolvePullRequestEventCommitsOk() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'pull_request_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\PullRequestEvent", $event); + $pullRequest = $event->pullRequest; + + $this->assertInstanceOf("Lpdigital\Github\Entity\PullRequest", $pullRequest); + + $commits = $pullRequest->getCommits(); + $this->assertTrue(is_array($commits)); + $commit = $commits[0]; + $this->assertInstanceOf("Lpdigital\Github\Entity\Commit", $commit); + } + + public function testResolvePullRequestHasIntegration() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'pull_request_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\Entity\Integration", $event->integration); + } + + public function testResolvePullRequestEventCommitThrowsException() + { + ini_set('user_agent', ''); + $this->setExpectedException('Lpdigital\Github\Exception\UserAgentNotFoundException'); + + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'pull_request_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + $event->pullRequest->getCommits(); + } + + public function testResolveWithMissingRepositoryThrowsException() + { + $this->setExpectedException('Lpdigital\Github\Exception\RepositoryNotFoundException'); + + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'repository_not_found.json'), true); + $this->resolver->resolve($jsonReceived); + } + + public function testResolveWithMalformedRepositoryThrowsException() + { + $this->setExpectedException('Lpdigital\Github\Exception\RepositoryNotFoundException'); + + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'repository_malformed.json'), true); + $this->resolver->resolve($jsonReceived); + } + + public function testResolveIntegrationInstallationEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'integration_installation_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\IntegrationInstallationEvent", $event); + $this->assertInstanceOf("Lpdigital\Github\Entity\Integration", $event->integration); + $this->assertInstanceOf("Lpdigital\Github\Entity\User", $event->sender); + + $this->assertInternalType('string', $event->integration->getAccessTokenUrl()); + $this->assertInternalType('string', $event->integration->getRepositoriesUrl()); + } + + public function testResolveIntegrationInstallationRepositoriesEvent() + { + $jsonReceived = json_decode(file_get_contents($this->jsonDataFolder.'integration_installation_repositories_event.json'), true); + $event = $this->resolver->resolve($jsonReceived); + + $this->assertInstanceOf("Lpdigital\Github\EventType\IntegrationInstallationRepositoriesEvent", $event); + $this->assertInstanceOf("Lpdigital\Github\Entity\Integration", $event->integration); + $this->assertInstanceOf("Lpdigital\Github\Entity\User", $event->sender); + $this->assertInternalType('string', $event->repositorySelection); + $this->assertInternalType('array', $event->repositoryAdded); + $this->assertInternalType('array', $event->repositoryRemoved); + + $this->assertInternalType('string', $event->integration->getAccessTokenUrl()); + $this->assertInternalType('string', $event->integration->getRepositoriesUrl()); + $this->assertInternalType('string', $event->integration->getHtmlUrl()); + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/commits.json b/lp-digital/github-event-parser/Tests/json-data/commits.json new file mode 100644 index 0000000..74effec --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/commits.json @@ -0,0 +1,72 @@ +[ + { + "sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "commit": { + "author": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:15Z" + }, + "committer": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:15Z" + }, + "message": "Update README.md", + "tree": { + "sha": "31b122c26a97cf9af023e9ddab94a82c6e77b0ea", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees/31b122c26a97cf9af023e9ddab94a82c6e77b0ea" + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "comment_count": 3 + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "html_url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c/comments", + "author": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + { + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "html_url": "https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b" + } + ] + } +] \ No newline at end of file diff --git a/lp-digital/github-event-parser/Tests/json-data/deployment_status_event.json b/lp-digital/github-event-parser/Tests/json-data/deployment_status_event.json new file mode 100644 index 0000000..17f639c --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/deployment_status_event.json @@ -0,0 +1,172 @@ +{ + "deployment": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments/710692", + "id": 710692, + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "ref": "master", + "task": "deploy", + "payload": { + }, + "environment": "production", + "description": null, + "creator": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "created_at": "2015-05-05T23:40:38Z", + "updated_at": "2015-05-05T23:40:38Z", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments/710692/statuses", + "repository_url": "https://api.github.com/repos/baxterthehacker/public-repo" + }, + "deployment_status": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments/710692/statuses/1115122", + "id": 1115122, + "state": "success", + "creator": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "description": null, + "target_url": null, + "created_at": "2015-05-05T23:40:39Z", + "updated_at": "2015-05-05T23:40:39Z", + "deployment_url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments/710692", + "repository_url": "https://api.github.com/repos/baxterthehacker/public-repo" + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:38Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/fork_event.json b/lp-digital/github-event-parser/Tests/json-data/fork_event.json new file mode 100644 index 0000000..e01d3c5 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/fork_event.json @@ -0,0 +1,196 @@ +{ + "forkee": { + "id": 35129393, + "name": "public-repo", + "full_name": "baxterandthehackers/public-repo", + "owner": { + "login": "baxterandthehackers", + "id": 7649605, + "avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterandthehackers", + "html_url": "https://github.com/baxterandthehackers", + "followers_url": "https://api.github.com/users/baxterandthehackers/followers", + "following_url": "https://api.github.com/users/baxterandthehackers/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterandthehackers/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterandthehackers/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterandthehackers/subscriptions", + "organizations_url": "https://api.github.com/users/baxterandthehackers/orgs", + "repos_url": "https://api.github.com/users/baxterandthehackers/repos", + "events_url": "https://api.github.com/users/baxterandthehackers/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterandthehackers/received_events", + "type": "Organization", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterandthehackers/public-repo", + "description": "", + "fork": true, + "url": "https://api.github.com/repos/baxterandthehackers/public-repo", + "forks_url": "https://api.github.com/repos/baxterandthehackers/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterandthehackers/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterandthehackers/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterandthehackers/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterandthehackers/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterandthehackers/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterandthehackers/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterandthehackers/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterandthehackers/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterandthehackers/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterandthehackers/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterandthehackers/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterandthehackers/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterandthehackers/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterandthehackers/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterandthehackers/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterandthehackers/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterandthehackers/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterandthehackers/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterandthehackers/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterandthehackers/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterandthehackers/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterandthehackers/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterandthehackers/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterandthehackers/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterandthehackers/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterandthehackers/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterandthehackers/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterandthehackers/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterandthehackers/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterandthehackers/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:30Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:27Z", + "git_url": "git://github.com/baxterandthehackers/public-repo.git", + "ssh_url": "git@github.com:baxterandthehackers/public-repo.git", + "clone_url": "https://github.com/baxterandthehackers/public-repo.git", + "svn_url": "https://github.com/baxterandthehackers/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": false, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "public": true + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:27Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 1, + "mirror_url": null, + "open_issues_count": 2, + "forks": 1, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterandthehackers", + "id": 7649605, + "avatar_url": "https://avatars.githubusercontent.com/u/7649605?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterandthehackers", + "html_url": "https://github.com/baxterandthehackers", + "followers_url": "https://api.github.com/users/baxterandthehackers/followers", + "following_url": "https://api.github.com/users/baxterandthehackers/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterandthehackers/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterandthehackers/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterandthehackers/subscriptions", + "organizations_url": "https://api.github.com/users/baxterandthehackers/orgs", + "repos_url": "https://api.github.com/users/baxterandthehackers/repos", + "events_url": "https://api.github.com/users/baxterandthehackers/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterandthehackers/received_events", + "type": "Organization", + "site_admin": false + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/gollum_event.json b/lp-digital/github-event-parser/Tests/json-data/gollum_event.json new file mode 100644 index 0000000..c14ed7b --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/gollum_event.json @@ -0,0 +1,126 @@ +{ + "pages": [ + { + "page_name": "Home", + "title": "Home", + "summary": null, + "action": "created", + "sha": "91ea1bd42aa2ba166b86e8aefe049e9837214e67", + "html_url": "https://github.com/baxterthehacker/public-repo/wiki/Home" + }, + { + "page_name": "Home2", + "title": "Home2", + "summary": null, + "action": "edited", + "sha": "91ea1bd42aa2ba166b86e8aefe049e9837214e68", + "html_url": "https://github.com/baxterthehacker/public-repo/wiki/Home2" + } + ], + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:17Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "jasonrudolph", + "id": 2988, + "avatar_url": "https://avatars.githubusercontent.com/u/2988?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/jasonrudolph", + "html_url": "https://github.com/jasonrudolph", + "followers_url": "https://api.github.com/users/jasonrudolph/followers", + "following_url": "https://api.github.com/users/jasonrudolph/following{/other_user}", + "gists_url": "https://api.github.com/users/jasonrudolph/gists{/gist_id}", + "starred_url": "https://api.github.com/users/jasonrudolph/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/jasonrudolph/subscriptions", + "organizations_url": "https://api.github.com/users/jasonrudolph/orgs", + "repos_url": "https://api.github.com/users/jasonrudolph/repos", + "events_url": "https://api.github.com/users/jasonrudolph/events{/privacy}", + "received_events_url": "https://api.github.com/users/jasonrudolph/received_events", + "type": "User", + "site_admin": true + } +} \ No newline at end of file diff --git a/lp-digital/github-event-parser/Tests/json-data/integration_installation_event.json b/lp-digital/github-event-parser/Tests/json-data/integration_installation_event.json new file mode 100644 index 0000000..4d5df08 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/integration_installation_event.json @@ -0,0 +1,46 @@ +{ + "action": "created", + "installation": { + "id": 2, + "account": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "access_tokens_url": "https://api.github.com/installations/2/access_tokens", + "repositories_url": "https://api.github.com/installation/repositories" + }, + "sender": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/integration_installation_repositories_event.json b/lp-digital/github-event-parser/Tests/json-data/integration_installation_repositories_event.json new file mode 100644 index 0000000..4860de9 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/integration_installation_repositories_event.json @@ -0,0 +1,58 @@ +{ + "action": "removed", + "installation": { + "id": 2, + "account": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + }, + "access_tokens_url": "https://api.github.com/installations/2/access_tokens", + "repositories_url": "https://api.github.com/installation/repositories", + "html_url": "https://github.com/settings/installations/2" + }, + "repository_selection": "selected", + "repositories_added": [ + + ], + "repositories_removed": [ + { + "id": 1296269, + "name": "Hello-World", + "full_name": "octocat/Hello-World" + } + ], + "sender": { + "login": "octocat", + "id": 1, + "avatar_url": "https://github.com/images/error/octocat_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/octocat", + "html_url": "https://github.com/octocat", + "followers_url": "https://api.github.com/users/octocat/followers", + "following_url": "https://api.github.com/users/octocat/following{/other_user}", + "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", + "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", + "organizations_url": "https://api.github.com/users/octocat/orgs", + "repos_url": "https://api.github.com/users/octocat/repos", + "events_url": "https://api.github.com/users/octocat/events{/privacy}", + "received_events_url": "https://api.github.com/users/octocat/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/issue_commit_event.json b/lp-digital/github-event-parser/Tests/json-data/issue_commit_event.json new file mode 100644 index 0000000..6f6e7d8 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/issue_commit_event.json @@ -0,0 +1,182 @@ +{ + "action": "created", + "issue": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2/labels{/name}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2/comments", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2/events", + "html_url": "https://github.com/baxterthehacker/public-repo/issues/2", + "id": 73464126, + "number": 2, + "title": "Spelling error in the README file", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/labels/bug", + "name": "bug", + "color": "fc2929" + } + ], + "state": "open", + "locked": false, + "assignee": null, + "milestone": null, + "comments": 1, + "created_at": "2015-05-05T23:40:28Z", + "updated_at": "2015-05-05T23:40:28Z", + "closed_at": null, + "body": "It looks like you accidently spelled 'commit' with two 't's." + }, + "comment": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments/99262140", + "html_url": "https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140", + "issue_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2", + "id": 99262140, + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "created_at": "2015-05-05T23:40:28Z", + "updated_at": "2015-05-05T23:40:28Z", + "body": "You are totally right! I'll get this fixed right away." + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:27Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/issue_event.json b/lp-digital/github-event-parser/Tests/json-data/issue_event.json new file mode 100755 index 0000000..fe79aad --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/issue_event.json @@ -0,0 +1,154 @@ +{ + "action": "opened", + "issue": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2/labels{/name}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2/comments", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/2/events", + "html_url": "https://github.com/baxterthehacker/public-repo/issues/2", + "id": 73464126, + "number": 2, + "title": "Spelling error in the README file", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/labels/bug", + "name": "bug", + "color": "fc2929" + } + ], + "state": "open", + "locked": false, + "assignee": null, + "milestone": null, + "comments": 0, + "created_at": "2015-05-05T23:40:28Z", + "updated_at": "2015-05-05T23:40:28Z", + "closed_at": null, + "body": "It looks like you accidently spelled 'commit' with two 't's." + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:27Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/lp-digital/github-event-parser/Tests/json-data/pull_request_event.json b/lp-digital/github-event-parser/Tests/json-data/pull_request_event.json new file mode 100644 index 0000000..35563a1 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/pull_request_event.json @@ -0,0 +1,415 @@ +{ + "action": "opened", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1", + "id": 34778301, + "html_url": "https://github.com/baxterthehacker/public-repo/pull/1", + "diff_url": "https://github.com/baxterthehacker/public-repo/pull/1.diff", + "patch_url": "https://github.com/baxterthehacker/public-repo/pull/1.patch", + "issue_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1", + "number": 1, + "state": "open", + "locked": false, + "title": "Update the README with new information", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "body": "This is a pretty simple change that we need to pull into master.", + "created_at": "2015-05-05T23:40:27Z", + "updated_at": "2015-05-05T23:40:27Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": null, + "assignee": null, + "milestone": null, + "commits_url": "./Tests/json-data/commits.json", + "review_comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1/comments", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "head": { + "label": "baxterthehacker:changes", + "ref": "changes", + "sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:26Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 1, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "base": { + "label": "baxterthehacker:master", + "ref": "master", + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:26Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 1, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1" + }, + "html": { + "href": "https://github.com/baxterthehacker/public-repo/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c" + } + }, + "merged": false, + "mergeable": null, + "mergeable_state": "unknown", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:26Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 1, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 1234 + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/pull_request_review_comment_event.json b/lp-digital/github-event-parser/Tests/json-data/pull_request_review_comment_event.json new file mode 100644 index 0000000..9934971 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/pull_request_review_comment_event.json @@ -0,0 +1,446 @@ +{ + "action": "created", + "comment": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments/29724692", + "id": 29724692, + "diff_hunk": "@@ -1 +1 @@\n-# public-repo", + "path": "README.md", + "position": 1, + "original_position": 1, + "commit_id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "original_commit_id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "body": "Maybe you should use more emojji on this line.", + "created_at": "2015-05-05T23:40:27Z", + "updated_at": "2015-05-05T23:40:27Z", + "html_url": "https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692", + "pull_request_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1", + "_links": { + "self": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments/29724692" + }, + "html": { + "href": "https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692" + }, + "pull_request": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1" + } + } + }, + "pull_request": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1", + "id": 34778301, + "html_url": "https://github.com/baxterthehacker/public-repo/pull/1", + "diff_url": "https://github.com/baxterthehacker/public-repo/pull/1.diff", + "patch_url": "https://github.com/baxterthehacker/public-repo/pull/1.patch", + "issue_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1", + "number": 1, + "state": "open", + "locked": false, + "title": "Update the README with new information", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "body": "This is a pretty simple change that we need to pull into master.", + "created_at": "2015-05-05T23:40:27Z", + "updated_at": "2015-05-05T23:40:27Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "18721552ba489fb84e12958c1b5694b5475f7991", + "assignee": null, + "milestone": null, + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/commits", + "review_comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1/comments", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "head": { + "label": "baxterthehacker:changes", + "ref": "changes", + "sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:27Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 1, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "base": { + "label": "baxterthehacker:master", + "ref": "master", + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:27Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 1, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1" + }, + "html": { + "href": "https://github.com/baxterthehacker/public-repo/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c" + } + } + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:27Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 1, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/lp-digital/github-event-parser/Tests/json-data/push_event.json b/lp-digital/github-event-parser/Tests/json-data/push_event.json new file mode 100644 index 0000000..3ff5745 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/push_event.json @@ -0,0 +1,164 @@ +{ + "ref": "refs/heads/changes", + "before": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "after": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "head": "invalid_head_need_real_payload", + "created": false, + "deleted": false, + "forced": false, + "base_ref": null, + "size": 1, + "distinct_size": 1, + "compare": "https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f", + "commits": [ + { + "id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "distinct": true, + "message": "Update README.md", + "timestamp": "2015-05-05T19:40:15-04:00", + "url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "author": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "username": "baxterthehacker" + }, + "committer": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "username": "baxterthehacker" + }, + "added": [ + + ], + "removed": [ + + ], + "modified": [ + "README.md" + ] + } + ], + "head_commit": { + "id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "distinct": true, + "message": "Update README.md", + "timestamp": "2015-05-05T19:40:15-04:00", + "url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "author": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "username": "baxterthehacker" + }, + "committer": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "username": "baxterthehacker" + }, + "added": [ + + ], + "removed": [ + + ], + "modified": [ + "README.md" + ] + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com" + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://github.com/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": 1430869212, + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": 1430869217, + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 0, + "forks": 0, + "open_issues": 0, + "watchers": 0, + "default_branch": "master", + "stargazers": 0, + "master_branch": "master" + }, + "pusher": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/release_event.json b/lp-digital/github-event-parser/Tests/json-data/release_event.json new file mode 100644 index 0000000..4c3f48a --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/release_event.json @@ -0,0 +1,148 @@ +{ + "action": "published", + "release": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/releases/1261438", + "assets_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases/1261438/assets", + "upload_url": "https://uploads.github.com/repos/baxterthehacker/public-repo/releases/1261438/assets{?name}", + "html_url": "https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1", + "id": 1261438, + "tag_name": "0.0.1", + "target_commitish": "master", + "name": null, + "draft": false, + "author": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "prerelease": false, + "created_at": "2015-05-05T23:40:12Z", + "published_at": "2015-05-05T23:40:38Z", + "assets": [ + + ], + "tarball_url": "https://api.github.com/repos/baxterthehacker/public-repo/tarball/0.0.1", + "zipball_url": "https://api.github.com/repos/baxterthehacker/public-repo/zipball/0.0.1", + "body": null + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:38Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/lp-digital/github-event-parser/Tests/json-data/repository_malformed.json b/lp-digital/github-event-parser/Tests/json-data/repository_malformed.json new file mode 100644 index 0000000..472d856 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/repository_malformed.json @@ -0,0 +1,204 @@ +{ + "id": 214015194, + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "name": "baxterthehacker/public-repo", + "target_url": null, + "context": "default", + "description": null, + "state": "success", + "commit": { + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "commit": { + "author": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:12Z" + }, + "committer": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:12Z" + }, + "message": "Initial commit", + "tree": { + "sha": "02b49ad0ba4f1acd9f06531b21e16a4ac5d341d0", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees/02b49ad0ba4f1acd9f06531b21e16a4ac5d341d0" + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "comment_count": 1 + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "html_url": "https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b/comments", + "author": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + + ] + }, + "branches": [ + { + "name": "master", + "commit": { + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b" + } + }, + { + "name": "changes", + "commit": { + "sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c" + } + }, + { + "name": "gh-pages", + "commit": { + "sha": "b11bb7545ac14abafc6191a0481b0d961e7793c6", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/b11bb7545ac14abafc6191a0481b0d961e7793c6" + } + } + ], + "created_at": "2015-05-05T23:40:39Z", + "updated_at": "2015-05-05T23:40:39Z", + "repository": { + "id": 35129377, + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:39Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/repository_not_found.json b/lp-digital/github-event-parser/Tests/json-data/repository_not_found.json new file mode 100644 index 0000000..2912468 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/repository_not_found.json @@ -0,0 +1,119 @@ +{ + "id": 214015194, + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "name": "baxterthehacker/public-repo", + "target_url": null, + "context": "default", + "description": null, + "state": "success", + "commit": { + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "commit": { + "author": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:12Z" + }, + "committer": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:12Z" + }, + "message": "Initial commit", + "tree": { + "sha": "02b49ad0ba4f1acd9f06531b21e16a4ac5d341d0", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees/02b49ad0ba4f1acd9f06531b21e16a4ac5d341d0" + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "comment_count": 1 + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "html_url": "https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b/comments", + "author": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + + ] + }, + "branches": [ + { + "name": "master", + "commit": { + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b" + } + }, + { + "name": "changes", + "commit": { + "sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c" + } + }, + { + "name": "gh-pages", + "commit": { + "sha": "b11bb7545ac14abafc6191a0481b0d961e7793c6", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/b11bb7545ac14abafc6191a0481b0d961e7793c6" + } + } + ], + "created_at": "2015-05-05T23:40:39Z", + "updated_at": "2015-05-05T23:40:39Z", + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/status_event.json b/lp-digital/github-event-parser/Tests/json-data/status_event.json new file mode 100755 index 0000000..607445e --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/status_event.json @@ -0,0 +1,206 @@ +{ + "id": 214015194, + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "name": "baxterthehacker/public-repo", + "target_url": null, + "context": "default", + "description": null, + "state": "success", + "commit": { + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "commit": { + "author": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:12Z" + }, + "committer": { + "name": "baxterthehacker", + "email": "baxterthehacker@users.noreply.github.com", + "date": "2015-05-05T23:40:12Z" + }, + "message": "Initial commit", + "tree": { + "sha": "02b49ad0ba4f1acd9f06531b21e16a4ac5d341d0", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees/02b49ad0ba4f1acd9f06531b21e16a4ac5d341d0" + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "comment_count": 1 + }, + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "html_url": "https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b/comments", + "author": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "committer": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "parents": [ + + ] + }, + "branches": [ + { + "name": "master", + "commit": { + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/9049f1265b7d61be4a8904a9a27120d2064dab3b" + } + }, + { + "name": "changes", + "commit": { + "sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c" + } + }, + { + "name": "gh-pages", + "commit": { + "sha": "b11bb7545ac14abafc6191a0481b0d961e7793c6", + "url": "https://api.github.com/repos/baxterthehacker/public-repo/commits/b11bb7545ac14abafc6191a0481b0d961e7793c6" + } + } + ], + "created_at": "2015-05-05T23:40:39Z", + "updated_at": "2015-05-05T23:40:39Z", + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:39Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} diff --git a/lp-digital/github-event-parser/Tests/json-data/watch_event.json b/lp-digital/github-event-parser/Tests/json-data/watch_event.json new file mode 100644 index 0000000..e71cd76 --- /dev/null +++ b/lp-digital/github-event-parser/Tests/json-data/watch_event.json @@ -0,0 +1,109 @@ +{ + "action": "started", + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:30Z", + "pushed_at": "2015-05-05T23:40:27Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 2, + "forks": 0, + "open_issues": 2, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + } +} \ No newline at end of file diff --git a/lp-digital/github-event-parser/composer.json b/lp-digital/github-event-parser/composer.json new file mode 100644 index 0000000..40b46bf --- /dev/null +++ b/lp-digital/github-event-parser/composer.json @@ -0,0 +1,33 @@ +{ + "name": "lp-digital/github-event-parser", + "description": "PHP library to get a readable representation of events dispatched by Github API v3", + "type": "library", + "license": "GPL-3.0+", + "keywords": ["github", "event", "json parser"], + "homepage": "https://github.com/Lp-digital/github-event-parser", + "authors": [ + { + "name": "Mickaël Andrieu", + "email": "mickael.andrieu@lp-digital.fr" + } + ], + "autoload": { + "psr-4": { "Lpdigital\\Github\\": "" } + }, + "autoload-dev": { + "psr-4": { "Tests\\": "Tests/" } + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "phpunit/phpunit": "~4.7", + "friendsofphp/php-cs-fixer": "~1.11" + }, + "minimum-stability": "stable", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + } +} diff --git a/lp-digital/github-event-parser/phpunit.xml.dist b/lp-digital/github-event-parser/phpunit.xml.dist new file mode 100644 index 0000000..5cbe3d1 --- /dev/null +++ b/lp-digital/github-event-parser/phpunit.xml.dist @@ -0,0 +1,34 @@ + + + + + + + + Tests + + + + + + . + + Tests + vendor + + + + + + + diff --git a/symfony.lock b/symfony.lock index 608d38a..35d07f1 100644 --- a/symfony.lock +++ b/symfony.lock @@ -1,4 +1,7 @@ { + "aws/aws-sdk-php": { + "version": "3.112.6" + }, "bref/bref": { "version": "0.5.5" }, @@ -129,6 +132,9 @@ "mnapoli/silly": { "version": "1.7.1" }, + "mtdowling/jmespath.php": { + "version": "2.4.0" + }, "nette/bootstrap": { "version": "v3.0.0" },