-
-
Notifications
You must be signed in to change notification settings - Fork 598
Add Traffic #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Add Traffic #499
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aad9546
Create Traffic.php
m1guelpf f05e626
Add Clones
m1guelpf a229d8a
Apply fixes from StyleCI
m1guelpf 350b828
Add Traffic to Repo
m1guelpf d6767ea
Add Traffic
m1guelpf ded9d04
Apply fixes from StyleCI
m1guelpf 8264b32
list() -> referers()
m1guelpf bf17eab
Test skeleton
m1guelpf 73f9828
Apply fixes from StyleCI
m1guelpf 51d5ea1
Add per
m1guelpf 079e7f9
Remove //
m1guelpf b2ec158
Fix Syntax Error
m1guelpf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
namespace Github\Api\Repository; | ||
|
||
use Github\Api\AbstractApi; | ||
use Github\Exception\MissingArgumentException; | ||
|
||
/** | ||
* @link https://developer.github.com/v3/repos/traffic/ | ||
* @author Miguel Piedrafita <[email protected]> | ||
*/ | ||
class Traffic extends AbstractApi | ||
{ | ||
/** | ||
* @link https://developer.github.com/v3/repos/traffic/#list-referrers | ||
* | ||
* @param string $owner | ||
* @param string $repository | ||
* | ||
* @return array | ||
*/ | ||
public function referers($owner, $repository) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/popular/referrers'); | ||
} | ||
/** | ||
* @link https://developer.github.com/v3/repos/traffic/#list-paths | ||
* | ||
* @param string $owner | ||
* @param string $repository | ||
* | ||
* @return array | ||
*/ | ||
public function paths($owner, $repository) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/popular/paths'); | ||
} | ||
/** | ||
* @link https://developer.github.com/v3/repos/traffic/#views | ||
* | ||
* @param string $owner | ||
* @param string $repository | ||
* @param string|day $per | ||
* | ||
* @return array | ||
*/ | ||
public function views($owner, $repository, $per = 'day') | ||
{ | ||
return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/views?per='.rawurlencode($per)); | ||
} | ||
/** | ||
* @link https://developer.github.com/v3/repos/traffic/#clones | ||
* | ||
* @param string $owner | ||
* @param string $repository | ||
* | ||
* @return array | ||
*/ | ||
public function clones($owner, $repository) | ||
{ | ||
return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/clones'); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
use Github\Tests\Api\TestCase; | ||
|
||
class TrafficTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shoulddoSomething() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the name of this function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should also update the test content |
||
{ | ||
// Create a variable with the "Server response". | ||
$expectedValue = array('comment1'); | ||
|
||
// Get the API mock (see "getApiClass" below). | ||
$api = $this->getApiMock(); | ||
|
||
$api->expects($this->once()) // Expect one call | ||
->method('get') // A GET request | ||
->with('/gists/123/comments/456') // URI should be "/gists/123/comments/456" | ||
->will($this->returnValue($expectedValue)); // Should return the "Server response" | ||
|
||
// Call Comments::show | ||
$result = $api->show(123, 456); | ||
|
||
// Verify that the result is the "Server response" as we expect. | ||
$this->assertEquals($expectedValue, $result); | ||
} | ||
|
||
protected function getApiClass() | ||
{ | ||
// Tell the "getAPIMock" what class to mock. | ||
return \Github\Api\Gist\Comments::class; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing parameter
per
. See https://developer.github.com/v3/repos/traffic/#clonesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not added.