Exemplo n.º 1
0
        public WorkspaceResponse UpdateWorkspace(string workspaceId, UpdateWorkspace body = null)
        {
            if (string.IsNullOrEmpty(workspaceId))
            {
                throw new ArgumentNullException(nameof(workspaceId));
            }

            if (string.IsNullOrEmpty(VersionDate))
            {
                throw new ArgumentNullException("versionDate cannot be null. Use 'CONVERSATION_VERSION_DATE_2017_05_26'");
            }

            WorkspaceResponse result = null;

            try
            {
                result = this.Client.WithAuthentication(this.UserName, this.Password)
                         .PostAsync($"{this.Endpoint}/v1/workspaces/{workspaceId}")
                         .WithArgument("version", VersionDate)
                         .WithBody <UpdateWorkspace>(body)
                         .As <WorkspaceResponse>()
                         .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
Exemplo n.º 2
0
        public WorkspaceResponse CreateWorkspace(CreateWorkspace request)
        {
            WorkspaceResponse result = null;

            if (request == null)
            {
                throw new ArgumentNullException("parameter: request");
            }

            try
            {
                result =
                    this.Client.WithAuthentication(this.UserName, this.Password)
                    .PostAsync($"{this.Endpoint}{PATH_CONVERSATION}")
                    .WithArgument("version", VERSION_DATE_2017_05_26)
                    .WithHeader("accept", HttpMediaType.TEXT_HTML)
                    .WithBody <CreateWorkspace>(request, MediaTypeHeaderValue.Parse(HttpMediaType.APPLICATION_JSON))
                    .As <WorkspaceResponse>()
                    .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }