Skip to content

Commit

Permalink
fix: Handle zero max stock (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie authored Oct 11, 2024
1 parent f7064af commit 9fb3fe8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
20 changes: 12 additions & 8 deletions skyetel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@

[![Build](https://github.com/somleng/somleng-integrations/actions/workflows/skyetel.yml/badge.svg)](https://github.com/somleng/somleng-integrations/actions/workflows/skyetel.yml)

This integration connects [Skyetel](https://skyetel.com/) to [Somleng](https://www.somleng.org/docs.html).

## Features

* Automatically purchase DIDs from Skyetel and add them to your Somleng carrier account.
This integration runs on a schedule and automatically orders DIDs from [Skyetel](https://skyetel.com/) and adds them to [Somleng](https://www.somleng.org/docs.html). It keeps the stock levels between `MIN_STOCK` and `MAX_STOCK` for each city configured in the `supported_cities.csv` file.

## Configuration

Add configuration parameters here.
| Variable | Description | Example | Required | Default |
| -------------------------- | --------------------------------------------------------- | ---------------------- | -------- | ---------------------- |
| SOMLENG_API_KEY | Somleng Carrier API Key SID | change-me | true | none |
| SKYETEL_USERNAME | Skyetel API Username Token | change-me | true | none |
| SKYETEL_PASSWORD | Skyetel API Password | change-me | true | none |
| MIN_STOCK | Minimum number of phone numbers to maintain per city | 50 | true | 0 |
| MAX_STOCK | Maximum number of phone numbers to maintain per city | 100 | true | 0 |
| SUPPORTED_CITIES_DATA_FILE | Name of the CSV file containing supported cities | `supported_cities.csv` | false | `supported_cities.csv` |
| SOMLENG_NUMBER_VISIBILITY | Visibility of created phone number. `public` or `private` | `public` | false | public |

## Usage

Add usage instructions here.
See [examples](https://github.com/somleng/somleng-integrations/tree/develop/skyetel/examples).

## Deployment

The [docker image](https://github.com/somleng/somleng-integrations/pkgs/container/somleng-skyetel) is available on Github.
The [docker image](https://github.com/somleng/somleng-integrations/pkgs/container/somleng-skyetel) is automatically configured for deployment to AWS Lambda.
2 changes: 1 addition & 1 deletion skyetel/app/workflows/generate_shopping_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def call
)
current_stock = inventory_item ? inventory_item.quantity : 0

next if current_stock >= min_stock
next if max_stock.zero? || current_stock >= min_stock

result << ShoppingList::LineItem.new(
country: city.country,
Expand Down
2 changes: 1 addition & 1 deletion skyetel/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ The image is ready to be deployed to AWS Lambda and can be triggered by a schedu
If you're not using Lambda, you can run your image with the following command.

```bash
docker run --platform linux/amd64 --rm -it -e APP_ENV=production -e SOMLENG_API_KEY='somleng-carrier-api-key' SOMLENG_API_KEY='somleng-carrier-api-key' -e SKYETEL_USERNAME='skyetel-username' -e SKYETEL_PASSWORD='skyetel-password' -e MAX_STOCK=2 --entrypoint ruby somleng-skyetel:example -r ./app.rb -e App::Handler.process
docker run --platform linux/amd64 --rm -it -e APP_ENV=production -e SOMLENG_API_KEY='somleng-carrier-api-key' SOMLENG_API_KEY='somleng-carrier-api-key' -e SKYETEL_USERNAME='skyetel-username' -e SKYETEL_PASSWORD='skyetel-password' -e MIN_STOCK=2 -e MAX_STOCK=2 --entrypoint ruby somleng-skyetel:example -r ./app.rb -e App::Handler.process
```
2 changes: 1 addition & 1 deletion skyetel/examples/supported_cities.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
country,region,name
US,FL,Jacksonville
US,WA,Seattle

0 comments on commit 9fb3fe8

Please sign in to comment.