Purchase class

class starfish.purchase.Purchase(agent, listing, purchase_id, account)

Bases: starfish.purchase.purchase_base.PurchaseBase

This class is returned by purchasing an asset uning the Listing.purchase() method.

Parameters
  • agent (Agent) – agent that was used create this object.

  • listing (Listing) – Listing used to purchase this asset.

  • purchase_id (str) – purchase_id used to buy this asset.

property consume_asset

Consume a purchased asset. This call will try to download the asset data.

You can call the is_purchased() property before hand to check that you have already purchased this asset.

Parameters

download_path (str) – Path to download the asset files too.

Returns

data returned from the asset , or False

Type

object or False

property get_type
property is_completed
Currently the same as is_purchase_valid, but renamed to be more meaningfull

with the wait_for_completion method.

Returns

boolean True if the purchase has completed and finished, else False if the purchase is invalid or the has not finished.

property is_purchase_valid

Test to see if this purchased asset can be accessed and is valid.

Returns

boolean value if this asset has been purchased

Type

boolean

property is_purchased
Returns

True if this asset is a purchased asset.

Type

boolean

wait_for_completion(timeout_seconds=60)

Some purchases ( squid ), require to wait for the smart contracts to complete This method will call the underlying agent to wait for the purchase to complete

Parameters

timeout_seconds (integer) – Optional seconds to waif to purchase to complete. Default: 60 seconds

Returns

True if successfull or an error message if failed

Type

string or boolean

Raises

OceanPurchaseError – if the correct events are not received