GithubHelp home page GithubHelp logo

sellsy-api's Introduction

sellsy-api

A tiny client to manage your Sellsy plateform using Python

sellsy-api is a client for the official Sellsy API in order to allow you to get and manipulate data from Sellsy plateform. The official client was written in PHP, here is a client written in pure python.

Features

  • Allows you to connect with your Oauth private API keys
  • Access to all methods listed here with only a single function
  • Error handler

Requirements

Installing

If you are using pip as PM:

# Connect to your virtualenv
$  workon projectenv

# Use pip to install the package
$  pip install sellsy_api

Or if you are using pipenv (pip needs to be installed too):

$  cd /path/to/my/project
$  pipenv install sellsy_api

Verify now if the package as been successfully installed

$  python
>> import sellsy_api # Should not raise exception

Quick Start

import os
import sellsy_api

client = sellsy_api.Client(
    'my_consumer_token',
    'my_consumer_secret',
    'my_user_token',
    'my_user_secret')

try:
    infos = client.api(method='Infos.getInfos')
    prospect = client.api(method='Prospects.getOne', params={ 'id': 55 })
except sellsy_api.SellsyAuthenticateError as e: # raised if credential keys are not valid
    print('Authentication failed ! Details : {}'.format(e))
except sellsy_api.SellsyError as e: # raised if an error is returned by Sellsy API (
    print(e)
    
prospect_name = prospect['corporation']['name']
         

You can access the full Sellsy API methods using client.api(method='', params={}).

The function returns a dictionary containing the response:

{
   "corporation":{
      "id":"55",
      "corpid":"644",
      "name":"New Prospect",
      "...":"...",
      "created":"2013-01-31 14:49:35",
      "updated":"2013-01-31 16:41:38"
   },
   "contacts":[
      {
         "id":"44",
         "prospectid":"55",
         "...":"...",
         "sign":"",
         "birthdate":"0000-00-00"
      }
   ]
}

For now, two exceptions could be raised by calling the function:

  • SellsyAuthenticateError : if one of consumer_key, consumer_secret, user_token or user_secret is invalid or if authentication failed
  • SellsyError: Sellsy API could return error depends on unexcistant ressource or method not valid for example. So this exception is raised and you can access the exception infos to have more details or error : {code} - {detail} where code if one of code error described here (in Error Process tab).
  • COMING SOON: more exceptions to catch precise errors through distinct exceptions (example: SellsyRessourceNotFound if the ressource you asked for does not exists) and not only through a unique SellsyError with different messages...

Links

License

sellsy-api's People

Contributors

annouar 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.