Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bank_card_payment/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM jfloff/alpine-python
COPY test_dwolla.py /test_dwolla.py
COPY requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN chmod +x /test_dwolla.py
ENTRYPOINT ["/test_dwolla.py"]
1 change: 1 addition & 0 deletions bank_card_payment/app/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dwollav2>=1.3.0
20 changes: 20 additions & 0 deletions bank_card_payment/app/test_dwolla.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
import dwollav2
import sys
payment_id = sys.argv[1]


client = dwollav2.Client(
key = 'XfEX77omgP2XNRjI04wQOA3nusm6xrJy7xRoiulVLdh4hxhwDS',
secret = 'HhpRzVXYX3t4NMpcwS7pC4XgJsqXi5E2DQIBNWevGGwvQOxpda',
environment = 'sandbox'
)

app_token = client.Auth.client()

payment_info = app_token.get('https://api-sandbox.dwolla.com/transfers/%s' % payment_id)
amount = '%(value)s %(currency)s' % (payment_info.body['amount'])
payer_ID = payment_info.body['id']
print(amount,payer_ID)


29 changes: 29 additions & 0 deletions bank_card_payment/chain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"default": "kovan",
"chains": {
"dev": {
"host": "http://localhost:8545",
"sms": "http://localhost:5000",
"id": "17",
"hub": "0x60E25C038D70A15364DAc11A042DB1dD7A2cccBC"
},
"ropsten": {
"host": "https://ropsten.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7",
"id": "3"
},
"rinkeby": {
"host": "https://rinkeby.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7",
"id": "4"
},
"kovan": {
"host": "https://kovan.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7",
"id": "42",
"sms": "https://sms-kovan.iex.ec"
},
"mainnet": {
"host": "https://mainnet.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7",
"id": "1",
"sms": "https://sms-mainnet.iex.ec"
}
}
}
5 changes: 5 additions & 0 deletions bank_card_payment/deployed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"app": {
"42": "0x4f29393e0e9842DdEaf49a0AC2e7fc66CFA00a33"
}
}
35 changes: 35 additions & 0 deletions bank_card_payment/iexec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"description": "My iExec ressource description, must be at least 150 chars long in order to pass the validation checks. Describe your application, dataset or workerpool to your users",
"license": "MIT",
"author": "?",
"social": {
"website": "?",
"github": "?"
},
"logo": "logo.png",
"buyConf": {
"params": "",
"tag": "0x0000000000000000000000000000000000000000000000000000000000000000",
"trust": "0",
"callback": "0x0000000000000000000000000000000000000000"
},
"app": {
"owner": "0xe597d6fD63A56e645DbD680C56599038e5E02Be3",
"name": "BankCardPayment",
"type": "DOCKER",
"multiaddr": "registry.hub.docker.com/thomasvangurp/price-feed:1.0.0",
"checksum": "0x78495ddcb012dd32091cfa80a757c240d3dcc0366db64869c902e6802b043daa",
"mrenclave": ""
},
"order": {
"apporder": {
"app": "0x4f29393e0e9842DdEaf49a0AC2e7fc66CFA00a33",
"appprice": "0",
"volume": "1000000",
"tag": "0x0000000000000000000000000000000000000000000000000000000000000000",
"datasetrestrict": "0x0000000000000000000000000000000000000000",
"workerpoolrestrict": "0x0000000000000000000000000000000000000000",
"requesterrestrict": "0x0000000000000000000000000000000000000000"
}
}
}
15 changes: 15 additions & 0 deletions bank_card_payment/orders.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"42": {
"apporder": {
"app": "0x4f29393e0e9842DdEaf49a0AC2e7fc66CFA00a33",
"appprice": "0",
"volume": "1000000",
"tag": "0x0000000000000000000000000000000000000000000000000000000000000000",
"datasetrestrict": "0x0000000000000000000000000000000000000000",
"workerpoolrestrict": "0x0000000000000000000000000000000000000000",
"requesterrestrict": "0x0000000000000000000000000000000000000000",
"salt": "0x911dc3bcbd5991abd8e56cfb0d51889b51045425b8e7771e78d179cdb5de7fa4",
"sign": "0xf26c19dfc30a01701d95be4acf87198222d9081f33ce99589a445358c325ad814a0467f3ae0702f101418ac05208e33139a6f2243ea2e77951fc60512978342f1c"
}
}
}
1 change: 1 addition & 0 deletions bank_card_payment/smart-contract
Submodule smart-contract added at b7cd4e
7 changes: 7 additions & 0 deletions weather_api/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM jfloff/alpine-python
COPY config.ini /config.ini
COPY darkskyp_api_call.py /darkskyp_api_call.py
COPY requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN chmod +x /darkskyp_api_call.py
ENTRYPOINT ["/darkskyp_api_call.py"]
6 changes: 6 additions & 0 deletions weather_api/app/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[openweathermap]
api=c1b5213b85fc28611f3a462ac85000f4
[darksky]
api=28ea66e419c8820705d5496cce3ac0ae
[opencagedata]
api=812c8fc8222b49a0b650fea303db6f5c
54 changes: 54 additions & 0 deletions weather_api/app/darkskyp_api_call.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
import configparser
import requests
import sys
import ciso8601
import time
from opencage.geocoder import OpenCageGeocode

def get_api_key(api_name):
config = configparser.ConfigParser()
config.read('config.ini')
return config[api_name]['api']

def get_unixtime(date):
"""return unixtime for date"""
ts = ciso8601.parse_datetime(date)
# to get time in seconds:
return int(time.mktime(ts.timetuple()))


