Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fylein/fyle-netsuite-api

Backend repository for Fyle <> Netsuite integration
https://github.com/fylein/fyle-netsuite-api

team-integrations

Last synced: about 2 months ago
JSON representation

Backend repository for Fyle <> Netsuite integration

Awesome Lists containing this project

README

        

# Fyle NetSuite API
Django Rest Framework API for Fyle Netsuite Integration.

### Setup

* Add and update the `fyle_integrations_imports` submodule
```bash
$ git submodule init
$ git submodule update
```

* Download and install Docker desktop for Mac from [here.](https://www.docker.com/products/docker-desktop)

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

* Rename docker-compose.yml.template to docker-compose.yml

```
$ mv docker-compose.yml.template docker-compose.yml
```

* Setup environment variables in docker_compose.yml

```yaml
environment:
SECRET_KEY: thisisthedjangosecretkey
ALLOWED_HOSTS: "*"
DEBUG: "False"
API_URL: http://localhost:8000/api
DATABASE_URL: postgres://postgres:postgres@db:5432/netsuite_db
FYLE_BASE_URL:
FYLE_CLIENT_ID:
FYLE_CLIENT_SECRET:
FYLE_TOKEN_URI:
NS_CONSUMER_KEY:
NS_CONSUMER_SECRET:
```

* 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 db psql -h db -U postgres netsuite_db
```

* To tail the logs a service you can do

```
docker-compose logs -f
```

* 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
```

### Running Tests

* Add the following environment variables to setup.sh file

```
export API_URL='http://localhost:8000/api'
export FYLE_BASE_URL='
export FYLE_CLIENT_ID=''
export FYLE_CLIENT_SECRET=''
export FYLE_REFRESH_TOKEN=''
export FYLE_TOKEN_URI='fyle_token_uri'
export NS_ACCOUNT_ID=''
```
* Run the following commands

```
docker-compose -f docker-compose-pipeline.yml build
docker-compose -f docker-compose-pipeline.yml up -d
docker-compose -f docker-compose-pipeline.yml exec api pytest tests/
```

* 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
```

* You should see output like this

```
Sravans-MacBook-Air:fyle-netsuite-api sravankumar$ pytest apps/users/tests/

Creating test database for alias 'default'...
System check identified no issues (0 silenced).
......
----------------------------------------------------------------------
Ran 6 tests in 15.670s

OK
Destroying test database for alias 'default'...
```