Moesif.Middleware
1.3.14
See the version list below for details.
dotnet add package Moesif.Middleware --version 1.3.14
NuGet\Install-Package Moesif.Middleware -Version 1.3.14
<PackageReference Include="Moesif.Middleware" Version="1.3.14" />
paket add Moesif.Middleware --version 1.3.14
#r "nuget: Moesif.Middleware, 1.3.14"
// Install Moesif.Middleware as a Cake Addin #addin nuget:?package=Moesif.Middleware&version=1.3.14 // Install Moesif.Middleware as a Cake Tool #tool nuget:?package=Moesif.Middleware&version=1.3.14
MoesifApi Lib for C#
Check out Moesif's Developer Documentation and C# API Reference to learn more
How to Install:
Install the Nuget Package:
Install-Package Moesif.Api
How to Use:
Your Moesif Application Id can be found in the Moesif Portal. After signing up for a Moesif account, your Moesif Application Id will be displayed during the onboarding steps.
You can always find your Moesif Application Id at any time by logging into the Moesif Portal, click on the top right menu, and then clicking Installation.
Create Event
using System;
using System.Collections.Generic;
using Moesif.Api;
using Moesif.Api.Models;
using Moesif.Api.Exceptions;
using Moesif.Api.Controllers;
using System.Threading.Tasks;
// Create client instance using your ApplicationId
var client = new MoesifApiClient("My Application Id");
var apiClient = client.Api;
// Parameters for the API call
var reqHeaders = new Dictionary<string, string>();
reqHeaders.Add("Host", "api.acmeinc.com");
reqHeaders.Add("Accept", "*/*");
reqHeaders.Add("Connection", "Keep-Alive");
reqHeaders.Add("User-Agent", "Dalvik/2.1.0 (Linux; U; Android 5.0.2; C6906 Build/14.5.A.0.242)");
reqHeaders.Add("Content-Type", "application/json");
reqHeaders.Add("Content-Length", "126");
reqHeaders.Add("Accept-Encoding", "gzip");
var reqBody = ApiHelper.JsonDeserialize<object>(@" {
""items"": [
{
""type"": 1,
""id"": ""fwfrf""
},
{
""type"": 2,
""id"": ""d43d3f""
}
]
}");
var rspHeaders = new Dictionary<string, string>();
rspHeaders.Add("Date", "Tue, 23 Nov 2019 23:46:49 GMT");
rspHeaders.Add("Vary", "Accept-Encoding");
rspHeaders.Add("Pragma", "no-cache");
rspHeaders.Add("Expires", "-1");
rspHeaders.Add("Content-Type", "application/json; charset=utf-8");
rspHeaders.Add("Cache-Control", "no-cache");
var rspBody = ApiHelper.JsonDeserialize<object>(@" {
""Title"": ""Hello"",
""Message"": ""Hello World""
}");
var eventReq = new EventRequestModel()
{
Time = DateTime.Now.AddSeconds(-1),
Uri = "https://api.acmeinc.com/items/reviews/",
Verb = "PATCH",
ApiVersion = "1.1.0",
IpAddress = "61.48.220.123",
Headers = reqHeaders,
Body = reqBody
};
var eventRsp = new EventResponseModel()
{
Time = DateTime.Now,
Status = 500,
Headers = rspHeaders,
Body = rspBody
};
Dictionary<string, string> metadata = new Dictionary<string, string>
{
{ "id", "123456789" },
{ "datacenter", "West US" },
{ "image", "123" }
};
var eventModel = new EventModel()
{
Request = eventReq,
Response = eventRsp,
UserId = "12345",
CompanyId = "67890",
SessionToken = "23jdf0owekfmcn4u3qypxg09w4d8ayrcdx8nu2ng]s98y18cx98q3yhwmnhcfx43f",
Metadata = metadata
};
// Perform API call
try
{
await apiClient.CreateEventAsync(eventModel);
}
catch(APIException) {};
Update a Single User
Create or update a user profile in Moesif.
The metadata field can be any customer demographic or other info you want to store.
Only the UserId
field is required.
For details, visit the C# API Reference.
var apiClient = new MoesifApiClient("YOUR_COLLECTOR_APPLICATION_ID").Api;;
// Campaign object is optional, but useful if you want to track ROI of acquisition channels
// See https://www.moesif.com/docs/api#users for campaign schema
var campaign = new CampaignModel()
{
UtmSource = "google",
UtmMedium = "cpc"
UtmCampaign = "adwords"
UtmTerm = "api+tooling"
UtmContent = "landing"
};
// metadata can be any custom dictionary
var metadata = new Dictionary<string, object>
{
{"email", "john@acmeinc.com"},
{"first_name", "John"},
{"last_name", "Doe"},
{"title", "Software Engineer"},
{"sales_info", new Dictionary<string, string> {
{"stage", "Customer"},
{"lifetime_value", 24000},
{"account_owner", "mary@contoso.com"}
}
};
// Only user_id is required
var user = new UserModel()
{
UserId = "12345",
CompanyId = "67890",
Campaign = campaign,
Metadata = metadata
};
// Update the user asynchronously
await apiClient.UpdateUserAsync(user);
// Update the user synchronously
apiClient.UpdateUser(user);
Update Users in Batch
Similar to UpdateUser, but used to update a list of users in one batch.
Only the UserId
field is required.
For details, visit the C# API Reference.
var apiClient = new MoesifApiClient("YOUR_COLLECTOR_APPLICATION_ID").Api;;
var users = new List<UserModel>();
var metadataA = new Dictionary<string, object>
{
{"email", "john@acmeinc.com"},
{"first_name", "John"},
{"last_name", "Doe"},
{"title", "Software Engineer"},
{"sales_info", new Dictionary<string, string> {
{"stage", "Customer"},
{"lifetime_value", 24000},
{"account_owner", "mary@contoso.com"}
}
};
// Only user_id is required
var userA = new UserModel()
{
UserId = "12345",
CompanyId = "67890", // If set, associate user with a company object
Metadata = metadataA
};
var metadataB = new Dictionary<string, object>
{
{"email", "mary@acmeinc.com"},
{"first_name", "Mary"},
{"last_name", "Jane"},
{"title", "Software Engineer"},
{"sales_info", new Dictionary<string, string> {
{"stage", "Customer"},
{"lifetime_value", 24000},
{"account_owner", "mary@contoso.com"}
}
};
// Only user_id is required
var userB = new UserModel()
{
UserId = "54321",
CompanyId = "67890",
Metadata = metadataA
};
users.Add(userA);
users.Add(userB);
// Update the users asynchronously
await apiClient.UpdateUsersBatchAsync(users);
// Update the users synchronously
apiClient.UpdateUsersBatch(users);
Update a Single Company
Create or update a company profile in Moesif.
The metadata field can be any company demographic or other info you want to store.
Only the CompanyId
field is required.
For details, visit the C# API Reference.
var apiClient = new MoesifApiClient("YOUR_COLLECTOR_APPLICATION_ID").Api;;
// Campaign object is optional, but useful if you want to track ROI of acquisition channels
// See https://www.moesif.com/docs/api#companies for campaign schema
var campaign = new CampaignModel()
{
UtmSource = "google",
UtmMedium = "cpc"
UtmCampaign = "adwords"
UtmTerm = "api+tooling"
UtmContent = "landing"
};
// metadata can be any custom dictionary
var metadata = new Dictionary<string, object>
{
{"org_name", "Acme, Inc"},
{"plan_name", "Free"},
{"deal_stage", "Lead"},
{"mrr", 24000},
{"demographics", new Dictionary<string, string> {
{"alexa_ranking", 500000},
{"employee_count", 47}
}
};
// Only company id is required
var company = new CompanyModel()
{
CompanyId = "67890",
CompanyDomain = "acmeinc.com", // If domain is set, Moesif will enrich your profiles with publicly available info
Campaign = campaign,
Metadata = metadata
};
// Update the company asynchronously
await apiClient.UpdateCompanyAsync(company);
// Update the company synchronously
apiClient.UpdateCompany(company);
Update Companies in Batch
Similar to updateCompany, but used to update a list of companies in one batch.
Only the CompanyId
field is required.
For details, visit the C# API Reference.
var apiClient = new MoesifApiClient("YOUR_COLLECTOR_APPLICATION_ID").Api;;
var companies = new List<CompanyModel>();
// Campaign object is optional, but useful if you want to track ROI of acquisition channels
// See https://www.moesif.com/docs/api#companies for campaign schema
var campaignA = new CampaignModel()
{
UtmSource = "google",
UtmMedium = "cpc"
UtmCampaign = "adwords"
UtmTerm = "api+tooling"
UtmContent = "landing"
};
// metadata can be any custom dictionary
var metadataA = new Dictionary<string, object>
{
{"org_name", "Acme, Inc"},
{"plan_name", "Free"},
{"deal_stage", "Lead"},
{"mrr", 24000},
{"demographics", new Dictionary<string, string> {
{"alexa_ranking", 500000},
{"employee_count", 47}
}
};
// Only company id is required
var companyA = new CompanyModel()
{
CompanyId = "67890",
CompanyDomain = "acmeinc.com", // If domain is set, Moesif will enrich your profiles with publicly available info
Campaign = campaign,
Metadata = metadata
};
// metadata can be any custom dictionary
var metadataB = new Dictionary<string, object>
{
{"org_name", "Contoso, Inc"},
{"plan_name", "Paid"},
{"deal_stage", "Lead"},
{"mrr", 48000},
{"demographics", new Dictionary<string, string> {
{"alexa_ranking", 500000},
{"employee_count", 53}
}
};
// Only company id is required
var companyB = new CompanyModel()
{
CompanyId = "09876",
CompanyDomain = "contoso.com", // If domain is set, Moesif will enrich your profiles with publicly available info
Campaign = campaign,
Metadata = metadata
};
companies.Add(companyA);
companies.Add(companyB);
// Update the companies asynchronously
await apiClient.UpdateCompaniesBatchAsync(companies);
// Update the companies synchronously
apiClient.UpdateCompaniesBatch(companies);
How To Test:
The SDK also contain tests, which are contained in the Moesif.Api.Tests project. In order to invoke these test cases, you will need NUnit 3.0 Test Adapter Extension for Visual Studio. Once the SDK is complied, the test cases should appear in the Test Explorer window. Here, you can click Run All to execute these test cases.
Compatibility:
The build process generates a portable class library, which can be used like a normal class library. The generated library is compatible with Windows Forms, Windows RT, Windows Phone 8, Silverlight 5, Xamarin iOS, Xamarin Android and Mono. More information on how to use can be found at the following link.
http://msdn.microsoft.com/en-us/library/vstudio/gg597391(v=vs.100).aspx
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- Microsoft.Owin (>= 3.1.0)
- Moesif.Api (>= 2.0.3)
- Newtonsoft.Json (>= 9.0.1)
- System.IdentityModel.Tokens.Jwt (>= 6.8.0)
- System.ValueTuple (>= 4.5.0)
-
.NETStandard 2.0
- Microsoft.AspNetCore.Http (>= 2.1.0)
- Microsoft.AspNetCore.Http.Extensions (>= 2.1.0)
- Moesif.Api (>= 2.0.3)
- Newtonsoft.Json (>= 9.0.1)
- System.IdentityModel.Tokens.Jwt (>= 6.8.0)
- System.ValueTuple (>= 4.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.1.1 | 52 | 11/22/2024 |
3.1.0 | 53 | 11/21/2024 |
3.0.11 | 81 | 11/15/2024 |
3.0.10 | 82 | 11/13/2024 |
3.0.9 | 90 | 11/12/2024 |
1.5.2 | 73 | 11/15/2024 |
1.5.1 | 90 | 11/8/2024 |
1.5.0 | 74 | 11/8/2024 |
1.4.9 | 255 | 8/30/2024 |
1.4.8 | 873 | 6/6/2024 |
1.4.7 | 267 | 6/4/2024 |
1.4.6 | 107 | 5/29/2024 |
1.4.5 | 140 | 5/23/2024 |
1.4.4 | 108 | 5/21/2024 |
1.4.3 | 2,554 | 11/8/2023 |
1.4.2 | 113 | 11/7/2023 |
1.4.1 | 122 | 11/3/2023 |
1.4.0 | 156 | 10/31/2023 |
1.3.25 | 12,904 | 8/8/2023 |
1.3.24 | 221 | 7/24/2023 |
1.3.23 | 181 | 6/13/2023 |
1.3.22 | 164 | 6/10/2023 |
1.3.21 | 184 | 6/10/2023 |
1.3.20 | 3,736 | 10/6/2022 |
1.3.19 | 404 | 10/5/2022 |
1.3.18 | 412 | 10/5/2022 |
1.3.17 | 487 | 9/13/2022 |
1.3.16 | 453 | 9/7/2022 |
1.3.15 | 449 | 9/1/2022 |
1.3.14 | 419 | 8/30/2022 |
1.3.13 | 2,945 | 4/15/2021 |
1.3.12 | 427 | 4/1/2021 |
1.3.11 | 406 | 3/26/2021 |
1.3.10 | 529 | 3/18/2021 |
1.3.8 | 477 | 3/12/2021 |
1.3.7 | 443 | 2/9/2021 |
1.3.5 | 449 | 2/4/2021 |
1.3.4 | 417 | 2/2/2021 |
1.3.3 | 422 | 1/15/2021 |
1.3.2 | 485 | 1/9/2021 |
1.3.1 | 625 | 6/15/2020 |
1.3.0 | 500 | 6/15/2020 |
1.2.1 | 486 | 6/11/2020 |
1.1.6 | 558 | 6/9/2020 |
1.1.5 | 492 | 6/8/2020 |
1.1.4 | 526 | 6/8/2020 |
1.1.3 | 807 | 1/7/2020 |
1.1.2 | 595 | 12/19/2019 |
1.1.1 | 589 | 12/14/2019 |
1.1.0 | 567 | 11/15/2019 |
1.0.3 | 586 | 10/22/2019 |
1.0.2 | 594 | 8/27/2019 |
1.0.1 | 706 | 8/23/2019 |
0.2.2 | 604 | 6/26/2019 |
0.2.1 | 606 | 6/18/2019 |
0.2.0 | 619 | 5/30/2019 |
0.1.7 | 602 | 3/23/2019 |
0.1.6 | 660 | 3/1/2019 |
0.1.5 | 637 | 2/25/2019 |
0.1.4 | 617 | 2/25/2019 |
0.1.3 | 668 | 2/11/2019 |
0.1.1 | 753 | 11/19/2018 |
0.1.0 | 787 | 11/17/2018 |