Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added on method for group API

  • Loading branch information...
commit e9db69caff28b4b603b3da2602317fa9a02ef4b9 1 parent 2ca7444
@hemant24 hemant24 authored
View
134 core/src/main/java/org/springframework/social/flickr/api/Group2.java
@@ -0,0 +1,134 @@
+
+package org.springframework.social.flickr.api;
+
+import java.util.LinkedHashMap;
+
+public class Group2{
+ private String description;//
+ private Number iconfarm;
+ private String iconserver;
+ private String id;
+ private Number is_admin;
+ private Number is_member;
+ private Number is_moderator;
+ private Number ispoolmoderated;
+ private String lang;
+ private String members;//
+ private String name;//
+ private String pool_count;//
+ private String privacy;//
+ private Restrictions restrictions;
+ private Roles roles;
+ private String rules;//
+ private Throttle throttle;
+ private String topic_count;//
+
+ public String getDescription(){
+ return this.description;
+ }
+ public void setDescription(LinkedHashMap<String,String> description){
+ this.description = description.get(FlickrConstant.JSONCONTENT);
+ }
+ public Number getIconfarm(){
+ return this.iconfarm;
+ }
+ public void setIconfarm(Number iconfarm){
+ this.iconfarm = iconfarm;
+ }
+ public String getIconserver(){
+ return this.iconserver;
+ }
+ public void setIconserver(String iconserver){
+ this.iconserver = iconserver;
+ }
+ public String getId(){
+ return this.id;
+ }
+ public void setId(String id){
+ this.id = id;
+ }
+ public Number getIs_admin(){
+ return this.is_admin;
+ }
+ public void setIs_admin(Number is_admin){
+ this.is_admin = is_admin;
+ }
+ public Number getIs_member(){
+ return this.is_member;
+ }
+ public void setIs_member(Number is_member){
+ this.is_member = is_member;
+ }
+ public Number getIs_moderator(){
+ return this.is_moderator;
+ }
+ public void setIs_moderator(Number is_moderator){
+ this.is_moderator = is_moderator;
+ }
+ public Number getIspoolmoderated(){
+ return this.ispoolmoderated;
+ }
+ public void setIspoolmoderated(Number ispoolmoderated){
+ this.ispoolmoderated = ispoolmoderated;
+ }
+ public String getLang(){
+ return this.lang;
+ }
+ public void setLang(String lang){
+ this.lang = lang;
+ }
+ public String getMembers(){
+ return this.members;
+ }
+ public void setMembers(LinkedHashMap<String,String> members){
+ this.members = members.get(FlickrConstant.JSONCONTENT);;
+ }
+ public String getName(){
+ return this.name;
+ }
+ public void setName(LinkedHashMap<String,String> name){
+ this.name = name.get(FlickrConstant.JSONCONTENT);
+ }
+ public String getPool_count(){
+ return this.pool_count;
+ }
+ public void setPool_count(LinkedHashMap<String,String> pool_count){
+ this.pool_count = pool_count.get(FlickrConstant.JSONCONTENT);
+ }
+ public String getPrivacy(){
+ return this.privacy;
+ }
+ public void setPrivacy(LinkedHashMap<String,String> privacy){
+ this.privacy = privacy.get(FlickrConstant.JSONCONTENT);
+ }
+ public Restrictions getRestrictions(){
+ return this.restrictions;
+ }
+ public void setRestrictions(Restrictions restrictions){
+ this.restrictions = restrictions;
+ }
+ public Roles getRoles(){
+ return this.roles;
+ }
+ public void setRoles(Roles roles){
+ this.roles = roles;
+ }
+ public String getRules(){
+ return this.rules;
+ }
+ public void setRules(LinkedHashMap<String,String> rules){
+ this.rules = rules.get(FlickrConstant.JSONCONTENT);
+ }
+ public Throttle getThrottle(){
+ return this.throttle;
+ }
+ public void setThrottle(Throttle throttle){
+ this.throttle = throttle;
+ }
+ public String getTopic_count(){
+ return this.topic_count;
+ }
+ public void setTopic_count(LinkedHashMap<String,String> topic_count){
+ this.topic_count = topic_count.get(FlickrConstant.JSONCONTENT);
+ }
+}
View
2  core/src/main/java/org/springframework/social/flickr/api/GroupsOperations.java
@@ -36,5 +36,5 @@
* @param lang the lang
* @return the info
*/
- Group getInfo(String apiKey, String groupId, String lang);
+ Group2 getInfo(String apiKey, String groupId, String lang);
}
View
71 core/src/main/java/org/springframework/social/flickr/api/Restrictions.java
@@ -0,0 +1,71 @@
+
+package org.springframework.social.flickr.api;
+
+import java.util.List;
+
+public class Restrictions{
+ private Number art_ok;
+ private Number has_geo;
+ private Number images_ok;
+ private Number moderate_ok;
+ private Number photos_ok;
+ private Number restricted_ok;
+ private Number safe_ok;
+ private Number screens_ok;
+ private Number videos_ok;
+
+ public Number getArt_ok(){
+ return this.art_ok;
+ }
+ public void setArt_ok(Number art_ok){
+ this.art_ok = art_ok;
+ }
+ public Number getHas_geo(){
+ return this.has_geo;
+ }
+ public void setHas_geo(Number has_geo){
+ this.has_geo = has_geo;
+ }
+ public Number getImages_ok(){
+ return this.images_ok;
+ }
+ public void setImages_ok(Number images_ok){
+ this.images_ok = images_ok;
+ }
+ public Number getModerate_ok(){
+ return this.moderate_ok;
+ }
+ public void setModerate_ok(Number moderate_ok){
+ this.moderate_ok = moderate_ok;
+ }
+ public Number getPhotos_ok(){
+ return this.photos_ok;
+ }
+ public void setPhotos_ok(Number photos_ok){
+ this.photos_ok = photos_ok;
+ }
+ public Number getRestricted_ok(){
+ return this.restricted_ok;
+ }
+ public void setRestricted_ok(Number restricted_ok){
+ this.restricted_ok = restricted_ok;
+ }
+ public Number getSafe_ok(){
+ return this.safe_ok;
+ }
+ public void setSafe_ok(Number safe_ok){
+ this.safe_ok = safe_ok;
+ }
+ public Number getScreens_ok(){
+ return this.screens_ok;
+ }
+ public void setScreens_ok(Number screens_ok){
+ this.screens_ok = screens_ok;
+ }
+ public Number getVideos_ok(){
+ return this.videos_ok;
+ }
+ public void setVideos_ok(Number videos_ok){
+ this.videos_ok = videos_ok;
+ }
+}
View
29 core/src/main/java/org/springframework/social/flickr/api/Roles.java
@@ -0,0 +1,29 @@
+
+package org.springframework.social.flickr.api;
+
+import java.util.List;
+
+public class Roles{
+ private String admin;
+ private String member;
+ private String moderator;
+
+ public String getAdmin(){
+ return this.admin;
+ }
+ public void setAdmin(String admin){
+ this.admin = admin;
+ }
+ public String getMember(){
+ return this.member;
+ }
+ public void setMember(String member){
+ this.member = member;
+ }
+ public String getModerator(){
+ return this.moderator;
+ }
+ public void setModerator(String moderator){
+ this.moderator = moderator;
+ }
+}
View
15 core/src/main/java/org/springframework/social/flickr/api/Throttle.java
@@ -0,0 +1,15 @@
+
+package org.springframework.social.flickr.api;
+
+import java.util.List;
+
+public class Throttle{
+ private String mode;
+
+ public String getMode(){
+ return this.mode;
+ }
+ public void setMode(String mode){
+ this.mode = mode;
+ }
+}
View
6 core/src/main/java/org/springframework/social/flickr/api/impl/FlickrTemplate.java
@@ -27,6 +27,7 @@
import org.springframework.social.flickr.api.FavoritesOperations;
import org.springframework.social.flickr.api.Flickr;
import org.springframework.social.flickr.api.GalleriesOperations;
+import org.springframework.social.flickr.api.GroupsOperations;
import org.springframework.social.flickr.api.PeopleOperations;
import org.springframework.social.flickr.api.PhotoCommentOperations;
import org.springframework.social.flickr.api.PhotoLicenseOperations;
@@ -51,6 +52,7 @@
private ActivityOperations activityOperations;
private BlogsOperations blogsOperations;
private CommonsOperations commonsOperations;
+ private GroupsOperations groupsOperations;
@@ -76,6 +78,7 @@ private void initSubApis() {
this.activityOperations = new ActivityTemplate(getRestTemplate(), isAuthorized());
this.blogsOperations = new BlogsTemplate(getRestTemplate(), isAuthorized());
this.commonsOperations = new CommonsTemplate(getRestTemplate(), isAuthorized());
+ this.groupsOperations = new GroupsTemplate(getRestTemplate(), isAuthorized());
}
@@ -138,5 +141,8 @@ public BlogsOperations blogsOperations(){
public CommonsOperations commonsOperations(){
return commonsOperations;
}
+ public GroupsOperations groupsOperations(){
+ return groupsOperations;
+ }
}
View
6 core/src/main/java/org/springframework/social/flickr/api/impl/GroupsTemplate.java
@@ -1,7 +1,7 @@
package org.springframework.social.flickr.api.impl;
import org.springframework.social.flickr.api.Category;
-import org.springframework.social.flickr.api.Group;
+import org.springframework.social.flickr.api.Group2;
import org.springframework.social.flickr.api.Groups;
import org.springframework.social.flickr.api.GroupsOperations;
import org.springframework.util.LinkedMultiValueMap;
@@ -34,7 +34,7 @@ public Category browse(String apiKey, String catId) {
}
@Override
- public Group getInfo(String apiKey, String groupId, String lang) {
+ public Group2 getInfo(String apiKey, String groupId, String lang) {
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
if (apiKey != null)
parameters.set("api_key", apiKey);
@@ -43,7 +43,7 @@ public Group getInfo(String apiKey, String groupId, String lang) {
if (lang != null)
parameters.set("lang", lang);
return restTemplate.getForObject(
- buildUri("flickr.groups.getInfo", parameters), Group.class);
+ buildUri("flickr.groups.getInfo", parameters), Group2.class);
}
@Override
View
19 core/src/test/java/org/springframework/social/flickr/connect/GroupsTemplateTest.java
@@ -4,7 +4,10 @@
import static org.springframework.social.test.client.RequestMatchers.method;
import static org.springframework.social.test.client.RequestMatchers.requestTo;
import static org.springframework.social.test.client.ResponseCreators.withResponse;
+import junit.framework.Assert;
+
import org.junit.Test;
+import org.springframework.social.flickr.api.Group2;
/**
* @author HemantS
@@ -28,5 +31,21 @@ public void searchTest() {
.andRespond(
withResponse(jsonResource("testuser"), responseHeaders));
}
+
+ @Test
+ public void infoTest() {
+ mockServer
+ .expect(requestTo("http://api.flickr.com/services/rest/?api_key=23&group_id=1878057%40N24&method=flickr.groups.getInfo&format=json&nojsoncallback=1"))
+ .andExpect(method(GET))
+ .andRespond(
+ withResponse(jsonResource("group"), responseHeaders));
+ Group2 group = flickr.groupsOperations().getInfo("23", "1878057@N24", null);
+ assertGroup(group);
+ }
+
+ private void assertGroup(Group2 group) {
+ Assert.assertEquals("goa", group.getDescription());
+
+ }
}
View
11 core/src/test/resources/org/springframework/social/flickr/connect/group.json
@@ -0,0 +1,11 @@
+{ "group": { "id": "1878057@N24", "iconserver": 0, "iconfarm": 0,
+ "name": { "_content": "GoaGroup" },
+ "description": { "_content": "goa" },
+ "rules": { "_content": "" },
+ "members": { "_content": 1 },
+ "pool_count": { "_content": 3 },
+ "topic_count": { "_content": 0 },
+ "privacy": { "_content": 2 }, "lang": "", "ispoolmoderated": 0,
+ "roles": { "member": "Member", "moderator": "Moderator", "admin": "Admin" }, "is_member": 1, "is_moderator": 0, "is_admin": 1,
+ "throttle": { "mode": "none" },
+ "restrictions": { "photos_ok": 1, "videos_ok": 1, "images_ok": 1, "screens_ok": 1, "art_ok": 1, "safe_ok": 1, "moderate_ok": 0, "restricted_ok": 0, "has_geo": 0 } }, "stat": "ok" }
Please sign in to comment.
Something went wrong with that request. Please try again.