From 3e630ae3e551d9e97fa6be8fedea97a432e57e0a Mon Sep 17 00:00:00 2001 From: Daniel Von Fange Date: Thu, 17 May 2018 06:46:46 -0400 Subject: [PATCH 1/2] Document review api --- source/includes/resources/purchases.md | 10 ++++-- source/includes/resources/reviews.md | 47 ++++++++++++++++++++++++++ source/index.html.md | 1 + 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 source/includes/resources/reviews.md diff --git a/source/includes/resources/purchases.md b/source/includes/resources/purchases.md index 67e55be..83d3108 100644 --- a/source/includes/resources/purchases.md +++ b/source/includes/resources/purchases.md @@ -61,7 +61,8 @@ The Purchase will change to the **"buyer_pending"** stage. A 21 day timer will s > To mark a purchase as received ```javascript -const transaction = await origin.purchases.buyerConfirmReceipt(purchaseAddress) +const review = {rating: 5, reviewText: "Prompt shipping!" } +const transaction = await origin.purchases.buyerConfirmReceipt(purchaseAddress, review) await transaction.isFinished() ``` @@ -69,12 +70,15 @@ This method is **called by the buyer** when the Purchase is in the **"buyer_pend The Purchase will change to the **"seller_pending"** stage. +A rating from 1 to 5 is required as a part of a review. Review text is optional. + ## sellerGetPayout > To mark a purchase as received ```javascript -const transaction = await origin.purchases.sellerGetPayout(purchaseAddress) +const review = {rating: 5, reviewText: "Good buyer!" } +const transaction = await origin.purchases.sellerGetPayout(purchaseAddress, review) await transaction.isFinished() ``` @@ -84,6 +88,8 @@ The seller will receive all eth value on the contract. The Purchase will change to the **"complete"** stage. +A rating from 1 to 5 is required as a part of a review. Review text is optional. + ## getLogs > To get the transaction logs for a purchase diff --git a/source/includes/resources/reviews.md b/source/includes/resources/reviews.md new file mode 100644 index 0000000..4e13a45 --- /dev/null +++ b/source/includes/resources/reviews.md @@ -0,0 +1,47 @@ +# Review + +Reviews are created by the buyer and seller during the purchase process. A review has a required 1-5 rating and an optional reviewText text field. + +## find + +> To lookup reviews + +```javascript +const purchaseAddress = "0x521b8d5f9e432e6b23d79fac02e5792eb8746ce1" +const reviews = await origin.reviews.find({purchaseAddress: purchaseAddress}) +// Returns +[{ + blockHash: "0xf8d740a4eb381f99c259129da68df30b6a63cb3596839b4b40f01e8e4b55821b", + blockNumber: 20, + ipfsHash: undefined, + purchaseAddress: "0x521b8d5f9e432e6b23d79fac02e5792eb8746ce1", + rating: 5, + reviewText: "", + revieweeAddress: "0x627306090abaB3A6e1400e9345bC60c78a8BEf57", + revieweeRole: "BUYER", + reviewerAddress: "0x821aEa9a577a9b44299B9c15c88cf3087F3b5544", + timestamp: 1526496009, + transactionHash: "0x94642427369cc50cee75a92df128c654c7d62b644d6c00f76e2404eadadf38bb" +}, +{ + rating: 5, + reviewText: "Very quick payment", + blockHash: "0xcce740a4eb381f99c259129da68df30b6a63cb3596839b4b40f01e8e4b55821b", + blockNumber: 220, + ipfsHash: "QmfXRgtSbrGggApvaFCa88ofeNQP79G18DpWaSW1Wya1u8", + purchaseAddress: "0x521b8d5f9e432e6b23d79fac02e5792eb8746ce1", + revieweeAddress: "0x821aEa9a577a9b44299B9c15c88cf3087F3b5544", + revieweeRole: "SELLER", + reviewerAddress: "0x627306090abaB3A6e1400e9345bC60c78a8BEf57", + timestamp: 1526496009, + transactionHash: "0xAC642427369cc50cee75a92df128c654c7d62b644d6c00f76e2404eadadfr91a" +}] +``` + +You can find reviews with the following filter options: + +- `purchaseAddress` +- `userAddress` - support coming soon +- `sellerAddress` - support coming soon +- `buyerAddress` - support coming soon +- `listingAddress` - support coming soon \ No newline at end of file diff --git a/source/index.html.md b/source/index.html.md index 3ab0af5..dc44788 100644 --- a/source/index.html.md +++ b/source/index.html.md @@ -18,6 +18,7 @@ includes: - resources/attestations - resources/listings - resources/purchases + - resources/reviews - resources/users - listing_schemas - getting_help From f00f52abfa21696e9e1a6d70f07a6e0665172efd Mon Sep 17 00:00:00 2001 From: Micah Alcorn Date: Thu, 17 May 2018 11:55:02 -0600 Subject: [PATCH 2/2] Elaborate on review creation --- source/includes/resources/reviews.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/includes/resources/reviews.md b/source/includes/resources/reviews.md index 4e13a45..2eed215 100644 --- a/source/includes/resources/reviews.md +++ b/source/includes/resources/reviews.md @@ -1,6 +1,6 @@ # Review -Reviews are created by the buyer and seller during the purchase process. A review has a required 1-5 rating and an optional reviewText text field. +Reviews are created by the buyer in the [receipt](/#purchase-buyerconfirmreceipt) stage and by the seller in the [payout](#purchase-sellergetpayout) stage of the purchase process. A review consists of a required 1-5 rating and an optional reviewText text field. ## find