Beispiel #1
0
        public Group GetGroup(GroupId groupId)
        {
            Silanis.ESL.API.Group apiGroup = apiClient.GetGroup(groupId.Id);
            Group sdkGroup = new GroupConverter(apiGroup).ToSDKGroup();

            return(sdkGroup);
        }
Beispiel #2
0
        public Group GetGroup(GroupId groupId)
        {
            string path = template.UrlFor(UrlTemplate.GROUPS_ID_PATH)
                          .Replace("{groupId}", groupId.Id)
                          .Build();

            try {
                string response = restClient.Get(path);
                Silanis.ESL.API.Group apiGroup = JsonConvert.DeserializeObject <Silanis.ESL.API.Group> (response, settings);
                Group sdkGroup = new GroupConverter(apiGroup).ToSDKGroup();
                return(sdkGroup);
            } catch (Exception e) {
                throw new EslException("Failed to retrieve group." + " Exception: " + e.Message);
            }
        }
Beispiel #3
0
        public Silanis.ESL.API.Group CreateGroup(Silanis.ESL.API.Group apiGroup)
        {
            string path = template.UrlFor(UrlTemplate.GROUPS_PATH).Build();

            try {
                string json     = JsonConvert.SerializeObject(apiGroup, settings);
                string response = restClient.Post(path, json);
                Silanis.ESL.API.Group apiResponse = JsonConvert.DeserializeObject <Silanis.ESL.API.Group> (response);
                return(apiResponse);
            }
            catch (EslServerException e) {
                throw new EslServerException("Failed to create new group." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Failed to create new group." + " Exception: " + e.Message, e);
            }
        }
Beispiel #4
0
        public Silanis.ESL.API.Group ToAPIGroup()
        {
            if (apiGroup != null)
            {
                return(apiGroup);
            }
            else
            {
                Silanis.ESL.API.Group result = ToAPIGroupWithoutMembers();

                foreach (GroupMember sdkMember in sdkGroup.Members)
                {
                    result.AddMember(new GroupMemberConverter(sdkMember).ToAPIGroupMember());
                }
                return(result);
            }
        }
Beispiel #5
0
        public Group CreateGroup(Group group)
        {
            string path = template.UrlFor(UrlTemplate.GROUPS_PATH).Build();

            Silanis.ESL.API.Group apiGroup = new GroupConverter(group).ToAPIGroupWithoutMembers();
            try {
                string json     = JsonConvert.SerializeObject(apiGroup, settings);
                string response = restClient.Post(path, json);
                Silanis.ESL.API.Group apiResponse = JsonConvert.DeserializeObject <Silanis.ESL.API.Group> (response);
                Group sdkGroup = new GroupConverter(apiResponse).ToSDKGroup();
                foreach (GroupMember groupMember in group.Members)
                {
                    InviteMember(sdkGroup.Id, groupMember);
                }
                return(sdkGroup);
            } catch (Exception e) {
                throw new EslException("Failed to create new group." + " Exception: " + e.Message);
            }
        }
Beispiel #6
0
        public Silanis.ESL.API.Group InviteMember(string groupId, Silanis.ESL.API.GroupMember apiGroupMember)
        {
            string path = template.UrlFor(UrlTemplate.GROUPS_INVITE_PATH)
                          .Replace("{groupId}", groupId)
                          .Build();

            try {
                string json     = JsonConvert.SerializeObject(apiGroupMember, settings);
                string response = restClient.Post(path, json);
                Silanis.ESL.API.Group apiResponse = JsonConvert.DeserializeObject <Silanis.ESL.API.Group> (response);
                return(apiResponse);
            }
            catch (EslServerException e) {
                throw new EslServerException("Failed to invite member." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Failed to invite member." + " Exception: " + e.Message, e);
            }
        }
        public Silanis.ESL.API.Group ToAPIGroupWithoutMembers() {
            if (apiGroup != null)
            {
                return apiGroup;
            }
            else
            {
                Silanis.ESL.API.Group result = new Silanis.ESL.API.Group();
                result.Name = sdkGroup.Name;
                result.Created = sdkGroup.Created;
                result.Updated = sdkGroup.Updated;
				if (sdkGroup.Id != null)
				{
					result.Id = sdkGroup.Id.Id;
				}
                result.Email = sdkGroup.Email;
                result.EmailMembers = sdkGroup.EmailMembers;
                return result;
            }
        }
Beispiel #8
0
 public Silanis.ESL.API.Group ToAPIGroupWithoutMembers()
 {
     if (apiGroup != null)
     {
         return(apiGroup);
     }
     else
     {
         Silanis.ESL.API.Group result = new Silanis.ESL.API.Group();
         result.Name    = sdkGroup.Name;
         result.Created = sdkGroup.Created;
         result.Updated = sdkGroup.Updated;
         if (sdkGroup.Id != null)
         {
             result.Id = sdkGroup.Id.Id;
         }
         result.Email        = sdkGroup.Email;
         result.EmailMembers = sdkGroup.EmailMembers;
         return(result);
     }
 }
 public GroupConverter( Group group )
 {
     sdkGroup = group;
     apiGroup = null;
 }
Beispiel #10
0
 public GroupConverter( Silanis.ESL.API.Group apiGroup ) 
 {
     this.apiGroup = apiGroup;
     sdkGroup = null;
 }
Beispiel #11
0
 public GroupConverter(Group group)
 {
     sdkGroup = group;
     apiGroup = null;
 }
Beispiel #12
0
 public GroupConverter(Silanis.ESL.API.Group apiGroup)
 {
     this.apiGroup = apiGroup;
     sdkGroup      = null;
 }
Beispiel #13
0
 public Group InviteMember(GroupId groupId, GroupMember groupMember)
 {
     Silanis.ESL.API.GroupMember apiGroupMember = new GroupMemberConverter(groupMember).ToAPIGroupMember();
     Silanis.ESL.API.Group       apiResponse    = apiClient.InviteMember(groupId.Id, apiGroupMember);
     return(new GroupConverter(apiResponse).ToSDKGroup());
 }