Skip to content

Commit 328eb9b

Browse files
committed
refactor(HttpMethod): Specified HTTP method for delete calls
1 parent 71f8079 commit 328eb9b

File tree

11 files changed

+47
-38
lines changed

11 files changed

+47
-38
lines changed

Scripts/Connection/RESTConnector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ private IEnumerator ProcessRequestQueue()
419419
Response resp = new Response();
420420

421421
DateTime startTime = DateTime.Now;
422-
if (string.IsNullOrEmpty(req.HttpMethod) || req.Delete)
422+
if (string.IsNullOrEmpty(req.HttpMethod))
423423
{
424424
UnityWebRequest www = null;
425425
if (req.Forms != null)

Scripts/Services/Assistant/v1/Assistant.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using IBM.Watson.DeveloperCloud.Utilities;
2424
using System;
2525
using MiniJSON;
26+
using UnityEngine.Networking;
2627

2728
namespace IBM.Watson.DeveloperCloud.Services.Assistant.v1
2829
{
@@ -347,7 +348,7 @@ public bool DeleteWorkspace(SuccessCallback<object> successCallback, FailCallbac
347348
}
348349
}
349350
req.Parameters["version"] = VersionDate;
350-
req.Delete = true;
351+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
351352

352353
req.OnResponse = OnDeleteWorkspaceResponse;
353354

@@ -844,7 +845,7 @@ public bool DeleteIntent(SuccessCallback<object> successCallback, FailCallback f
844845
}
845846
}
846847
req.Parameters["version"] = VersionDate;
847-
req.Delete = true;
848+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
848849

849850
req.OnResponse = OnDeleteIntentResponse;
850851

@@ -1348,7 +1349,7 @@ public bool DeleteExample(SuccessCallback<object> successCallback, FailCallback
13481349
}
13491350
}
13501351
req.Parameters["version"] = VersionDate;
1351-
req.Delete = true;
1352+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
13521353

13531354
req.OnResponse = OnDeleteExampleResponse;
13541355

@@ -1848,7 +1849,7 @@ public bool DeleteCounterexample(SuccessCallback<object> successCallback, FailCa
18481849
}
18491850
}
18501851
req.Parameters["version"] = VersionDate;
1851-
req.Delete = true;
1852+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
18521853

18531854
req.OnResponse = OnDeleteCounterexampleResponse;
18541855

@@ -2347,7 +2348,7 @@ public bool DeleteEntity(SuccessCallback<object> successCallback, FailCallback f
23472348
}
23482349
}
23492350
req.Parameters["version"] = VersionDate;
2350-
req.Delete = true;
2351+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
23512352

23522353
req.OnResponse = OnDeleteEntityResponse;
23532354

@@ -2963,7 +2964,7 @@ public bool DeleteValue(SuccessCallback<object> successCallback, FailCallback fa
29632964
}
29642965
}
29652966
req.Parameters["version"] = VersionDate;
2966-
req.Delete = true;
2967+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
29672968

29682969
req.OnResponse = OnDeleteValueResponse;
29692970

@@ -3474,7 +3475,7 @@ public bool DeleteSynonym(SuccessCallback<object> successCallback, FailCallback
34743475
}
34753476
}
34763477
req.Parameters["version"] = VersionDate;
3477-
req.Delete = true;
3478+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
34783479

34793480
req.OnResponse = OnDeleteSynonymResponse;
34803481

@@ -3978,7 +3979,7 @@ public bool DeleteDialogNode(SuccessCallback<object> successCallback, FailCallba
39783979
}
39793980
}
39803981
req.Parameters["version"] = VersionDate;
3981-
req.Delete = true;
3982+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
39823983

39833984
req.OnResponse = OnDeleteDialogNodeResponse;
39843985

@@ -4594,7 +4595,7 @@ public bool DeleteUserData(SuccessCallback<object> successCallback, FailCallback
45944595
}
45954596
req.Parameters["customer_id"] = customerId;
45964597
req.Parameters["version"] = VersionDate;
4597-
req.Delete = true;
4598+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
45984599

45994600
req.OnResponse = OnDeleteUserDataResponse;
46004601

Scripts/Services/Conversation/v1/Conversation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
using IBM.Watson.DeveloperCloud.Logging;
2424
using MiniJSON;
2525
using System.Collections.Generic;
26-
using UnityEngine;
26+
using UnityEngine.Networking;
2727

