"""Three authored consumers of an original JSON-shaped payload; no external APIs."""
import csv,io
REQUIRED={'customer_id','amount_minor','currency'}
v1={'customer_id':'C17','amount_minor':1200,'currency':'GBP'}
v2={'customer_id':'C17','reference':'PO-7','amount_minor':1200,'currency':'GBP'}
def permissive(p):
    return tuple(p[k] for k in ('customer_id','amount_minor','currency'))
def strict(p):
    if set(p)!=REQUIRED:raise ValueError('unexpected or missing fields')
    return permissive(p)
def positional_export(p):
    out=io.StringIO();w=csv.writer(out)
    w.writerow(['customer_id','amount_minor','currency']);w.writerow(list(p.values()))
    return out.getvalue()
assert permissive(v1)==permissive(v2)
try:strict(v2)
except ValueError:pass
else:raise AssertionError('strict consumer accepted extra field')
rows=list(csv.reader(io.StringIO(positional_export(v2))))
assert len(rows[0])==3 and len(rows[1])==4
assert rows[1][1]=='PO-7' and rows[0][1]=='amount_minor'
assert strict(v1)==('C17',1200,'GBP')
print('5/5 authored consumer assertions passed.')
print(positional_export(v2),end='')
