@cinerino/sdk 12.3.0-alpha.10 → 12.3.0-alpha.12
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/example/src/chevre/default/findProductOffers.ts +43 -0
- package/lib/abstract/chevre/productOffer.d.ts +33 -0
- package/lib/abstract/chevre/productOffer.js +84 -0
- package/lib/abstract/chevre.d.ts +9 -0
- package/lib/abstract/chevre.js +20 -0
- package/lib/abstract/chevreAdmin/productOffer.d.ts +22 -35
- package/lib/abstract/chevreAdmin/productOffer.js +12 -4
- package/lib/bundle.js +750 -632
- package/package.json +2 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
// import * as moment from 'moment';
|
|
3
|
+
|
|
4
|
+
import * as client from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
const authClient = await client.auth.ClientCredentials.createInstance({
|
|
10
|
+
domain: <string>process.env.CHEVRE_AUTHORIZE_SERVER_DOMAIN,
|
|
11
|
+
clientId: <string>process.env.CHEVRE_CLIENT_ID,
|
|
12
|
+
clientSecret: <string>process.env.CHEVRE_CLIENT_SECRET,
|
|
13
|
+
scopes: [],
|
|
14
|
+
state: ''
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const productOfferService = await (await client.loadChevre({
|
|
18
|
+
endpoint: <string>process.env.CHEVRE_ENDPOINT,
|
|
19
|
+
auth: authClient
|
|
20
|
+
})).createProductOfferInstance({
|
|
21
|
+
project: { id: PROJECT_ID },
|
|
22
|
+
seller: { id: '' }
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const result = await productOfferService.findProductOffers({
|
|
26
|
+
page: 1,
|
|
27
|
+
limit: 1,
|
|
28
|
+
// identifiers: ['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', '20250924ValidForMemberTier'],
|
|
29
|
+
itemOfferedIdentifiers: ['x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', '20250924ValidForMemberTier']
|
|
30
|
+
// startFrom: new Date(),
|
|
31
|
+
// startThrough: moment()
|
|
32
|
+
// .add(1, 'days')
|
|
33
|
+
// .toDate()
|
|
34
|
+
});
|
|
35
|
+
console.log(result);
|
|
36
|
+
console.log(result.length, 'offers returned');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
main()
|
|
40
|
+
.then(() => {
|
|
41
|
+
console.log('success!');
|
|
42
|
+
})
|
|
43
|
+
.catch(console.error);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as factory from '../factory';
|
|
2
|
+
import { Service } from '../service';
|
|
3
|
+
export declare type IProductOfferAsFindResult = Pick<factory.productOffer.IProductOffer, 'acceptedPaymentMethod' | 'availability' | 'identifier' | 'itemOffered' | 'validForMemberTier' | 'validFrom' | 'validThrough'> & {
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
export interface IFindParams {
|
|
7
|
+
/**
|
|
8
|
+
* max: 100
|
|
9
|
+
*/
|
|
10
|
+
limit: number;
|
|
11
|
+
page: number;
|
|
12
|
+
/**
|
|
13
|
+
* オファーコレクションコード
|
|
14
|
+
* max length: 10
|
|
15
|
+
*/
|
|
16
|
+
itemOfferedIdentifiers?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* オファーコード
|
|
19
|
+
* max length: 10
|
|
20
|
+
*/
|
|
21
|
+
identifiers?: string[];
|
|
22
|
+
id?: string;
|
|
23
|
+
/**
|
|
24
|
+
* 有効なメンバープログラムティアコード
|
|
25
|
+
*/
|
|
26
|
+
validForMemberTierIdentifier?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* プロダクトオファーサービス
|
|
30
|
+
*/
|
|
31
|
+
export declare class ProductOfferService extends Service {
|
|
32
|
+
findProductOffers(params: IFindParams): Promise<IProductOfferAsFindResult[]>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.ProductOfferService = void 0;
|
|
55
|
+
var http_status_1 = require("http-status");
|
|
56
|
+
var service_1 = require("../service");
|
|
57
|
+
var BASE_URI = '/productOffers';
|
|
58
|
+
/**
|
|
59
|
+
* プロダクトオファーサービス
|
|
60
|
+
*/
|
|
61
|
+
var ProductOfferService = /** @class */ (function (_super) {
|
|
62
|
+
__extends(ProductOfferService, _super);
|
|
63
|
+
function ProductOfferService() {
|
|
64
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
65
|
+
}
|
|
66
|
+
ProductOfferService.prototype.findProductOffers = function (params) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
var _this = this;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
return [2 /*return*/, this.fetch({
|
|
71
|
+
uri: BASE_URI,
|
|
72
|
+
method: 'GET',
|
|
73
|
+
qs: params,
|
|
74
|
+
expectedStatusCodes: [http_status_1.OK]
|
|
75
|
+
})
|
|
76
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
77
|
+
return [2 /*return*/, response.json()];
|
|
78
|
+
}); }); })];
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
return ProductOfferService;
|
|
83
|
+
}(service_1.Service));
|
|
84
|
+
exports.ProductOfferService = ProductOfferService;
|
package/lib/abstract/chevre.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { PaymentProductService } from './chevre/paymentService';
|
|
|
8
8
|
import type { PlaceService } from './chevre/place';
|
|
9
9
|
import type { HasPOSService } from './chevre/place/hasPOS';
|
|
10
10
|
import type { ProductService } from './chevre/product';
|
|
11
|
+
import type { ProductOfferService } from './chevre/productOffer';
|
|
11
12
|
import type { SellerService } from './chevre/seller';
|
|
12
13
|
import type { TripService } from './chevre/trip';
|
|
13
14
|
export declare namespace service {
|
|
@@ -77,6 +78,13 @@ export declare namespace service {
|
|
|
77
78
|
namespace Product {
|
|
78
79
|
let svc: typeof ProductService | undefined;
|
|
79
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* プロダクトオファーサービス
|
|
83
|
+
*/
|
|
84
|
+
type ProductOffer = ProductOfferService;
|
|
85
|
+
namespace ProductOffer {
|
|
86
|
+
let svc: typeof ProductOfferService | undefined;
|
|
87
|
+
}
|
|
80
88
|
/**
|
|
81
89
|
* 販売者サービス
|
|
82
90
|
*/
|
|
@@ -107,6 +115,7 @@ export declare class Chevre {
|
|
|
107
115
|
createPlaceInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<PlaceService>;
|
|
108
116
|
createHasPOSInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<HasPOSService>;
|
|
109
117
|
createProductInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<ProductService>;
|
|
118
|
+
createProductOfferInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<ProductOfferService>;
|
|
110
119
|
createSellerInstance(params: Pick<IOptions, 'project'>): Promise<SellerService>;
|
|
111
120
|
createTripInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<TripService>;
|
|
112
121
|
}
|
package/lib/abstract/chevre.js
CHANGED
|
@@ -80,6 +80,9 @@ var service;
|
|
|
80
80
|
var Product;
|
|
81
81
|
(function (Product) {
|
|
82
82
|
})(Product = service.Product || (service.Product = {}));
|
|
83
|
+
var ProductOffer;
|
|
84
|
+
(function (ProductOffer) {
|
|
85
|
+
})(ProductOffer = service.ProductOffer || (service.ProductOffer = {}));
|
|
83
86
|
var Seller;
|
|
84
87
|
(function (Seller) {
|
|
85
88
|
})(Seller = service.Seller || (service.Seller = {}));
|
|
@@ -247,6 +250,23 @@ var Chevre = /** @class */ (function () {
|
|
|
247
250
|
});
|
|
248
251
|
});
|
|
249
252
|
};
|
|
253
|
+
Chevre.prototype.createProductOfferInstance = function (params) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
+
var _a;
|
|
256
|
+
return __generator(this, function (_b) {
|
|
257
|
+
switch (_b.label) {
|
|
258
|
+
case 0:
|
|
259
|
+
if (!(service.ProductOffer.svc === undefined)) return [3 /*break*/, 2];
|
|
260
|
+
_a = service.ProductOffer;
|
|
261
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return require('./chevre/productOffer'); })];
|
|
262
|
+
case 1:
|
|
263
|
+
_a.svc = (_b.sent()).ProductOfferService;
|
|
264
|
+
_b.label = 2;
|
|
265
|
+
case 2: return [2 /*return*/, new service.ProductOffer.svc(__assign(__assign(__assign({}, this.options), params), { retryableStatusCodes: [] }))];
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
};
|
|
250
270
|
Chevre.prototype.createSellerInstance = function (params) {
|
|
251
271
|
return __awaiter(this, void 0, void 0, function () {
|
|
252
272
|
var _a;
|
|
@@ -1,60 +1,48 @@
|
|
|
1
1
|
import * as factory from '../factory';
|
|
2
2
|
import { Service } from '../service';
|
|
3
|
-
interface
|
|
4
|
-
typeOf: factory.offerType.Offer;
|
|
3
|
+
export interface IFindParams {
|
|
5
4
|
/**
|
|
6
|
-
*
|
|
5
|
+
* max: 20
|
|
7
6
|
*/
|
|
8
|
-
identifier: string;
|
|
9
|
-
itemOffered: {
|
|
10
|
-
typeOf: factory.offerType.AggregateOffer;
|
|
11
|
-
/**
|
|
12
|
-
* プロダクトオファーコレクションコード
|
|
13
|
-
*/
|
|
14
|
-
identifier: string;
|
|
15
|
-
};
|
|
16
|
-
availability: factory.itemAvailability.InStock | factory.itemAvailability.OutOfStock;
|
|
17
|
-
validFrom: Date;
|
|
18
|
-
validThrough: Date;
|
|
19
|
-
acceptedPaymentMethod?: {
|
|
20
|
-
typeOf: 'PaymentMethod';
|
|
21
|
-
identifier: string;
|
|
22
|
-
};
|
|
23
|
-
validForMemberTier?: Pick<factory.issuer.IMemberProgramTier, 'identifier' | 'typeOf'>;
|
|
24
|
-
}
|
|
25
|
-
interface ICreateValidForMemberTierParams {
|
|
26
|
-
identifier: string;
|
|
27
|
-
validForMemberTier: {
|
|
28
|
-
identifier: string;
|
|
29
|
-
};
|
|
30
|
-
validFrom: Date;
|
|
31
|
-
validThrough: Date;
|
|
32
|
-
}
|
|
33
|
-
export interface IFindParams {
|
|
34
7
|
limit: number;
|
|
35
8
|
page: number;
|
|
36
9
|
itemOfferedIdentifier?: string;
|
|
37
10
|
itemOfferedIdentifiers?: string[];
|
|
38
11
|
identifiers?: string[];
|
|
39
12
|
id?: string;
|
|
13
|
+
validForMemberTierIdentifier?: string;
|
|
40
14
|
}
|
|
41
15
|
/**
|
|
42
16
|
* プロダクトオファーサービス
|
|
43
17
|
*/
|
|
44
18
|
export declare class ProductOfferService extends Service {
|
|
45
19
|
/**
|
|
46
|
-
*
|
|
20
|
+
* メンバープログラムティアで有効なプロダクトオファーを追加する
|
|
21
|
+
*/
|
|
22
|
+
createValidForMemberTierByIdentifier(
|
|
23
|
+
/**
|
|
24
|
+
* max: 20
|
|
47
25
|
*/
|
|
48
|
-
|
|
26
|
+
params: factory.productOffer.IAddValidForMemberTierParams[], options: {
|
|
27
|
+
/**
|
|
28
|
+
* プロダクトオファーコレクションコード
|
|
29
|
+
*/
|
|
49
30
|
itemOfferedIdentifier: string;
|
|
50
31
|
}): Promise<void>;
|
|
51
32
|
/**
|
|
52
|
-
*
|
|
33
|
+
* メンバープログラムティアで有効なプロダクトオファーを編集する
|
|
34
|
+
*/
|
|
35
|
+
updateValidForMemberTierByIdentifier(
|
|
36
|
+
/**
|
|
37
|
+
* max: 20
|
|
53
38
|
*/
|
|
54
|
-
|
|
39
|
+
params: factory.productOffer.IAddValidForMemberTierParams[], options: {
|
|
40
|
+
/**
|
|
41
|
+
* プロダクトオファーコレクションコード
|
|
42
|
+
*/
|
|
55
43
|
itemOfferedIdentifier: string;
|
|
56
44
|
}): Promise<void>;
|
|
57
|
-
findProductOffers(params: IFindParams): Promise<(IProductOffer & {
|
|
45
|
+
findProductOffers(params: IFindParams): Promise<(Omit<factory.productOffer.IProductOffer, 'project'> & {
|
|
58
46
|
id: string;
|
|
59
47
|
})[]>;
|
|
60
48
|
/**
|
|
@@ -66,4 +54,3 @@ export declare class ProductOfferService extends Service {
|
|
|
66
54
|
token: string;
|
|
67
55
|
}>;
|
|
68
56
|
}
|
|
69
|
-
export {};
|
|
@@ -64,9 +64,13 @@ var ProductOfferService = /** @class */ (function (_super) {
|
|
|
64
64
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* メンバープログラムティアで有効なプロダクトオファーを追加する
|
|
68
68
|
*/
|
|
69
|
-
ProductOfferService.prototype.createValidForMemberTierByIdentifier = function (
|
|
69
|
+
ProductOfferService.prototype.createValidForMemberTierByIdentifier = function (
|
|
70
|
+
/**
|
|
71
|
+
* max: 20
|
|
72
|
+
*/
|
|
73
|
+
params, options) {
|
|
70
74
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
75
|
var itemOfferedIdentifier;
|
|
72
76
|
return __generator(this, function (_a) {
|
|
@@ -88,9 +92,13 @@ var ProductOfferService = /** @class */ (function (_super) {
|
|
|
88
92
|
});
|
|
89
93
|
};
|
|
90
94
|
/**
|
|
91
|
-
*
|
|
95
|
+
* メンバープログラムティアで有効なプロダクトオファーを編集する
|
|
96
|
+
*/
|
|
97
|
+
ProductOfferService.prototype.updateValidForMemberTierByIdentifier = function (
|
|
98
|
+
/**
|
|
99
|
+
* max: 20
|
|
92
100
|
*/
|
|
93
|
-
|
|
101
|
+
params, options) {
|
|
94
102
|
return __awaiter(this, void 0, void 0, function () {
|
|
95
103
|
var itemOfferedIdentifier;
|
|
96
104
|
return __generator(this, function (_a) {
|