2828
namespace IBM.Watson.DeveloperCloud.Services.Conversation.v1
2929
{
@@ -337,7 +337,7 @@ public bool DeleteUserData(SuccessCallback<object> successCallback, FailCallback
337337
}
338338
req.Parameters["customer_id"] = customerId;
339339
req.Parameters["version"] = VersionDate;
340-
req.Delete = true;
340+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
341341

342342
req.OnResponse = OnDeleteUserDataResponse;
343343

Scripts/Services/Discovery/v1/Discovery.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System.Collections.Generic;
2525
using System.IO;
2626
using System.Text;
27+
using UnityEngine.Networking;
2728

2829
namespace IBM.Watson.DeveloperCloud.Services.Discovery.v1
2930
{
@@ -538,7 +539,7 @@ public bool DeleteEnvironment(SuccessCallback<DeleteEnvironmentResponse> success
538539
}
539540
req.Parameters["version"] = VersionDate;
540541
req.OnResponse = OnDeleteEnvironmentResponse;
541-
req.Delete = true;
542+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
542543

543544
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format(Environment, environmentID));
544545
if (connector == null)
@@ -978,7 +979,7 @@ public bool DeleteConfiguration(SuccessCallback<DeleteConfigurationResponse> suc
978979
}
979980
req.Parameters["version"] = VersionDate;
980981
req.OnResponse = OnDeleteConfigurationResponse;
981-
req.Delete = true;
982+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
982983

983984
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format(Configuration, environmentID, configurationID));
984985
if (connector == null)
@@ -1092,7 +1093,7 @@ private void OnDeleteConfigurationResponse(RESTConnector.Request req, RESTConnec
10921093
throw new WatsonException(string.Format("Failed to load content: {0}", e.Message));
10931094
}
10941095

1095-
string contentMimeType = Utility.GetMimeType(Path.GetExtension(contentFilePath));
1096+
string contentMimeType = Utilities.Utility.GetMimeType(Path.GetExtension(contentFilePath));
10961097

10971098
return PreviewConfiguration(successCallback, failCallback, environmentID, configurationID, configurationFilePath, contentData, contentMimeType, metadata, customData);
10981099
}
@@ -1607,7 +1608,7 @@ public bool DeleteCollection(SuccessCallback<DeleteCollectionResponse> successCa
16071608
}
16081609
req.Parameters["version"] = VersionDate;
16091610
req.OnResponse = OnDeleteCollectionResponse;
1610-
req.Delete = true;
1611+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
16111612

