Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-9663] Fix missing namespace on some class #15

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,25 @@ Total tests: 42
Passed: 42
Total time: 7.0222 Seconds
```

## Changes

### v4.0.0

- **breaking change**: moved `AutosuggestInputType` and `Request<T>` to `what3words.dotnet.wrapper.request` namespace

### v3.1.1

- fix: revert Refit v6.0.24

### v3.1.0

- feat: validation helper methods

### v3.0.5

- fix: updated Line class visibility

### v3.0.4

- fix: culture variant on coordinates double to URL
82 changes: 42 additions & 40 deletions what3words.dotnet.wrapper/request/AutosuggestInputType.cs
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public enum AutosuggestInputType
namespace what3words.dotnet.wrapper.request
{
/**
* Text typed by a user, e.g.'index.home.raf'. Default setting.
* Expects exactly two dots and no whitespace in the input.
*/
TEXT,
/**
* JSON from Nuance VoConHybrid.
* This should only be used with grammars provided by what3words ltd;
* using other grammars will cause run-time exceptions.
* Language detection is disabled, so lang must be set for non-English input.
*/
VOCON_HYBRID,
/**
* Text from the Nuance server at https://dictation.nuancemobility.net/NMDPAsrCmdServlet/dictation -
* please contact Nuance before attempting to use this server.
* Use with text from any other source is unsupported and results may not be as expected.
* Does not handle text in languages in which words are not separated by spaces, e.g. Chinese.
* Language detection is disabled, so lang must be set for non-English input.
*/
NMDP_ASR,
/**
*
*
* Text output from speech recognition software. E.g. "index home raft".
* This input type handles spaces between words.
* Users should not pronounce 'dot' when speaking a 3 word address.
* Does not handle text in languages in which words are not separated by spaces, e.g. Chinese.
* Language detection is disabled, so lang must be set.
*/
GENERIC_VOICE,
/**
* Text from Speechmatics voice recognition.
* Use with text from any other source is unsupported and results may not be as expected.
* This should only be used with grammars provided by what3words ltd;
* using other grammars will cause run-time exceptions.
* Language detection is disabled, so language must be set.
*/
SPEECHMATICS
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public enum AutosuggestInputType
{
/**
* Text typed by a user, e.g.'index.home.raf'. Default setting.
* Expects exactly two dots and no whitespace in the input.
*/
TEXT,
/**
* JSON from Nuance VoConHybrid.
* This should only be used with grammars provided by what3words ltd;
* using other grammars will cause run-time exceptions.
* Language detection is disabled, so lang must be set for non-English input.
*/
VOCON_HYBRID,
/**
* Text from the Nuance server at https://dictation.nuancemobility.net/NMDPAsrCmdServlet/dictation -
* please contact Nuance before attempting to use this server.
* Use with text from any other source is unsupported and results may not be as expected.
* Does not handle text in languages in which words are not separated by spaces, e.g. Chinese.
* Language detection is disabled, so lang must be set for non-English input.
*/
NMDP_ASR,
/**
* Text output from speech recognition software. E.g. "index home raft".
* This input type handles spaces between words.
* Users should not pronounce 'dot' when speaking a 3 word address.
* Does not handle text in languages in which words are not separated by spaces, e.g. Chinese.
* Language detection is disabled, so lang must be set.
*/
GENERIC_VOICE,
/**
* Text from Speechmatics voice recognition.
* Use with text from any other source is unsupported and results may not be as expected.
* This should only be used with grammars provided by what3words ltd;
* using other grammars will cause run-time exceptions.
* Language detection is disabled, so language must be set.
*/
SPEECHMATICS
}

}
92 changes: 48 additions & 44 deletions what3words.dotnet.wrapper/request/IW3WRequests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,74 @@
using what3words.dotnet.wrapper.response;
using static what3words.dotnet.wrapper.request.ConvertTo3WARequest;

#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public interface IW3WRequests
{

[Get("/convert-to-3wa")]
Task<Address> ConvertTo3WA(ConvertTo3WAOptions options);
namespace what3words.dotnet.wrapper.request
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public interface IW3WRequests
{

[Get("/convert-to-coordinates?words={words}")]
Task<Address> ConvertToCoordinates(string words);
[Get("/convert-to-3wa")]
Task<Address> ConvertTo3WA(ConvertTo3WAOptions options);

[Get("/available-languages")]
Task<AvailableLanguages> AvailableLanguages();
[Get("/convert-to-coordinates?words={words}")]
Task<Address> ConvertToCoordinates(string words);

[Get("/grid-section?bounding-box={boundingBox}")]
Task<GridSection> GridSection(string boundingBox);
[Get("/available-languages")]
Task<AvailableLanguages> AvailableLanguages();

[Get("/autosuggest")]
Task<AutoSuggest> AutoSuggest(string input, AutosuggestOptions options);
[Get("/grid-section?bounding-box={boundingBox}")]
Task<GridSection> GridSection(string boundingBox);

[Get("/autosuggest-with-coordinates")]
Task<AutoSuggestWithCoordinates> AutoSuggestWithCoordinates(string input, AutosuggestOptions options);
[Get("/autosuggest")]
Task<AutoSuggest> AutoSuggest(string input, AutosuggestOptions options);

[Get("/autosuggest-selection?raw-input={rawInput}&selection={selection}&rank={rank}&source-api={sourceApi}")]
Task AutoSuggestSelection(string rawInput, string selection, int? rank, string sourceApi, AutosuggestOptions options);
}
[Get("/autosuggest-with-coordinates")]
Task<AutoSuggestWithCoordinates> AutoSuggestWithCoordinates(string input, AutosuggestOptions options);

public abstract class Request<T>
{
protected abstract Task<T> ApiRequest { get; }
[Get("/autosuggest-selection?raw-input={rawInput}&selection={selection}&rank={rank}&source-api={sourceApi}")]
Task AutoSuggestSelection(string rawInput, string selection, int? rank, string sourceApi, AutosuggestOptions options);
}

/**
* <summary> Request API call asynchronously </summary>
*/
public async Task<APIResponse<T>> RequestAsync()
public abstract class Request<T>
{
try
{
return new APIResponse<T>(await ApiRequest);
}
catch (Refit.ApiException e)
protected abstract Task<T> ApiRequest { get; }

/**
* <summary> Request API call asynchronously </summary>
*/
public async Task<APIResponse<T>> RequestAsync()
{
var apiException = await e.GetContentAsAsync<what3words.dotnet.wrapper.response.ApiException>();
if (apiException != null)
try
{
return new APIResponse<T>(await ApiRequest);
}
catch (Refit.ApiException e)
{
return new APIResponse<T>(apiException.Error);
var apiException = await e.GetContentAsAsync<what3words.dotnet.wrapper.response.ApiException>();
if (apiException != null)
{
return new APIResponse<T>(apiException.Error);
}
else
{
var error = new APIError
{
Code = What3WordsError.UnknownError.ToString(),
Message = e.Message
};
return new APIResponse<T>(error);
}
}
else
catch (Exception e)
{
var error = new APIError
{
Code = What3WordsError.UnknownError.ToString(),
Code = What3WordsError.NetworkError.ToString(),
Message = e.Message
};
return new APIResponse<T>(error);
}
}
catch (Exception e)
{
var error = new APIError
{
Code = What3WordsError.NetworkError.ToString(),
Message = e.Message
};
return new APIResponse<T>(error);
}
}
}
8 changes: 4 additions & 4 deletions what3words.dotnet.wrapper/what3words.dotnet.wrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Authors>What3words</Authors>
<Product>What3words .NET Wrapper</Product>
<PackageId>what3words.dotnet.wrapper</PackageId>
<PackageVersion>3.1.1</PackageVersion>
<PackageVersion>4.0.0</PackageVersion>
<Description>A .NET library to use the what3words v3 API.

API methods are grouped into a single service object which can be centrally managed by a
Expand All @@ -23,9 +23,9 @@
<PackageProjectUrl>https://developer.what3words.com/public-api</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>3.1.1</Version>
<AssemblyVersion>3.1.1</AssemblyVersion>
<FileVersion>3.1.1</FileVersion>
<Version>4.0.0</Version>
<AssemblyVersion>4.0.0</AssemblyVersion>
<FileVersion>4.0.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down