HashtagSell / posting-api

API for storage and retrieval of posting details for Hashtagsell
0 stars 0 forks source link

Big change to offers socket.io emits. #71

Closed that1guy closed 9 years ago

that1guy commented 9 years ago

Josh, among all the feedback we've received we've learned that we need to perfect the communication between the buyer and seller as they send their offers and schedule a meeting. We believe this is one of the largest things holding us back from creating ideal user experience and opening app to public. Therefore we ebay 360 code should be put on hold, and this is our focus.

When we launch users should be able to push to personal FB, Twitter, Ebay and search/buy internal hashtagsell items for free with Venmo (I've integrated Venmo payments into htsApp and commented out braintree, so all payments are free). So we just need to perfect buyer/seller communication then open to public.

Here's the new user experience we're building:

See the requests below as I try to walk us through the workflow.

Buyer proposes the price and pickup location. UI POSTs this deal request to posting api.

{
  "accepted": false,   */this deal is not accepted, just a proposal*/
  "actor": {   */this is the user who is triggering the socket.io emit*/
    "username": "bdavis",
    "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
    "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
    "role": "buyer"
  },
  "posting": entire_post_object,
  "proposedDeal": {
    "price": {
      "value": "75",
      "currency": "USD",
      "paymentType" : {
        "venmo": true,
        "cash" : false
      }
    },
    "location" : {
      "full_address", "1810 Polk St. San Francisco, California, USA"
      "coordinates" : [
        "longitude_here", "latitude_here"
      ]
    },
    fulfillment: {
      ship: false,
      localDelivery: false,
      pickup: true
    },
    comment: "Really want this item!  "
  },
  "proposedTimes": [],
  "reciepient" : {        */this is the user who should be notified when the socket.io emit occurs*/
    "username": "brozeph",
    "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
    "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
    "role": "seller"
  },
  "type": "deal",  */this is a deal proposal.. not a meeting proposal.*/
  "timestamp": "2015-07-08T19:35:28.534Z"
}

Socket.io emits this object to the posts room. UI will sort by timestamp and notify seller of proposed deal.

{
  "id":"559c6439623ed2911da4eeb9",
  "offerId":"cd58288d19b5451e998960d675437a46",
  "posting": entire_post_object,
  "offerHistory": [
    {
      "accepted": false,
      "actor": {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        },
        comment: "Really want this item!"
      },
      "proposedTimes": [],
      "reciepient" : {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "type": "deal",
      "timestamp": "2015-07-08T19:35:28.534Z"
    },
  ]
}

Seller accepts the buyers proposed price, location, and pickup proposal. UI POSTs this object to API.

{
  "accepted": true,
  "actor": {
    "username": "brozeph",
    "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
    "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
    "role": "seller"
  },
  "id":"559c6439623ed2911da4eeb9",
  "offerId":"cd58288d19b5451e998960d675437a46",
  "posting": entire_post_object,
  "proposedDeal": {
    "price": {
      "value": "75",
      "currency": "USD",
      "paymentType" : {
        "venmo": true,
        "cash" : false
      }
    },
    "location" : {
      "full_address", "1810 Polk St. San Francisco, California, USA"
      "coordinates" : [
        "longitude_here", "latitude_here"
      ]
    },
    fulfillment: {
      ship: false,
      localDelivery: false,
      pickup: true
    },
    comment: "Okay, sounds good.  I'll lower price and meet ya there."
  },
  "proposedTimes": [],
  "reciepient" : {
    "username": "bdavis",
    "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
    "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
    "role": "buyer"
  },
  "type": "deal",
  "timestamp": "2015-07-08T19:35:28.534Z"
}

Socket.io emits object in posting room with original proposal from buyer AND acceptance from seller. The UI will sort by timestamp and notify buyer their deal was accepted.

{
  "id":"559c6439623ed2911da4eeb9",
  "offerId":"cd58288d19b5451e998960d675437a46",
  "posting": entire_post_object,
  "offerHistory": [
    {
      "accepted": false,
      "actor": {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        },
        comment: "Really want this item!"
      },
      "proposedTimes": [],
      "reciepient" : {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "type": "deal",
      "timestamp": "2015-07-08T19:35:28.534Z"
    },
    {
      "accepted": true,
      "actor": {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        },
       comment: "Okay, sounds good.  I'll lower price and meet ya there."
      },
      "proposedTimes": [],
      "reciepient" : {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "type": "deal",
      "timestamp": "2015-07-08T19:35:28.534Z"
    }
  ]
}

Buyer proposes one or more meeting times that works for them. UI posts this object to API.

{
  "accepted": false,
  "actor": {
    "username": "bdavis",
    "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
    "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
    "role": "buyer"
  },
  "id":"657e938d3da14b01b795dc859d22329c",
  "offerId":"cd58288d19b5451e998960d675437a46",
  "posting": entire_post_object,
  "proposedDeal": {
    "price": {
      "value": "75",
      "currency": "USD",
      "paymentType" : {
        "venmo": true,
        "cash" : false
      }
    },
    "location" : {
      "full_address", "1810 Polk St. San Francisco, California, USA"
      "coordinates" : [
        "longitude_here", "latitude_here"
      ]
    },
    fulfillment: {
      ship: false,
      localDelivery: false,
      pickup: true
    }
  },
  "proposedTimes": [
    {
      "_id": "559d7b8073e97a8904f331ec",
      "when": "2015-07-22T21:30:00.000Z",
    },
    {
      "_id": "559d7b8073e97a8904f331eb",
      "when": "2015-07-22T21:30:00.000Z",
    }
  ],
  "reciepient" : {
    "username": "brozeph",
    "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
    "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
    "role": "seller"
  },
  "type": "date",
  "timestamp": "2015-07-08T19:35:28.534Z"
}

Socket.io emits meeting request in the postings room. This emit object should have the original proposal from buyer AND deal acceptance from seller AND proposal for meeting time from buyer. The UI will sort by timestamp.

{
  "id":"559c6439623ed2911da4eeb9",
  "offerId":"cd58288d19b5451e998960d675437a46",
  "posting": entire_post_object,
  "offerHistory": [
    {
      "accepted": false,
      "actor": {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        },
        comment: "Really want this item!"
      },
      "proposedTimes": [],
      "reciepient" : {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "type": "deal",
      "timestamp": "2015-07-08T19:35:28.534Z"
    },
    {
      "accepted": true,
      "actor": {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        },
       comment: "Okay, sounds good.  I'll lower price and meet ya there."
      },
      "proposedTimes": [],
      "reciepient" : {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "type": "deal",
      "timestamp": "2015-07-08T19:35:28.534Z"
    },
    {
      "accepted": false,
      "actor": {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        }
      },
      "proposedTimes": [
        {
          "_id": "559d7b8073e97a8904f331ec",
          "when": "2015-07-22T21:30:00.000Z",
        },
        {
          "_id": "559d7b8073e97a8904f331eb",
          "when": "2015-07-22T21:30:00.000Z",
        }
      ],
      "reciepient" : {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "type": "date",
      "timestamp": "2015-07-08T19:35:28.534Z"
    },
  ]
}

Sellers accepts one of the proposed times. UI POSTs this object to API.

{
  "accepted": true,
  "actor": {
    "username": "brozeph",
    "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
    "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
    "role": "seller"
  },
  "id":"657e938d3da14b01b795dc859d22329c",
  "offerId":"cd58288d19b5451e998960d675437a46",
  "posting": entire_post_object,
  "proposedDeal": {
    "price": {
      "value": "75",
      "currency": "USD",
      "paymentType" : {
        "venmo": true,
        "cash" : false
      }
    },
    "location" : {
      "full_address", "1810 Polk St. San Francisco, California, USA"
      "coordinates" : [
        "longitude_here", "latitude_here"
      ]
    },
    fulfillment: {
      ship: false,
      localDelivery: false,
      pickup: true
    }
  },
  "proposedTimes": [
    {
      "_id": "559d7b8073e97a8904f331ec",
      "when": "2015-07-22T21:30:00.000Z",
      "acceptedAt": "2015-07-08T19:35:28.534Z"
    },
    {
      "_id": "559d7b8073e97a8904f331eb",
      "when": "2015-07-22T21:30:00.000Z",
    }
  ],
  "reciepient" : {
    "username": "bdavis",
    "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
    "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
    "role": "buyer"
  },
  "type": "date",
  "timestamp": "2015-07-08T19:35:28.534Z"
}

Socket.io emits object in postings room with original proposal from buyer AND acceptance from seller AND proposal for meeting time AND acceptance from seller for meeting time. The UI will sort by timestamp.

{
  "id":"559c6439623ed2911da4eeb9",
  "offerId":"cd58288d19b5451e998960d675437a46",
  "posting": entire_post_object,
  "offerHistory": [
    {
      "accepted": false,
      "actor": {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        },
        comment: "Really want this item!"
      },
      "proposedTimes": [],
      "reciepient" : {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "type": "deal",
      "timestamp": "2015-07-08T19:35:28.534Z"
    },
    {
      "accepted": true,
      "actor": {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        },
       comment: "Okay, sounds good.  I'll lower price and meet ya there."
      },
      "proposedTimes": [],
      "reciepient" : {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "type": "deal",
      "timestamp": "2015-07-08T19:35:28.534Z"
    },
    {
      "accepted": false,
      "actor": {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        }
      },
      "proposedTimes": [
        {
          "_id": "559d7b8073e97a8904f331ec",
          "when": "2015-07-22T21:30:00.000Z",
        },
        {
          "_id": "559d7b8073e97a8904f331eb",
          "when": "2015-07-22T21:30:00.000Z",
        }
      ],
      "reciepient" : {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "type": "date",
      "timestamp": "2015-07-08T19:35:28.534Z"
    },
    {
      "accepted": true,
      "actor": {
        "username": "brozeph",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "seller"
      },
      "proposedDeal": {
        "price": {
          "value": "75",
          "currency": "USD",
          "paymentType" : {
            "venmo": true,
            "cash" : false
          }
        },
        "location" : {
          "full_address", "1810 Polk St. San Francisco, California, USA"
          "coordinates" : [
            "longitude_here", "latitude_here"
          ]
        },
        fulfillment: {
          ship: false,
          localDelivery: false,
          pickup: true
        }
      },
      "proposedTimes": [
        {
          "_id": "559d7b8073e97a8904f331ec",
          "when": "2015-07-22T21:30:00.000Z",
          "acceptedAt": "2015-07-08T19:35:28.534Z"
        },
        {
          "_id": "559d7b8073e97a8904f331eb",
          "when": "2015-07-22T21:30:00.000Z",
        }
      ],
      "reciepient" : {
        "username": "bdavis",
        "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
        "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
        "role": "buyer"
      },
      "type": "date",
      "timestamp": "2015-07-08T19:35:28.534Z"
    }
  ]
}

If the UI performs a GET request to get all offers associated with a post it should get this response. /v1/postings/{postingId}/offers/{?start,count,filters,sort}

{
  "username": "that1guy",
  "heading": "ikea desk",
  "body": "I'm selling my <span class=\"mention-highlighter\" contenteditable=\"false\">#ikea desk</span>&nbsp;for <span class=\"mention-highlighter-price\" contenteditable=\"false\">$40</span>&nbsp;<span class=\"mention-highlighter-location\" contenteditable=\"false\">@San Francisco, CA, United States</span>&nbsp;",
  "expiresAt": "2015-07-21T23:51:13.397Z",
  "categoryCode": "SFUR",
  "annotations": [
    {
      "key": "Year",
      "value": null
    },
    {
      "key": "Brand",
      "value": null
    },
    {
      "key": "Color",
      "value": null
    },
    {
      "key": "Material Type",
      "value": null
    }
  ],
  "postingId": "532cf35fb53e4cc08ccd507a00ba5c5a",
  "facebook": {
    "id": "1378709109126588_1417342811929884"
  },
  "twitter": {
    "id": 618567986408878100
  },
  "ebay": {
    "endTime": "2015-07-14T23:51:16.064Z",
    "itemId": 110164741804,
    "paypalEmail": "admin@hashtagsell.com",
    "startTime": "2015-07-07T23:51:16.064Z",
    "token": "AgAAAA**AQAAAA**aAAAAA**hmLyVA**nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4GhDZSCqASdj6x9nY+seQ**oxgDAA**AAMAAA**N9hHa8m+zOe6j/3hM3obZpu2burAHmfX92uyE0xfkHxEZ48/CxBgz/r770My02y5TjAERwusQ92OSfOK9vWauOAqUaY0zbiRVx/UYIMiZMQTobahuoo8z7yingaGoV9h1uA3zBrI6WtHStirGs0RVZPJJtNeACxAAGtP8RIGiIloWwrqMijdAd8FA1yRbVADPsLM3FXrE06ezV+do5FT53YgHuH5kuvxpqhwq6F1xhH5Z1CsZ0oJ+fmfcdCMYmIPgSaS1dvz2V0dF/JXPYOcsvkRIoULOm7js0SXl9Y4gQKtSLL8DGFNKSysXE5EZmYlnt5r1STb1FgW55mVMZRwzQo4YpahFcCS0uVLPOc7UV5wcaCNIWJomHwMu6PFMUuAtQCl3jHYh0ldxivvVDtsQkNFk/wu7D2GgllOCoBXBzU4sRaSx4pIpNo7apaaCLY6YHYhl7qKKiv8mYNyPPNNTSrL/0ErmPramBtoLrAlNmXg0IaUHDhHaaHX1skcQkNA80Y97blozAgd2+rHhTettp9GBbJIYnZJH0H1CJtWU5Shd4Wy/SY3cTi8OPmRk+xDTCnozNhOY59Gg/MPjyWeoyXPQ5OLyI1kPy/+yt8Edt1UIvcc8EI8LqIT/GDqKkpOPDEBJtPuBHdCAUOwo7TUOz4c+IGWC6eGjH62fyoQ/Qvz36v0Cg7w2u0iHq1jSgLD/q7JDSmJnJDCNt9g3kcdahj/GaYZfQ+Ne7AdpJkNa4pkEK81zcFw4t35X0miAo2f",
    "url": "http://cgi.sandbox.ebay.com/ws/eBayISAPI.dll?ViewItem&item=110164741804"
  },
  "language": "EN",
  "images": [],
  "geo": {
    "location": {
      "city": "San Francisco",
      "state": "CA",
      "country": "US",
      "postalCode": "94103"
    },
    "coordinates": [
      -122.41941550000001,
      37.7749295
    ]
  },
  "createdAt": "2015-07-07T23:51:13.397Z",
  "askingPrice": {
    "value": "40",
    "currency": "USD"
  },
  "external": {
    "threeTaps": {
      "categoryGroup": "SSSS",
      "category": "SFUR",
      "location": {
        "state": "CA",
        "formatted": "San Francisco, CA, USA",
        "country": "US"
      }
    },
    "source": {
      "code": "HSHTG"
    }
  },
  "offers": {
    "options": {
      "start": 0,
      "count": 100
    },
    "results": [
      {
        "id":"559c6439623ed2911da4eeb9",
        "offerId":"cd58288d19b5451e998960d675437a46",
        "offerHistory": [
          {
            "accepted": false,
            "actor": {
              "username": "bdavis",
              "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
              "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
              "role": "buyer"
            },
            "proposedDeal": {
              "price": {
                "value": "75",
                "currency": "USD",
                "paymentType" : {
                  "venmo": true,
                  "cash" : false
                }
              },
              "location" : {
                "full_address", "1810 Polk St. San Francisco, California, USA"
                "coordinates" : [
                  "longitude_here", "latitude_here"
                ]
              },
              fulfillment: {
                ship: false,
                localDelivery: false,
                pickup: true
              }
            },
            "proposedTimes": [],
            "reciepient" : {
              "username": "brozeph",
              "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
              "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
              "role": "seller"
            },
            "type": "deal",
            "timestamp": "2015-07-08T19:35:28.534Z"
          },
          {
            "accepted": true,
            "actor": {
              "username": "brozeph",
              "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
              "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
              "role": "seller"
            },
            "proposedDeal": {
              "price": {
                "value": "75",
                "currency": "USD",
                "paymentType" : {
                  "venmo": true,
                  "cash" : false
                }
              },
              "location" : {
                "full_address", "1810 Polk St. San Francisco, California, USA"
                "coordinates" : [
                  "longitude_here", "latitude_here"
                ]
              },
              fulfillment: {
                ship: false,
                localDelivery: false,
                pickup: true
              }
            },
            "proposedTimes": [],
            "reciepient" : {
              "username": "bdavis",
              "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
              "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
              "role": "buyer"
            },
            "type": "deal",
            "timestamp": "2015-07-08T19:35:28.534Z"
          },
          {
            "accepted": false,
            "actor": {
              "username": "bdavis",
              "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
              "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
              "role": "buyer"
            },
            "proposedDeal": {
              "price": {
                "value": "75",
                "currency": "USD",
                "paymentType" : {
                  "venmo": true,
                  "cash" : false
                }
              },
              "location" : {
                "full_address", "1810 Polk St. San Francisco, California, USA"
                "coordinates" : [
                  "longitude_here", "latitude_here"
                ]
              },
              fulfillment: {
                ship: false,
                localDelivery: false,
                pickup: true
              }
            },
            "proposedTimes": [
              {
                "_id": "559d7b8073e97a8904f331ec",
                "when": "2015-07-22T21:30:00.000Z",
              },
              {
                "_id": "559d7b8073e97a8904f331eb",
                "when": "2015-07-22T21:30:00.000Z",
              }
            ],
            "reciepient" : {
              "username": "brozeph",
              "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
              "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
              "role": "seller"
            },
            "type": "date",
            "timestamp": "2015-07-08T19:35:28.534Z"
          },
          {
            "accepted": true,
            "actor": {
              "username": "brozeph",
              "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
              "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
              "role": "seller"
            },
            "proposedDeal": {
              "price": {
                "value": "75",
                "currency": "USD",
                "paymentType" : {
                  "venmo": true,
                  "cash" : false
                }
              },
              "location" : {
                "full_address", "1810 Polk St. San Francisco, California, USA"
                "coordinates" : [
                  "longitude_here", "latitude_here"
                ]
              },
              fulfillment: {
                ship: false,
                localDelivery: false,
                pickup: true
              }
            },
            "proposedTimes": [
              {
                "_id": "559d7b8073e97a8904f331ec",
                "when": "2015-07-22T21:30:00.000Z",
                "acceptedAt": "2015-07-08T19:35:28.534Z"
              },
              {
                "_id": "559d7b8073e97a8904f331eb",
                "when": "2015-07-22T21:30:00.000Z",
              }
            ],
            "reciepient" : {
              "username": "bdavis",
              "profile_photo": "//static.hashtagsell.com/htsApp/placeholders/user-placeholder.png",
              "banner_photos": "//static.hashtagsell.com/htsApp/placeholders/header-placeholder.png,
              "role": "buyer"
            },
            "type": "date",
            "timestamp": "2015-07-08T19:35:28.534Z"
          }
        ]
      },
      {
        history between another potential buyer and seller
      }
    ],
    "total": 1
  }
}
that1guy commented 9 years ago

Side note: we have a really simple ui for all of this.. it's quite brilliant if I say so myself. :)

brozeph commented 9 years ago

Updating offers model to look as follows:

{
    offerId : 'abc123',
    postingId : 'zyx321',
    proposals : [{
        acceptedAt : '2015-01-31T14:37:00Z',
        comment : '',
        isOwnerReply : false, // when the owner of the item replies, this should be set to true
        price : {
            currency : 'USD',
            value : '11.00'
        },
        when : '2015-02-03T10:00:00Z',
        where : 'San Francisco Library'
    }, {
        comment : '$10 is too low',
        isOwnerReply : true,
        price : {
            currency : 'USD',
            value : '12.00'
        },
        when : '2015-02-03T10:00:00Z',
        where : 'San Francisco Library'
    }, {
        comment : '', 
        isOwnerReply : false,
        price : {
            currency : 'USD',
            value : '10.00'
        },
        when : '2015-02-03T10:00:00Z',
        where : 'San Francisco Library'
    }],
    username : 'brozeph' // the user who created this offer
}

The ping-pong between the owner of the posting and the user that created the offer will be tracked in the proposals sub-document collection of the posting. The following fields can be specified for each counter offer:

The above example shows the following interaction:

// POST /v1/postings/zyx321/offers
{
  "proposals": [{
    "price" : { 
      "currency" : "USD",
      "value" : "10.00"
    },
    "when" : "2015-02-03T10:00:00Z",
    "where" : "San Francisco Library"
  }],
  "username": "brozeph"
}
// PUT /v1/postings/zyx321/offers
{
  "proposals": [{
    "comment" : "$10 is too low",
    "isOwnerReply" : true,
    "price" : { 
      "currency" : "USD",
      "value" : "12.00"
    },
    "when" : "2015-02-03T10:00:00Z",
    "where" : "San Francisco Library"
  }, {
    "price" : { 
      "currency" : "USD",
      "value" : "10.00"
    },
    "when" : "2015-02-03T10:00:00Z",
    "where" : "San Francisco Library"
  }]
}
// PUT /v1/postings/zyx321/offers/abc123
{
  "proposals": [{
    "price" : { 
      "currency" : "USD",
      "value" : "11.00"
    },
    "when" : "2015-02-03T10:00:00Z",
    "where" : "San Francisco Library"
  }, {
    "comment" : "$10 is too low",
    "isOwnerReply" : true,
    "price" : { 
      "currency" : "USD",
      "value" : "12.00"
    },
    "when" : "2015-02-03T10:00:00Z",
    "where" : "San Francisco Library"
  }, {
    "price" : { 
      "currency" : "USD",
      "value" : "10.00"
    },
    "when" : "2015-02-03T10:00:00Z",
    "where" : "San Francisco Library"
  }]
}
// POST /v1/postings/zyx321/offers/abc123/accept
{
  "price" : { 
      "currency" : "USD",
      "value" : "11.00"
  },
  "when" : "2015-02-03T10:00:00Z",
  "where" : "San Francisco Library"
}

The acceptance of a proposal is dependent upon the flag field isOwnerReply. In the event that the isOwnerReply value is true, then the user who created the offer is the one that can accept.

brozeph commented 9 years ago

Ok, this now exists in a branch named rework-offers:

git pull
git checkout rework-offers
NODE_ENV=local npm start

If you are testing the realtime-svc in conjunction with these changes, you will also need to checkout the rework-offers branch that exists in the realtime-svc as well.

brozeph commented 9 years ago

Assigning to @that1guy for validation and feedback

that1guy commented 9 years ago

FYI, corrected small error in /lib/model/message.js in realtime-svc. :)

https://github.com/HashtagSell/realtime-svc/commit/25bf1c040ea588d8f04661cfc9bc69777979ae41

that1guy commented 9 years ago

FYI. Added socket.io emit for EVENT_UPDATED_OFFER.

https://github.com/HashtagSell/posting-api/commit/649250860a3a126d23be3023416ed5515045d599

https://github.com/HashtagSell/realtime-svc/commit/b2a7e0f3bce88d269063c08bc07d687bbc6c35ff

that1guy commented 9 years ago

Awesome! We've met requirements here and implementation is running in staging ENV.