Products API
You can use the Products API to access and manipulate a store's catalog.
Get product
Product> GetAsync(string id)
public static async Task<Retrieves the product for the given id.
Arguments
Argument | Type | Description | Required |
---|---|---|---|
id | string | ID of the product to look up. | Yes |
Returns
This call returns a Product object, and throws an APIException otherwise.
Example request
using System;
using Salesfly;
using Salesfly.Api;
using Salesfly.Exceptions;
class Program
{
static async Task Main(string[] args)
{
var apiKey = Environment.GetEnvironmentVariable("SALESFLY_APIKEY");
try
{
SalesflyClient.Init(apiKey);
var product = await Api.Product.GetAsync("1");
Console.WriteLine("Product name: " + product.Name);
} catch (ResponseException e) {
Console.WriteLine("Failed to retrieve product");
}
}
}
Add product
Product options)
public static async Task CreateAsync(Adds a new product to your catalog.
Arguments
Argument | Type | Description | Required |
---|---|---|---|
options | Product | Product options. | Yes |
Returns
This call returns a product object, and throws an APIException otherwise.
Example request
using System;
using Salesfly;
using Salesfly.Api;
using Salesfly.Exceptions;
class Program
{
static async Task Main(string[] args)
{
var apiKey = Environment.GetEnvironmentVariable("SALESFLY_APIKEY");
try
{
SalesflyClient.Init(apiKey);
var options = new Product
{
Name = "Widget",
Description = "Widget description",
Price = 9.90
};
await Api.Product.CreateAsync(options);
} catch (ResponseException e) {
Console.WriteLine("Failed to add product");
}
}
}
Update product
client.products.update(id, options)
Product options)
public static async Task UpdateAsync(string id,Updates the product for the given id.
Arguments
Argument | Type | Description | Required |
---|---|---|---|
id | string | ID of the product to look update. | Yes |
options | Product | Product options. | Yes |
Returns
This call returns a nothing if successful, and throws an APIException otherwise.
Example request
using System;
using Salesfly;
using Salesfly.Api;
using Salesfly.Exceptions;
class Program
{
static async Task Main(string[] args)
{
var apiKey = Environment.GetEnvironmentVariable("SALESFLY_APIKEY");
try
{
SalesflyClient.Init(apiKey);
var options = new Product
{
Name = "New widget"
};
await Api.Product.UpdateAsync("1", options);
} catch (ResponseException e) {
Console.WriteLine("Failed to update product");
}
}
}
Remove product
public static async Task DeleteAsync(string id)
Deletes the product for the given id.
Arguments
Argument | Type | Description | Required |
---|---|---|---|
id | string | ID of the product to delete. | Yes |
Returns
This call returns a nothing if successful, and throws an APIException otherwise.
Example request
using System;
using Salesfly;
using Salesfly.Api;
using Salesfly.Exceptions;
class Program
{
static async Task Main(string[] args)
{
var apiKey = Environment.GetEnvironmentVariable("SALESFLY_APIKEY");
try
{
SalesflyClient.Init(apiKey);
await Api.Product.DeleteAsync("1");
} catch (ResponseException e) {
Console.WriteLine("Failed to delete product");
}
}
}