示例#1
0
        public async Task CreateWorkspaceUser(WorkspaceUserModel model)
        {
            var url = new Uri(v8Url, String.Format("workspaces/{0}/invite", model.From.RemoteId.Value.ToString()));

            var json = JsonConvert.SerializeObject(new {
                emails = new string[] { model.To.Email },
            });
            var httpReq = SetupRequest(new HttpRequestMessage()
            {
                Method     = HttpMethod.Post,
                RequestUri = url,
                Content    = new StringContent(json, Encoding.UTF8, "application/json"),
            });
            var httpResp = await httpClient.SendAsync(httpReq)
                           .ConfigureAwait(continueOnCapturedContext: false);

            PrepareResponse(httpResp);

            var wrap = JObject.Parse(await httpResp.Content.ReadAsStringAsync()
                                     .ConfigureAwait(continueOnCapturedContext: false));
            var data = wrap ["data"] [0].ToObject <WorkspaceUserModel> ();

            model.Merge(data);
            // In case the local model has changed in the mean time (and merge does nothing),
            // make sure that the remote id is set.
            if (model.RemoteId == null)
            {
                model.RemoteId = data.RemoteId;
            }
        }
示例#2
0
        public Task DeleteWorkspaceUser(WorkspaceUserModel model)
        {
            var url = new Uri(v8Url, String.Format("workspace_users/{0}", model.RemoteId.Value.ToString()));

            return(DeleteModel(url));
        }