24SevenOffice.MappedApi 0.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package 24SevenOffice.MappedApi --version 0.1.1
NuGet\Install-Package 24SevenOffice.MappedApi -Version 0.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="24SevenOffice.MappedApi" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add 24SevenOffice.MappedApi --version 0.1.1
#r "nuget: 24SevenOffice.MappedApi, 0.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install 24SevenOffice.MappedApi as a Cake Addin
#addin nuget:?package=24SevenOffice.MappedApi&version=0.1.1

// Install 24SevenOffice.MappedApi as a Cake Tool
#tool nuget:?package=24SevenOffice.MappedApi&version=0.1.1

Mapped 24SevenOffice API

Mapped 24SevenOffice API is a library intended to be reused by various integrations in order to save time implementing common scenarios of interaction with 24SevenOffice WCF SOAP services. This library targets .NET Standard 2.0, which means it's usable both with full .NET framework and .NET core (also other things that .NET Standard 2.0 supports).

You no longer need to

  • add service references (instead, they are added within this library!);
  • implement identity and session info management (instead, use provided abstractions e.g. ISessionInfo!);
  • invent bycicle to properly unit- and integration-test your code (instead, use interfaces!);
  • call web-services synchronously (instead, use async/await!)

Core concepts

TfsoApiFactory

TfsoApiFactory is a type that is used to create API service clients. It can be reused because it has no state of it's own.

Service clients

Each service provided by 24SevenOffice can be consumed with corresponding service client. Currently supported 24SevenOffice services:

  • Authenticate (IAuthenticateClient implemented by AuthenticateSoapClient)
  • AccountService (IAccountClient implemented by AccountServiceSoapClient)
  • AttachmentService (IAttachmentClient implemented by AttachmentServiceSoapClient)
  • ClientService (IClientClient implemented by ClientServiceSoapClient)
  • CompanyService (ICompanyClient implemented by CompanyServiceSoapClient)
  • FileService (IFileClient implemented by FileServiceSoapClient)
  • FileInfoService (IFileInfoClient implemented by FileInfoServiceSoapClient)
  • InvitationService (IInvitationClient implemented by InvitationServiceSoapClient)
  • InvoiceService (IInvoiceClient implemented by InvoiceServiceSoapClient)
  • PaymentService (IPaymentClient implemented by PaymentServiceSoapClient)
  • PersonService (IPersonClient implemented by PersonServiceSoapClient)
  • ProductService (IProductClient implemented by ProductServiceSoapClient)
  • ProjectService (IProjectClient implemented by ProjectServiceSoapClient)
  • SalesOppService (ISalesOppClient implemented by SalesOppServiceSoapClient)
  • TemplateService (ITemplateClient implemented by TemplateServiceSoapClient)
  • TimeService (ITimeClient implemented by TimeServiceSoapClient)
  • TransactionService (ITransactionClient implemented by TransactionServiceSoapClient)

Full list of services is available here.

Service clients shouldn't be reused because there are no thread safety guarantees.

24SevenOffice session and Identities

Session Info Diagram

Upon logging in to 24SevenOffice, you receive a sessionId string. With this library, you actually receive ISessionInfo object.

ISessionInfo

ISessionInfo object is an aggregate of sessionId string, ICredentials and IIdentityCollection objects and UTC timestamp of it's creation date.

This interface was designed to be shallow-immutable.

public interface ISessionInfo
{
    string SessionId { get; }
    ICredentials Credentials { get; }
    IIdentityCollection Identities { get; }
    DateTime CreatedOn { get; }
}
ICredentials

Represents credentials user has logged in with. It may be useful if you want to prolong user session without bothering the user.

This interface is designed to be immutable.

public interface ICredentials : IEquatable<Credentials>
{
    bool IsEmpty {get;}
    string Login { get; }
    string Password { get; }
}
IIdentityCollection

By logging in to 24SevenOffice, you are also assigned an identity, which represents the company you've logged in into. There may be multiple that the user is a part of, hence the identity concept. 24SevenOffice supports switching identities, and to make this easier, IIdentityCollection was created.

The purpose of this interface is to manage the current state of the session regarding identities. When you use AuthenticateSoapClient to log in, or change identity, or set identity by id, AuthenticateSoapClient performs necessary calls to the IIdentityCollection to reflect the current identity, the default identity and list of available identities.

This interface was designed to be mutable, but you shouldn't need to mutate it directly from your code.

public interface IIdentityCollection
{
    // returns a copy of identities stored within
    [NotNull] IReadOnlyList<Identity> List { get; }

    // gets or sets current identity
    Identity CurrentIdentity { [CanBeNull] get; [NotNull] set; }

    // gets default identity, can't set it here
    [CanBeNull] Identity DefaultIdentity { get; }

    // finds identity by id in a list of stored identities. if not found, returns null
    [CanBeNull] Identity FindById(Guid id);

    // indicates, whether there any identities stored within
    bool HasIdentities { get; }

    // clears the inner identity list, and populates it from "identities" parameter
    void PopulateFrom([NotNull] Identity[] identities);
}

All of these are designed to be testable and extensible. For example, SessionInfo constructor allows you to specify your own implementation of both ICredentials and IIdentityCollection.

public class SessionInfo : ISessionInfo
{
    public SessionInfo([NotNull] string sessionId, 
                       [NotNull] ICredentials credentials, 
                       [NotNull] IIdentityCollection identityCollection)
    {
        SessionId = sessionId ?? throw new ArgumentNullException(nameof(sessionId));
        Credentials = credentials ?? throw new ArgumentNullException(nameof(credentials));
        Identities = identityCollection ?? throw new ArgumentNullException(nameof(identityCollection));
        CreatedOn = DateTime.UtcNow;
    }

