/// <summary>
        /// Returns a list of library locations for a given product.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns a list of library locations for the given product token.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public async Task <List <LibraryLocation> > GetProductLibraryLocationsAsync(ProductToken productToken)
        {
            var request  = new BaseRequest("getProductLibraryLocations", UserKey, productToken: productToken);
            var response = await request.MakeRequestAsync <LibraryLocationsResponse>(this);

            return(response.Data.LibraryLocations);
        }
        /// <summary>
        /// Returns a zipfile containing the text of all of licenses for a given product.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns a zipfile containing the text of all of licenses for a given product.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public async Task <byte[]> GetLicensesTextZipAsync(ProductToken productToken)
        {
            var request  = new BaseRequest("getLicensesTextZip", UserKey, productToken: productToken);
            var response = await request.MakeRequestAsync(this);

            return(response);
        }
Beispiel #3
0
        /// <summary>
        /// Returns a dictionary of licenses and counts for a given product.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns a dictionary of licenses and counts for a given product.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public Dictionary <string, int> GetProductLicenseHistogram(ProductToken productToken)
        {
            var request  = new BaseRequest("getProductLicenseHistogram", UserKey, productToken: productToken);
            var response = request.MakeRequest <LicensesHistogramResponse>(this);

            return(response.Data.LicenseHistogram);
        }
        /// <summary>
        /// Get basic information regarding all projects for a specific product: name, token, creation date and last updated date.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns the vitals within the organization for all products.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public async Task <List <Vitals> > GetProductProjectVitalsAsync(ProductToken productToken)
        {
            var request  = new BaseRequest("getProductProjectVitals", UserKey, productToken: productToken);
            var response = await request.MakeRequestAsync <ProjectVitalsResponse>(this);

            return(response.Data.ProjectVitals);
        }
Beispiel #5
0
        /// <summary>
        /// Returns a list of alerts for a given product.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns a list of alerts for the given product token.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public List <Alert> GetProductAlerts(ProductToken productToken)
        {
            var request  = new BaseRequest("getProductAlerts", UserKey, productToken: productToken);
            var response = request.MakeRequest <AlertsResponse>(this);

            return(response.Data.Alerts);
        }
        /// <summary>Returns a list of alerts for a given product with the specified type.</summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <param name="alertType">The alert type to use to filter the alerts.</param>
        /// <param name="fromDate">An optional parameter that filters alerts after this date.</param>
        /// <param name="toDate">An optional parameter that filters alerts before this date.</param>
        /// <returns>Returns a list of alerts for the given product token.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public async Task <List <Alert> > GetProductAlertsByTypeAsync(ProductToken productToken, string alertType, DateTime?fromDate = null, DateTime?toDate = null)
        {
            var request  = new AlertTypeRequest("getProductAlertsByType", UserKey, productToken: productToken, alertType: alertType, fromDate: fromDate, toDate: toDate);
            var response = await request.MakeRequestAsync <AlertsResponse>(this);

            return(response.Data.Alerts);
        }
Beispiel #7
0
        /// <summary>
        /// Returns a zipfile containing the text of all of licenses for a given product.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns a zipfile containing the text of all of licenses for a given product.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public byte[] GetLicensesTextZip(ProductToken productToken)
        {
            var request  = new BaseRequest("getLicensesTextZip", UserKey, productToken: productToken);
            var response = request.MakeRequest(this);

            return(response);
        }
Beispiel #8
0
        /// <summary>
        /// Returns a list of library locations for a given product.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns a list of library locations for the given product token.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public List <LibraryLocation> GetProductLibraryLocations(ProductToken productToken)
        {
            var request  = new BaseRequest("getProductLibraryLocations", UserKey, productToken: productToken);
            var response = request.MakeRequest <LibraryLocationsResponse>(this);

            return(response.Data.LibraryLocations);
        }
