Giter Site home page Giter Site logo

fyle-qbo-api's Introduction

Fyle QBO API

Django Rest Framework API for Fyle Quickbooks Online Integration

Setup

  • Download and install Docker desktop for Mac from here.

  • If you're using a linux machine, please download docker according to the distrubution you're on.

  • Copy docker-compose.yml.template as docker-compose.yml and add required secrets

    $ cp docker-compose.yml.template docker-compose.yml
    
  • Setup environment variables in docker_compose.yml

    environment:
      SECRET_KEY: thisisthedjangosecretkey
      ALLOWED_HOSTS: "*"
      DEBUG: "False"
      API_URL: http://localhost:8000/api
      DATABASE_URL: postgres://postgres:postgres@db:5432/qbo_db
      FYLE_BASE_URL:
      FYLE_CLIENT_ID:
      FYLE_CLIENT_SECRET:
      FYLE_TOKEN_URI:
      QBO_CLIENT_ID:
      QBO_CLIENT_SECRET:
      QBO_REDIRECT_URI:
      QBO_TOKEN_URI:
      QBO_ENVIRONMENT:
  • Build docker images

    docker-compose build api qcluster
    
  • Run docker containers

    docker-compose up -d db api qcluster
    
  • The database can be accessed by this command, on password prompt type postgres

    docker-compose run -e PGPASSWORD=postgres db psql -h db -U postgres qbo_db
    
  • To tail the logs of a service you can do

    docker-compose logs -f <api / qcluster>
    
  • To stop the containers

    docker-compose stop api qcluster
    
  • To restart any containers - would usually be needed with qcluster after you make any code changes

    docker-compose restart qcluster
    
  • To run bash inside any container for purpose of debugging do

    docker-compose exec api /bin/bash
    
  • To restart qcluster automatically after code changes, follow the steps below:

    pip install -r requirements.dev.txt
    python q_cluster_watcher.py
    

Running Tests

  • Add this to you Dockerfile before the # set environment variables step:

    # install the requirements from the requirements.txt file via git
    RUN apt-get update && apt-get install git -y --no-install-recommends
    
    ARG CI
    RUN if [ "$CI" = "ENABLED" ]; then \
            apt-get install lsb-release gnupg2 wget -y --no-install-recommends; \
            apt-cache search postgresql | grep postgresql; \
            sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'; \
            wget --no-check-certificate --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - ; \
            apt -y update; \
            apt-get install postgresql-14 -y --no-install-recommends; \
        fi
    
  • Add the following environment variables to setup.sh file

    export FYLE_BASE_URL=<fyle base url>
    export FYLE_CLIENT_ID=<client_id>
    export FYLE_CLIENT_SECRET=<client_secret>
    export FYLE_REFRESH_TOKEN=<refresh_token>
    export FYLE_TOKEN_URI=<fyle token uri>
    export QBO_CLIENT_ID=<qbo client id>
    export QBO_CLIENT_SECRET=<qbo client secret>
    export QBO_REDIRECT_URI=<qbo redirect uri>
    export QBO_TOKEN_URI=<qbo token uri>
    export QBO_ENVIRONMENT=<qbo environment>
    
  • Run the following commands

    1. source setup.sh
    2. docker-compose -f docker-compose-pipeline.yml build
    3. docker-compose -f docker-compose-pipeline.yml up -d
    4. docker-compose -f docker-compose-pipeline.yml exec api pytest tests/

    If the test_check_toekn_health() test fails then generate new refresh tokens and place them in test_refresh_token.txt file

  • Run the following command to update tests SQL fixture (tests/sql_fixtures/reset_db_fixtures/reset_db.sql)

    docker-compose -f docker-compose-pipeline.yml exec api /bin/bash tests/sql_fixtures/migration_fixtures/create_migration.sh
    

Working with pre commit hooks

  • Run below command to install pre commit, if it is not already installed. pre commit version must be at least 3.3.1.
brew install pre-commit
  • To set up pre commit hook in your local development environment run below command. This step may take a little longer to complete. Once done pre commit hooks will automatically run on changed files when you do git commit.
pre-commit install --install-hooks
  • To run pre commit hooks on all files run below command
pre-commit run --all-files
  • To skip pre commit hooks in case of emergency
git commit --no-verify -m "Commit_message"

fyle-qbo-api's People

Contributors

anishfyle avatar ashutosh619-sudo avatar ashwin1111 avatar chatterjeeshekhar avatar dependabot[bot] avatar dhaaranicit avatar harshithaputtaswamy avatar hrishabh17 avatar jayachandhar avatar kirtigautam avatar labhvam5 avatar nileshpant1999 avatar ruuushhh avatar shreyanshs7 avatar shwetabhk avatar sravanksk avatar vishalpandeynits avatar

Watchers

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