Ejemplo n.º 1
0
        /// <inheritdoc />
        public async Task <Organization> GetOrganization(string OrgNr)
        {
            Organization organization             = null;
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Organization));

            Uri endpointUrl = new Uri($"{_platformSettings.GetApiBaseEndpoint()}v1/organizations/{OrgNr}");

            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(endpointUrl);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    organization = await response.Content.ReadAsAsync <Organization>();
                }
                else
                {
                    _logger.LogError($"Getting organization with orgnr {OrgNr} failed with statuscode {response.StatusCode}");
                }
            }

            return(organization);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public async Task <UserProfile> GetUserProfile(int userId)
        {
            UserProfile userProfile = null;
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(UserProfile));

            Uri endpointUrl = new Uri($"{_platformSettings.GetApiBaseEndpoint()}v1/users/{userId}");

            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(endpointUrl);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    userProfile = await response.Content.ReadAsAsync <UserProfile>();
                }
                else
                {
                    _logger.LogError($"Getting user profile with userId {userId} failed with statuscode {response.StatusCode}");
                }
            }

            return(userProfile);
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public async Task <Person> GetPerson(string SSN)
        {
            Person person = null;
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Person));

            Uri endpointUrl = new Uri($"{_platformSettings.GetApiBaseEndpoint()}v1/persons/{SSN}");

            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(endpointUrl);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    person = await response.Content.ReadAsAsync <Person>();
                }
                else
                {
                    _logger.LogError($"Getting person with ssn {SSN} failed with statuscode {response.StatusCode}");
                }
            }

            return(person);
        }
Ejemplo n.º 4
0
        /// <inheritdoc/>
        public async Task <Party> GetParty(int partyId)
        {
            Party party = null;
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Party));

            Uri endpointUrl = new Uri($"{_platformSettings.GetApiBaseEndpoint()}v1/party/{partyId}");

            using (HttpClient client = new HttpClient())
            {
                HttpResponseMessage response = await client.GetAsync(endpointUrl);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    party = await response.Content.ReadAsAsync <Party>();
                }
                else
                {
                    _logger.LogError($"Getting party with partyID {partyId} failed with statuscode {response.StatusCode}");
                }
            }

            return(party);
        }