Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parámetros de Options #100

Closed
sbaezamella opened this issue Jul 24, 2024 · 1 comment
Closed

Parámetros de Options #100

sbaezamella opened this issue Jul 24, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@sbaezamella
Copy link

sbaezamella commented Jul 24, 2024

Describe el bug

En la actualización a la version 5.0.0 de la 4.0.0, la clase Transaction permite recibir un parámetro opcional timeout declarado en el constructor pero no así en los tipos de la clase Options. Lo anterior ocasiona que se tenga que declarar una variable Options y pasarla directamente a Transaction. A qué se debe esta diferencia en los tipos? La clase lo declara requerido pero el constructor opcional.

Para reproducir

  1. Crea un objeto Transaction
new WebpayPlus.Transaction({
    commerceCode,
    apiKey,
    environment,
});
  1. Se ve un error de typescript del tipo Property 'timeout' is missing in type '{ commerceCode: string; apiKey: string; environment: string; }' but required in type 'Options'.ts(2345)

Comportamiento observado

Se recibe un error de typescript cuando no se pasa timeout directamente a Transaction pero se resuelve si se hace lo siguiente:

const options = new Options(
  commerceCodes[transactionType],
  apiKey,
  environment,
);
new WebpayPlus.Transaction(options)

Dentro de los tipos se ve así

declare class Options {
    /** Unique commerce identifier provided by Transbank */
    commerceCode: string;
    /** The secret used to authenticate against the API, it must be kept safe at all times. */
    apiKey: string;
    /** Environment correspond to the environment to use, it can be Integration or
     * Production, each has a unique URL. */
    environment: string;
    /** Timeout for requests in milliseconds */
    timeout: number;
    /**
     * Create an instance of Options
     * @param commerceCode unique commerce identifier provided by Transbank
     * @param apiKey the secret used to authenticate against the API, it must be kept safe at all times.
     * @param environment Environment correspond to the environment to use, it can be Integration or
     * Production, each has a unique URL.
     * @param timeout Timeout for requests in milliseconds
     */
    constructor(commerceCode: string, apiKey: string, environment: string, timeout?: number);
}

Creo que timeout declarado como propiedad de la clase debería ser opcional

Comportamiento esperado

Se espera que no se tenga que declarar una variable del tipo Options para no romper la implementación actual.

Versiones (por favor agrega aquí la siguiente información):

  • SDK: 5.0.0
  • Node.js: 20.9.0
  • NPM: 10.1.0
@sbaezamella sbaezamella added the bug Something isn't working label Jul 24, 2024
@mastudillot
Copy link
Member

mastudillot commented Jul 30, 2024

Hola, revisamos lo que comentas y quedo solucionado en el PR #101

Quedará agregado en el siguiente release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants