Git Product home page Git Product logo

freshsales-sdk-py's Introduction

freshsales-sdk-py

Unofficial Python SDK for accessing Freshsales.

Warning: This is undergoing active development and we will accept contributions once things are a little stable.

Installation

  1. Download this project and use it (copy it in your project, etc).
  2. Install it from pip.
pip install freshsalessdk

Usage

To use this SDK you'll need these Freshsales credentials and your Freshsales domain (https://domain.freshsales.io). See official documentation for steps. We'll assume these are available via environment variables thusly:

export FS_API_KEY=xxx
export FS_DOMAIN=yyy

The following snippet shows you how to initialize and use the SDK.

from freshsalessdk import FreshsalesSDK
import os

fs = FreshsalesSDK(
    domain=os.getenv('FS_DOMAIN'),
    api_key=os.getenv('FS_API_KEY')
)

# get contact views
contact_views = fs.contacts.get_views()

# get contacts in a view
view_id = contact_views[0]['id']
contacts = fs.contacts.get_all(view_id=view_id)
contacts = list(fs.contacts.get_all_generator(view_id=view_id))

# get specific contact
contact_id = 1232
contact = fs.contacts.get(id=contact_id)

# get contact activities
activities = fs.contacts.get_activities(id=contact_id)

# get account views
account_views = fs.accounts.get_views()

# get accounts in a view
view_id = account_views[0]['id']
accounts = fs.accounts.get_all(view_id=view_id)
accounts = list(fs.accounts.get_all_generator(view_id=view_id))

# get one account
account_id = 1221
account = fs.accounts.get(id=account_id)

# get deal views
deal_views = fs.deals.get_views()

# get deals in a view
view_id = deal_views[0]['id']
deals = fs.deals.get_all(view_id=view_id)
deals = list(fs.deals.get_all_generator(view_id=view_id))

# get single deal
deal_id = 12121
deal = fs.deals.get(id=deal_id)

# get lead views
lead_views = fs.leads.get_views()

# get leads in a view
view_id = lead_views[0]['id']
leads = fs.leads.get_all(view_id=view_id)
leads = list(fs.leads.get_all_generator(view_id=view_id))

# get single lead
lead_id = 121212
lead = fs.leads.get(id=lead_id)

Code-hygiene, Tests and Code Coverage

To ensure that coding styles are followed, run the following command:

pylint --rcfile=.pylintrc freshsalessdk test

To run integration tests, you'll need to set FS_DOMAIN and FS_API_KEY environment variables. In addition, you should have a view with all objects "All Contacts" for contacts and similarly "All Accounts" for accounts and "All Deals" for deals. Then simply run:

python -m pytest

To get code coverage, run the tests thusly.

python -m pytest --cov=freshsalessdk

Which produces output like this:

---------- coverage: platform darwin, python 3.7.4-final-0 -----------
Name                             Stmts   Miss  Cover
----------------------------------------------------
freshsalessdk/__init__.py            3      0   100%
freshsalessdk/freshsalessdk.py     130      6    95%
----------------------------------------------------
TOTAL                              133      6    95%

We want to maintain more than 90% code coverage. To get lots of debugging data during tests, edit the pytest.ini file.

To get code coverage report in HTML, run this command:

python -m pytest --cov=freshsalessdk --cov-report html:cov_html

License

This project is licensed under the MIT License - see the LICENSE file for details

freshsales-sdk-py's People

Contributors

rohanfyle avatar snarayanank2 avatar

Watchers

 avatar  avatar  avatar

freshsales-sdk-py's Issues

Missing docstrings

In .pylintrc, we've disabled the following checks

  • missing-function-docstring
  • missing-module-docstring
  • missing-class-docstring

We need to fix these issues and re-enable these checks.

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.