Exemplo n.º 1
0
        public async Task <EventResponse> GetWaEventDetails(int eventId)
        {
            var apiEventResource = $"accounts/{_accountId}/events/{eventId}";

            var response = new HttpResponseMessage();
            var token    = await GetTokenAsync();

            try
            {
                response = await WildApricotOps.GetRequest(apiEventResource, token);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception(e.Message);
            }

            var apiResponse = await response.Content.ReadAsStringAsync();

            var eventDetailsReturned = Newtonsoft.Json.JsonConvert.DeserializeObject <EventResponse>(apiResponse);

            if (eventDetailsReturned == null)
            {
                throw new ExecutionError("Event could not be found");
            }

            return(eventDetailsReturned);
        }
Exemplo n.º 2
0
        public async Task <Contact> GetContact(string email)
        {
            var apiEventResource = $"accounts/{_accountId}/contacts";
            var query            = new List <string>
            {
                "$async=false",
                $"simpleQuery={email}"
            };

            HttpResponseMessage response;
            var token = await GetTokenAsync();

            try
            {
                response = await WildApricotOps.GetRequest(apiEventResource, token, query);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception(e.Message);
            }

            var content = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <QueryContactResponse>(content);

            if (result.Contacts.Count == 0)
            {
                return(null);
            }

            var returnedContact = result.Contacts[0];

            return(new Contact
            {
                FirstName = returnedContact.FirstName,
                LastName = returnedContact.LastName,
                Email = returnedContact.Email,
                Organization = returnedContact.Organization,
                Status = returnedContact.Status,
                Id = returnedContact.Id
            });
        }
Exemplo n.º 3
0
        public async Task <EventRegistrationResponse> GetEventRegistration(int registrationId)
        {
            var apiEventResource = $"accounts/{_accountId}/eventregistrations/{registrationId}";
            HttpResponseMessage response;
            var token = await GetTokenAsync();

            try
            {
                response = await WildApricotOps.GetRequest(apiEventResource, token);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new Exception(e.Message);
            }

            var content = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <EventRegistrationResponse>(content);

            return(result);
        }