Skip to content

SeanoNET/NetoDotNET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetoDotNET Build Status

A .NET Client wrapper for the Neto API. See Neto API Documentation

Currently WIP

Getting Started

Install the NuGet package

Install-Package NetoDotNET.Core

Configure StoreManager

var neto = new StoreManager("NETO_STORE_URL", "NETO_API_KEY", "NETO_USERNAME");

Using appsettings

  1. Copy appsettings.example.json and rename it to appsettings.json
  2. Set your NETO_STORE_URL, NETO_API_KEY, NETO_USERNAME
{
  "NETO_STORE_URL": "<YOUR_NETO_STORE_URL>",
  "NETO_API_KEY": "<YOUR_NETO_API_KEY>",
  "NETO_USERNAME": "<YOUR_NETO_USERNAME>"
}
  1. Install Microsoft.Extensions.Configuration nuget package
Install-Package Microsoft.Extensions.Configuration -Version 2.2.0

Configure StoreManager using the config values from appsettings.json

// Load from configuration
var configBuilder = new ConfigurationBuilder()
    .SetBasePath(Directory.GetCurrentDirectory())
    .AddJsonFile("appsettings.json", true, true);

var config = configBuilder.Build();

var neto = new StoreManager(config.GetSection("NETO_STORE_URL").Value, config.GetSection("NETO_API_KEY").Value, config.GetSection("NETO_USERNAME").Value);

See Microsoft.Extensions.Configuration

Implementation Status

Resource Complete
Accounting System 0%
Orders / Invoices 100%
Payments 100%
RMA 100%
Products 100%
Categories deprecated see Content 100%
Warehouses 100%
Content 100%
Currency 100%
Customers 100%
Shipping 100%
Suppliers 100%
Voucher 0%
Cart 0%
Notification Events (Webhooks) 0%

Examples

Products

List products

Retrieve products that have an id equal to 1, 2 or 3.

var filter = new GetItemFilter(new int[] { 1, 2, 3 });

Item[] result = neto.Products.GetItem(filter);

foreach (Item i in result)
{
    Console.WriteLine($"{i.ID} - {i.Name}");
}

Add a product

Add a new product.

NewItem[] item = new NewItem[] {
    new NewItem {
        Name = "My New Item",
        SKU = "1234",
        DefaultPrice = 1.00m
    }
};

var result = neto.Products.AddItem(item);

switch (result.Ack)
{
    case Ack.Success:
        foreach (var i in result.Item)
        {
            Console.WriteLine($"Created ID:{i.InventoryID} SKU: {i.SKU} at {result.CurrentTime}");
        }
        break;

    case Ack.Warning:
        foreach (var warn in result.Messages.Warning)
        {
            Console.WriteLine($"Warning: {warn.Message}");
        }
        break;
}

Update a product

Update an existing product.

Item[] item = new Item[] {
    new Item {
        Name = "My New Item - Updated",
        SKU = "1234"
    }
};

var result = neto.Products.UpdateItem(item);

switch (result.Ack)
{
    case Ack.Success:
        foreach (var i in result.Item)
        {
            Console.WriteLine($"Updated ID:{i.InventoryID} SKU: {i.SKU} at {result.CurrentTime}");
        }
        break;

    case Ack.Warning:
        foreach (var warn in result.Messages.Warning)
        {
            Console.WriteLine($"Warning: {warn.Message}");
        }
        break;
}

Categories

List categories

Retrieve a category that has an id equal to 99.

var filter = new GetCategoryFilter(99);

Retrieve a category that has a category name equal to '[Sample] Product Category'.

var filter = new GetCategoryFilter("[Sample] Product Category");
Category[] result = neto.Categories.GetCategory(filter);

foreach (Category i in result)
{
    Console.WriteLine($"{i.CategoryID} - {i.CategoryName}");
}

Create a new category

var newCategory = new Category[] {
            new Category
            {
                CategoryName = "Clothing"
            }
};

var result = neto.Categories.AddCategory(newCategory);

switch (result.Ack)
{
    case Ack.Success:
        foreach (var i in result.Category)
        {
            Console.WriteLine($"Created ID: {i.CategoryID}");
        }
        break;

    case Ack.Warning:
        foreach (var warn in result.Messages.Warning)
        {
            Console.WriteLine($"Warning: {warn.Message}");
        }
        break;
}

Update a category

Update an existing category.

