Skip to content

Commit

Permalink
fix: Update rate centers (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie authored Oct 11, 2024
1 parent fe7b4ae commit 47aa0e5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion skyetel/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GEM
rack (3.1.7)
rainbow (3.1.1)
rake (13.2.1)
rate_center (0.1.6)
rate_center (0.1.7)
regexp_parser (2.9.2)
rexml (3.3.8)
rspec (3.13.0)
Expand Down
3 changes: 3 additions & 0 deletions skyetel/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module App
class Handler
def self.process(**)
new.process
rescue StandardError => e
Sentry.capture_exception(e)
raise(e)
end

def process
Expand Down
4 changes: 2 additions & 2 deletions skyetel/config/app_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ default: &default
skyetel_username: "<%= ENV['SKYETEL_USERNAME'] %>"
skyetel_password: "<%= ENV['SKYETEL_PASSWORD'] %>"
supported_cities_data_file: "<%= ENV.fetch('SUPPORTED_CITIES_DATA_FILE', 'supported_cities.csv') %>"
min_stock: "<%= ENV.fetch('MIN_STOCK', 50) %>"
max_stock: "<%= ENV.fetch('MAX_STOCK', 100) %>"
min_stock: "<%= ENV.fetch('MIN_STOCK', 0) %>"
max_stock: "<%= ENV.fetch('MAX_STOCK', 0) %>"
somleng_number_visibility: "<%= ENV.fetch('SOMLENG_NUMBER_VISIBILITY', 'public') %>"

development: &development
Expand Down
15 changes: 11 additions & 4 deletions skyetel/examples/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# Examples

## Build your own docker image

1. Edit the supported_cities.csv file with a list of supported cities
2. Build your own docker image
Edit the supported_cities.csv file with a list of supported cities and build your own docker image.

```bash
docker buildx build -t --platform linux/amd64 somleng-skyetel:example .
```

3. Run your image
## Deployment

The image is ready to be deployed to AWS Lambda and can be triggered by a scheduler.

## Standalone mode

If you're not using Lambda, you can run your image with the following command.

```bash
docker run --platform linux/amd64 --rm -it --entrypoint /bin/sh somleng-skyetel:example
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
```
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,NY,New York
US,FL,Jacksonville
4 changes: 2 additions & 2 deletions skyetel/spec/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module App
}
].to_json
)
stub_app_settings(max_stock: 2)
stub_app_settings(min_stock: 2, max_stock: 3)
stub_jsonapi_request(
:get, "https://api.somleng.org/carrier/v1/phone_numbers/stats",
response_body: file_fixture("somleng/responses/phone_number_stats.json").read
Expand All @@ -40,7 +40,7 @@ module App

App::Handler.process(event: {}, context: double("LambdaContext", as_json: {}))

expect(a_request(:post, "https://api.somleng.org/carrier/v1/phone_numbers")).to have_been_made.times(2)
expect(a_request(:post, "https://api.somleng.org/carrier/v1/phone_numbers")).to have_been_made.times(4)
end
end
end

0 comments on commit 47aa0e5

Please sign in to comment.