16121613
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format(Collection, environmentID, collectionID));
16131614
if (connector == null)
@@ -1822,7 +1823,7 @@ private void OnGetFieldsResponse(RESTConnector.Request req, RESTConnector.Respon
18221823
try
18231824
{
18241825
contentData = File.ReadAllBytes(contentFilePath);
1825-
contentMimeType = Utility.GetMimeType(Path.GetExtension(contentFilePath));
1826+
contentMimeType = Utilities.Utility.GetMimeType(Path.GetExtension(contentFilePath));
18261827
}
18271828
catch (Exception e)
18281829
{
@@ -2096,7 +2097,7 @@ public bool DeleteDocument(SuccessCallback<DeleteDocumentResponse> successCallba
20962097
}
20972098
req.Parameters["version"] = VersionDate;
20982099
req.OnResponse = OnDeleteDocumentResponse;
2099-
req.Delete = true;
2100+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
21002101

21012102
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format(Document, environmentID, collectionID, documentID));
21022103
if (connector == null)
@@ -2308,7 +2309,7 @@ private void OnGetDocumentResponse(RESTConnector.Request req, RESTConnector.Resp
23082309
try
23092310
{
23102311
contentData = File.ReadAllBytes(contentFilePath);
2311-
contentMimeType = Utility.GetMimeType(Path.GetExtension(contentFilePath));
2312+
contentMimeType = Utilities.Utility.GetMimeType(Path.GetExtension(contentFilePath));
23122313
}
23132314
catch (Exception e)
23142315
{
@@ -3626,7 +3627,7 @@ public bool DeleteExpansions(SuccessCallback<object> successCallback, FailCallba
36263627
}
36273628
req.Parameters["version"] = VersionDate;
36283629
req.OnResponse = OnDeleteExpansionsResponse;
3629-
req.Delete = true;
3630+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
36303631

36313632
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v1/environments/{0}/collections/{1}/expansions", environmentId, collectionId));
36323633
if (connector == null)
@@ -3823,7 +3824,7 @@ public bool DeleteUserData(SuccessCallback<object> successCallback, FailCallback
38233824
}
38243825
req.Parameters["customer_id"] = customerId;
38253826
req.Parameters["version"] = VersionDate;
3826-
req.Delete = true;
3827+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
38273828

38283829
req.OnResponse = OnDeleteUserDataResponse;
38293830

@@ -4138,7 +4139,7 @@ public bool DeleteCredentials(SuccessCallback<DeleteCredentials> successCallback
41384139
}
41394140
req.Parameters["version"] = VersionDate;
41404141
req.OnResponse = OnDeleteCredentialsResponse;
4141-
req.Delete = true;
4142+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
41424143

41434144
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format(CredentialEndpoint, environmentID, credentialId));
41444145
if (connector == null)

Scripts/Services/LanguageTranslator/v2/LanguageTranslator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using System;
2626
using FullSerializer;
2727
using System.IO;
28+
using UnityEngine.Networking;
2829

2930
namespace IBM.Watson.DeveloperCloud.Services.LanguageTranslator.v2
3031
{
@@ -664,7 +665,7 @@ public bool DeleteModel(SuccessCallback<DeleteModelResult> successCallback, Fail
664665
}
665666
req.Function = WWW.EscapeURL(model_id);
666667
req.OnResponse = DeleteModelResponse;
667-
req.Delete = true;
668+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
668669
return connector.Send(req);
669670
}
670671

Scripts/Services/LanguageTranslator/v3/LanguageTranslator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using System;
2626
using FullSerializer;
2727
using System.IO;
28+
using UnityEngine.Networking;
2829

2930
namespace IBM.Watson.DeveloperCloud.Services.LanguageTranslator.v3
3031
{
@@ -679,7 +680,7 @@ public bool DeleteModel(SuccessCallback<DeleteModelResult> successCallback, Fail
679680
}
680681
req.Function = WWW.EscapeURL(model_id);
681682
req.OnResponse = DeleteModelResponse;
682-
req.Delete = true;
683+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
683684
return connector.Send(req);
684685
}
685686

Scripts/Services/NaturalLanguageClassifier/v2/NaturalLanguageClassifier.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.Collections.Generic;
2424
using System.Text;
2525
using FullSerializer;
26+
using UnityEngine.Networking;
2627

2728
namespace IBM.Watson.DeveloperCloud.Services.NaturalLanguageClassifier.v1
2829
{
@@ -432,7 +433,7 @@ public bool DeleteClassifer(SuccessCallback<bool> successCallback, FailCallback
432433
}
433434
}
434435
req.OnResponse = OnDeleteClassifierResp;
435-
req.Delete = true;
436+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
436437

437438
return connector.Send(req);
438439
}

Scripts/Services/NaturalLanguageUnderstanding/v1/NaturalLanguageUnderstanding.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using System;
2323
using System.Collections.Generic;
2424
using System.Text;
25+
using UnityEngine.Networking;
2526

2627
namespace IBM.Watson.DeveloperCloud.Services.NaturalLanguageUnderstanding.v1
2728
{
@@ -349,7 +350,7 @@ public bool DeleteModel(SuccessCallback<bool> successCallback, FailCallback fail
349350
}
350351
req.Parameters["version"] = NaturalLanguageUnderstandingVersion.Version;
351352
req.OnResponse = OnDeleteModelResponse;
352-
req.Delete = true;
353+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
353354

354355
RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format(ModelEndpoint, modelId));
355356
if (connector == null)

Scripts/Services/SpeechToText/v1/SpeechToText.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using System.Text;
3030
using FullSerializer;
3131
using System.IO;
32+
using UnityEngine.Networking;
3233

3334
namespace IBM.Watson.DeveloperCloud.Services.SpeechToText.v1
3435
{
@@ -1499,7 +1500,7 @@ public bool DeleteCustomization(SuccessCallback<bool> successCallback, FailCallb
14991500
req.Headers.Add(kvp.Key, kvp.Value);
15001501
}
15011502
}
1502-
req.Delete = true;
1503+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
15031504
req.OnResponse = OnDeleteCustomizationResp;
15041505

15051506
string service = "/v1/customizations/{0}";
@@ -2125,7 +2126,7 @@ public bool DeleteCustomCorpus(SuccessCallback<bool> successCallback, FailCallba
21252126
req.Headers.Add(kvp.Key, kvp.Value);
21262127
}
21272128
}
2128-
req.Delete = true;
2129+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
21292130
req.OnResponse = OnDeleteCustomCorpusResp;
21302131