    // ... omitted for brevity
}

Examples

Generally, the best way to discover a library is to see it's unit-tests. However, some examples will be provided in this readme.

Authentication
using System;
using System.Threading.Tasks;
using MappedTfsoApi.Common.Facade;
using MappedTfsoApi.References.Authenticate;

namespace YourGreatApplication
{
    public class SomeClass
    {
        public Task<ISessionInfo> AuthenticationExample()
        {
            var factory = new TfsoApiFactory();
            var auth = factory.AuthenticateService();
            return auth.AuthenticateAndGetSessionInfoAsync(new Credential
            {
                ApplicationId = Guid.Parse("<your application key>"),
                Username = "<your login>",
                Password = "<your password>"
            });
        }
    }
}

Running this code and examining ISessionInfo object will yield following results:

{
  "SessionId": "<your session id>",
  "Credentials": {
    "IsEmpty": false,
    "Login": "<your login>",
    "Password": "<your password>"
  },
  "Identities": {
    "List": [
      list of identities
    ],
    "CurrentIdentity": {
      current identity, if any
    },
    "DefaultIdentity": {
      default identity, if any
    },
    "HasIdentities": true (or false, depending on whether there are any identities)
  },
  "CreatedOn": "UTC timestamp of session creation time"
}

Notes

This library is still in it's early stages, so any contributions/bug reports/feature requests are welcome!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on 24SevenOffice.MappedApi:

Package Downloads
24SevenOffice.MappedApi.Fakers

Provides a set of Bogus-powered Fakers for 24SevenOffice objects to ease unit-testing.

24SevenOffice.MappedGeneralLedgerApi

Provides a wrapper for General Ledger REST API that handles license information utilizing ISessionInfo.

24SevenOffice.MappedAccountAggregationApi

Provides a wrapper for Account Aggregation REST API that handles license information utilizing ISessionInfo.

24SevenOffice.MappedApi.Resilience

Provides a set of 24SevenOffice SOAP API wrappers covered by Polly resiliency policies for .NET Standard. Includes support for 24SevenOffice-specific session id cookies.

24SevenOffice.Decorated

Provides a decorated wrappers for 24SevenOffice SOAP and REST APIs that handles license information utilizing ISessionInfo.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.2 136 5/13/2024
3.0.0 140 5/9/2024
2.3.4 1,638 1/22/2024
2.3.0 423 11/17/2023
2.2.0 256 11/2/2023
2.1.0 234 10/31/2023
2.0.0 287 10/24/2023
1.0.22 1,496 9/21/2023
1.0.21 663 6/28/2023
1.0.20 385 6/20/2023
1.0.19 360 6/14/2023
1.0.18 397 6/13/2023
1.0.17 399 6/12/2023
1.0.16 513 5/31/2023
1.0.15 401 5/25/2023
1.0.14 367 5/25/2023
1.0.13 371 5/25/2023
1.0.12 8,511 6/3/2022
1.0.11 2,565 5/18/2022
1.0.10 2,384 4/21/2022
1.0.9 1,883 4/11/2022
1.0.8 15,311 11/3/2021
1.0.7 17,568 9/23/2021
1.0.6 2,375 3/16/2021
1.0.5 1,290 2/9/2021
1.0.4 1,983 12/18/2020
1.0.3 1,420 11/12/2020
1.0.2 1,623 11/9/2020
1.0.1 1,567 10/7/2020
1.0.0 1,570 9/30/2020
0.14.1 1,839 9/7/2020
0.14.0 1,749 6/26/2020
0.13.18 1,718 6/23/2020
0.13.17 1,748 6/16/2020
0.13.16 1,935 6/16/2020
0.13.15 1,839 6/13/2020
0.13.14 1,781 6/13/2020
0.13.13 1,759 6/12/2020
0.13.12 1,741 6/11/2020
0.13.11 1,706 6/11/2020
0.13.10 1,849 6/10/2020
0.13.9 1,734 6/9/2020
0.13.8 1,723 6/9/2020
0.13.7 1,797 6/4/2020
0.13.6 1,769 6/2/2020
0.13.5 1,815 6/2/2020
0.13.4 1,797 6/2/2020
0.13.3 1,766 6/2/2020
0.13.2 1,728 6/1/2020
0.13.1 1,734 6/1/2020
0.13.0 1,833 4/28/2020
0.12.6 1,985 3/26/2020
0.12.5 1,612 3/13/2020
0.12.4 1,589 3/12/2020
0.12.3 1,502 3/10/2020
0.12.2 1,498 3/10/2020
0.12.1 1,696 12/17/2019
0.12.0 1,495 12/9/2019
0.11.1 1,513 11/28/2019
0.11.0 1,540 11/27/2019
0.10.4 1,775 11/19/2019
0.10.3 1,669 10/3/2019
0.10.2 1,664 9/18/2019
0.10.0 1,661 9/3/2019
0.9.0 1,645 6/11/2019
0.8.0 2,512 5/14/2019
0.7.0 1,194 4/12/2019
0.6.0 901 3/26/2019
0.5.2 894 3/25/2019
0.5.0 818 2/26/2019
0.4.0 949 1/18/2019
0.3.0 987 11/23/2018
0.2.0 932 11/14/2018
0.1.2 1,145 8/14/2018
0.1.1 1,370 7/9/2018