@blob-solutions/vcr-am-sdk 0.1.0 → 0.4.0
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/README.md +37 -0
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +11 -6
- package/lib/index.d.ts +11 -6
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# VCR.AM SDK
|
|
2
|
+
|
|
3
|
+
This is the official VCR.AM SDK for TS/JS. It provides a simple way to interact with the VCR.AM API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @blob-solutions/vcr-am-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { VCRClient, SaleItem } from "@blob-solutions/vcr-am-sdk";
|
|
15
|
+
|
|
16
|
+
const VCR_AM_API_KEY = "YOUR_API_KEY";
|
|
17
|
+
const VCR_AM_CASHIER_ID = "YOUR_CASHIER_ID";
|
|
18
|
+
|
|
19
|
+
const vcrClient = new VCRClient(VCR_AM_API_KEY);
|
|
20
|
+
|
|
21
|
+
const items: SaleItems = [
|
|
22
|
+
// Add your items here
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const { crn, srcReceiptId } = await vcrClient.registerSale({
|
|
26
|
+
items,
|
|
27
|
+
amount: {
|
|
28
|
+
// Add your amount here
|
|
29
|
+
},
|
|
30
|
+
buyer: {
|
|
31
|
+
type: "individual",
|
|
32
|
+
},
|
|
33
|
+
cashier: {
|
|
34
|
+
id: apiEnv.VCR_AM_CASHIER_ID,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
```
|
package/lib/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var d=(e
|
|
1
|
+
"use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var d=(t,e)=>{for(var i in e)o(t,i,{get:e[i],enumerable:!0})},m=(t,e,i,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!y.call(t,s)&&s!==i&&o(t,s,{get:()=>e[s],enumerable:!(u=c(e,s))||u.enumerable});return t};var g=t=>m(o({},"__esModule",{value:!0}),t);var I={};d(I,{AVAILABLE_LANGUAGES:()=>b,VCRClient:()=>a,unitsKeys:()=>D});module.exports=g(I);var r=require("simple-typed-fetch"),n=require("zod"),f="https://vcr.am/api/v1",A=n.z.object({saleId:n.z.number(),crn:n.z.string(),srcReceiptId:n.z.number().int(),fiscal:n.z.string()}),a=class{constructor(e){this.apiKey=e}async registerSale(e){return await(0,r.simpleFetch)(async()=>await(0,r.fetchWithValidation)(`${f}/sales`,A,{method:"POST",headers:{"x-api-key":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)},n.z.object({error:n.z.string()})))()}};var D=["pc","unit","set","box","pack","case","hr","sess","proj","sub","kg","l","m","g","ml","cm","bottle","can","jar","bag","m2","dozen","pair","mm","roll","tube","km","ton","m3","pallet","other"],b=["hy","ru","en"];
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/lib/index.d.cts
CHANGED
|
@@ -40,13 +40,18 @@ type BaseAndAdditionalDiscounts = {
|
|
|
40
40
|
type ExistingOffer = {
|
|
41
41
|
externalId: string;
|
|
42
42
|
};
|
|
43
|
-
type
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
localizationStrategy: "translation" | "transliteration";
|
|
43
|
+
type OfferTitle = {
|
|
44
|
+
type: "localized";
|
|
45
|
+
content: Partial<Record<Language, string>> & {
|
|
46
|
+
hy: string;
|
|
49
47
|
};
|
|
48
|
+
localizationStrategy: "translation" | "transliteration";
|
|
49
|
+
} | {
|
|
50
|
+
type: "universal";
|
|
51
|
+
content: string;
|
|
52
|
+
};
|
|
53
|
+
type NewOffer = {
|
|
54
|
+
title: OfferTitle;
|
|
50
55
|
type: "product" | "service";
|
|
51
56
|
classifierCode: string;
|
|
52
57
|
defaultMeasureUnit: Unit;
|
package/lib/index.d.ts
CHANGED
|
@@ -40,13 +40,18 @@ type BaseAndAdditionalDiscounts = {
|
|
|
40
40
|
type ExistingOffer = {
|
|
41
41
|
externalId: string;
|
|
42
42
|
};
|
|
43
|
-
type
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
localizationStrategy: "translation" | "transliteration";
|
|
43
|
+
type OfferTitle = {
|
|
44
|
+
type: "localized";
|
|
45
|
+
content: Partial<Record<Language, string>> & {
|
|
46
|
+
hy: string;
|
|
49
47
|
};
|
|
48
|
+
localizationStrategy: "translation" | "transliteration";
|
|
49
|
+
} | {
|
|
50
|
+
type: "universal";
|
|
51
|
+
content: string;
|
|
52
|
+
};
|
|
53
|
+
type NewOffer = {
|
|
54
|
+
title: OfferTitle;
|
|
50
55
|
type: "product" | "service";
|
|
51
56
|
classifierCode: string;
|
|
52
57
|
defaultMeasureUnit: Unit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blob-solutions/vcr-am-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"virtual cash register",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@tsconfig/node20": "^20.1.4",
|
|
49
49
|
"@tsconfig/strictest": "^2.0.5",
|
|
50
|
-
"@types/node": "^20.
|
|
51
|
-
"tsup": "^8.0
|
|
52
|
-
"type-fest": "^4.
|
|
50
|
+
"@types/node": "^20.14.2",
|
|
51
|
+
"tsup": "^8.1.0",
|
|
52
|
+
"type-fest": "^4.20.0"
|
|
53
53
|
},
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|