Beispiel #9
0
        /// <summary>
        /// Get basic information regarding all projects for a specific product: name, token, creation date and last updated date.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns the vitals within the organization for all products.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public List <Vitals> GetProductProjectVitals(ProductToken productToken)
        {
            var request  = new BaseRequest("getProductProjectVitals", UserKey, productToken: productToken);
            var response = request.MakeRequest <ProjectVitalsResponse>(this);

            return(response.Data.ProjectVitals);
        }
        /// <summary>
        /// Returns a list of alerts for a given product.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns a list of alerts for the given product token.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public async Task <List <Alert> > GetProductAlertsAsync(ProductToken productToken)
        {
            var request  = new BaseRequest("getProductAlerts", UserKey, productToken: productToken);
            var response = await request.MakeRequestAsync <AlertsResponse>(this);

            return(response.Data.Alerts);
        }
Beispiel #11
0
 public BaseRequest(
     string requestType,
     string userKey,
     OrgToken orgToken         = null,
     ProductToken productToken = null,
     ProjectToken projectToken = null)
 {
     RequestType  = requestType ?? throw new ArgumentNullException(nameof(requestType));
     UserKey      = userKey;
     OrgToken     = orgToken;
     ProductToken = productToken;
     ProjectToken = projectToken;
 }
        public ServiceIntegrationTests()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile("appsettings.test.json", optional: true, reloadOnChange: true);
            var configuration = builder.Build();

            OrgToken     = new OrgToken(configuration.GetSection("whitesource:orgToken").Value);
            ProductToken = new ProductToken(configuration.GetSection("whitesource:productToken").Value);
            ProjectToken = new ProjectToken(configuration.GetSection("whitesource:projectToken").Value);
            LibraryUuid  = configuration.GetSection("whitesource:libraryUuid").Value;
            service      = new WhitesourceService(configuration.GetSection("whitesource:userKey").Value, configuration.GetSection("whitesource:url").Value);
        }
Beispiel #13
0
 public void SaveProduct(ProductToken token)
 {
     if (string.IsNullOrWhiteSpace(token.id))
     {
         var product = token.AsProduct();
         product.images = new string[6];
         product.likes  = new string[0];
         _productRepository.Create(product);
         token.id = product.id;
     }
     else
     {
         _productRepository.Save(token.AsProduct());
     }
 }
 public AlertTypeRequest(
     string requestType,
     string userKey,
     OrgToken orgToken         = null,
     ProductToken productToken = null,
     ProjectToken projectToken = null,
     string alertType          = null,
     DateTime?fromDate         = null,
     DateTime?toDate           = null)
     : base(requestType, userKey, orgToken, productToken, projectToken)
 {
     AlertType = alertType;
     FromDate  = fromDate;
     ToDate    = toDate;
 }
Beispiel #15
0
        public IHttpActionResult Save(ProductToken product)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _sellerService.SaveProduct(product);
                    return(Ok(product));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError(string.Empty, ex.Message);
                    return(BadRequest(ModelState));
                }
            }

            return(BadRequest(ModelState));
        }
        /// <summary>
        /// Returns a dictionary of licenses and counts for a given product.
        /// </summary>
        /// <param name="productToken">The Whitesource product token for the target product.</param>
        /// <returns>Returns a dictionary of licenses and counts for a given product.</returns>
        /// <exception cref="WhitesourceRequestException">Thrown if an exception occurs calling Whitesource service.</exception>
        public async Task <Dictionary <string, int> > GetProductLicenseHistogramAsync(ProductToken productToken)
        {
            var request  = new BaseRequest("getProductLicenseHistogram", UserKey, productToken: productToken);
            var response = await request.MakeRequestAsync <LicensesHistogramResponse>(this);

            return(response.Data.LicenseHistogram);
        }
Beispiel #17
0
        public IHttpActionResult GetProducts(ProductToken token)
        {
            _productService.SaveProduct(token);

            return(Ok(token));
        }
Beispiel #18
0
 public void SaveProduct(ProductToken product)
 {
     _productRepository.Save(product.AsProduct());
 }