# .NET Library

Integrate the Integrated POS into your application using the .NET library.

## Installation

1. Place the `PosIntegrado.Api.dll` and `PosIntegrado.Api.xml` files provided in the release package into your project's `libs/` directory.
2. Add a reference to the `PosIntegrado.Api.dll` file within your project.

## Key namespaces

Include the following key namespaces in your code:

```csharp
using PosIntegrado.Api;
using PosIntegrado.Api.Abstractions;
```

## Connector creation

Create a connector instance to communicate via USB or HTTP (Network) using the respective methods:

### Output HTTP connection

```csharp
var connector = Connector.CreateHttp("192.168.1.100", 8080);
```

### Output USB connection

```csharp
var connector = Connector.CreateUsb("COM3");
```

## Error handling

Check the `Result<T>` pattern to handle expected business logic rather than relying on exceptions:

```csharp
var response = connector.SomeOperation(request);

if (response.IsSuccess)
{
    // Proceed with response.Value
}
else
{
    // Handle error with response.Error
}
```

## Sale flow example

Review the following example demonstrating the structure of a single-step sale flow:

```csharp
// 1. Initialize connector
var connector = Connector.CreateHttp("192.168.1.100", 8080);

// 2. Build the request
var request = new SaleRequest 
{
    Amount = 15000,
    SaleType = SaleType.Card,
    PrintOnPos = true
};

// 3. Execute the sale
var result = connector.Sale(request);

// 4. Handle the result
if (result.IsSuccess)
{
    var saleResponse = result.Value;
    Console.WriteLine($"Sale Approved: {saleResponse.AuthorizationCode}");
}
else
{
    Console.WriteLine($"Sale Failed: {result.Error.Message}");
}
```

## Next steps

* Run the full flow end to end with the [Quick Start](/en/integrated-pos/first-steps-pos/quickstart-integrated-pos) guide.
* Look up every method signature and parameter in the [Methods and Parameters Reference](/en/integrated-pos/reference/methods-parameters).