marketplace-hub-client 0.0.1 → 0.0.2

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 CHANGED
@@ -1,63 +1,97 @@
1
- # MarketplaceHubClient
1
+ # Marketplace Hub Client Library
2
2
 
3
- This version 21.
3
+ A professional, enterprise-grade Angular client library for interacting with the Marketplace Hub API. This library features built-in security, standard response wrapping, and a developer-friendly interface.
4
4
 
5
- ## Code scaffolding
5
+ ## Features
6
6
 
7
- Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
7
+ - **Standardized API Responses**: All endpoints return a consistent `ApiResponse<T>` wrapper.
8
+ - **Automated Authentication**: Built-in interceptor for `HMAC-SHA256` request signing and `API-KEY` management.
9
+ - **Type Safety**: Fully typed models generated for all API entities.
10
+ - **Idempotency**: Automatic `Idempotency-Key` generation for safe mutating requests (`POST`, `PUT`, `PATCH`).
8
11
 
9
- ```bash
10
- ng generate component component-name
11
- ```
12
-
13
- For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
12
+ ## Installation
14
13
 
15
14
  ```bash
16
- ng generate --help
15
+ npm install marketplace-hub-client
17
16
  ```
18
17
 
19
- ## Building
20
-
21
- To build the library, run:
22
-
23
- ```bash
24
- ng build marketplace-hub-client
25
- ```
18
+ ## Quick Start
26
19
 
27
- This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
20
+ ### 1. Provide the API in your app
28
21
 
29
- ### Publishing the Library
22
+ In your `app.config.ts`:
30
23
 
31
- Once the project is built, you can publish your library by following these steps:
24
+ ```typescript
25
+ import { ApplicationConfig } from '@angular/core';
26
+ import { provideApi } from 'marketplace-hub-client';
32
27
 
33
- 1. Navigate to the `dist` directory:
34
- ```bash
35
- cd dist/marketplace-hub-client
36
- ```
28
+ export const appConfig: ApplicationConfig = {
29
+ providers: [
30
+ provideApi({
31
+ basePath: 'https://api.marketplace-hub.com',
32
+ api_key: 'YOUR_API_KEY',
33
+ apiSecret: 'YOUR_API_SECRET' // Used for HMAC signature
34
+ })
35
+ ]
36
+ };
37
+ ```
37
38
 
38
- 2. Run the `npm publish` command to publish your library to the npm registry:
39
- ```bash
40
- npm publish
41
- ```
39
+ ### 2. Inject and use Services
40
+
41
+ ```typescript
42
+ import { Component, OnInit, inject } from '@angular/core';
43
+ import { ContentService, ProductResponse, ApiResponse } from 'marketplace-hub-client';
44
+
45
+ @Component({
46
+ selector: 'app-product-list',
47
+ standalone: true,
48
+ template: `
49
+ <div *ngIf="products">
50
+ <h3>{{ products.message.detail }}</h3>
51
+ <ul>
52
+ <li *ngFor="let product of products.data.content">
53
+ {{ product.name }} - {{ product.price }}
54
+ </li>
55
+ </ul>
56
+ </div>
57
+ `
58
+ })
59
+ export class ProductListComponent implements OnInit {
60
+ private contentService = inject(ContentService);
61
+ products?: ApiResponse<any>;
62
+
63
+ ngOnInit() {
64
+ this.contentService.getProducts({ page: 0, size: 10 }).subscribe(response => {
65
+ this.products = response;
66
+ });
67
+ }
68
+ }
69
+ ```
42
70
 
43
- ## Running unit tests
71
+ ## API Response Structure
44
72
 
45
- To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
73
+ Every response from the library follows this structure:
46
74
 
47
- ```bash
48
- ng test
75
+ ```typescript
76
+ export interface ApiResponse<T> {
77
+ timestamp: number;
78
+ status: number;
79
+ message: {
80
+ detail: string;
81
+ };
82
+ data: T;
83
+ }
49
84
  ```
50
85
 
51
- ## Running end-to-end tests
86
+ ## Authentication Headers
52
87
 
53
- For end-to-end (e2e) testing, run:
54
-
55
- ```bash
56
- ng e2e
57
- ```
88
+ The library automatically injects the following headers for every request when configured:
58
89
 
59
- Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
90
+ - `X-API-KEY`: Your provided API Key.
91
+ - `X-TIMESTAMP`: Current epoch timestamp.
92
+ - `X-SIGNATURE`: `HMAC-SHA256(body + timestamp, secret)` encoded in Base64.
93
+ - `Idempotency-Key`: A unique UUID for mutating requests.
60
94
 
61
- ## Additional Resources
95
+ ## License
62
96
 
63
- For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
97
+ MIT © ITWays
@@ -405,14 +405,10 @@ class BaseService {
405
405
  /**
406
406
  * Marketplace Hub API
407
407
  *
408
- *
409
- *
410
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
411
- * https://openapi-generator.tech
412
- * Do not edit the class manually.
408
+ * This client library provides a professional interface for interacting with the Marketplace Hub API.
413
409
  */
414
410
  /* tslint:disable:no-unused-variable member-ordering */
415
- class ContentAPIService extends BaseService {
411
+ class ContentService extends BaseService {
416
412
  httpClient;
417
413
  constructor(httpClient, basePath, configuration) {
418
414
  super(basePath, configuration);
@@ -922,10 +918,10 @@ class ContentAPIService extends BaseService {
922
918
  reportProgress: reportProgress
923
919
  });
924
920
  }
925
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ContentAPIService, deps: [{ token: i1.HttpClient }, { token: BASE_PATH, optional: true }, { token: Configuration, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
926
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ContentAPIService, providedIn: 'root' });
921
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ContentService, deps: [{ token: i1.HttpClient }, { token: BASE_PATH, optional: true }, { token: Configuration, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
922
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ContentService, providedIn: 'root' });
927
923
  }
928
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ContentAPIService, decorators: [{
924
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: ContentService, decorators: [{
929
925
  type: Injectable,
930
926
  args: [{
931
927
  providedIn: 'root'
@@ -939,7 +935,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImpor
939
935
  type: Optional
940
936
  }] }] });
941
937
 
942
- const APIS = [ContentAPIService];
938
+ const APIS = [ContentService];
943
939
 
944
940
  /**
945
941
  * Marketplace Hub API
@@ -1220,5 +1216,5 @@ function provideApi(configOrBasePath) {
1220
1216
  * Generated bundle index. Do not edit.
1221
1217
  */
1222
1218
 
1223
- export { APIS, ApiModule, BASE_PATH, COLLECTION_FORMATS, CategoryResponse, Configuration, ContentAPIService, ProductResponse, PublicPaymentMethodResponse, apiAuthenticationInterceptor, provideApi };
1219
+ export { APIS, ApiModule, BASE_PATH, COLLECTION_FORMATS, CategoryResponse, Configuration, ContentService, ProductResponse, PublicPaymentMethodResponse, apiAuthenticationInterceptor, provideApi };
1224
1220
  //# sourceMappingURL=marketplace-hub-client.mjs.map