internal static async Task<RaveGroup> AddGroupAsync(RaveGroup group) {
      using (var client = new HttpClient()) {
        client.DefaultRequestHeaders.Authorization = Credentials.BasicAuthHeader;
        var url = string.Format("https://www.getrave.com/remoteservices/rest/siteadmin/groups");
        var r = await client.PostAsync(url, new StringContent(Utils.SerializeXml(MapFrom(group)), Encoding.UTF8, "application/xml"));

        if (r.IsSuccessStatusCode) { return MapFrom(Utils.DeserializeXml<RaveGroupServiceModel>(await r.Content.ReadAsStringAsync())); }
        throw new RaveServiceException(r);
      }
    }
 private static RaveGroupServiceModel MapFrom(RaveGroup o) {
   if (o == null) { return null; }
   return new RaveGroupServiceModel {
     ID = o.ID == 0 ? null : o.ID.ToString(),
     Name = o.Name,
     Description = o.Description,
     Keyword = o.Keyword,
     AlertPhoneDefault = o.AlertPhones,
     AlertEmailDefault = o.AlertEmails,
     OfficialCircle = o.OfficialCircle,
     Public = o.Public,
     AnyoneCanPost = o.AnyoneCanPost,
     NumSubscriptions = o.Subscriptions == 0 ? null : o.Subscriptions.ToString()
   };
 }
Exemplo n.º 3
0
 public static async Task<RaveGroup> UpdateAsync(RaveGroup group) {
   return await RaveGroupServiceModel.UpdateGroupAsync(group);
 }
Exemplo n.º 4
0
 public static async Task<RaveGroup> AddAysnc(RaveGroup group) {
   return await RaveGroupServiceModel.AddGroupAsync(group);
 }