Skip to content

Commit fa39c79

Browse files
author
Juan Cernadas
authored
Merge pull request #36 from onready/develop
Develop
2 parents 69b1e90 + 78f6a8b commit fa39c79

30 files changed

+904
-97
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ Customer Credit | :white_check_mark: |
109109
Subscriptions (V2) | :white_check_mark: |
110110
Rates and Benefits | :white_check_mark: |
111111
Checkout | :white_check_mark: |
112+
Giftcard Hub | :white_check_mark: |
112113
Antifraud Provider | :x: |
113114
Giftcard | :x: |
114-
Giftcard Hub | :x: |
115115
Giftcard Provider Protocol | :x: |
116116
Payment Provider Protocol | :x: |

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@onreadydesa/vtex-node-sdk",
3-
"version": "1.15.0-beta",
3+
"version": "1.16.0-beta",
44
"description": "VTEX Node SDK, built 100% with Typescript and 0 dependencies!",
55
"author": "Onready",
66
"private": false,
@@ -38,15 +38,15 @@
3838
"prepublishOnly": "yarn lint && yarn test && yarn build"
3939
},
4040
"devDependencies": {
41-
"@babel/core": "7.10.4",
41+
"@babel/core": "7.10.5",
4242
"@babel/preset-env": "7.10.4",
4343
"@babel/preset-typescript": "7.10.4",
44-
"@types/jest": "26.0.4",
44+
"@types/jest": "26.0.5",
4545
"@types/node": "14.0.23",
4646
"@typescript-eslint/eslint-plugin": "3.6.1",
4747
"@typescript-eslint/parser": "3.6.1",
4848
"babel-jest": "26.1.0",
49-
"eslint": "7.4.0",
49+
"eslint": "7.5.0",
5050
"eslint-config-airbnb-base": "14.2.0",
5151
"eslint-config-prettier": "6.11.0",
5252
"eslint-plugin-import": "2.22.0",
@@ -56,8 +56,8 @@
5656
"nock": "13.0.2",
5757
"prettier": "2.0.5",
5858
"rimraf": "3.0.2",
59-
"ts-jest": "26.1.2",
60-
"typescript": "3.9.6"
59+
"ts-jest": "26.1.3",
60+
"typescript": "3.9.7"
6161
},
6262
"engines": {
6363
"node": ">=8.0.0"

src/VTEX.ts

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { CustomerCredit } from "./modules/customer-credit";
1919
import { Subscriptions } from "./modules/subscriptions/v2";
2020
import { RatesAndBenefits } from "./modules/rates-and-benefits";
2121
import { Checkout } from "./modules/checkout";
22+
import { GiftCardHub } from "./modules/giftcard-hub";
2223

2324
export class VTEX {
2425
private static buildErrorMessage(paramName: string): string {
@@ -123,6 +124,11 @@ export class VTEX {
123124
*/
124125
readonly checkout: Checkout;
125126

127+
/**
128+
* GiftCard Hub Module
129+
*/
130+
readonly giftCardHub: GiftCardHub;
131+
126132
/**
127133
* @param {string} store
128134
* @param {string} appKey
@@ -163,5 +169,6 @@ export class VTEX {
163169
this.subscriptions = new Subscriptions(vtexHttpClient);
164170
this.ratesAndBenefits = new RatesAndBenefits(vtexHttpClient);
165171
this.checkout = new Checkout(vtexHttpClient);
172+
this.giftCardHub = new GiftCardHub(vtexHttpClient);
166173
}
167174
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { VtexHttpClient } from "../../utils/VtexHttpClient";
2+
import { Provider } from "./apis/provider";
3+
import { Transaction } from "./apis/transaction";
4+
5+
export class GiftCardHub {
6+
/**
7+
* Provider API
8+
*/
9+
readonly provider: Provider;
10+
11+
/**
12+
* Transaction API
13+
*/
14+
readonly transaction: Transaction;
15+
16+
constructor(vtexHttpClient: VtexHttpClient) {
17+
this.provider = new Provider(vtexHttpClient);
18+
this.transaction = new Transaction(vtexHttpClient);
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import { AbstractApi } from "../../../AbstractApi";
2+
import { VtexHttpResponse } from "../../../../utils/VtexHttpResponse";
3+
import { ListAllGiftCardProvidersResponseItem } from "./responses/ListAllGiftCardProvidersResponseItem";
4+
import { CreateOrUpdateGiftCardProviderByIdRequest } from "./requests/CreateOrUpdateGiftCardProviderByIdRequest";
5+
6+
export class Provider extends AbstractApi {
7+
private static readonly BASE_PATH: string = "/api/giftcardproviders";
8+
9+
/**
10+
* Returns a collection of giftcard providers from a store.
11+
* @param {number} from
12+
* @param {number} to
13+
* @param {object} additionalHeaders
14+
*/
15+
listAllGiftCardProviders(
16+
from?: number,
17+
to?: number,
18+
additionalHeaders?: object
19+
): Promise<VtexHttpResponse<Array<ListAllGiftCardProvidersResponseItem>>> {
20+
let headers: any = {};
21+
if (from && to) {
22+
headers["REST-Range"] = `${from}-${to}`;
23+
}
24+
if (additionalHeaders) {
25+
headers = { ...headers, ...additionalHeaders };
26+
}
27+
return this.vtexHttpClient.performRequest(
28+
Provider.BASE_PATH,
29+
this.HTTP_METHODS.GET,
30+
null,
31+
headers
32+
);
33+
}
34+
35+
/**
36+
* Returns a giftcard provider from a store.
37+
* @param {string} giftCardProviderId
38+
* @param {object} additionalHeaders
39+
*/
40+
getGiftCardProviderById(
41+
giftCardProviderId: string,
42+
additionalHeaders?: object
43+
): Promise<VtexHttpResponse<ListAllGiftCardProvidersResponseItem>> {
44+
const path = `${Provider.BASE_PATH}/${giftCardProviderId}`;
45+
return this.vtexHttpClient.performRequest(
46+
path,
47+
this.HTTP_METHODS.GET,
48+
null,
49+
additionalHeaders
50+
);
51+
}
52+
53+
/**
54+
* Create or update a giftcard provider from a store.
55+
* @param {string} giftCardProviderId
56+
* @param {CreateOrUpdateGiftCardProviderByIdRequest} data
57+
* @param {object} additionalHeaders
58+
*/
59+
createOrUpdateGiftCardProviderById(
60+
giftCardProviderId: string,
61+
data: CreateOrUpdateGiftCardProviderByIdRequest,
62+
additionalHeaders?: object
63+
): Promise<VtexHttpResponse<ListAllGiftCardProvidersResponseItem>> {
64+
const path = `${Provider.BASE_PATH}/${giftCardProviderId}`;
65+
return this.vtexHttpClient.performRequest(
66+
path,
67+
this.HTTP_METHODS.PUT,
68+
data,
69+
additionalHeaders
70+
);
71+
}
72+
73+
/**
74+
* Delete a giftcard provider from a store.
75+
* @param {string} giftCardProviderId
76+
* @param {object} additionalHeaders
77+
*/
78+
deleteGiftCardProviderById(
79+
giftCardProviderId: string,
80+
additionalHeaders?: object
81+
): Promise<VtexHttpResponse<ListAllGiftCardProvidersResponseItem>> {
82+
const path = `${Provider.BASE_PATH}/${giftCardProviderId}`;
83+
return this.vtexHttpClient.performRequest(
84+
path,
85+
this.HTTP_METHODS.DELETE,
86+
null,
87+
additionalHeaders
88+
);
89+
}
90+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./Provider";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface CreateOrUpdateGiftCardProviderByIdRequest {
2+
serviceUrl?: string;
3+
oauthProvider?: string;
4+
caption?: string;
5+
preAuthEnabled?: boolean;
6+
cancelEnabled?: boolean;
7+
appToken?: string;
8+
appKey?: string;
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { CreateOrUpdateGiftCardProviderByIdRequest } from "../requests/CreateOrUpdateGiftCardProviderByIdRequest";
2+
3+
interface Self {
4+
href?: string;
5+
}
6+
7+
export interface ListAllGiftCardProvidersResponseItem
8+
extends CreateOrUpdateGiftCardProviderByIdRequest {
9+
id?: string;
10+
_self?: Self;
11+
}

0 commit comments

Comments
 (0)