This repository has been archived by the owner on Dec 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74c0e5e
commit 691c76c
Showing
7 changed files
with
466 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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,142 @@ | ||
/** | ||
* Copyright (c) 2017, Mihai Emil Andronache | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
package com.amihaiemil.versioneye; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.json.JsonArray; | ||
import javax.json.JsonObject; | ||
|
||
/** | ||
* VersionEye Team backed by a JsonObject. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 1.0.0 | ||
*/ | ||
final class JsonTeam implements Team { | ||
|
||
/** | ||
* Team. | ||
*/ | ||
private JsonObject team; | ||
|
||
/** | ||
* Ctor. | ||
* @param team Given team. | ||
*/ | ||
JsonTeam(final JsonObject team) { | ||
this.team = team; | ||
} | ||
|
||
@Override | ||
public String teamId() { | ||
return this.team.getString("ids"); | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return this.team.getString("name"); | ||
} | ||
|
||
@Override | ||
public boolean versionNotifications() { | ||
return this.team.getBoolean("version_notifications"); | ||
} | ||
|
||
@Override | ||
public boolean licenseNotifications() { | ||
return this.team.getBoolean("license_notifications"); | ||
} | ||
|
||
@Override | ||
public boolean securityNotifications() { | ||
return this.team.getBoolean("security_notifications"); | ||
} | ||
|
||
@Override | ||
public boolean monday() { | ||
return this.team.getBoolean("monday"); | ||
} | ||
|
||
@Override | ||
public boolean tuesday() { | ||
return this.team.getBoolean("tuesday"); | ||
} | ||
|
||
@Override | ||
public boolean wednesday() { | ||
return this.team.getBoolean("wednesday"); | ||
} | ||
|
||
@Override | ||
public boolean thursday() { | ||
return this.team.getBoolean("thursday"); | ||
} | ||
|
||
@Override | ||
public boolean friday() { | ||
return this.team.getBoolean("friday"); | ||
} | ||
|
||
@Override | ||
public boolean saturday() { | ||
return this.team.getBoolean("saturday"); | ||
} | ||
|
||
@Override | ||
public boolean sunday() { | ||
return this.team.getBoolean("sunday"); | ||
} | ||
|
||
@Override | ||
public List<UserData> users() { | ||
final JsonArray users = this.team.getJsonArray("users"); | ||
final List<UserData> members = new ArrayList<>(); | ||
for(int idx = 0; idx < users.size(); idx++) { | ||
members.add(new JsonUserData(users.getJsonObject(idx))); | ||
} | ||
return members; | ||
} | ||
|
||
@Override | ||
public String createdAt() { | ||
return this.team.getString("created_at"); | ||
} | ||
|
||
@Override | ||
public String updatedAt() { | ||
return this.team.getString("updated_at"); | ||
} | ||
|
||
@Override | ||
public JsonObject json() { | ||
return this.team; | ||
} | ||
|
||
} |
This file contains 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 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,78 @@ | ||
/** | ||
* Copyright (c) 2017, Mihai Emil Andronache | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
package com.amihaiemil.versioneye; | ||
|
||
import java.io.IOException; | ||
import java.net.HttpURLConnection; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.json.JsonArray; | ||
import com.jcabi.http.Request; | ||
import com.jcabi.http.response.JsonResponse; | ||
import com.jcabi.http.response.RestResponse; | ||
|
||
/** | ||
* Real implementation for {@link Teams}. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 1.0.0 | ||
*/ | ||
final class RtTeams implements Teams { | ||
|
||
/** | ||
* HTTP request. | ||
*/ | ||
private Request req; | ||
|
||
/** | ||
* Ctor. | ||
* @param entry HTTP request. | ||
* @param orgKey The organization's api_key | ||
*/ | ||
RtTeams(final Request entry, final String orgKey) { | ||
this.req = entry.uri().queryParam("api_key", orgKey).back(); | ||
} | ||
|
||
@Override | ||
public List<Team> fetch() throws IOException { | ||
final JsonArray array = this.req.fetch() | ||
.as(RestResponse.class) | ||
.assertStatus(HttpURLConnection.HTTP_OK) | ||
.as(JsonResponse.class) | ||
.json() | ||
.readArray(); | ||
final List<Team> teams = new ArrayList<>(); | ||
for(int idx=0; idx<array.size(); idx++) { | ||
teams.add( | ||
new JsonTeam(array.getJsonObject(idx)) | ||
); | ||
} | ||
return teams; | ||
} | ||
|
||
} |
This file contains 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,139 @@ | ||
/** | ||
* Copyright (c) 2017, Mihai Emil Andronache | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
* list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* Neither the name of the copyright holder nor the names of its | ||
* contributors may be used to endorse or promote products derived from | ||
* this software without specific prior written permission. | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
*/ | ||
package com.amihaiemil.versioneye; | ||
|
||
import java.util.List; | ||
|
||
import javax.json.JsonObject; | ||
|
||
/** | ||
* A VersionEye Team. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 1.0.0 | ||
* | ||
*/ | ||
public interface Team { | ||
|
||
/** | ||
* Team id. | ||
* @return String | ||
*/ | ||
String teamId(); | ||
|
||
/** | ||
* Team name. | ||
* @return String | ||
*/ | ||
String name(); | ||
|
||
/** | ||
* Does this team receive versions notifications? | ||
* @return Boolean. | ||
*/ | ||
boolean versionNotifications(); | ||
|
||
/** | ||
* Does this team receive licenses notifications? | ||
* @return Boolean. | ||
*/ | ||
boolean licenseNotifications(); | ||
|
||
/** | ||
* Does this team receive security notifications? | ||
* @return Boolean. | ||
*/ | ||
boolean securityNotifications(); | ||
|
||
/** | ||
* Should notifications be sent on Mondays? | ||
* @return Boolean. | ||
*/ | ||
boolean monday(); | ||
|
||
/** | ||
* Should notifications be sent on Tuesdays? | ||
* @return Boolean. | ||
*/ | ||
boolean tuesday(); | ||
|
||
/** | ||
* Should notifications be sent on Wednesdays? | ||
* @return Boolean. | ||
*/ | ||
boolean wednesday(); | ||
|
||
/** | ||
* Should notifications be sent on Thursdays? | ||
* @return Boolean. | ||
*/ | ||
boolean thursday(); | ||
|
||
/** | ||
* Should notifications be sent on Fridays? | ||
* @return Boolean. | ||
*/ | ||
boolean friday(); | ||
|
||
/** | ||
* Should notifications be sent on Saturdays? | ||
* @return Boolean. | ||
*/ | ||
boolean saturday(); | ||
|
||
/** | ||
* Should notifications be sent on Sundays? | ||
* @return Boolean. | ||
*/ | ||
boolean sunday(); | ||
|
||
/** | ||
* Members of this team. | ||
* @return List of UserData. | ||
*/ | ||
List<UserData> users(); | ||
|
||
/** | ||
* Created at. | ||
* @return String. | ||
*/ | ||
String createdAt(); | ||
|
||
/** | ||
* Updated at. | ||
* @return String. | ||
*/ | ||
String updatedAt(); | ||
|
||
/** | ||
* This Team as JsonObject. | ||
* @return JsonObject. | ||
*/ | ||
JsonObject json(); | ||
|
||
} |
Oops, something went wrong.
691c76c
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.
Puzzle
45-46f15e48
disappeared, that's why I closed as #47691c76c
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.
Puzzle
37-8087fd76
discovered and submitted as #49