Skip to content

Commit a1819bf

Browse files
committed
Added getClones method to GHRepository (https://developer.github.com/v3/repos/traffic/#clones).
1 parent 8accf07 commit a1819bf

6 files changed

Lines changed: 277 additions & 150 deletions

File tree

src/main/java/org/kohsuke/github/GHRepository.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,13 @@ public GHRepositoryViews getViews() throws IOException{
14881488
return root.retrieve().to(getApiTailUrl("/traffic/views"), GHRepositoryViews.class);
14891489
}
14901490

1491+
/**
1492+
* <a href="https://developer.github.com/v3/repos/traffic/#clones">https://developer.github.com/v3/repos/traffic/#clones</a>
1493+
*/
1494+
public GHRepositoryClones getClones() throws IOException{
1495+
return root.retrieve().to(getApiTailUrl("/traffic/clones"), GHRepositoryClones.class);
1496+
}
1497+
14911498
@Override
14921499
public int hashCode() {
14931500
return ("Repository:"+getOwnerName()+":"+name).hashCode();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.kohsuke.github;
2+
3+
import java.util.Date;
4+
import java.util.List;
5+
6+
public class GHRepositoryClones extends GHRepositoryTrafficInfo {
7+
private List<DayClones> clones;
8+
9+
public GHRepositoryClones() {
10+
}
11+
12+
public GHRepositoryClones(Integer count, Integer uniques, List<DayClones> clones) {
13+
super(count, uniques);
14+
this.clones = clones;
15+
}
16+
17+
public List<DayClones> getClones() {
18+
return clones;
19+
}
20+
21+
public static class DayClones extends GHRepositoryTrafficInfo.DayInfo {
22+
public DayClones() {
23+
}
24+
25+
public DayClones(String timestamp, Integer count, Integer uniques) {
26+
super(timestamp, count, uniques);
27+
}
28+
29+
public DayClones(Date timestamp, Integer count, Integer uniques) {
30+
super(timestamp, count, uniques);
31+
}
32+
}
33+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package org.kohsuke.github;
2+
3+
import java.util.Date;
4+
5+
public abstract class GHRepositoryTrafficInfo {
6+
private Integer count;
7+
private Integer uniques;
8+
9+
public GHRepositoryTrafficInfo() {
10+
}
11+
12+
public GHRepositoryTrafficInfo(Integer count, Integer uniques) {
13+
this.count = count;
14+
this.uniques = uniques;
15+
}
16+
17+
public Integer getCount() {
18+
return count;
19+
}
20+
21+
public Integer getUniques() {
22+
return uniques;
23+
}
24+
25+
public static abstract class DayInfo {
26+
private Date timestamp;
27+
private Integer count;
28+
private Integer uniques;
29+
30+
public Date getTimestamp() {
31+
return timestamp;
32+
}
33+
34+
public Integer getCount() {
35+
return count;
36+
}
37+
38+
public Integer getUniques() {
39+
return uniques;
40+
}
41+
42+
public DayInfo() {
43+
}
44+
45+
public DayInfo(String timestamp, Integer count, Integer uniques) {
46+
this.timestamp = GitHub.parseDate(timestamp);
47+
this.count = count;
48+
this.uniques = uniques;
49+
}
50+
51+
public DayInfo(Date timestamp, Integer count, Integer uniques) {
52+
this.timestamp = timestamp;
53+
this.count = count;
54+
this.uniques = uniques;
55+
}
56+
}
57+
}

src/main/java/org/kohsuke/github/GHRepositoryViews.java

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,31 @@
33
import java.util.Date;
44
import java.util.List;
55

6-
public class GHRepositoryViews{
7-
private Integer count;
8-
private Integer uniques;
6+
public class GHRepositoryViews extends GHRepositoryTrafficInfo {
97
private List<DayViews> views;
108

119
public GHRepositoryViews() {
1210
}
1311

1412
public GHRepositoryViews(Integer count, Integer uniques, List<DayViews> views) {
15-
this.count = count;
16-
this.uniques = uniques;
13+
super(count, uniques);
1714
this.views = views;
1815
}
1916

20-
public Integer getCount() {
21-
return count;
22-
}
23-
24-
public Integer getUniques() {
25-
return uniques;
26-
}
27-
2817
public List<DayViews> getViews() {
2918
return views;
3019
}
3120

32-
public static class DayViews {
33-
private Date timestamp;
34-
private Integer count;
35-
private Integer uniques;
36-
37-
public Date getTimestamp() {
38-
return timestamp;
39-
}
40-
41-
public Integer getCount() {
42-
return count;
43-
}
44-
45-
public Integer getUniques() {
46-
return uniques;
47-
}
48-
21+
public static class DayViews extends GHRepositoryTrafficInfo.DayInfo {
4922
public DayViews() {
5023
}
5124

5225
public DayViews(String timestamp, Integer count, Integer uniques) {
53-
this.timestamp = GitHub.parseDate(timestamp);
54-
this.count = count;
55-
this.uniques = uniques;
26+
super(timestamp, count, uniques);
5627
}
5728

5829
public DayViews(Date timestamp, Integer count, Integer uniques) {
59-
this.timestamp = timestamp;
60-
this.count = count;
61-
this.uniques = uniques;
30+
super(timestamp, count, uniques);
6231
}
6332
}
6433
}

src/test/java/org/kohsuke/github/RepositoryTrafficMockTest.java

Lines changed: 0 additions & 114 deletions
This file was deleted.

0 commit comments

Comments
 (0)