Skip to content

Vendor

GET

using System;
using System.Threading.Tasks;
using Wdcs.Wip.Api;
using Wdcs.Wip.Client;
using Wdcs.Wip.Model;

namespace wip_project.Api
{
    public partial class VendorService : IGetApi
    {
        public async Task GetAsync(string apiUrl, string username, string password)
        {
            var config = new Configuration()
            {
                BasePath = apiUrl
            };
            var tokenRequest = new TokenApi(config);
            // Get the Token
            var response = tokenRequest.Create(new TokenUser(username, password));
            var authorization = "Bearer " + response.AuthToken;

            var api = new VendorApi(config);
            var vendors = await api.GetAsync(authorization);
            foreach (var vendor in vendors.Results)
            {
                Console.WriteLine($"Vendor: {vendor.VendorId}  Name: {vendor.Name}");
            }
        }
    }
}