GithubHelp home page GithubHelp logo

markbeazley / prestasharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bukimedia/prestasharp

0.0 1.0 0.0 460 KB

CSharp .Net client library for the PrestaShop API via web service

C# 100.00%

prestasharp's Introduction

PrestaSharp

CSharp .Net client library for the PrestaShop API via web service

Introduction

A simple .Net REST client written in C# for the Prestashop API. PrestaSharp uses the RestSharp library to consume the Prestashop services.

Basic usage

  1. Initiate a client instance:
	string BaseUrl = "http://www.myweb.com/api";
	string Account = "ASDLKJOIQWEPROQWUPRPOQPPRQOW";
	string Password = "";
	ManufacturerFactory ManufacturerFactory = new ManufacturerFactory(BaseUrl, Account, Password);
  1. Perform CRUD actions through the client:
	Bukimedia.PrestaSharp.Entities.manufacturer Manufacturer = ManufacturerFactory.Get(6);
	Manufacturer.name = "Iron Maiden";
	Manufacturer.active = 1;        
	ManufacturerFactory.Add(Manufacturer);
	ManufacturerFactory.Update(Manufacturer);
	ManufacturerFactory.Delete(Manufacturer);
  1. Add an image:
	Bukimedia.PrestaSharp.Entities.product MyProduct = new Bukimedia.PrestaSharp.Entities.product()
	MyProduct = ProductFactory.Add(MyProduct)
	ImageFactory.AddProductImage((long)MyProduct.id, "C:\\MyImage.jpg");

Advanced usage

  1. Get all. This sample retrieves the list of manufacturers:
	List<manufacturer> manufacturers = ManufacturerFactory.GetAll();
  1. Get ids. This sample retrieves the list of the manufacturer ids:
	List<long> ids = ManufacturerFactory.GetIds();
  1. Get by filter. This sample retrieves the list of manufacturers which name is "Metallica":
	Dictionary<string, string> dtn = new Dictionary<string, string>();
	dtn.Add("name", "Metallica");
	List<manufacturer> manufacturers = ManufacturerFactory.GetByFilter(dtn, null, null);
  1. Get by filter with wildcards. This sample retrieves the manufacturers which name starts with "Metall":
	Dictionary<string, string> dtn = new Dictionary<string, string>();
	dtn.Add("name", "[Metall]%");
	List<manufacturer> manufacturers = ManufacturerFactory.GetByFilter(dtn, null, null);
  1. Get ids by filter. This sample retrieves the list of the manufacturers ids which name is "Metallica":
	Dictionary<string, string> dtn = new Dictionary<string, string>();
	dtn.Add("name", "Metallica");
	List<long> ids = ManufacturerFactory.GetIdsByFilter(dtn, null, null);
  1. Get ids by filter with wildcards. This sample retrieves the list of the manufacturers ids which name starts with "Metall":
	Dictionary<string, string> dtn = new Dictionary<string, string>();
	dtn.Add("name", "[Metall]%");
	List<long> ids = ManufacturerFactory.GetIdsByFilter(dtn, null, null);
  1. Get by complex filter. This sample retrieves the top five manufacturers in ascendent sorting which name starts with "Metall":
	Dictionary<string, string> dtn = new Dictionary<string, string>();
	dtn.Add("name", "[Metall]%");
	List<manufacturer> manufacturers = ManufacturerFactory.GetByFilter(dtn, "name_ASC", "5");
  1. Get by filter for pagination. This sample retrieves the top five manufacturers from tenth position in ascendent sorting which name starts with "Metall":
	Dictionary<string, string> dtn = new Dictionary<string, string>();
	dtn.Add("name", "[Metall]%");
	List<manufacturer> manufacturers = ManufacturerFactory.GetByFilter(dtn, "name_ASC", "[9,5]");
  1. Get by filter by range date. This sample retrieves the orders in a date range:
	DateTime StartDate = new DateTime (2016, 1, 1);
	DateTime StartDate = new DateTime (2016, 1, 31);
	Dictionary<string, string> filter = new Dictionary<string, string>();
    string dFrom = string.Format("{0:yyyy-MM-dd HH:mm:ss}", StartDate);
    string dTo = string.Format("{0:yyyy-MM-dd HH:mm:ss}", EndDate);
    filter.Add("date_add", "[" + dFrom + "," + dTo + "]");
    List<long> PrestaSharpOrderIds = this.OrderFactory.GetIdsByFilter(filter, "id_DESC", null);

Supported resources

  • Address
  • Carriers
  • Carts
  • Categories
  • Combinations
  • Currencies
  • Customers
  • Customer Messages
  • Customer Threads
  • Guests
  • Groups
  • Images
  • Languages
  • Manufacturers
  • Orders
  • Order Carriers
  • Order Cart Rules
  • Order Histories
  • Order Invoices
  • Order States
  • Products
  • Product Features
  • Product Feature Values
  • Product Options
  • Product Option Values
  • Product Suppliers
  • Shops
  • Specific Prices
  • Specific Price Rules
  • States
  • Stock Availables
  • Tags
  • Tax
  • Tax Rule
  • Tax Rule Groups
  • Warehouse
  • Zones

Supported actions

  • Create
  • Read
  • Update
  • Delete

Roadmap

  • Add other resources

License

PrestaSharp is GNU General Public License (GPL)

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantabilty or fitness for a particular purpose. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Bukimedia reserves the right to mention of companies or individuals who use this software.

Copyright (C) 2016 Bukimedia

prestasharp's People

Contributors

eduleonpavon avatar ldellacherie avatar dakmorsd avatar gryzzli avatar markbeazley avatar adastier avatar ologesa avatar jakobt avatar newturko avatar scherer-michael avatar krpec avatar bryant1410 avatar shemes avatar toldotechnik avatar luisalb avatar

Watchers

 avatar

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.