Exemplo n.º 1
0
        private async Task <SetupWithMembershipResult> SetupAndCreateMembership(IZendeskClient client)
        {
            var setup = await Setup(client);

            var createdOrganisationMembership = await client
                                                .OrganizationMemberships
                                                .CreateAsync(new OrganizationMembership
            {
                OrganizationId = setup.Organization.Id,
                UserId         = setup.User.Id
            });

            Assert.True(createdOrganisationMembership.Id.HasValue);

            var getOrganisationMembership = await client
                                            .OrganizationMemberships
                                            .GetAsync(createdOrganisationMembership.Id.Value);

            Assert.NotNull(getOrganisationMembership);

            return(new SetupWithMembershipResult(
                       createdOrganisationMembership,
                       setup.Organization,
                       setup.User));
        }
Exemplo n.º 2
0
        public void BeforeScenario()
        {
            _customerClient = new ZendeskClient(new Uri(ConfigurationManager.AppSettings["zendeskhost"]),
                                                new ZendeskDefaultConfiguration(ConfigurationManager.AppSettings["zendeskenduserusername"], ConfigurationManager.AppSettings["zendesktoken"]));

            _supportUserClient = new ZendeskClient(new Uri(ConfigurationManager.AppSettings["zendeskhost"]),
                                                   new ZendeskDefaultConfiguration(ConfigurationManager.AppSettings["zendeskusername"], ConfigurationManager.AppSettings["zendesktoken"]));
        }
Exemplo n.º 3
0
        private async Task TeardownAndDeleteMembership(IZendeskClient client, SetupWithMembershipResult setup)
        {
            await client
            .OrganizationMemberships
            .DeleteAsync(setup.OrganizationMembership.Id.Value);

            await Teardown(client, setup);
        }
        public void BeforeScenario()
        {
            _customerClient = new ZendeskClient(new Uri(ConfigurationManager.AppSettings["zendeskhost"]),
                new ZendeskDefaultConfiguration(ConfigurationManager.AppSettings["zendeskenduserusername"], ConfigurationManager.AppSettings["zendesktoken"]));

            _supportUserClient = new ZendeskClient(new Uri(ConfigurationManager.AppSettings["zendeskhost"]),
                 new ZendeskDefaultConfiguration(ConfigurationManager.AppSettings["zendeskusername"], ConfigurationManager.AppSettings["zendesktoken"]));
        }
Exemplo n.º 5
0
        private async Task Teardown(IZendeskClient client, BasicSetupResult setup)
        {
            await client
            .Users
            .DeleteAsync(setup.User.Id);

            await client
            .Organizations
            .DeleteAsync(setup.Organization.Id);
        }
Exemplo n.º 6
0
        private static void ConnectToZendesk()
        {
            string mode     = ConfigurationManager.AppSettings["zendeskMode"].ToString();
            string apiToken = string.Empty;
            string apiURL   = string.Empty;

            if ((mode != null) && (mode == "production"))
            {
                apiToken = ConfigurationManager.AppSettings["zendeskAPIToken"].ToString();
                apiURL   = ConfigurationManager.AppSettings["zendeskURL"].ToString();
            }
            else if ((mode != null) && (mode == "sandbox"))
            {
                apiToken = ConfigurationManager.AppSettings["zendeskSandboxAPIToken"].ToString();
                apiURL   = ConfigurationManager.AppSettings["zendeskSandboxURL"].ToString();
            }

            if (HttpContext.Current.Session["ActiveUser"] != null)
            {
                Class_Objects.User u = (Class_Objects.User)HttpContext.Current.Session["ActiveUser"];
                zendeskUsername = u.ZendeskEmail;
                if (zendeskUsername == string.Empty || zendeskUsername == null)
                {
                    throw new Exception("Your Zendesk email address credentials are not set up. Please see I.T.");
                }

                zendeskURI    = new Uri(apiURL);
                configuration = new ZendeskDefaultConfiguration(zendeskUsername, apiToken);

                //if (!sandbox)
                //{
                //    // zendeskURI = new Uri(zendeskURL);
                //    // configuration = new ZendeskDefaultConfiguration(zendeskUsername, zendeskAPIToken);
                //    zendeskURI = new Uri(apiURL);
                //    configuration = new ZendeskDefaultConfiguration(zendeskUsername, apiToken);
                //}
                //else
                //{
                //    // zendeskURI = new Uri(zendeskSandboxURL);
                //    // configuration = new ZendeskDefaultConfiguration(zendeskUsername, zendeskSandboxAPIToken);
                //    zendeskURI = new Uri(apiURL);
                //    configuration = new ZendeskDefaultConfiguration(zendeskUsername, apiToken);
                //}

                client = new ZendeskClient(zendeskURI, configuration);
                ServicePointManager.Expect100Continue = true;
                ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            }
        }
Exemplo n.º 7
0
        private async Task <BasicSetupResult> Setup(IZendeskClient client)
        {
            var id = Guid.NewGuid().ToString();

            var createdOrganisation = await client.Organizations
                                      .CreateAsync(new Organization
            {
                ExternalId = id,
                Name       = $"ZendeskApi.Client.IntegrationTests {id}"
            });

            var userId = Guid.NewGuid().ToString();

            var user = await client.Users
                       .CreateAsync(new UserCreateRequest(userId));

            return(new BasicSetupResult(createdOrganisation, user));
        }
Exemplo n.º 8
0
        //static IZendeskClient _zClient;
        static void Main(string[] args)

        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            var configuration = builder.Build();

            var ticket = new ZendeskTicketRequest
            {
                ticket = new Ticket
                {
                    Subject     = $"Yey, this is a console ticket with id {Guid.NewGuid().ToString()}",
                    Description = $"blah blah blah",
                    Priority    = Priority.Normal.ToString().ToLowerInvariant(),
                    Type        = Type.Problem.ToString().ToLowerInvariant(),
                    Status      = Status.New.ToString().ToLowerInvariant()
                }
            };

            _client = new ZendeskClient <ZendeskTicketRequest>(configuration);
            _client.PostTicketAsync(ticket).GetAwaiter().GetResult();
        }
Exemplo n.º 9
0
 public TicketFieldResource(IZendeskClient client)
 {
     Client = client;
 }