var updateCategory = new Category[] {
    new Category
    {
        CategoryID = 105,
        CategoryName = "Clothing Updated"
    }
};

var result = neto.Categories.UpdateCategory(updateCategory);

switch (result.Ack)
{
    case Ack.Success:
        foreach (var i in result.Category)
        {
            Console.WriteLine($"Updated ID: {i.CategoryID}");
        }
        break;

    case Ack.Warning:
        foreach (var warn in result.Messages.Warning)
        {
            Console.WriteLine($"Warning: {warn.Message}");
        }
        break;
}

Customers

List customers

Get a customer using a username

var filter = new GetCustomerFilter("SAMPLE_John");

Customer[] result = neto.Customers.GetCustomer(filter);

foreach (Customer i in result)
{
    Console.WriteLine($"{i.ID} - {i.Username}");
}

Create a new customer

Customer[] customer = new Customer[] {
    new Customer {
        Username = "test",
        EmailAddress = "test@test.com",
        ABN = "123412341234",
        BillingAddress = new BillingAddress
        {
            BillFirstName = "Test",
            BillLastName = "Customer"
        }       
    }
};

var result = neto.Customers.AddCustomer(customer);

switch (result.Ack)
{
    case Ack.Success:
        foreach (var i in result.Customer)
        {
            Console.WriteLine($"Created Username:{i.Username} at {result.CurrentTime}");
        }
        break;

    case Ack.Warning:
        foreach (var warn in result.Messages.Warning)
        {
            Console.WriteLine($"Warning: {warn.Message}");
        }
        break;
}

Update a customer

Update an existing customer.

Customer[] customer = new Customer[] {
    new Customer {
        Username = "test",
        BillingAddress = new BillingAddress
        {
            BillFirstName = "Test Updated"
        }
    }
};

var result = neto.Customers.UpdateCustomer(customer);

switch (result.Ack)
{
    case Ack.Success:
        foreach (var i in result.Item)
        {
            Console.WriteLine($"Updated Username:{i.Username} at {result.CurrentTime}");
        }
        break;

    case Ack.Warning:
        foreach (var warn in result.Messages.Warning)
        {
            Console.WriteLine($"Warning: {warn.Message}");
        }
        break;
}

Orders

List orders

Get an order using an id

var filter = new GetOrderFilter("DEMO13-7");

Order[] result = neto.Orders.GetOrder(filter);

foreach (Order i in result)
{
    Console.WriteLine($"{i.OrderID} - {i.GrandTotal}");
}

Create a new order

AddOrder[] addOrder = new AddOrder[] {
    new AddOrder {
        Username = "test",
        ShippingMethod = "Test",
        ShipStreet1 = "123 test street",
        ShipState = "ST",
        ShipCity = "City",
        BillState = "ST",
        ShipCountry = "AU",
        ShipFirstName = "Test",
        ShipLastName = "Order",
        BillPostCode = "1234",
        BillStreet1 = "123 test street",
        ShipPostCode = "1234",
        BillCity = "City",
        BillFirstName ="Test",
        BillLastName = "Order"
    }
};

var result = neto.Orders.AddOrder(addOrder);

switch (result.Ack)
{
    case Ack.Success:
        foreach (var i in result.Order)
        {
            Console.WriteLine($"Created ID:{i.OrderID} at {result.CurrentTime}");
        }
        break;

    case Ack.Warning:
        foreach (var warn in result.Messages.Warning)
        {
            Console.WriteLine($"Warning: {warn.Message}");
        }
        break;
}

Update an order

Update an existing order.

Order[] order = new Order[] {
    new Order {
        OrderID = "DEMO12-16",
        InternalOrderNotes = "Updated"
    }
};

var result = neto.Orders.UpdateOrder(order);

switch (result.Ack)
{
    case Ack.Success:
        foreach (var i in result.Order)
        {
            Console.WriteLine($"Updated ID:{i.OrderID} at {result.CurrentTime}");
        }
        break;

    case Ack.Warning:
        foreach (var warn in result.Messages.Warning)
        {
            Console.WriteLine($"Warning: {warn.Message}");
        }
        break;
}

Other Examples

See Program.cs for more examples

Contributing

Running Tests

Add appsettings.json to NetoDotNET.Test see Using appsettingsjson

Integration tests use real data inside of your Neto store. If tests fail it may be because the resource not longer exists or is out of sync