Skip to content

Commit

Permalink
Change item registration response
Browse files Browse the repository at this point in the history
  • Loading branch information
yuneg11 committed Dec 8, 2019
1 parent 2d473e5 commit fa480f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/backend/responses/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
const builder = require("../utils/builder");
const resource = require("../utils/resource");

module.exports.itemRegistrationSuccess = (itemName, itemDetail, itemPrice, imageUrl, nickname) => {
module.exports.itemRegistrationSuccess = (itemName, itemDetail, itemPrice, imageUrl) => {
// Construct registration guide
const resultThumbnail = builder.getThumbnail(imageUrl);
const resultTitle = itemName;
const resultDescription = itemDetail;
const resultPrice = itemPrice;
const resultNickname = nickname;
const resultMainMenuButton = builder.getButton("처음으로", "block", "처음으로", resource.welcomeBlockId);
const resultCard = builder.getCommerceCard(resultTitle, resultDescription, resultPrice, resultThumbnail, result, [resultMainMenuButton]);
const resultCard = builder.getCommerceCard(resultTitle, resultDescription, resultPrice, resultThumbnail, null, [resultMainMenuButton]);

// Build response
return builder.buildResponse([resultCard]);
Expand Down
6 changes: 6 additions & 0 deletions src/backend/tests/item_registration.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@
"name": "스킬 테스트",
"clientExtra": {},
"params": {
"item_category": "전자기기",
"item_name": "어어",
"item_price": "{\"amount\": 10000, \"unit\": \"\"}",
"item_detail": "처음으로",
"$item_image": "{\"privacyAgreement\":\"Y\",\"imageQuantity\":\"3\",\"secureUrls\":\"List(http://secure.kakaocdn.net/dna/biS7Z3/K6avpFEudv/XXX/img_org.jpg?credential=Kq0eSbCrZgKIq51jh41Uf1jLsUh7VWcz&expires=1575476312&allow_ip=&allow_referer=&signature=gAuRfga0QSVLQTu%2Fto7KhmgKyGI%3D, http://secure.kakaocdn.net/dna/cjvCoE/K6aAZNxD00/XXX/img_org.jpg?credential=Kq0eSbCrZgKIq51jh41Uf1jLsUh7VWcz&expires=1575476312&allow_ip=&allow_referer=&signature=JZ61bx1qvBaR6RHGo352yak7fHA%3D, http://secure.kakaocdn.net/dna/bPthHV/K6aA1q3sS8/XXX/img_org.jpg?credential=Kq0eSbCrZgKIq51jh41Uf1jLsUh7VWcz&expires=1575476312&allow_ip=&allow_referer=&signature=9rz9GHZDcgjnucALZpUjFe71QAY%3D)\",\"expire\":\"1970-01-19T14:37:56+0900\"}"
},
"id": "5dda19bf8192ac00011a2918",
"detailParams": {
"item_category": {
"origin": "전자기기",
"value": "전자기기",
"groupName": ""
},
"item_name": {
"origin": "상품의 이름",
"value": "상품의 이름",
Expand Down
9 changes: 5 additions & 4 deletions src/backend/utils/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,19 @@ const getCarousel = (type, cards) => {
}

const getCommerceCard = (title, description, price, thumbnail, nickname, buttons=[]) => {
return {
const card = {
commerceCard: {
description: title + "\n" + description,
price: price,
currency: "won",
thumbnails: [ thumbnail ],
profile: {
nickname: nickname
},
buttons: buttons
}
};
if (nickname != null) {
card["profile"] = { nickname: nickname }
}
return card;
}

module.exports = {
Expand Down

0 comments on commit fa480f8

Please sign in to comment.