@sparkrewards/sra-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist-cjs/index.js +8 -0
- package/dist-cjs/models/index.js +4 -0
- package/dist-cjs/models/models_0.js +1901 -0
- package/dist-cjs/openapi.js +7 -0
- package/dist-cjs/openapi.json +2864 -0
- package/dist-cjs/protocols/Aws_restJson1.js +2939 -0
- package/dist-cjs/server/AppAPIService.js +371 -0
- package/dist-cjs/server/index.js +5 -0
- package/dist-cjs/server/operations/DeleteUser.js +121 -0
- package/dist-cjs/server/operations/FavoritePlans.js +125 -0
- package/dist-cjs/server/operations/FavoriteShops.js +122 -0
- package/dist-cjs/server/operations/GetShop.js +126 -0
- package/dist-cjs/server/operations/GetShopPublic.js +127 -0
- package/dist-cjs/server/operations/GetUser.js +121 -0
- package/dist-cjs/server/operations/LikeOrg.js +124 -0
- package/dist-cjs/server/operations/NearbyShops.js +121 -0
- package/dist-cjs/server/operations/NearbyShopsPublic.js +122 -0
- package/dist-cjs/server/operations/NearestShop.js +126 -0
- package/dist-cjs/server/operations/OnboardUser.js +122 -0
- package/dist-cjs/server/operations/PinnedShop.js +126 -0
- package/dist-cjs/server/operations/PinnedShopPublic.js +127 -0
- package/dist-cjs/server/operations/Plan.js +123 -0
- package/dist-cjs/server/operations/PlanPublic.js +124 -0
- package/dist-cjs/server/operations/Plans.js +124 -0
- package/dist-cjs/server/operations/PopularShops.js +122 -0
- package/dist-cjs/server/operations/PopularShopsPublic.js +123 -0
- package/dist-cjs/server/operations/RadiusShops.js +123 -0
- package/dist-cjs/server/operations/RecordVisit.js +129 -0
- package/dist-cjs/server/operations/RedeemFirstTimeReward.js +125 -0
- package/dist-cjs/server/operations/RedeemPointReward.js +126 -0
- package/dist-cjs/server/operations/RedeemVisitReward.js +125 -0
- package/dist-cjs/server/operations/SearchShopsPublic.js +125 -0
- package/dist-cjs/server/operations/SearchSuggestion.js +126 -0
- package/dist-cjs/server/operations/UpdateUser.js +121 -0
- package/dist-cjs/server/operations/index.js +29 -0
- package/dist-es/index.js +4 -0
- package/dist-es/models/index.js +1 -0
- package/dist-es/models/models_0.js +1893 -0
- package/dist-es/openapi.js +3 -0
- package/dist-es/openapi.json +2864 -0
- package/dist-es/protocols/Aws_restJson1.js +2878 -0
- package/dist-es/server/AppAPIService.js +366 -0
- package/dist-es/server/index.js +2 -0
- package/dist-es/server/operations/DeleteUser.js +115 -0
- package/dist-es/server/operations/FavoritePlans.js +119 -0
- package/dist-es/server/operations/FavoriteShops.js +116 -0
- package/dist-es/server/operations/GetShop.js +120 -0
- package/dist-es/server/operations/GetShopPublic.js +121 -0
- package/dist-es/server/operations/GetUser.js +115 -0
- package/dist-es/server/operations/LikeOrg.js +118 -0
- package/dist-es/server/operations/NearbyShops.js +115 -0
- package/dist-es/server/operations/NearbyShopsPublic.js +116 -0
- package/dist-es/server/operations/NearestShop.js +120 -0
- package/dist-es/server/operations/OnboardUser.js +116 -0
- package/dist-es/server/operations/PinnedShop.js +120 -0
- package/dist-es/server/operations/PinnedShopPublic.js +121 -0
- package/dist-es/server/operations/Plan.js +117 -0
- package/dist-es/server/operations/PlanPublic.js +118 -0
- package/dist-es/server/operations/Plans.js +118 -0
- package/dist-es/server/operations/PopularShops.js +116 -0
- package/dist-es/server/operations/PopularShopsPublic.js +117 -0
- package/dist-es/server/operations/RadiusShops.js +117 -0
- package/dist-es/server/operations/RecordVisit.js +123 -0
- package/dist-es/server/operations/RedeemFirstTimeReward.js +119 -0
- package/dist-es/server/operations/RedeemPointReward.js +120 -0
- package/dist-es/server/operations/RedeemVisitReward.js +119 -0
- package/dist-es/server/operations/SearchShopsPublic.js +119 -0
- package/dist-es/server/operations/SearchSuggestion.js +120 -0
- package/dist-es/server/operations/UpdateUser.js +115 -0
- package/dist-es/server/operations/index.js +26 -0
- package/dist-types/index.d.ts +9 -0
- package/dist-types/models/index.d.ts +1 -0
- package/dist-types/models/models_0.d.ts +832 -0
- package/dist-types/openapi.d.ts +7 -0
- package/dist-types/protocols/Aws_restJson1.d.ts +87 -0
- package/dist-types/server/AppAPIService.d.ts +76 -0
- package/dist-types/server/index.d.ts +2 -0
- package/dist-types/server/operations/DeleteUser.d.ts +41 -0
- package/dist-types/server/operations/FavoritePlans.d.ts +41 -0
- package/dist-types/server/operations/FavoriteShops.d.ts +41 -0
- package/dist-types/server/operations/GetShop.d.ts +41 -0
- package/dist-types/server/operations/GetShopPublic.d.ts +41 -0
- package/dist-types/server/operations/GetUser.d.ts +41 -0
- package/dist-types/server/operations/LikeOrg.d.ts +41 -0
- package/dist-types/server/operations/NearbyShops.d.ts +41 -0
- package/dist-types/server/operations/NearbyShopsPublic.d.ts +41 -0
- package/dist-types/server/operations/NearestShop.d.ts +41 -0
- package/dist-types/server/operations/OnboardUser.d.ts +41 -0
- package/dist-types/server/operations/PinnedShop.d.ts +41 -0
- package/dist-types/server/operations/PinnedShopPublic.d.ts +41 -0
- package/dist-types/server/operations/Plan.d.ts +41 -0
- package/dist-types/server/operations/PlanPublic.d.ts +41 -0
- package/dist-types/server/operations/Plans.d.ts +41 -0
- package/dist-types/server/operations/PopularShops.d.ts +41 -0
- package/dist-types/server/operations/PopularShopsPublic.d.ts +41 -0
- package/dist-types/server/operations/RadiusShops.d.ts +41 -0
- package/dist-types/server/operations/RecordVisit.d.ts +41 -0
- package/dist-types/server/operations/RedeemFirstTimeReward.d.ts +41 -0
- package/dist-types/server/operations/RedeemPointReward.d.ts +41 -0
- package/dist-types/server/operations/RedeemVisitReward.d.ts +41 -0
- package/dist-types/server/operations/SearchShopsPublic.d.ts +41 -0
- package/dist-types/server/operations/SearchSuggestion.d.ts +41 -0
- package/dist-types/server/operations/UpdateUser.d.ts +41 -0
- package/dist-types/server/operations/index.d.ts +26 -0
- package/package.json +66 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ShopListInput, } from "../../models/models_0";
|
|
2
|
+
import { deserializePopularShopsPublicRequest, serializeFrameworkException, serializePopularShopsPublicResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
|
|
3
|
+
import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
|
|
4
|
+
import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
|
|
5
|
+
import { fromBase64, toBase64, } from "@smithy/util-base64";
|
|
6
|
+
import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
|
|
7
|
+
export var PopularShopsPublicServerInput;
|
|
8
|
+
(function (PopularShopsPublicServerInput) {
|
|
9
|
+
PopularShopsPublicServerInput.validate = ShopListInput.validate;
|
|
10
|
+
})(PopularShopsPublicServerInput || (PopularShopsPublicServerInput = {}));
|
|
11
|
+
export class PopularShopsPublicSerializer {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.serialize = serializePopularShopsPublicResponse;
|
|
14
|
+
this.deserialize = deserializePopularShopsPublicRequest;
|
|
15
|
+
}
|
|
16
|
+
isOperationError(error) {
|
|
17
|
+
const names = ["ValidationException", "RuntimeError"];
|
|
18
|
+
return names.includes(error.name);
|
|
19
|
+
}
|
|
20
|
+
;
|
|
21
|
+
serializeError(error, ctx) {
|
|
22
|
+
switch (error.name) {
|
|
23
|
+
case "ValidationException": {
|
|
24
|
+
return serializeValidationExceptionError(error, ctx);
|
|
25
|
+
}
|
|
26
|
+
case "RuntimeError": {
|
|
27
|
+
return serializeRuntimeErrorError(error, ctx);
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const getPopularShopsPublicHandler = (operation) => {
|
|
36
|
+
const mux = new httpbinding.HttpBindingMux([
|
|
37
|
+
new httpbinding.UriSpec('GET', [
|
|
38
|
+
{ type: 'path_literal', value: "public" },
|
|
39
|
+
{ type: 'path_literal', value: "shops" },
|
|
40
|
+
{ type: 'path_literal', value: "popular" },
|
|
41
|
+
], [], { service: "AppAPI", operation: "PopularShopsPublic" }),
|
|
42
|
+
]);
|
|
43
|
+
const customizer = (ctx, failures) => {
|
|
44
|
+
if (!failures) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
name: "ValidationException",
|
|
49
|
+
$fault: "client",
|
|
50
|
+
message: __generateValidationSummary(failures),
|
|
51
|
+
fieldList: failures.map(failure => ({
|
|
52
|
+
path: failure.path,
|
|
53
|
+
message: __generateValidationMessage(failure)
|
|
54
|
+
}))
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
return new PopularShopsPublicHandler(operation, mux, new PopularShopsPublicSerializer(), serializeFrameworkException, customizer);
|
|
58
|
+
};
|
|
59
|
+
const serdeContextBase = {
|
|
60
|
+
base64Encoder: toBase64,
|
|
61
|
+
base64Decoder: fromBase64,
|
|
62
|
+
utf8Encoder: toUtf8,
|
|
63
|
+
utf8Decoder: fromUtf8,
|
|
64
|
+
streamCollector: streamCollector,
|
|
65
|
+
requestHandler: new NodeHttpHandler(),
|
|
66
|
+
disableHostPrefix: true
|
|
67
|
+
};
|
|
68
|
+
async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
|
|
69
|
+
let input;
|
|
70
|
+
try {
|
|
71
|
+
input = await serializer.deserialize(request, {
|
|
72
|
+
endpoint: () => Promise.resolve(request), ...serdeContextBase
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (__isFrameworkException(error)) {
|
|
77
|
+
return serializeFrameworkException(error, serdeContextBase);
|
|
78
|
+
}
|
|
79
|
+
;
|
|
80
|
+
return serializeFrameworkException(new __SerializationException(), serdeContextBase);
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
let validationFailures = validationFn(input);
|
|
84
|
+
if (validationFailures && validationFailures.length > 0) {
|
|
85
|
+
let validationException = validationCustomizer({ operation: operationName }, validationFailures);
|
|
86
|
+
if (validationException) {
|
|
87
|
+
return serializer.serializeError(validationException, serdeContextBase);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let output = await operation(input, context);
|
|
91
|
+
return serializer.serialize(output, serdeContextBase);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (serializer.isOperationError(error)) {
|
|
95
|
+
return serializer.serializeError(error, serdeContextBase);
|
|
96
|
+
}
|
|
97
|
+
console.log('Received an unexpected error', error);
|
|
98
|
+
return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export class PopularShopsPublicHandler {
|
|
102
|
+
constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
|
|
103
|
+
this.operation = operation;
|
|
104
|
+
this.mux = mux;
|
|
105
|
+
this.serializer = serializer;
|
|
106
|
+
this.serializeFrameworkException = serializeFrameworkException;
|
|
107
|
+
this.validationCustomizer = validationCustomizer;
|
|
108
|
+
}
|
|
109
|
+
async handle(request, context) {
|
|
110
|
+
const target = this.mux.match(request);
|
|
111
|
+
if (target === undefined) {
|
|
112
|
+
console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.PopularShopsPublic. This indicates a misconfiguration.');
|
|
113
|
+
return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
114
|
+
}
|
|
115
|
+
return handle(request, context, "PopularShopsPublic", this.serializer, this.operation, this.serializeFrameworkException, PopularShopsPublicServerInput.validate, this.validationCustomizer);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ShopListInput, } from "../../models/models_0";
|
|
2
|
+
import { deserializeRadiusShopsRequest, serializeFrameworkException, serializeRadiusShopsResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
|
|
3
|
+
import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
|
|
4
|
+
import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
|
|
5
|
+
import { fromBase64, toBase64, } from "@smithy/util-base64";
|
|
6
|
+
import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
|
|
7
|
+
export var RadiusShopsServerInput;
|
|
8
|
+
(function (RadiusShopsServerInput) {
|
|
9
|
+
RadiusShopsServerInput.validate = ShopListInput.validate;
|
|
10
|
+
})(RadiusShopsServerInput || (RadiusShopsServerInput = {}));
|
|
11
|
+
export class RadiusShopsSerializer {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.serialize = serializeRadiusShopsResponse;
|
|
14
|
+
this.deserialize = deserializeRadiusShopsRequest;
|
|
15
|
+
}
|
|
16
|
+
isOperationError(error) {
|
|
17
|
+
const names = ["ValidationException", "RuntimeError"];
|
|
18
|
+
return names.includes(error.name);
|
|
19
|
+
}
|
|
20
|
+
;
|
|
21
|
+
serializeError(error, ctx) {
|
|
22
|
+
switch (error.name) {
|
|
23
|
+
case "ValidationException": {
|
|
24
|
+
return serializeValidationExceptionError(error, ctx);
|
|
25
|
+
}
|
|
26
|
+
case "RuntimeError": {
|
|
27
|
+
return serializeRuntimeErrorError(error, ctx);
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const getRadiusShopsHandler = (operation) => {
|
|
36
|
+
const mux = new httpbinding.HttpBindingMux([
|
|
37
|
+
new httpbinding.UriSpec('GET', [
|
|
38
|
+
{ type: 'path_literal', value: "public" },
|
|
39
|
+
{ type: 'path_literal', value: "shops" },
|
|
40
|
+
{ type: 'path_literal', value: "radius" },
|
|
41
|
+
], [], { service: "AppAPI", operation: "RadiusShops" }),
|
|
42
|
+
]);
|
|
43
|
+
const customizer = (ctx, failures) => {
|
|
44
|
+
if (!failures) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
name: "ValidationException",
|
|
49
|
+
$fault: "client",
|
|
50
|
+
message: __generateValidationSummary(failures),
|
|
51
|
+
fieldList: failures.map(failure => ({
|
|
52
|
+
path: failure.path,
|
|
53
|
+
message: __generateValidationMessage(failure)
|
|
54
|
+
}))
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
return new RadiusShopsHandler(operation, mux, new RadiusShopsSerializer(), serializeFrameworkException, customizer);
|
|
58
|
+
};
|
|
59
|
+
const serdeContextBase = {
|
|
60
|
+
base64Encoder: toBase64,
|
|
61
|
+
base64Decoder: fromBase64,
|
|
62
|
+
utf8Encoder: toUtf8,
|
|
63
|
+
utf8Decoder: fromUtf8,
|
|
64
|
+
streamCollector: streamCollector,
|
|
65
|
+
requestHandler: new NodeHttpHandler(),
|
|
66
|
+
disableHostPrefix: true
|
|
67
|
+
};
|
|
68
|
+
async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
|
|
69
|
+
let input;
|
|
70
|
+
try {
|
|
71
|
+
input = await serializer.deserialize(request, {
|
|
72
|
+
endpoint: () => Promise.resolve(request), ...serdeContextBase
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (__isFrameworkException(error)) {
|
|
77
|
+
return serializeFrameworkException(error, serdeContextBase);
|
|
78
|
+
}
|
|
79
|
+
;
|
|
80
|
+
return serializeFrameworkException(new __SerializationException(), serdeContextBase);
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
let validationFailures = validationFn(input);
|
|
84
|
+
if (validationFailures && validationFailures.length > 0) {
|
|
85
|
+
let validationException = validationCustomizer({ operation: operationName }, validationFailures);
|
|
86
|
+
if (validationException) {
|
|
87
|
+
return serializer.serializeError(validationException, serdeContextBase);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
let output = await operation(input, context);
|
|
91
|
+
return serializer.serialize(output, serdeContextBase);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (serializer.isOperationError(error)) {
|
|
95
|
+
return serializer.serializeError(error, serdeContextBase);
|
|
96
|
+
}
|
|
97
|
+
console.log('Received an unexpected error', error);
|
|
98
|
+
return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export class RadiusShopsHandler {
|
|
102
|
+
constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
|
|
103
|
+
this.operation = operation;
|
|
104
|
+
this.mux = mux;
|
|
105
|
+
this.serializer = serializer;
|
|
106
|
+
this.serializeFrameworkException = serializeFrameworkException;
|
|
107
|
+
this.validationCustomizer = validationCustomizer;
|
|
108
|
+
}
|
|
109
|
+
async handle(request, context) {
|
|
110
|
+
const target = this.mux.match(request);
|
|
111
|
+
if (target === undefined) {
|
|
112
|
+
console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.RadiusShops. This indicates a misconfiguration.');
|
|
113
|
+
return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
114
|
+
}
|
|
115
|
+
return handle(request, context, "RadiusShops", this.serializer, this.operation, this.serializeFrameworkException, RadiusShopsServerInput.validate, this.validationCustomizer);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { RecordVisitInput, } from "../../models/models_0";
|
|
2
|
+
import { deserializeRecordVisitRequest, serializeFrameworkException, serializeInvalidOperationErrorError, serializeRecordVisitResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
|
|
3
|
+
import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
|
|
4
|
+
import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
|
|
5
|
+
import { fromBase64, toBase64, } from "@smithy/util-base64";
|
|
6
|
+
import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
|
|
7
|
+
export var RecordVisitServerInput;
|
|
8
|
+
(function (RecordVisitServerInput) {
|
|
9
|
+
RecordVisitServerInput.validate = RecordVisitInput.validate;
|
|
10
|
+
})(RecordVisitServerInput || (RecordVisitServerInput = {}));
|
|
11
|
+
export class RecordVisitSerializer {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.serialize = serializeRecordVisitResponse;
|
|
14
|
+
this.deserialize = deserializeRecordVisitRequest;
|
|
15
|
+
}
|
|
16
|
+
isOperationError(error) {
|
|
17
|
+
const names = ["ValidationException", "RuntimeError", "InvalidOperationError"];
|
|
18
|
+
return names.includes(error.name);
|
|
19
|
+
}
|
|
20
|
+
;
|
|
21
|
+
serializeError(error, ctx) {
|
|
22
|
+
switch (error.name) {
|
|
23
|
+
case "ValidationException": {
|
|
24
|
+
return serializeValidationExceptionError(error, ctx);
|
|
25
|
+
}
|
|
26
|
+
case "RuntimeError": {
|
|
27
|
+
return serializeRuntimeErrorError(error, ctx);
|
|
28
|
+
}
|
|
29
|
+
case "InvalidOperationError": {
|
|
30
|
+
return serializeInvalidOperationErrorError(error, ctx);
|
|
31
|
+
}
|
|
32
|
+
default: {
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export const getRecordVisitHandler = (operation) => {
|
|
39
|
+
const mux = new httpbinding.HttpBindingMux([
|
|
40
|
+
new httpbinding.UriSpec('POST', [
|
|
41
|
+
{ type: 'path_literal', value: "visit" },
|
|
42
|
+
], [
|
|
43
|
+
{ type: 'query', key: "shop_id" },
|
|
44
|
+
{ type: 'query', key: "timestamp" },
|
|
45
|
+
{ type: 'query', key: "lat" },
|
|
46
|
+
{ type: 'query', key: "lon" },
|
|
47
|
+
], { service: "AppAPI", operation: "RecordVisit" }),
|
|
48
|
+
]);
|
|
49
|
+
const customizer = (ctx, failures) => {
|
|
50
|
+
if (!failures) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
name: "ValidationException",
|
|
55
|
+
$fault: "client",
|
|
56
|
+
message: __generateValidationSummary(failures),
|
|
57
|
+
fieldList: failures.map(failure => ({
|
|
58
|
+
path: failure.path,
|
|
59
|
+
message: __generateValidationMessage(failure)
|
|
60
|
+
}))
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
return new RecordVisitHandler(operation, mux, new RecordVisitSerializer(), serializeFrameworkException, customizer);
|
|
64
|
+
};
|
|
65
|
+
const serdeContextBase = {
|
|
66
|
+
base64Encoder: toBase64,
|
|
67
|
+
base64Decoder: fromBase64,
|
|
68
|
+
utf8Encoder: toUtf8,
|
|
69
|
+
utf8Decoder: fromUtf8,
|
|
70
|
+
streamCollector: streamCollector,
|
|
71
|
+
requestHandler: new NodeHttpHandler(),
|
|
72
|
+
disableHostPrefix: true
|
|
73
|
+
};
|
|
74
|
+
async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
|
|
75
|
+
let input;
|
|
76
|
+
try {
|
|
77
|
+
input = await serializer.deserialize(request, {
|
|
78
|
+
endpoint: () => Promise.resolve(request), ...serdeContextBase
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (__isFrameworkException(error)) {
|
|
83
|
+
return serializeFrameworkException(error, serdeContextBase);
|
|
84
|
+
}
|
|
85
|
+
;
|
|
86
|
+
return serializeFrameworkException(new __SerializationException(), serdeContextBase);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
let validationFailures = validationFn(input);
|
|
90
|
+
if (validationFailures && validationFailures.length > 0) {
|
|
91
|
+
let validationException = validationCustomizer({ operation: operationName }, validationFailures);
|
|
92
|
+
if (validationException) {
|
|
93
|
+
return serializer.serializeError(validationException, serdeContextBase);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
let output = await operation(input, context);
|
|
97
|
+
return serializer.serialize(output, serdeContextBase);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
if (serializer.isOperationError(error)) {
|
|
101
|
+
return serializer.serializeError(error, serdeContextBase);
|
|
102
|
+
}
|
|
103
|
+
console.log('Received an unexpected error', error);
|
|
104
|
+
return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export class RecordVisitHandler {
|
|
108
|
+
constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
|
|
109
|
+
this.operation = operation;
|
|
110
|
+
this.mux = mux;
|
|
111
|
+
this.serializer = serializer;
|
|
112
|
+
this.serializeFrameworkException = serializeFrameworkException;
|
|
113
|
+
this.validationCustomizer = validationCustomizer;
|
|
114
|
+
}
|
|
115
|
+
async handle(request, context) {
|
|
116
|
+
const target = this.mux.match(request);
|
|
117
|
+
if (target === undefined) {
|
|
118
|
+
console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.RecordVisit. This indicates a misconfiguration.');
|
|
119
|
+
return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
120
|
+
}
|
|
121
|
+
return handle(request, context, "RecordVisit", this.serializer, this.operation, this.serializeFrameworkException, RecordVisitServerInput.validate, this.validationCustomizer);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { RedeemFirstTimeRewardInput, } from "../../models/models_0";
|
|
2
|
+
import { deserializeRedeemFirstTimeRewardRequest, serializeFrameworkException, serializeRedeemFirstTimeRewardResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
|
|
3
|
+
import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
|
|
4
|
+
import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
|
|
5
|
+
import { fromBase64, toBase64, } from "@smithy/util-base64";
|
|
6
|
+
import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
|
|
7
|
+
export var RedeemFirstTimeRewardServerInput;
|
|
8
|
+
(function (RedeemFirstTimeRewardServerInput) {
|
|
9
|
+
RedeemFirstTimeRewardServerInput.validate = RedeemFirstTimeRewardInput.validate;
|
|
10
|
+
})(RedeemFirstTimeRewardServerInput || (RedeemFirstTimeRewardServerInput = {}));
|
|
11
|
+
export class RedeemFirstTimeRewardSerializer {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.serialize = serializeRedeemFirstTimeRewardResponse;
|
|
14
|
+
this.deserialize = deserializeRedeemFirstTimeRewardRequest;
|
|
15
|
+
}
|
|
16
|
+
isOperationError(error) {
|
|
17
|
+
const names = ["ValidationException", "RuntimeError"];
|
|
18
|
+
return names.includes(error.name);
|
|
19
|
+
}
|
|
20
|
+
;
|
|
21
|
+
serializeError(error, ctx) {
|
|
22
|
+
switch (error.name) {
|
|
23
|
+
case "ValidationException": {
|
|
24
|
+
return serializeValidationExceptionError(error, ctx);
|
|
25
|
+
}
|
|
26
|
+
case "RuntimeError": {
|
|
27
|
+
return serializeRuntimeErrorError(error, ctx);
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const getRedeemFirstTimeRewardHandler = (operation) => {
|
|
36
|
+
const mux = new httpbinding.HttpBindingMux([
|
|
37
|
+
new httpbinding.UriSpec('PUT', [
|
|
38
|
+
{ type: 'path_literal', value: "rewards" },
|
|
39
|
+
{ type: 'path_literal', value: "redeem" },
|
|
40
|
+
{ type: 'path_literal', value: "first-time" },
|
|
41
|
+
], [
|
|
42
|
+
{ type: 'query', key: "org_id" },
|
|
43
|
+
], { service: "AppAPI", operation: "RedeemFirstTimeReward" }),
|
|
44
|
+
]);
|
|
45
|
+
const customizer = (ctx, failures) => {
|
|
46
|
+
if (!failures) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
name: "ValidationException",
|
|
51
|
+
$fault: "client",
|
|
52
|
+
message: __generateValidationSummary(failures),
|
|
53
|
+
fieldList: failures.map(failure => ({
|
|
54
|
+
path: failure.path,
|
|
55
|
+
message: __generateValidationMessage(failure)
|
|
56
|
+
}))
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
return new RedeemFirstTimeRewardHandler(operation, mux, new RedeemFirstTimeRewardSerializer(), serializeFrameworkException, customizer);
|
|
60
|
+
};
|
|
61
|
+
const serdeContextBase = {
|
|
62
|
+
base64Encoder: toBase64,
|
|
63
|
+
base64Decoder: fromBase64,
|
|
64
|
+
utf8Encoder: toUtf8,
|
|
65
|
+
utf8Decoder: fromUtf8,
|
|
66
|
+
streamCollector: streamCollector,
|
|
67
|
+
requestHandler: new NodeHttpHandler(),
|
|
68
|
+
disableHostPrefix: true
|
|
69
|
+
};
|
|
70
|
+
async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
|
|
71
|
+
let input;
|
|
72
|
+
try {
|
|
73
|
+
input = await serializer.deserialize(request, {
|
|
74
|
+
endpoint: () => Promise.resolve(request), ...serdeContextBase
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (__isFrameworkException(error)) {
|
|
79
|
+
return serializeFrameworkException(error, serdeContextBase);
|
|
80
|
+
}
|
|
81
|
+
;
|
|
82
|
+
return serializeFrameworkException(new __SerializationException(), serdeContextBase);
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
let validationFailures = validationFn(input);
|
|
86
|
+
if (validationFailures && validationFailures.length > 0) {
|
|
87
|
+
let validationException = validationCustomizer({ operation: operationName }, validationFailures);
|
|
88
|
+
if (validationException) {
|
|
89
|
+
return serializer.serializeError(validationException, serdeContextBase);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let output = await operation(input, context);
|
|
93
|
+
return serializer.serialize(output, serdeContextBase);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (serializer.isOperationError(error)) {
|
|
97
|
+
return serializer.serializeError(error, serdeContextBase);
|
|
98
|
+
}
|
|
99
|
+
console.log('Received an unexpected error', error);
|
|
100
|
+
return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export class RedeemFirstTimeRewardHandler {
|
|
104
|
+
constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
|
|
105
|
+
this.operation = operation;
|
|
106
|
+
this.mux = mux;
|
|
107
|
+
this.serializer = serializer;
|
|
108
|
+
this.serializeFrameworkException = serializeFrameworkException;
|
|
109
|
+
this.validationCustomizer = validationCustomizer;
|
|
110
|
+
}
|
|
111
|
+
async handle(request, context) {
|
|
112
|
+
const target = this.mux.match(request);
|
|
113
|
+
if (target === undefined) {
|
|
114
|
+
console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.RedeemFirstTimeReward. This indicates a misconfiguration.');
|
|
115
|
+
return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
116
|
+
}
|
|
117
|
+
return handle(request, context, "RedeemFirstTimeReward", this.serializer, this.operation, this.serializeFrameworkException, RedeemFirstTimeRewardServerInput.validate, this.validationCustomizer);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { RedeemPointRewardInput, } from "../../models/models_0";
|
|
2
|
+
import { deserializeRedeemPointRewardRequest, serializeFrameworkException, serializeRedeemPointRewardResponse, serializeRuntimeErrorError, serializeValidationExceptionError, } from "../../protocols/Aws_restJson1";
|
|
3
|
+
import { InternalFailureException as __InternalFailureException, SerializationException as __SerializationException, generateValidationMessage as __generateValidationMessage, generateValidationSummary as __generateValidationSummary, isFrameworkException as __isFrameworkException, httpbinding, } from "@aws-smithy/server-common";
|
|
4
|
+
import { NodeHttpHandler, streamCollector, } from "@smithy/node-http-handler";
|
|
5
|
+
import { fromBase64, toBase64, } from "@smithy/util-base64";
|
|
6
|
+
import { fromUtf8, toUtf8, } from "@smithy/util-utf8";
|
|
7
|
+
export var RedeemPointRewardServerInput;
|
|
8
|
+
(function (RedeemPointRewardServerInput) {
|
|
9
|
+
RedeemPointRewardServerInput.validate = RedeemPointRewardInput.validate;
|
|
10
|
+
})(RedeemPointRewardServerInput || (RedeemPointRewardServerInput = {}));
|
|
11
|
+
export class RedeemPointRewardSerializer {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.serialize = serializeRedeemPointRewardResponse;
|
|
14
|
+
this.deserialize = deserializeRedeemPointRewardRequest;
|
|
15
|
+
}
|
|
16
|
+
isOperationError(error) {
|
|
17
|
+
const names = ["ValidationException", "RuntimeError"];
|
|
18
|
+
return names.includes(error.name);
|
|
19
|
+
}
|
|
20
|
+
;
|
|
21
|
+
serializeError(error, ctx) {
|
|
22
|
+
switch (error.name) {
|
|
23
|
+
case "ValidationException": {
|
|
24
|
+
return serializeValidationExceptionError(error, ctx);
|
|
25
|
+
}
|
|
26
|
+
case "RuntimeError": {
|
|
27
|
+
return serializeRuntimeErrorError(error, ctx);
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const getRedeemPointRewardHandler = (operation) => {
|
|
36
|
+
const mux = new httpbinding.HttpBindingMux([
|
|
37
|
+
new httpbinding.UriSpec('PUT', [
|
|
38
|
+
{ type: 'path_literal', value: "rewards" },
|
|
39
|
+
{ type: 'path_literal', value: "redeem" },
|
|
40
|
+
{ type: 'path_literal', value: "point" },
|
|
41
|
+
], [
|
|
42
|
+
{ type: 'query', key: "org_id" },
|
|
43
|
+
{ type: 'query', key: "reward_id" },
|
|
44
|
+
], { service: "AppAPI", operation: "RedeemPointReward" }),
|
|
45
|
+
]);
|
|
46
|
+
const customizer = (ctx, failures) => {
|
|
47
|
+
if (!failures) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
name: "ValidationException",
|
|
52
|
+
$fault: "client",
|
|
53
|
+
message: __generateValidationSummary(failures),
|
|
54
|
+
fieldList: failures.map(failure => ({
|
|
55
|
+
path: failure.path,
|
|
56
|
+
message: __generateValidationMessage(failure)
|
|
57
|
+
}))
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
return new RedeemPointRewardHandler(operation, mux, new RedeemPointRewardSerializer(), serializeFrameworkException, customizer);
|
|
61
|
+
};
|
|
62
|
+
const serdeContextBase = {
|
|
63
|
+
base64Encoder: toBase64,
|
|
64
|
+
base64Decoder: fromBase64,
|
|
65
|
+
utf8Encoder: toUtf8,
|
|
66
|
+
utf8Decoder: fromUtf8,
|
|
67
|
+
streamCollector: streamCollector,
|
|
68
|
+
requestHandler: new NodeHttpHandler(),
|
|
69
|
+
disableHostPrefix: true
|
|
70
|
+
};
|
|
71
|
+
async function handle(request, context, operationName, serializer, operation, serializeFrameworkException, validationFn, validationCustomizer) {
|
|
72
|
+
let input;
|
|
73
|
+
try {
|
|
74
|
+
input = await serializer.deserialize(request, {
|
|
75
|
+
endpoint: () => Promise.resolve(request), ...serdeContextBase
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
if (__isFrameworkException(error)) {
|
|
80
|
+
return serializeFrameworkException(error, serdeContextBase);
|
|
81
|
+
}
|
|
82
|
+
;
|
|
83
|
+
return serializeFrameworkException(new __SerializationException(), serdeContextBase);
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
let validationFailures = validationFn(input);
|
|
87
|
+
if (validationFailures && validationFailures.length > 0) {
|
|
88
|
+
let validationException = validationCustomizer({ operation: operationName }, validationFailures);
|
|
89
|
+
if (validationException) {
|
|
90
|
+
return serializer.serializeError(validationException, serdeContextBase);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
let output = await operation(input, context);
|
|
94
|
+
return serializer.serialize(output, serdeContextBase);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
if (serializer.isOperationError(error)) {
|
|
98
|
+
return serializer.serializeError(error, serdeContextBase);
|
|
99
|
+
}
|
|
100
|
+
console.log('Received an unexpected error', error);
|
|
101
|
+
return serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export class RedeemPointRewardHandler {
|
|
105
|
+
constructor(operation, mux, serializer, serializeFrameworkException, validationCustomizer) {
|
|
106
|
+
this.operation = operation;
|
|
107
|
+
this.mux = mux;
|
|
108
|
+
this.serializer = serializer;
|
|
109
|
+
this.serializeFrameworkException = serializeFrameworkException;
|
|
110
|
+
this.validationCustomizer = validationCustomizer;
|
|
111
|
+
}
|
|
112
|
+
async handle(request, context) {
|
|
113
|
+
const target = this.mux.match(request);
|
|
114
|
+
if (target === undefined) {
|
|
115
|
+
console.log('Received a request that did not match software.amazon.smithy.app#AppAPI.RedeemPointReward. This indicates a misconfiguration.');
|
|
116
|
+
return this.serializeFrameworkException(new __InternalFailureException(), serdeContextBase);
|
|
117
|
+
}
|
|
118
|
+
return handle(request, context, "RedeemPointReward", this.serializer, this.operation, this.serializeFrameworkException, RedeemPointRewardServerInput.validate, this.validationCustomizer);
|
|
119
|
+
}
|
|
120
|
+
}
|