21312132
string service = "/v1/customizations/{0}/corpora/{1}";
@@ -2567,7 +2568,7 @@ public bool DeleteCustomWord(SuccessCallback<bool> successCallback, FailCallback
25672568
req.Headers.Add(kvp.Key, kvp.Value);
25682569
}
25692570
}
2570-
req.Delete = true;
2571+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
25712572
req.OnResponse = OnDeleteCustomWordResp;
25722573

25732574
string service = "/v1/customizations/{0}/words/{1}";
@@ -2950,7 +2951,7 @@ public bool DeleteAcousticCustomization(SuccessCallback<bool> successCallback, F
29502951
req.Headers.Add(kvp.Key, kvp.Value);
29512952
}
29522953
}
2953-
req.Delete = true;
2954+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
29542955
req.OnResponse = OnDeleteAcousticCustomizationResp;
29552956

29562957
string service = "/v1/acoustic_customizations/{0}";
@@ -3383,7 +3384,7 @@ public bool DeleteAcousticResource(SuccessCallback<bool> successCallback, FailCa
33833384
req.Headers.Add(kvp.Key, kvp.Value);
33843385
}
33853386
}
3386-
req.Delete = true;
3387+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
33873388
req.Timeout = 10f;
33883389
req.OnResponse = OnDeleteAcousticResourceResp;
33893390

@@ -3654,7 +3655,7 @@ public bool DeleteUserData(SuccessCallback<object> successCallback, FailCallback
36543655
}
36553656
}
36563657
req.Parameters["customer_id"] = customerId;
3657-
req.Delete = true;
3658+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
36583659

36593660
req.OnResponse = OnDeleteUserDataResponse;
36603661

Scripts/Services/TextToSpeech/v1/TextToSpeech.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using System;
2626
using FullSerializer;
2727
using System.Text.RegularExpressions;
28+
using UnityEngine.Networking;
2829

2930
namespace IBM.Watson.DeveloperCloud.Services.TextToSpeech.v1
3031
{
@@ -406,7 +407,7 @@ public bool ToSpeech(SuccessCallback<AudioClip> successCallback, FailCallback fa
406407
string escapedText = text.Replace("\\\"", "\"");
407408
string decodedText = DecodeUnicodeCharacters(escapedText);
408409

409-
string textId = Utility.GetMD5(decodedText);
410+
string textId = Utilities.Utility.GetMD5(decodedText);
410411

411412
RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/synthesize");
412413
if (connector == null)
@@ -853,7 +854,7 @@ public bool DeleteCustomization(SuccessCallback<bool> successCallback, FailCallb
853854
}
854855
}
855856
req.Timeout = RequestTimeout;
856-
req.Delete = true;
857+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
857858
req.OnResponse = OnDeleteCustomizationResp;
858859

859860
string service = "/v1/customizations/{0}";
@@ -1304,7 +1305,7 @@ public bool DeleteCustomizationWord(SuccessCallback<bool> successCallback, FailC
13041305
}
13051306
}
13061307
req.Timeout = RequestTimeout;
1307-
req.Delete = true;
1308+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
13081309
req.OnResponse = OnDeleteCustomizationWordResp;
13091310

13101311
string service = "/v1/customizations/{0}/words/{1}";
@@ -1572,7 +1573,7 @@ public bool DeleteUserData(SuccessCallback<object> successCallback, FailCallback
15721573
}
15731574
}
15741575
req.Parameters["customer_id"] = customerId;
1575-
req.Delete = true;
1576+
req.HttpMethod = UnityWebRequest.kHttpVerbDELETE;
15761577

15771578
req.OnResponse = OnDeleteUserDataResponse;
15781579

0 commit comments

Comments
 (0)