@warpstore/warpstore-package 1.0.0 → 1.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 ADDED
@@ -0,0 +1,31 @@
1
+ # warpstore-package
2
+
3
+ Esta biblioteca oferece aos desenvolvedores uma coleção descomplicada de funcionalidades para facilitar a integração a API da Warp Store em seu site, permitindo a exibição e venda de produtos cadastrados no nosso Dashboard.
4
+
5
+ ## 📲 Instalação
6
+
7
+ 1. Instale o nosso NODE SDK usando o comando logo abaixo:
8
+ ```sh
9
+ $ npm i @warpstore/warpstore-package
10
+ ```
11
+
12
+
13
+ ## 🌟 Começando
14
+
15
+ O uso simples se parece com:
16
+
17
+ ```javascript
18
+ const warpstore = new WarpStore()
19
+
20
+ const response = await warpstore.template.v1.getStoreInfo({
21
+ subDomain: "seu_sub_dominio",
22
+ // domain: "ou_seu_dominio"
23
+ })
24
+
25
+ if(response.isFailure()){
26
+ console.log(response.value.errorName);
27
+ return;
28
+ }
29
+
30
+ console.log(response.value);
31
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warpstore/warpstore-package",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "dist/src/main.js",
6
6
  "types": "dist/src/main.d.ts",
@@ -42,4 +42,4 @@
42
42
  "ts-node-dev": "^2.0.0",
43
43
  "tsconfig-paths": "^4.2.0"
44
44
  }
45
- }
45
+ }
@@ -3,34 +3,34 @@ import { Either, failure, success } from "@/core/logic";
3
3
  import axios, { AxiosResponse } from "axios"
4
4
 
5
5
  const api = axios.create({
6
- baseURL: 'http://localhost:5000',
6
+ baseURL: 'https://api.warpstore.app',
7
7
  timeout: 1000,
8
8
  validateStatus: () => true
9
9
  })
10
10
 
11
11
  export class RequestManager {
12
12
 
13
- static async makeRequest<TResponse, TError, >(path: string, httpInput: RequestManager.HttpInput = {} as any): Promise<Either<TError, TResponse>> {
13
+ static async makeRequest<TResponse, TError,>(path: string, httpInput: RequestManager.HttpInput = {} as any): Promise<Either<TError, TResponse>> {
14
14
  const { body, headers, query, method } = httpInput
15
15
 
16
16
  let response: AxiosResponse
17
17
 
18
- if(method === "POST") {
18
+ if (method === "POST") {
19
19
  response = await api.post(path, body, {
20
20
  headers,
21
21
  params: query
22
22
  })
23
- }else {
23
+ } else {
24
24
  response = await api.get(path, {
25
25
  headers,
26
26
  params: query
27
27
  })
28
28
  }
29
29
 
30
- if(response.status !== 200) {
30
+ if (response.status !== 200) {
31
31
  return failure(new CustomDomainError(response.data?.error?.name)) as any
32
32
  }
33
-
33
+
34
34
  return success(response.data) as any
35
35
  }
36
36
 
@@ -40,7 +40,7 @@ export namespace RequestManager {
40
40
 
41
41
 
42
42
  export type HttpInput = {
43
- method: "GET" | "POST"
43
+ method: "GET" | "POST"
44
44
  body?: object
45
45
  headers?: object
46
46
  query?: object