def get_coordinates(api_key, location):
geocoder = OpenCageGeocode(api_key)
result = geocoder.geocode(location, no_annotations='1')
if result and len(result):
longitude = result[0]['geometry']['lng']
latitude = result[0]['geometry']['lat']
else:
sys.stderr.write("not found: %s\n" % location)
return latitude,longitude

def get_weather(api_key, lat, long, date):
weatherdict = {'api_key':api_key,'start':date,'lat':lat,'long':long}
url = "https://api.darksky.net/forecast/{api_key}/{lat},{long},{start}?exclude=currently,flags,hourly".format(**weatherdict)
r = requests.get(url)
return r.json()


def main():
if len(sys.argv) != 3:
exit("Usage: {} DATE LOCATION".format(sys.argv[0]))
date = sys.argv[1]
epoch_time = str(get_unixtime(date))
location = sys.argv[2]

api_key_ds = get_api_key('darksky')
api_key_oc = get_api_key('opencagedata')
lat,long = get_coordinates(api_key_oc, location)
weather = get_weather(api_key_ds, lat,long, epoch_time)

print(weather['daily']['data'][0]['summary'])


if __name__ == '__main__':
main()
41 changes: 41 additions & 0 deletions weather_api/app/openweathermap_api_call.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3
import configparser
import requests
import sys
import ciso8601
import time

def get_api_key():
config = configparser.ConfigParser()
config.read('config.ini')
return config['openweathermap']['api']

def get_unixtime(date):
"""return unixtime for date"""
ts = ciso8601.parse_datetime(date)
# to get time in seconds:
return int(time.mktime(ts.timetuple()))

def get_weather(api_key, location, date):
weatherdict = {'api_key':api_key,'start':date,'city ID':location}
url = "http://history.openweathermap.org/data/2.5/history/city?q={city ID}&type=hour&start={start}&cnt=1".format(**weatherdict)
# url = "https://api.openweathermap.org/data/2.5/weather?q={}&units=metric&appid={}".format(location, api_key)
r = requests.get(url)
return r.json()


def main():
if len(sys.argv) != 3:
exit("Usage: {} LOCATION".format(sys.argv[0]))
date = sys.argv[1]
epoch_time = str(get_unixtime(date))
location = sys.argv[2]

api_key = get_api_key()
weather = get_weather(api_key, location, epoch_time)

print(weather['weather'][0]['description'])


if __name__ == '__main__':
main()
3 changes: 3 additions & 0 deletions weather_api/app/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
requests
ciso8601==1.0.1
opencage
29 changes: 29 additions & 0 deletions weather_api/chain.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"default": "kovan",
"chains": {
"dev": {
"host": "http://localhost:8545",
"sms": "http://localhost:5000",
"id": "17",
"hub": "0x60E25C038D70A15364DAc11A042DB1dD7A2cccBC"
},
"ropsten": {
"host": "https://ropsten.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7",
"id": "3"
},
"rinkeby": {
"host": "https://rinkeby.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7",
"id": "4"
},
"kovan": {
"host": "https://kovan.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7",
"id": "42",
"sms": "https://sms-kovan.iex.ec"
},
"mainnet": {
"host": "https://mainnet.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7",
"id": "1",
"sms": "https://sms-mainnet.iex.ec"
}
}
}
5 changes: 5 additions & 0 deletions weather_api/deployed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"app": {
"42": "0x5f9049B4461Be705eCf75688042e3593f3E2eD42"
}
}
35 changes: 35 additions & 0 deletions weather_api/iexec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"description": "My iExec ressource description, must be at least 150 chars long in order to pass the validation checks. Describe your application, dataset or workerpool to your users",
"license": "MIT",
"author": "?",
"social": {
"website": "?",
"github": "?"
},
"logo": "logo.png",
"buyConf": {
"params": "",
"tag": "0x0000000000000000000000000000000000000000000000000000000000000000",
"trust": "0",
"callback": "0x0000000000000000000000000000000000000000"
},
"app": {
"owner": "0xe597d6fD63A56e645DbD680C56599038e5E02Be3",
"name": "WeatherOracle",
"type": "DOCKER",
"multiaddr": "registry.hub.docker.com/thomasvangurp/weather_oracle:1.0.0",
"checksum": "0xcbeeaa8491196182d0160b8b60e96175ba50c19476201074dc93bd0b980d4ad0",
"mrenclave": ""
},
"order": {
"apporder": {
"app": "0x5f9049B4461Be705eCf75688042e3593f3E2eD42",
"appprice": "0",
"volume": "1000000",
"tag": "0x0000000000000000000000000000000000000000000000000000000000000000",
"datasetrestrict": "0x0000000000000000000000000000000000000000",
"workerpoolrestrict": "0x0000000000000000000000000000000000000000",
"requesterrestrict": "0x0000000000000000000000000000000000000000"
}
}
}
15 changes: 15 additions & 0 deletions weather_api/orders.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"42": {
"apporder": {
"app": "0x5f9049B4461Be705eCf75688042e3593f3E2eD42",
"appprice": "0",
"volume": "1000000",
"tag": "0x0000000000000000000000000000000000000000000000000000000000000000",
"datasetrestrict": "0x0000000000000000000000000000000000000000",
"workerpoolrestrict": "0x0000000000000000000000000000000000000000",
"requesterrestrict": "0x0000000000000000000000000000000000000000",
"salt": "0xd8f63c3065e0fcca5374c2e85ec222cfa3ad92dcb465b3b8b19dd2f0982e7bdb",
"sign": "0xeb86d1560702069a210c1caf682f1a336096b5b3c316da2eecff42107a622cad2bf72fbf6e54f28dff42f07e3d56083d5d7e183aed26464c00e8ede95f1546291b"
}
}
}
1 change: 1 addition & 0 deletions weather_api/smart-contract
Submodule smart-contract added at b7cd4e