-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from onready/develop
Develop
- Loading branch information
Showing
16 changed files
with
850 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { VtexHttpClient } from "../../utils/VtexHttpClient"; | ||
import { Feed } from "./apis/feed"; | ||
import { Send } from "./apis/send"; | ||
import { Manage } from "./apis/manage"; | ||
|
||
export class Suggestions { | ||
/** | ||
* Feed API | ||
*/ | ||
readonly feed: Feed; | ||
|
||
/** | ||
* Feed API | ||
*/ | ||
readonly send: Send; | ||
|
||
/** | ||
* Manage API | ||
*/ | ||
readonly manage: Manage; | ||
|
||
constructor(vtexHttpClient: VtexHttpClient) { | ||
this.feed = new Feed(vtexHttpClient); | ||
this.send = new Send(vtexHttpClient); | ||
this.manage = new Manage(vtexHttpClient); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { AbstractApi } from "../../../AbstractApi"; | ||
import { VtexHttpResponse } from "../../../../utils/VtexHttpResponse"; | ||
|
||
export class Feed extends AbstractApi { | ||
/** | ||
* | ||
* @param {string} params Example: q=search&seller=1 | ||
*/ | ||
getSuggestions(params?: string): Promise<VtexHttpResponse> { | ||
const path = `/${this.vtexHttpClient.vtexCredentials.store}/suggestions?${ | ||
params || "" | ||
}`; | ||
return this.vtexHttpClient.performRequest(path, this.HTTP_METHODS.GET); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Feed"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { AbstractApi } from "../../../AbstractApi"; | ||
import { VtexHttpClient } from "../../../../utils/VtexHttpClient"; | ||
import { VtexHttpResponse } from "../../../../utils/VtexHttpResponse"; | ||
import { MatchRequest } from "./requests/MatchRequest"; | ||
|
||
export class Manage extends AbstractApi { | ||
private readonly basePath: string; | ||
|
||
constructor(vtexHttpClient: VtexHttpClient) { | ||
super(vtexHttpClient); | ||
this.basePath = `/${vtexHttpClient.vtexCredentials.store}/suggestions`; | ||
} | ||
|
||
/** | ||
* | ||
* @param {string} sellerId | ||
* @param {string} sellerSkuId | ||
*/ | ||
getSuggestion( | ||
sellerId: string, | ||
sellerSkuId: string | ||
): Promise<VtexHttpResponse> { | ||
const path = `${this.basePath}/${sellerId}/${sellerSkuId}`; | ||
return this.vtexHttpClient.performRequest(path, this.HTTP_METHODS.GET); | ||
} | ||
|
||
/** | ||
* | ||
* @param {string} sellerId | ||
* @param {string} sellerSkuId | ||
*/ | ||
deleteSuggestion( | ||
sellerId: string, | ||
sellerSkuId: string | ||
): Promise<VtexHttpResponse> { | ||
const path = `${this.basePath}/${sellerId}/${sellerSkuId}`; | ||
return this.vtexHttpClient.performRequest(path, this.HTTP_METHODS.DELETE); | ||
} | ||
|
||
/** | ||
* Get all versions for a specific suggestion | ||
* @param {string} sellerId | ||
* @param {string} sellerSkuId | ||
*/ | ||
getVersions( | ||
sellerId: string, | ||
sellerSkuId: string | ||
): Promise<VtexHttpResponse> { | ||
const path = `${this.basePath}/${sellerId}/${sellerSkuId}/versions`; | ||
return this.vtexHttpClient.performRequest(path, this.HTTP_METHODS.GET); | ||
} | ||
|
||
/** | ||
* Get a specific version for a suggestion. To list the versions available, | ||
* use 'GET Versions' request. Replace {{version}} parameter with the chosen version. | ||
* @param {string} sellerId | ||
* @param {string} sellerSkuId | ||
* @param {string} version | ||
*/ | ||
getSuggestionByVersion( | ||
sellerId: string, | ||
sellerSkuId: string, | ||
version: string | ||
): Promise<VtexHttpResponse> { | ||
const path = `${this.basePath}/${sellerId}/${sellerSkuId}/versions/${version}`; | ||
return this.vtexHttpClient.performRequest(path, this.HTTP_METHODS.GET); | ||
} | ||
|
||
/** | ||
* Apply a match for a version of a suggestion. All information inside curly brackets should be replaced, | ||
* some of them are highlighted below.{{score}}: Should be a decimal value that represents the confidence | ||
* level.Default rules for score: score < 30: suggestion will be denied; score > 30 and < 80 - suggestion | ||
* status continue as 'Pending'; score >= 80 - suggestion will be accepted and processed in accordance with | ||
* body specification. The executions rules are defined by existence of information in request body, below | ||
* is the precedence order and information about each match type. skuRef: should be specifed when type is | ||
* a sku match; productRef: should be specified when type is a product match. | ||
* @param {string} sellerId | ||
* @param {string} sellerSkuId | ||
* @param {string} version | ||
* @param {string} matchId | ||
* @param {MatchRequest} data | ||
*/ | ||
match( | ||
sellerId: string, | ||
sellerSkuId: string, | ||
version: string, | ||
matchId: string, | ||
data: MatchRequest | ||
): Promise<VtexHttpResponse> { | ||
const path = `${this.basePath}/${sellerId}/${sellerSkuId}/versions/${version}/matches/${matchId}`; | ||
return this.vtexHttpClient.performRequest( | ||
path, | ||
this.HTTP_METHODS.PUT, | ||
data | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Manage"; |
30 changes: 30 additions & 0 deletions
30
src/modules/suggestions/apis/manage/requests/MatchRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
interface Product { | ||
name?: string; | ||
description?: string; | ||
categoryId?: number; | ||
brandId?: number; | ||
specifications?: string; | ||
} | ||
|
||
interface Sku { | ||
name?: string; | ||
eans?: Array<string>; | ||
refId?: string; | ||
height?: number; | ||
width?: number; | ||
length?: number; | ||
weight?: number; | ||
images?: any; | ||
unitMultiplier?: number; | ||
measurementUnit?: string; | ||
specifications: any; | ||
} | ||
|
||
export interface MatchRequest { | ||
matcherId?: string; | ||
score?: string; | ||
skuRef?: string; | ||
productRef?: string; | ||
product?: Product; | ||
sku?: Sku; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { AbstractApi } from "../../../AbstractApi"; | ||
import { SaveSuggestionRequest } from "./requests/SaveSuggestionRequest"; | ||
import { VtexHttpResponse } from "../../../../utils/VtexHttpResponse"; | ||
|
||
export class Send extends AbstractApi { | ||
/** | ||
* Insert or update a suggestion | ||
* @param {string} sellerId | ||
* @param {string} sellerSkuId | ||
* @param {SaveSuggestionRequest} data | ||
*/ | ||
saveSuggestion( | ||
sellerId: string, | ||
sellerSkuId: string, | ||
data: SaveSuggestionRequest | ||
): Promise<VtexHttpResponse> { | ||
const path = `/${this.vtexHttpClient.vtexCredentials.store}/suggestions/${sellerId}/${sellerSkuId}`; | ||
return this.vtexHttpClient.performRequest( | ||
path, | ||
this.HTTP_METHODS.PUT, | ||
data | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Send"; |
41 changes: 41 additions & 0 deletions
41
src/modules/suggestions/apis/send/requests/SaveSuggestionRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
interface Specification { | ||
fieldName?: string; | ||
fieldValue?: string; | ||
} | ||
|
||
interface Image { | ||
imageName?: string; | ||
imageUrl?: string; | ||
} | ||
|
||
interface Pricing { | ||
Currency?: string; | ||
SalePrice?: number; | ||
CurrencySymbol?: string; | ||
} | ||
|
||
export interface SaveSuggestionRequest { | ||
ProductId?: number; | ||
ProductName?: string; | ||
NameComplete?: string; | ||
ProductDescription?: string; | ||
BrandName?: string; | ||
SkuName?: string; | ||
SellerId?: number; | ||
Height?: number; | ||
Width?: number; | ||
Length?: number; | ||
WeightKg?: number; | ||
Updated?: boolean; | ||
RefId?: string; | ||
SellerStockKeepingUnitId?: number; | ||
CategoryFullPath?: string; | ||
SkuSpecifications?: Array<Specification>; | ||
ProductSpecifications?: Array<Specification>; | ||
Images?: Array<Image>; | ||
EAN?: string; | ||
MeasurementUnit?: string; | ||
UnitMultiplier?: number; | ||
AvailableQuantity?: number; | ||
Pricing?: Pricing; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Suggestions"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.