-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update host uri and add project apikind
- Loading branch information
Showing
9 changed files
with
356 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
CustomVoice-API-Samples/CSharp/CustomVoice-API/API/DTO/Project.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
|
||
namespace CustomVoice_API.API.DTO | ||
{ | ||
class Project | ||
{ | ||
[JsonConstructor] | ||
private Project( | ||
string self, | ||
string projectKind, | ||
string displayName, | ||
string description, | ||
IReadOnlyDictionary<string, string> properties, | ||
CultureInfo locale, | ||
DateTime createdDateTime) | ||
{ | ||
this.Self = self; | ||
this.Properties = properties; | ||
this.DisplayName = displayName; | ||
this.Description = description; | ||
this.ProjectKind = projectKind; | ||
this.Locale = locale.Name; | ||
this.CreatedDateTime = createdDateTime; | ||
} | ||
|
||
public string Self { get; private set; } | ||
|
||
public string ProjectKind { get; private set; } | ||
|
||
public string DisplayName { get; private set; } | ||
|
||
public string Description { get; private set; } | ||
|
||
public IReadOnlyDictionary<string, string> Properties { get; private set; } | ||
|
||
public string Locale { get; private set; } | ||
|
||
public DateTime CreatedDateTime { get; private set; } | ||
|
||
public static Project Create( | ||
string self, | ||
string projectKind, | ||
string name, | ||
string description, | ||
IReadOnlyDictionary<string, string> properties, | ||
CultureInfo locale, | ||
DateTime createdDateTime, | ||
OneApiState status) | ||
{ | ||
return new Project( | ||
self, | ||
projectKind, | ||
name, | ||
description, | ||
properties, | ||
locale, | ||
createdDateTime); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
CustomVoice-API-Samples/CSharp/CustomVoice-API/API/DTO/ProjectDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace CustomVoice_API.API.DTO | ||
{ | ||
class ProjectDefinition | ||
{ | ||
private ProjectDefinition( | ||
string name, | ||
string displayName, | ||
string description, | ||
string locale, | ||
IReadOnlyDictionary<string, string> properties, | ||
string projectKind) | ||
{ | ||
this.Name = name; | ||
this.DisplayName = displayName; | ||
this.Description = description; | ||
this.Locale = locale; | ||
this.Properties = properties; | ||
this.ProjectKind = projectKind; | ||
} | ||
|
||
public string Name { get; private set; } | ||
|
||
public string DisplayName { get; private set; } | ||
|
||
public string Description { get; private set; } | ||
|
||
public string Locale { get; private set; } | ||
|
||
public IReadOnlyDictionary<string, string> Properties { get; private set; } | ||
|
||
public string ProjectKind { get; private set; } | ||
|
||
public static ProjectDefinition Create( | ||
string name, | ||
string displayname, | ||
string description, | ||
string locale, | ||
IReadOnlyDictionary<string, string> properties, | ||
string projectKind) | ||
{ | ||
return new ProjectDefinition( | ||
name, | ||
displayname, | ||
description, | ||
locale, | ||
properties, | ||
projectKind); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
CustomVoice-API-Samples/CSharp/CustomVoice-API/API/Project.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using CustomVoice_API.API.DTO; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Net; | ||
|
||
namespace CustomVoice_API.API | ||
{ | ||
class Project | ||
{ | ||
public static IEnumerable<DTO.Project> Get(string subscriptionKey, string hostURI) | ||
{ | ||
string url = string.Format(CultureInfo.InvariantCulture, hostURI + API_V3.VoiceProject_Get); | ||
return APIHelper.Get<IEnumerable<DTO.Project>>(subscriptionKey, url); | ||
} | ||
|
||
public static bool DeleteById(string subscriptionKey, string hostURI, string projectId) | ||
{ | ||
string url = string.Format(CultureInfo.InvariantCulture, hostURI + API_V3.VoiceProject_DeleteById, projectId); | ||
var response = APIHelper.Delete(subscriptionKey, url); | ||
if (response.StatusCode != HttpStatusCode.NoContent) | ||
{ | ||
APIHelper.PrintErrorMessage(response); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public static bool Create(string subscriptionKey, string hostURI, string name, string description, string gender, string locale) | ||
{ | ||
var properties = new Dictionary<string, string>(); | ||
properties.Add("Gender", gender.Substring(0, 1).ToUpper() + gender.Substring(1)); | ||
|
||
var projectDefinition = ProjectDefinition.Create( | ||
name, | ||
name, | ||
description, | ||
locale, | ||
properties, | ||
"TextToSpeech"); | ||
var response = APIHelper.Submit<ProjectDefinition>(subscriptionKey, hostURI + API_V3.VoiceProject_Create, projectDefinition); | ||
|
||
if (response.StatusCode != HttpStatusCode.Accepted && response.StatusCode != HttpStatusCode.Created) | ||
{ | ||
APIHelper.PrintErrorMessage(response); | ||
return false; | ||
} | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
{ | ||
public enum APIKind | ||
{ | ||
project, | ||
dataset, | ||
model, | ||
voicetest, | ||
|
Oops, something went wrong.