Giter Site home page Giter Site logo

interfax / interfax-dotnet Goto Github PK

View Code? Open in Web Editor NEW
8.0 10.0 14.0 802 KB

Fax send and receive in .NET with the InterFAX REST API

Home Page: https://www.interfax.net/en/dev/dotnet

License: MIT License

C# 99.88% HTML 0.12%
fax fax-api hipaa inbound interfax interfax-api library dotnet csharp vb-net online-fax outbound receive sdk send

interfax-dotnet's Issues

InboundFax.MessageId datatype is inconsistent API

InboundFax.MessageId is a string, but all other operations against an InboundFax require fax identification by integer.

Working with the API while processing the inbound queue requires integer parsing to complete the cycle of Inbound.GetList, GetFaxImageStream, MarkAsRead.

FaxClient should not set default serialization settings

Any time a FaxClient is created in our application, it overwrites the default serialization settings in Json.Net. Investigating the code, there is this code block in the constructor that should be removed/reworked:

JsonConvert.DefaultSettings = () => { var settings = new JsonSerializerSettings(); settings.Converters.Add(new StringEnumConverter { CamelCaseText = true }); return settings; };
This is generally considered a bad practice for any libraries as it interferes with app behavior.

Deploying inside Azure Functions...

I am trying to use this SDK within my Azure Functions project. Everything works great when I test on my machine. However, when I deploy my project to Azure (production), I get a runtime error saying that the 'SupportedMediaTypes.json' file is not deployed in the 'bin' folder. Instead, Visual Studio places this file inside the parent '\wwwroot' folder.

I do not know how to instruct VS to place this file in the '\wwwroot\bin' folder where the 'InterFAX.Api.dll' assembly is located and where this assembly is looking for it. Also, why is this file even necessary? It would be nice if the SDK just supported these types by default, unless overridden by the presence of this file. Alternatively, if I could setup the mappings in code, rather than via this file.

Please help - this is crucial I resolve this issue. Many thanks in advance!

Typo README.md

Hi Team,

I see typo fileDocument => faxDocument in "Send fax" section.

SupportedMediaTypes.json Location

In issue #23 it mentions that it uses an embedded version of this file in the assembly but in the code in Documents.cs it also look like if there is not a file on disk it tries to write it out to disk.

`var assembly = Assembly.GetAssembly(typeof(Documents));
var assemblyPath = Path.GetDirectoryName(assembly.Location);
var typesFile = Path.Combine(assemblyPath, "SupportedMediaTypes.json");

if (!File.Exists(typesFile))
{
// unpack the types file to the assembly path
using (var resource = assembly.GetManifestResourceStream("InterFAX.Api.SupportedMediaTypes.json"))
{
using (var file = new FileStream(typesFile, FileMode.Create, FileAccess.Write))
{
resource.CopyTo(file);
}
}
}`

This is a problem I am encountering because it is trying to write the file into the same folder as that the assembly is located in, which if often protected from writing and which with a Store applications it cannot do.

Would it be possible to have a property that is set to define where to write this file and any other files it needs? I have seen other products that define something like "ReferencePath" so that we can define where this is written or I believe this location will work properly for most desktop scenarios, Store and non-Store, although I am not sure about web.

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);

TLS 1.0 Depreciated causing Exceptions

Since the library 1.05 is built on .NET 4.5.2, it requires an additional line of code to be invoked prior to any API calls to force use of TLS 1.2:

C# ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
VB ServicePointManager.SecurityProtocol = DirectCast(3072,System.Net.SecurityProtocolType)

Here is some useful information regarding TLS1.2 and .NET:
https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls

For 2008 R2, registry settings to enable support.
https://support.microsoft.com/en-us/help/3140245/update-to-enable-tls-1-1-and-tls-1-2-as-a-default-secure-protocols-in
https://support.microsoft.com/en-us/help/3154518/support-for-tls-system-default-versions-included-in-the-net-framework
https://docs.microsoft.com/en-us/windows-server/security/tls/tls-registry-settings

There are a few options I foresee:

  1. Update the documentation to include mention of the above line before invoking
  2. Hardcode the above line into the client to force TLS1.2 usage
  3. Recompile the client to require .NET 4.7+ (which uses operating system defaults)

Potential problems with each one:
Option 1: Added complexity put upon the end user/developer
Option 2: You've now hardcoded something which will eventually become a problem.
Option 3: Limit usage by potential users/developers that use older .NET versions.

Request - Fax byte[] in addition to files...

Please consider supporting FaxClient.Documents.BuildFaxDocument(byte[], ...) in addition to filename and uri building options. We have a need to send from a byte[] directly without the option to be able to write to disk first (which would be unwanted overhead even if we could). Many thanks!

Make integration tests work with any set of user credentials

Currently we are using hard coded fax and document IDs in some places in the integration tests. As a result the tests fail when a different user tries to edit the code and run the tests, as they do not have access to the same resources.

We should fix this, one way to do this is to "find" a fax ID first based on the whole list of faxes.

How to set up proxy?

We are using below code to connect. But we are not sure where to add proxy settings. Can you please help ?

        public void Initialise(HttpMessageHandler messageHandler = null, HttpClient httpClient = 
        null)
        {
        var username = _faxConfiguration.UserName;
        var password = _faxConfiguration.Password;
        if (string.IsNullOrEmpty(username))
            throw new ArgumentException($"{username} has not been set.");

        if (string.IsNullOrEmpty(password))
            throw new ArgumentException($"{password} has not been set.");

        Account = new Account(this);
        Inbound = new Inbound(this);
        Outbound = new Outbound(this);
        Documents = new Documents(this);

        HttpClient = messageHandler == null ? new HttpClient() : new HttpClient(messageHandler);
        HttpClient = httpClient ?? HttpClient;

        HttpClient.BaseAddress = new Uri($"https://rest.interfax.net/");
        HttpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        HttpClient.DefaultRequestHeaders.Add("Authorization",
            new List<string> { $"Basic {Utils.Base64Encode($"{username}:{password}")}" });

        JsonConvert.DefaultSettings = () =>
        {
            var settings = new JsonSerializerSettings();
            settings.Converters.Add(new StringEnumConverter { CamelCaseText = true });
            return settings;
        };
    }

Rename project

The project is referred to as interfax-csharp but the url is interfax-dotnet

Fix: InterFAX.Api does not have a strong name...

My project complains when building with the InterFAX.Api assembly. Below is the error:

"Referenced assembly 'InterFAX.Api, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' does not have a strong name."

Can you please resolve this and post an updated version to Nuget? Many thanks.

Error on Mac with .NET for Mac

I've installed .NET for Mac via: https://www.microsoft.com/net/core#macos

I am using VS Code with Nuget installed, and when I install the file and run dotnet restore I get the following error.

Errors in /Users/cbetta/code/playground/hwapp/hwapp.csproj
      Package InterFAX.Api 1.0.4 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package InterFAX.Api 1.0.4 supports: net452 (.NETFramew
ork,Version=v4.5.2)
      Package Microsoft.AspNet.WebApi.Client 5.2.3 is not compatible with netcoreapp1.1 (.NETCoreApp,Version=v1.1). Package Microsoft.AspNet.WebApi.Clien
t 5.2.3 supports:
        - net45 (.NETFramework,Version=v4.5)
        - portable-net45+netcore45+wp8+wp81+wpa81 (.NETPortable,Version=v0.0,Profile=wp8+netcore45+net45+wp81+wpa81)
      One or more packages are incompatible with .NETCoreApp,Version=v1.1.

Any clues?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.