@warpstore/warpstore-package 1.0.1 → 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 CHANGED
@@ -1,7 +1,8 @@
1
1
  # warpstore-package
2
2
 
3
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
- ## 📲 Installation
4
+
5
+ ## 📲 Instalação
5
6
 
6
7
  1. Instale o nosso NODE SDK usando o comando logo abaixo:
7
8
  ```sh
@@ -27,34 +28,4 @@ if(response.isFailure()){
27
28
  }
28
29
 
29
30
  console.log(response.value);
30
- ```
31
-
32
- ## ✨ Logic
33
-
34
- Each operation will yield one of two outcomes: a MercadoPagoError in the event of an error, or the desired value in case of a successful operation.
35
-
36
- You can check if the operation was successfull or not by calling the methods:
37
- ```javascript
38
- const payment = await mercadoPago.value.payment.create()
39
- if(payment.isFailure()) console.log("operation failed")
40
- if(payment.isSuccess()) console.log("operation succeeded")
41
- ```
42
- Definition of MercadoPagoError:
43
- ```javascript
44
- class MercadoPagoError {
45
- message: string;
46
- aditionalInfo: any;
47
- status: number;
48
- code: number | string
49
- }
50
- ```
51
- response if successfull:
52
- ```javascript
53
- const response = {
54
- id: string
55
- payment_method_id: string
56
- // ...
57
- }
58
- ```
59
-
60
- Keep in mind the responses are not typed, so you will have to look at the documentation to consult what each operation will return.
31
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warpstore/warpstore-package",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "dist/src/main.js",
6
6
  "types": "dist/src/main.d.ts",
@@ -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