Giter Site home page Giter Site logo

tcgplayer / akeneo-csharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pardahlman/akeneo-csharp

0.0 1.0 0.0 128 KB

A .NET Client for Akeneo PIM's API.

Home Page: https://akeneonet.readthedocs.io

License: MIT License

C# 99.25% PowerShell 0.75%

akeneo-csharp's Introduction

Akeneo .NET Client

Build Status NuGet GitHub release Documentation Status

.NET Client to consume Akeneo PIM's RESTful API.

Overview

  • Runs on .NET Core and .NET Framework
  • Create, update and delete resources from the API
  • Upload and download media files
  • Search and filter products
  • Strongly typed attributes, search criterias and more
  • Convenience classes for creating product values

๐Ÿ“˜ Full documentation at akeneonet.readthedocs.io.

Getting started

Install NuGet package

This package is available as a release on nuget.org.

PM> Install-Package Akeneo.NET 

Create OAuth Client and Secret

Follow the official instructions to create client id and client secret

php app/console pim:oauth-server:create-client \
        --grant_type="password" \
        --grant_type="refresh_token"

Create .NET client

Create an instance of the client by providing the URL to Akeneo PIM together with client id/secret and user name and password. The client will request access token and refresh token when needed.

var client = new AkeneoClient(new ClientOptions
{
    ApiEndpoint = new Uri("http://localhost:8080"),
    ClientId = "1_3qwnpneuey80o080g0gco84ow4gsoo88skc880ssckgcg0okkg",
    ClientSecret = "3aw5l2xnvugwg0kc800g4k8s4coo80kkkc8ccs0so08gg08oc8",
    UserName = "admin",
    Password = "admdin"
});

Create, delete and update

That's it! Use the client's generic methods to create, get, update and remove Attributes, Attribute Options, Families, Categories and Products.

Note: There are some endpoints that are not implemented in the current version (1.7.3) of Akeneo PIM. For example, only products can be removed.

Programmatically define a product and specify its categories, values etc

var product = new Product
{
    Identifier = "nike_air",
    Categories = new List<string>
    {
        Category.Shoes,
        Category.Sport,
        Category.Fashion
    },
    Family = Family.Shoes,
    Values = new Dictionary<string, List<ProductValue>>
    {
        {
            "shoe_size", new List<ProductValue>
            {
                new ProductValue {Locale = Locales.EnglishUs, Data = "10"},
                new ProductValue {Locale = Locales.SwedenSwedish, Data = "42"},
            }
        },
        {
            "name", new List<ProductValue>
            {
                new ProductValue {Data = "Nike Air"}
            }
        }
    }
};

Add it to the PIM

var response = await Client.CreateAsync(product);
if (response.Code != HttpStatusCode.Created)
{
    _logger.Information(
        "Endpoint returned {statusCode}. Message: {message}, Errors: {@errors}",
        response.Code, response.Message, response.Errors
    );
})

Update it

product.Enabled = true;
var response = await Client.UpdateAsync(product);

Remove it

var response = await Client.DeleteAsync<Product>(product.Identifier);

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.