PTI.Microservices.Library 1.0.0.7

Cloud Services library designed to be consumed in Microservices

There is a newer prerelease version of this package available.
See the version list below for details.
Install-Package PTI.Microservices.Library -Version 1.0.0.7
dotnet add package PTI.Microservices.Library --version 1.0.0.7
<PackageReference Include="PTI.Microservices.Library" Version="1.0.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PTI.Microservices.Library --version 1.0.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PTI.Microservices.Library, 1.0.0.7"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install PTI.Microservices.Library as a Cake Addin
#addin nuget:?package=PTI.Microservices.Library&version=1.0.0.7

// Install PTI.Microservices.Library as a Cake Tool
#tool nuget:?package=PTI.Microservices.Library&version=1.0.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

PTI.Microservices.Library

Documentation for our NuGet Package "PTI.Microservices.Library"

The purpose of this package is to help developers create solutions faster by integrating several Cloud Services in one package,
and enforcing Logging and Exception Handling, while still allowing the developers to have the control over the configuration.
The package is designed to be consumed from microservices, so most items are async and do as little as possible, unless you configure it to do more, for example, in the case of Twitter Services, they support retry configuration, and have out of the box support for waiting for Twitter API Rate Limit, thanks for the great work done by Joe Mayo (https://github.com/JoeMayo) with his LinqToTwitter library.
The TwitterFakeFollowersService currently supports communicating back to the consumer by using Action delegates, and the future version of it will support using SignalR.
"PTI.Microservices.Library" is currently running under .NET Core 3.1.

The library is designed so that you can use your own Azure Resources, by setting your own configuration.

You can download the package at:
https://www.nuget.org/packages/PTI.Microservices.Library/

How To Use The Package

  1. Set your RapidApiKey.
  2. Register Services (or manually create services instances)

About the Configuration Classes

The services configuration classes have an endpoint property, in the case of Azure services, those will usually be the Url for your created resource in Azure, or the base azure service api.
In the case of the specialized services such as Customer Finder, Emotions Analyzer, Books Translation and similar, the property is prefilled with the Rapid API base service, if you use appSettings-based configuration the default value will be overwritten to respect developer-based configuration, this means you will need to set the correct service Url when using appSettings-based configuration.

Quick Samples

Setting your key

//The given key is for demo purposes and will stop working eventually. 
//To get your own key request it by writing to services@pticostarica.com
GlobalPackageConfiguration.RapidApiKey = "a3893edcbfmsh2efa1861dcc7a10p159864jsnf17e667d1bf7";

Register your services

services.AddSingleton(twitterConfiguration);
services.AddLogging();
services.AddTransient<ILogger, Logger<TwitterPossibleFakeAccount>>();
services.AddTransient<CustomHttpClientHandler>();
services.AddTransient<CustomHttpClient>();
services.AddTransient<TwitterService>();
services.AddTransient<TwitterPossibleFakeAccountService>();

Sample 1 - Upload Images with tags to Azure Custom Vision

[HttpPost("[action]")]
    public async Task<IActionResult> UploadImages([FromBody]UploadImagesModel model)
    {
        Guid projectId = Guid.Parse(model.ProjectId);
        List<Uri> lstImages = model.Items.Where(p=>p.IsSelected==true).Select(p => new Uri(p.ImageUrl)).ToList();
        var uploadImagesResult = await AzureCustomVisionService.UploadImagesAsync(lstImages, projectId);
        List<string> tags = new List<string>() { model.Tag };
        foreach (var singleImage in uploadImagesResult)
        {
            try
            {
                await this.AzureCustomVisionService.CreateImageTagsAsync(projectId,
                    singleImage.Image.Id,
                    tags);
                await Task.Delay(TimeSpan.FromSeconds(1));
            }
            catch (Exception ex)
            {
                this.Logger.LogError(ex, ex.Message);
            }
        }
        return Ok();
    }
    

Sample 2 - Detect Possible Twitter Fake Followers

await twitterFakeFollowersService.GetAllPossibleFakeFollowersForUsernameAsync(this.TwitterConfiguration.ScreenName,
            (possibleFakeUser) =>
            {
               //Your custom logic to execute when a new possible twitter fake user has been detected
            }, cancellationToken: cancellationTokenSource.Token);

Sample 3 - Detect current weather and hear it on Default Speakers

AudibleWeatherService audibleWeatherService = new AudibleWeatherService(logger, azureMapsService, azureSpeechService);
await audibleWeatherService.SpeakCurrentWeatherAsync(geoCoordinates);

Sample 4 - Translate a DOCX file to anothere language

var result = await booksTranslationService.TranslateDocXFileFromUrlAsync(fileUrl, TranslationLanguage.English, TranslationLanguage.Spanish,
BookTranslationMode.KeepFormatting, emailAddress:"youremail@yourdomain.xyz");

Sample 5 - Get All Keywords Found in an Azure Media Services Video Indexer Account

var allKeywords = await azureVideoIndexerService.GetAllKeywordsAsync(onNewKeywordFound:(keyword)=> 
{
   //Your custom code to execute when a keyword has been processed.Added so that you do not have to wait for the whole process to finish
});

Sample 6 - Detects Sentiment and Personality information based on text in a spreadsheet

var result =
    await emotionsAnalyzerService.AnalyzeFileFromUrlAsync(fileUrl,
    model: new Microservices.Library.Models.EmotionsAnalyzer.AnalyzeFileModel()
    {
        SourceFileUrl=fileUrl,
        EmailForResults="youremail@yourdomain.xyz",
        AnalysisWorksheet = 
            new Microservices.Library.Models.EmotionsAnalyzer.AnalysisWorksheet()
            {
               ColumnToAnalyze="PostText",
               ColumnWithDate="RecordDate",
               ColumnWithUniqueId="RecordUniqueId",
               SentimentPlaceholderColumn="SentimentAnalysisPlaceHolder",
               WorksheetName="FacebookPosts"
            },
            PlaceWorksheet=new Microservices.Library.Models.EmotionsAnalyzer.PlaceWorksheet()
            {
               SentimentPlaceholderColumn="PlaceSentimentPlaceHolder",
               WorksheetName="PlaceSentiment"
            }
    });

Sample 7 - Detect the topics found in a specified Twitter Username

TwitterDataAnalysisService twitterDataAnalysisService = new TwitterDataAnalysisService(
logger, twitterService, azureTextAnalyticsService);
var twitterUserTopics = await twitterDataAnalysisService.GetTopicsForUserAsync("twitterusername");

More samples at https://github.com/efonsecab/PTI.Microservices.Library/blob/master/README.md

The following are sample applications of things you could do with the package

For inquiries, and business deals, you can write an email to services@pticostarica.com

Roadmap

  • October 2020

    • Integrate Custom Finder APIs into the package. You can check our public APIs here:https://rapidapi.com/organization/pti-costa-rica
  • November 2020

    • Add Support for Azure Cognitive Search
    • Integrate PTI Emotions Analyzer APIs into the package.
  • December 2020

    • Add support for gRPC
    • Integrate PTI Books Translator APIs into the package
    • Enable package monthly payment using Paypal-based subscriptions.
  • January 2021

    • Create a .NET 5 based version of the package
    • Add support for SignalR to TwitterFakeFollowersService (only for .NET 5)
    • Integrate PTI's SitemapScanner into the main package (.NET 3.1 version)

    Feature Requests

    If there is any functionality you would like to see included in the package, write an email with the subject "Feature Request" to services@pticostarica.com

PTI.Microservices.Library

Documentation for our NuGet Package "PTI.Microservices.Library"

The purpose of this package is to help developers create solutions faster by integrating several Cloud Services in one package,
and enforcing Logging and Exception Handling, while still allowing the developers to have the control over the configuration.
The package is designed to be consumed from microservices, so most items are async and do as little as possible, unless you configure it to do more, for example, in the case of Twitter Services, they support retry configuration, and have out of the box support for waiting for Twitter API Rate Limit, thanks for the great work done by Joe Mayo (https://github.com/JoeMayo) with his LinqToTwitter library.
The TwitterFakeFollowersService currently supports communicating back to the consumer by using Action delegates, and the future version of it will support using SignalR.
"PTI.Microservices.Library" is currently running under .NET Core 3.1.

The library is designed so that you can use your own Azure Resources, by setting your own configuration.

You can download the package at:
https://www.nuget.org/packages/PTI.Microservices.Library/

How To Use The Package

  1. Set your RapidApiKey.
  2. Register Services (or manually create services instances)

About the Configuration Classes

The services configuration classes have an endpoint property, in the case of Azure services, those will usually be the Url for your created resource in Azure, or the base azure service api.
In the case of the specialized services such as Customer Finder, Emotions Analyzer, Books Translation and similar, the property is prefilled with the Rapid API base service, if you use appSettings-based configuration the default value will be overwritten to respect developer-based configuration, this means you will need to set the correct service Url when using appSettings-based configuration.

Quick Samples

Setting your key

//The given key is for demo purposes and will stop working eventually. 
//To get your own key request it by writing to services@pticostarica.com
GlobalPackageConfiguration.RapidApiKey = "a3893edcbfmsh2efa1861dcc7a10p159864jsnf17e667d1bf7";

Register your services

services.AddSingleton(twitterConfiguration);
services.AddLogging();
services.AddTransient<ILogger, Logger<TwitterPossibleFakeAccount>>();
services.AddTransient<CustomHttpClientHandler>();
services.AddTransient<CustomHttpClient>();
services.AddTransient<TwitterService>();
services.AddTransient<TwitterPossibleFakeAccountService>();

Sample 1 - Upload Images with tags to Azure Custom Vision

[HttpPost("[action]")]
    public async Task<IActionResult> UploadImages([FromBody]UploadImagesModel model)
    {
        Guid projectId = Guid.Parse(model.ProjectId);
        List<Uri> lstImages = model.Items.Where(p=>p.IsSelected==true).Select(p => new Uri(p.ImageUrl)).ToList();
        var uploadImagesResult = await AzureCustomVisionService.UploadImagesAsync(lstImages, projectId);
        List<string> tags = new List<string>() { model.Tag };
        foreach (var singleImage in uploadImagesResult)
        {
            try
            {
                await this.AzureCustomVisionService.CreateImageTagsAsync(projectId,
                    singleImage.Image.Id,
                    tags);
                await Task.Delay(TimeSpan.FromSeconds(1));
            }
            catch (Exception ex)
            {
                this.Logger.LogError(ex, ex.Message);
            }
        }
        return Ok();
    }
    

Sample 2 - Detect Possible Twitter Fake Followers

await twitterFakeFollowersService.GetAllPossibleFakeFollowersForUsernameAsync(this.TwitterConfiguration.ScreenName,
            (possibleFakeUser) =>
            {
               //Your custom logic to execute when a new possible twitter fake user has been detected
            }, cancellationToken: cancellationTokenSource.Token);

Sample 3 - Detect current weather and hear it on Default Speakers

AudibleWeatherService audibleWeatherService = new AudibleWeatherService(logger, azureMapsService, azureSpeechService);
await audibleWeatherService.SpeakCurrentWeatherAsync(geoCoordinates);

Sample 4 - Translate a DOCX file to anothere language

var result = await booksTranslationService.TranslateDocXFileFromUrlAsync(fileUrl, TranslationLanguage.English, TranslationLanguage.Spanish,
BookTranslationMode.KeepFormatting, emailAddress:"youremail@yourdomain.xyz");

Sample 5 - Get All Keywords Found in an Azure Media Services Video Indexer Account

var allKeywords = await azureVideoIndexerService.GetAllKeywordsAsync(onNewKeywordFound:(keyword)=> 
{
   //Your custom code to execute when a keyword has been processed.Added so that you do not have to wait for the whole process to finish
});

Sample 6 - Detects Sentiment and Personality information based on text in a spreadsheet

var result =
    await emotionsAnalyzerService.AnalyzeFileFromUrlAsync(fileUrl,
    model: new Microservices.Library.Models.EmotionsAnalyzer.AnalyzeFileModel()
    {
        SourceFileUrl=fileUrl,
        EmailForResults="youremail@yourdomain.xyz",
        AnalysisWorksheet = 
            new Microservices.Library.Models.EmotionsAnalyzer.AnalysisWorksheet()
            {
               ColumnToAnalyze="PostText",
               ColumnWithDate="RecordDate",
               ColumnWithUniqueId="RecordUniqueId",
               SentimentPlaceholderColumn="SentimentAnalysisPlaceHolder",
               WorksheetName="FacebookPosts"
            },
            PlaceWorksheet=new Microservices.Library.Models.EmotionsAnalyzer.PlaceWorksheet()
            {
               SentimentPlaceholderColumn="PlaceSentimentPlaceHolder",
               WorksheetName="PlaceSentiment"
            }
    });

Sample 7 - Detect the topics found in a specified Twitter Username

TwitterDataAnalysisService twitterDataAnalysisService = new TwitterDataAnalysisService(
logger, twitterService, azureTextAnalyticsService);
var twitterUserTopics = await twitterDataAnalysisService.GetTopicsForUserAsync("twitterusername");

More samples at https://github.com/efonsecab/PTI.Microservices.Library/blob/master/README.md

The following are sample applications of things you could do with the package

For inquiries, and business deals, you can write an email to services@pticostarica.com

Roadmap

  • October 2020

    • Integrate Custom Finder APIs into the package. You can check our public APIs here:https://rapidapi.com/organization/pti-costa-rica
  • November 2020

    • Add Support for Azure Cognitive Search
    • Integrate PTI Emotions Analyzer APIs into the package.
  • December 2020

    • Add support for gRPC
    • Integrate PTI Books Translator APIs into the package
    • Enable package monthly payment using Paypal-based subscriptions.
  • January 2021

    • Create a .NET 5 based version of the package
    • Add support for SignalR to TwitterFakeFollowersService (only for .NET 5)
    • Integrate PTI's SitemapScanner into the main package (.NET 3.1 version)

    Feature Requests

    If there is any functionality you would like to see included in the package, write an email with the subject "Feature Request" to services@pticostarica.com

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.3.9-preview 57 4/29/2021
1.0.3.8-preview 59 4/28/2021
1.0.3.7-preview 37 4/28/2021
1.0.3.6-preview 70 4/26/2021
1.0.3.5-preview 39 4/8/2021
1.0.3.4-preview 46 4/5/2021
1.0.3.3-preview 43 3/30/2021
1.0.3.2-preview 63 3/7/2021
1.0.3.1-preview 116 3/6/2021
1.0.3-preview 83 3/6/2021
1.0.1.3-preview 50 2/22/2021
1.0.1.2-preview 55 2/17/2021
1.0.1.1-preview 44 2/16/2021
1.0.1-preview 54 2/15/2021
1.0.0.7 67 1/27/2021
1.0.0.6 82 1/9/2021
1.0.0.5 156 11/20/2020
1.0.0.4 139 10/21/2020
1.0.0.3 126 10/19/2020
1.0.0.2 107 10/19/2020
1.0.0.1 113 9/26/2020
1.0.0 133 9/25/2020
0.0.5.11-preview 112 9/25/2020
0.0.5.10-preview 115 9/24/2020
0.0.5.9-preview 142 9/23/2020
0.0.5.8-preview 225 9/23/2020
0.0.5.7-preview 221 9/22/2020
0.0.5.6-preview 159 9/22/2020
0.0.5.5-preview 198 9/20/2020
0.0.5.4-preview 292 9/19/2020
0.0.5.3-preview 155 9/19/2020
0.0.5.2-preview 194 9/19/2020
0.0.5.1-preview 104 9/19/2020
0.0.5-preview 120 9/19/2020
0.0.4-preview 112 9/18/2020
0.0.3-preview 108 9/17/2020
0.0.2-preview 156 9/16/2020
0.0.1-preview 204 9/13/2020
Show less