diff --git a/src/ApiSettings.php b/src/ApiSettings.php index 17040acf99..b806a45824 100644 --- a/src/ApiSettings.php +++ b/src/ApiSettings.php @@ -17,6 +17,17 @@ final class ApiSettings { const NAMESPACE = 'ApiClients\\Client\\Github\\Resource'; + const ACCEPT_HEADER = [ + // License on repository object: https://developer.github.com/v3/licenses/#licenses + 'application/vnd.github.drax-preview+json', + + // Topics on repository object: https://developer.github.com/v3/repos/#repositories + 'application/vnd.github.mercy-preview+json', + + // Default header: https://developer.github.com/v3/#current-version + 'application/vnd.github.v3+json', + ]; + const TRANSPORT_OPTIONS = [ FoundationOptions::HYDRATOR_OPTIONS => [ HydratorOptions::NAMESPACE => self::NAMESPACE, @@ -47,6 +58,10 @@ public static function getOptions( $options = options_merge(self::TRANSPORT_OPTIONS, $auth->getOptions()); $options = options_merge($options, $suppliedOptions); $options[FoundationOptions::HYDRATOR_OPTIONS][HydratorOptions::NAMESPACE_SUFFIX] = $suffix; + + $acceptHeader = implode('; ', self::ACCEPT_HEADER); + $options[FoundationOptions::TRANSPORT_OPTIONS][TransportOptions::HEADERS]['Accept'] = $acceptHeader; + return $options; } } diff --git a/src/Resource/Async/EmptyLicense.php b/src/Resource/Async/EmptyLicense.php new file mode 100644 index 0000000000..0e57763d7c --- /dev/null +++ b/src/Resource/Async/EmptyLicense.php @@ -0,0 +1,9 @@ +key; + } + + /** + * @return string + */ + public function name() : string + { + return $this->name; + } + + /** + * @return string + */ + public function spdxId() : string + { + return $this->spdx_id; + } + + /** + * @return string + */ + public function url() : string + { + return $this->url; + } +} diff --git a/src/Resource/LicenseInterface.php b/src/Resource/LicenseInterface.php new file mode 100644 index 0000000000..97e9613737 --- /dev/null +++ b/src/Resource/LicenseInterface.php @@ -0,0 +1,30 @@ +description; + return $this->description; } /** @@ -339,4 +350,20 @@ public function owner() : User { return $this->owner; } + + /** + * @return License + */ + public function license() : License + { + return $this->license; + } + + /** + * @return array + */ + public function topics() : array + { + return $this->topics; + } } diff --git a/src/Resource/RepositoryInterface.php b/src/Resource/RepositoryInterface.php index 8d07d55401..af7171bbd2 100644 --- a/src/Resource/RepositoryInterface.php +++ b/src/Resource/RepositoryInterface.php @@ -133,4 +133,14 @@ public function htmlUrl() : string; * @return User */ public function owner() : User; + + /** + * @return License + */ + public function license() : License; + + /** + * @return array + */ + public function topics() : array; } diff --git a/src/Resource/Sync/EmptyLicense.php b/src/Resource/Sync/EmptyLicense.php new file mode 100644 index 0000000000..447ddc9b18 --- /dev/null +++ b/src/Resource/Sync/EmptyLicense.php @@ -0,0 +1,9 @@ +wait($this->handleCommand( + new BuildAsyncFromSyncCommand(self::HYDRATE_CLASS, $this) + )->then(function (LicenseInterface $license) { + return $license->refresh(); + })); + } +} diff --git a/tests/Resource/Async/EmptyLicenseTest.php b/tests/Resource/Async/EmptyLicenseTest.php new file mode 100644 index 0000000000..2809151bc4 --- /dev/null +++ b/tests/Resource/Async/EmptyLicenseTest.php @@ -0,0 +1,18 @@ +