Skip to content

Commit

Permalink
Merge pull request #32 from sovren/feature/10.2.0-updates
Browse files Browse the repository at this point in the history
v10.2.0 updates
  • Loading branch information
sovren-jwesson authored Jul 28, 2021
2 parents 746d1fb + 6d9aa6f commit 5078b76
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/Parsing/Basic Parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static async Task Main(string[] args)
}
catch (SovrenException e)
{
//this was an outright failure, always try/catch for SovrenExceptions when using SovrenClient
//the document could not be parsed, always try/catch for SovrenExceptions when using SovrenClient
Console.WriteLine($"Error: {e.SovrenErrorCode}, Message: {e.Message}");
}

Expand Down
2 changes: 1 addition & 1 deletion examples/Parsing/Parsing with Geocoding and Indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static async Task Main(string[] args)
}
catch (SovrenException e)
{
//this was an outright failure, always try/catch for SovrenExceptions when using SovrenClient
//the document could not be parsed, always try/catch for SovrenExceptions when using SovrenClient
Console.WriteLine($"Error: {e.SovrenErrorCode}, Message: {e.Message}");
}

Expand Down
8 changes: 5 additions & 3 deletions src/Sovren.SDK.Tests/IntegrationTests/ParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,10 @@ public async Task TestResumeQuality()
Assert.That(response.ResumeData.ResumeMetadata.ResumeQuality[0].Findings, Has.Count.AtLeast(1));
Assert.IsNotNull(response.ResumeData.ResumeMetadata.ResumeQuality[0].Findings[0].Message);
Assert.IsNotNull(response.ResumeData.ResumeMetadata.ResumeQuality[0].Findings[0].QualityCode);
Assert.AreEqual("227", response.ResumeData.ResumeMetadata.ResumeQuality[0].Findings[0].QualityCode);
Assert.IsNotNull(response.ResumeData.ResumeMetadata.ResumeQuality[0].Findings[3].SectionIdentifiers);
Assert.That(response.ResumeData.ResumeMetadata.ResumeQuality[0].Findings[3].SectionIdentifiers, Has.Count.AtLeast(1));
//do not test these since they are subject to change somewhat frequently
//Assert.AreEqual("111", response.ResumeData.ResumeMetadata.ResumeQuality[0].Findings[0].QualityCode);
//Assert.IsNotNull(response.ResumeData.ResumeMetadata.ResumeQuality[0].Findings[3].SectionIdentifiers);
//Assert.That(response.ResumeData.ResumeMetadata.ResumeQuality[0].Findings[3].SectionIdentifiers, Has.Count.AtLeast(1));

await Task.CompletedTask;
}
Expand Down Expand Up @@ -426,6 +427,7 @@ public async Task TestGeneralOutput()
Assert.IsNotNull(response.Value);

Assert.IsNotNull(response.Value.ConversionMetadata);
Assert.AreEqual(response.Value.ConversionMetadata.DocumentHash, "96E36138DAFB03B057D1607B86C452FE");
//Assert.IsNotNull(response.Value.Conversions);
Assert.IsNotNull(response.Value.ParsingMetadata);
Assert.IsNotNull(response.Value.ResumeData);
Expand Down
5 changes: 5 additions & 0 deletions src/Sovren.SDK/Models/API/Parsing/ConversionMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,10 @@ public class ConversionMetadata
/// This is a subset of <see cref="ApiResponseInfo.TotalElapsedMilliseconds"/>
/// </summary>
public int ElapsedMilliseconds { get; set; }

/// <summary>
/// The MD5 hash of the document bytes
/// </summary>
public string DocumentHash { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Sovren.SDK/Sovren.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Copyright>Copyright © 2021 Sovren Group, Inc. All rights reserved.</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/sovren/sovren-dotnet</PackageProjectUrl>
<Version>1.1.2</Version>
<Version>1.2.0</Version>
<PackageIcon>images\icon.png</PackageIcon>
<PackageIconUrl>https://raw.githubusercontent.com/sovren/sovren-dotnet/master/src/Sovren.SDK/icon.png</PackageIconUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
Expand Down
14 changes: 13 additions & 1 deletion src/Sovren.SDK/SovrenClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public sealed class SovrenClient
/// <param name="accountId">The account id for your account</param>
/// <param name="serviceKey">The service key for your account</param>
/// <param name="dataCenter">The Data Center for your account. Either <see cref="DataCenter.US"/> or <see cref="DataCenter.EU"/></param>
public SovrenClient(string accountId, string serviceKey, DataCenter dataCenter)
/// <param name="trackingTags">Optional tags to use to track API usage for your account</param>
public SovrenClient(string accountId, string serviceKey, DataCenter dataCenter, params string[] trackingTags)
{
if (string.IsNullOrEmpty(accountId))
throw new ArgumentNullException(nameof(accountId));
Expand All @@ -62,6 +63,17 @@ public SovrenClient(string accountId, string serviceKey, DataCenter dataCenter)
_httpClient = new RestClient(dataCenter.Root);
_httpClient.Headers.Add("Sovren-AccountId", accountId);
_httpClient.Headers.Add("Sovren-ServiceKey", serviceKey);

if (trackingTags != null && trackingTags.Length > 0)
{
string tagsHeaderValue = string.Join(", ", trackingTags);
if (tagsHeaderValue.Length >= 75)//API allows 100, but just to be safe, this should be way more than enough
{
throw new ArgumentException("Too many values or values are too long", nameof(trackingTags));
}

_httpClient.Headers.Add("Sovren-TrackingTag", tagsHeaderValue);
}
}

private void ProcessResponse<T>(RestResponse<T> response, string requestBody) where T : ISovrenResponse
Expand Down

0 comments on commit 5078b76

Please sign in to comment.