def get_order_payloads(order): items = [ ga.item( ol.product_name, ol.unit_price.gross, quantity=ol.quantity, item_id=ol.product_sku) for ol in order] return ga.transaction( order.id, items, revenue=order.total.gross, tax=order.total.tax, shipping=order.shipping_price.net)
def get_task_payloads(task): items = [ ga.item(ol.skill_name, ol.unit_price.gross, quantity=ol.quantity, item_id=ol.skill_sku) for ol in task ] return ga.transaction(task.id, items, revenue=task.total.gross, tax=task.total.tax, delivery=task.delivery_price.net)
def get_order_payloads(order): items = [ ga.item( str(order_line), order_line.unit_price.gross, quantity=order_line.quantity, item_id=order_line.product_sku, ) for order_line in order ] return ga.transaction( order.id, items, revenue=order.total.gross, tax=order.total.tax, shipping=order.shipping_price.net, )
def single_item_list(): return [item('item-01', Money(10, 'USD'))]
def test_required_params(): data = item('item-01', Money(10, 'USD')) assert data == {'t': 'item', 'in': 'item-01', 'ip': '10', 'cu': 'USD'}
def test_extra_params(): data = item('item-01', Money(10, 'USD'), ex='extra') assert data == { 't': 'item', 'in': 'item-01', 'ip': '10', 'cu': 'USD', 'ex': 'extra'}
def test_optional_params(): data = item('item-01', Money(10, 'USD'), item_id='it01', category='cat') assert data == { 't': 'item', 'in': 'item-01', 'ip': '10', 'cu': 'USD', 'ic': 'it01', 'iv': 'cat'}
def test_quantity(): data = item('item-01', Money(10, 'USD'), quantity=2) assert data == { 't': 'item', 'in': 'item-01', 'ip': '10', 'cu': 'USD', 'iq': '2'}