-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added lambda + api gateway untappdAPI
- Loading branch information
Deyvid
committed
Dec 29, 2019
1 parent
0f8020b
commit cabc973
Showing
8 changed files
with
127 additions
and
113 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
zip -r package.zip lambda-untappd_api.py lib/ src/ && \ | ||
aws lambda update-function-code \ | ||
--function-name untappdApi \ | ||
--zip-file fileb://./package.zip \ | ||
--profile optate \ | ||
--region us-east-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import datetime | ||
import functools | ||
import json | ||
import logging | ||
import os | ||
import re | ||
import sys | ||
|
||
from collections import defaultdict | ||
|
||
sys.path.insert(1, './lib') | ||
sys.path.insert(1, './src') | ||
|
||
from lib.bs4 import BeautifulSoup, SoupStrainer | ||
from lib import pymysql | ||
from lib import requests | ||
from lib import yaml | ||
|
||
|
||
from scraper import * | ||
from slack import * | ||
from untappd_api import * | ||
|
||
|
||
|
||
logging.basicConfig( | ||
filename=LOG_PATH, format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO) | ||
logging.info("=== Run started ===") | ||
logger = logging.getLogger() | ||
logger.setLevel(logging.INFO) | ||
|
||
|
||
def lambda_handler(event, context): | ||
|
||
if not event['queryStringParameters'] or not event['queryStringParameters']['beercode']: | ||
return { | ||
'statusCode': 400, | ||
'msg': 'Did not get beercode', | ||
'event': event | ||
} | ||
|
||
beercode = event['queryStringParameters']['beercode'] | ||
beer = fetchBeerInfo(beercode) | ||
beer_info = fetchDougBeerInfo(beer['beer_slug']) | ||
checkin_review = fetchCheckinReview(beer_info['recent_checkin_id']) | ||
|
||
return { | ||
'statusCode': 200, | ||
'body': json.dumps({ | ||
'beer': beer, | ||
'beer_info': beer_info, | ||
'review': checkin_review | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
from scraper import logtest | ||
import datetime | ||
import functools | ||
import json | ||
import logging | ||
import requests | ||
import os | ||
import pprint | ||
import re | ||
import sys | ||
|
||
logtest('l') | ||
from collections import defaultdict | ||
|
||
sys.path.insert(1, './lib') | ||
sys.path.insert(1, './src') | ||
|
||
|
||
from lib import yaml | ||
from lib import requests | ||
from lib import pymysql | ||
from lib.bs4 import BeautifulSoup, SoupStrainer | ||
|
||
from scraper import * | ||
from slack import * | ||
|
||
from untappd_api import * | ||
|
||
|
||
pp = pprint.PrettyPrinter(indent=3) | ||
|
||
beer = fetchBeerInfo('0062067313356') | ||
# pp.pprint(beer) | ||
# print("===") | ||
beer_info = fetchDougBeerInfo(beer['beer_slug']) | ||
pp.pprint(beer_info) | ||
checkin_review = fetchCheckinReview(beer_info['recent_checkin_id']) | ||
print(checkin_review) |