-
Notifications
You must be signed in to change notification settings - Fork 7
Some updates #14
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
base: master
Are you sure you want to change the base?
Some updates #14
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
| <AppDesignerFolder>Properties</AppDesignerFolder> | ||
| <RootNamespace>Saasu.API.Client.IntegrationTests</RootNamespace> | ||
| <AssemblyName>Saasu.API.Client.IntegrationTests</AssemblyName> | ||
| <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> | ||
| <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you changing the target framework?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My project was 4.6.1, and I couln't otherwise use the library. Upgrading my framework version led to other issues. I made this change before I intended the pull request.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PS. It's not a downgrade. Nuget packages should target the lowest possible framework that supports it, so it can be used as widely as possible. Packages targeted for a lower version framework can be used in a project using a higher version framework, but packages with a higher version framework can't be used in a project with a lower version. |
||
| <FileAlignment>512</FileAlignment> | ||
| <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
| <CurrentConfigFileName>app.config</CurrentConfigFileName> | ||
|
|
@@ -60,8 +60,8 @@ | |
| <Reference Include="Netaccounts.Ola.RestClient, Version=1.0.5689.19968, Culture=neutral, processorArchitecture=MSIL"> | ||
| <HintPath>..\packages\Saasu.API.Dotnet.LegacyRestClient.1.0\lib\Netaccounts.Ola.RestClient.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
| <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
| <Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
| <HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> | ||
| <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net471" /> | ||
| <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net471" /> | ||
| <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you downgrading the target framework?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above |
||
| <package id="NUnit" version="2.6.4" targetFramework="net471" /> | ||
| <package id="Saasu.API.Dotnet.LegacyRestClient" version="1.0" targetFramework="net471" /> | ||
| </packages> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ | |
|
|
||
| <Saasu.API.Client.Config> | ||
| <setting name="IgnoreSSLErrors" serializeAs="String"> | ||
| <value>false</value> | ||
| <value>true</value> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this value changed?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm getting connection SSL errors, though likely because I can't create an outbound connection. The HTTPClient stops working after a few hours after launch. This wasn't intended as part of the pull request. |
||
| </setting> | ||
| <setting name="BaseUri" serializeAs="String"> | ||
| <value>https://api.saasu.com/</value> | ||
|
|
@@ -41,9 +41,9 @@ | |
| <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | ||
| <dependentAssembly> | ||
| <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | ||
| <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" /> | ||
| <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> | ||
| </dependentAssembly> | ||
| </assemblyBinding> | ||
| </runtime> | ||
|
|
||
| </configuration> | ||
| <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /></startup></configuration> | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| using Saasu.API.Core.Framework; | ||
| using System; | ||
| using Saasu.API.Core.Framework; | ||
| using Saasu.API.Core.Globals; | ||
| using Saasu.API.Core.Models.RequestFiltering; | ||
| using System.IO; | ||
|
|
@@ -246,6 +247,14 @@ public virtual ProxyResponse GetResponse(string requestUrl) | |
| return new ProxyResponse(rawResponse, responseMsg.IsSuccessStatusCode, responseMsg.StatusCode, responseMsg.ReasonPhrase); | ||
| } | ||
|
|
||
| public virtual ProxyResponse<byte[]> GetBinaryResponse(string requestUrl) | ||
| { | ||
| var responseMsg = GetResponseMessage(requestUrl); | ||
| var content = responseMsg.Content.ReadAsByteArrayAsync().Result; | ||
| var rawResponse = string.Empty; | ||
| return new ProxyResponse<byte[]>(rawResponse, content, responseMsg.IsSuccessStatusCode, responseMsg.StatusCode, responseMsg.ReasonPhrase); | ||
| } | ||
|
|
||
| public virtual ProxyResponse<T> GetResponse<T>(string requestUri) where T : class | ||
| { | ||
| return GetResponse<T, T>(requestUri, null); | ||
|
|
@@ -292,57 +301,48 @@ protected virtual System.Net.Http.HttpResponseMessage GetResponseMessage(string | |
| { | ||
| return GetResponseMessage<object>(requestUri, null); | ||
| } | ||
|
|
||
| protected virtual System.Net.Http.HttpResponseMessage GetResponseMessage<T>(string requestUri, T postData) | ||
| { | ||
| HttpClient client = new HttpClient(); | ||
| client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(ContentType.AsContentTypeString())); | ||
| if (AuthenticationMethod == AuthenticationType.OAuth && !string.IsNullOrEmpty(_bearerToken)) | ||
| { | ||
| client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _bearerToken); | ||
| } | ||
| return GetResponseMessage<T>(requestUri, postData, ContentType.AsContentTypeString()); | ||
| } | ||
|
|
||
| MediaTypeFormatter mediaFormatter; | ||
| private static Lazy<HttpClient> Client {get;} = new Lazy<HttpClient>(() => | ||
| { | ||
| var client = new HttpClient(); | ||
| client.DefaultRequestHeaders.ConnectionClose = true; | ||
| return client; | ||
| }); | ||
|
|
||
|
|
||
| if (ContentType == RequestContentType.ApplicationXml) | ||
| { | ||
| mediaFormatter = new System.Net.Http.Formatting.XmlMediaTypeFormatter(); | ||
| protected virtual HttpResponseMessage GetResponseMessage<T>(string requestUri, T postData, string contentType) | ||
| { | ||
| var client = Client.Value; | ||
|
|
||
| } | ||
| else | ||
| using (var request = new HttpRequestMessage(OperationMethod, requestUri)) | ||
| { | ||
| mediaFormatter = new System.Net.Http.Formatting.JsonMediaTypeFormatter(); | ||
| } | ||
|
|
||
|
|
||
| if (!string.IsNullOrEmpty(contentType)) | ||
| request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(contentType)); | ||
|
|
||
| HttpResponseMessage responseMsg = null; | ||
| if (OperationMethod == HttpMethod.Get) | ||
| { | ||
| responseMsg = client.GetAsync(requestUri).Result; | ||
| } | ||
| else if (OperationMethod == HttpMethod.Delete && postData == null) | ||
| { | ||
| responseMsg = client.DeleteAsync(requestUri).Result; | ||
| } | ||
| else if (OperationMethod == HttpMethod.Head) | ||
| { | ||
| var rqstMsg = new HttpRequestMessage(HttpMethod.Head, requestUri); | ||
| responseMsg = client.SendAsync(rqstMsg).Result; | ||
| } | ||
| else | ||
| { | ||
| //Note: Need to explicitly specify the content type here otherwise this call fails. | ||
| if (OperationMethod == HttpMethod.Put) | ||
| if (AuthenticationMethod == AuthenticationType.OAuth && !string.IsNullOrEmpty(_bearerToken)) | ||
| { | ||
| responseMsg = client.PutAsync<T>(requestUri, postData, mediaFormatter).Result; | ||
| request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _bearerToken); | ||
| } | ||
| else | ||
|
|
||
| if (postData != null) | ||
| { | ||
| responseMsg = client.PostAsync<T>(requestUri, postData, mediaFormatter).Result; | ||
| request.Content = new ObjectContent<T>(postData, ContentType == RequestContentType.ApplicationXml | ||
| ? (MediaTypeFormatter) new XmlMediaTypeFormatter() | ||
| : new JsonMediaTypeFormatter()); | ||
| } | ||
|
|
||
| return client.SendAsync(request).Result; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to block the call and it won't be async. These changes will only allow a single http request at a time, where before multiple would have been supported.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I don't think so. HttpClient is intended to be shared, and is reentrant and thread safe. Unless I'm missing something. See https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/ |
||
|
|
||
| } | ||
|
|
||
| return responseMsg; | ||
| } | ||
|
|
||
|
|
||
| public T Deserialise<T>(string data) where T : class | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| <AppDesignerFolder>Properties</AppDesignerFolder> | ||
| <RootNamespace>Saasu.API.Client</RootNamespace> | ||
| <AssemblyName>Saasu.API.Client</AssemblyName> | ||
| <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> | ||
| <TargetFrameworkVersion>v4.6</TargetFrameworkVersion> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Downgrade |
||
| <FileAlignment>512</FileAlignment> | ||
| <TargetFrameworkProfile /> | ||
| <NuGetPackageImportStamp> | ||
|
|
@@ -53,8 +53,8 @@ | |
| <CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
| <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
| <Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
| <HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> | ||
| </Reference> | ||
| <Reference Include="System" /> | ||
| <Reference Include="System.ComponentModel.DataAnnotations" /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,9 @@ | |
| <metadata> | ||
| <id>Saasu.API.Dotnet.Sdk</id> | ||
| <title>API SDK for the Saasu API</title> | ||
| <version>1.1.7</version> | ||
| <version>1.1.7.2</version> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't change the nuspec file. We will do this for a release.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This commit was not intended to be a part of the pull request. Because there was no response to our request, we made this change internally so we could push to our private nuget repository without conflicts. |
||
| <authors>Saasu</authors> | ||
| <description>A client SDK for working with the Saasu API.</description> | ||
| <description>A client SDK for working with the Saasu API. Modified for Intellis internal use.</description> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not an appropriate description.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. This was not intended to be pulled to the base repo |
||
| <summary>A client SDK for working with the Saasu API.</summary> | ||
| <language>en-US</language> | ||
| <projectUrl>https://github.com/saasu/api-sdk-dotnet</projectUrl> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net471" /> | ||
| <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net471" /> | ||
| <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net46" /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Downgrade. |
||
| <package id="OctoPack" version="3.6.3" targetFramework="net471" developmentDependency="true" /> | ||
| </packages> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| namespace Saasu.API.Core.Models.Invoices | ||
| { | ||
| public class InvoicePdfResult : BaseResponseModel | ||
| { | ||
| public int InvoiceId { get; set; } | ||
|
|
||
| public byte[] Content { get; set; } | ||
|
|
||
|
|
||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <packages> | ||
| <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net471" /> | ||
| <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net471" /> | ||
| <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net46" /> | ||
| </packages> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I needed to use it in a project already including a higher version of Newtonsoft.Json than 7