Skip to content

Commit

Permalink
Merge pull request #34 from pagarme/CodeGen-NodeJS
Browse files Browse the repository at this point in the history
  • Loading branch information
grazielcosta authored Jul 31, 2024
2 parents 87c7384 + 6711335 commit 525629b
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 48 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
.DS_Store
node_modules
dist
coverage
test
coverage
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ npm install

## Initialize the API Client

**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/client.md)
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/client.md)

The following parameters are configurable for the API Client:

Expand All @@ -81,7 +81,7 @@ The following parameters are configurable for the API Client:
| `timeout` | `number` | Timeout for API calls.<br>*Default*: `0` |
| `httpClientOptions` | `Partial<HttpClientOptions>` | Stable configurable http client options. |
| `unstableHttpClientOptions` | `any` | Unstable configurable http client options. |
| `basicAuthCredentials` | [`BasicAuthCredentials`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/$a/https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/basic-authentication.md) | The credential object for basicAuth |
| `basicAuthCredentials` | [`BasicAuthCredentials`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/auth/basic-authentication.md) | The credential object for basicAuth |

### HttpClientOptions

Expand Down Expand Up @@ -121,38 +121,38 @@ const client = new Client({

This API uses the following authentication schemes.

* [`httpBasic (Basic Authentication)`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/$a/https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/basic-authentication.md)
* [`httpBasic (Basic Authentication)`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/auth/basic-authentication.md)

## API Errors

Here is the list of errors that the API might throw.

| HTTP Status Code | Error Description | Exception Class |
| --- | --- | --- |
| 400 | Invalid request | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/models/custom-error.md) |
| 401 | Invalid API key | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/models/custom-error.md) |
| 404 | An informed resource was not found | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/models/custom-error.md) |
| 412 | Business validation error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/models/custom-error.md) |
| 422 | Contract validation error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/models/custom-error.md) |
| 500 | Internal server error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/models/custom-error.md) |
| 400 | Invalid request | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/models/custom-error.md) |
| 401 | Invalid API key | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/models/custom-error.md) |
| 404 | An informed resource was not found | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/models/custom-error.md) |
| 412 | Business validation error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/models/custom-error.md) |
| 422 | Contract validation error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/models/custom-error.md) |
| 500 | Internal server error | [`CustomError`](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/models/custom-error.md) |

## List of APIs

* [Subscriptions](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/subscriptions.md)
* [Orders](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/orders.md)
* [Plans](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/plans.md)
* [Invoices](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/invoices.md)
* [Customers](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/customers.md)
* [Charges](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/charges.md)
* [Recipients](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/recipients.md)
* [Tokens](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/tokens.md)
* [Transactions](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/transactions.md)
* [Transfers](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/transfers.md)
* [Payables](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/payables.md)
* [Balance Operations](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/controllers/balance-operations.md)
* [Subscriptions](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/subscriptions.md)
* [Orders](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/orders.md)
* [Plans](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/plans.md)
* [Invoices](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/invoices.md)
* [Customers](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/customers.md)
* [Charges](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/charges.md)
* [Recipients](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/recipients.md)
* [Tokens](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/tokens.md)
* [Transactions](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/transactions.md)
* [Transfers](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/transfers.md)
* [Payables](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/payables.md)
* [Balance Operations](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/controllers/balance-operations.md)

## Classes Documentation

* [ApiResponse](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/api-response.md)
* [ApiError](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.10/doc/api-error.md)
* [ApiResponse](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/api-response.md)
* [ApiError](https://www.github.com/pagarme/pagarme-nodejs-sdk/tree/6.8.11/doc/api-error.md)

2 changes: 1 addition & 1 deletion doc/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The following parameters are configurable for the API Client:
| `timeout` | `number` | Timeout for API calls.<br>*Default*: `0` |
| `httpClientOptions` | `Partial<HttpClientOptions>` | Stable configurable http client options. |
| `unstableHttpClientOptions` | `any` | Unstable configurable http client options. |
| `basicAuthCredentials` | [`BasicAuthCredentials`]($a/basic-authentication.md) | The credential object for basicAuth |
| `basicAuthCredentials` | [`BasicAuthCredentials`](auth/basic-authentication.md) | The credential object for basicAuth |

## HttpClientOptions

Expand Down
2 changes: 2 additions & 0 deletions doc/models/create-credit-card-payment-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ The settings for creating a credit card payment
| `operationType` | `string \| undefined` | Optional | AuthOnly, AuthAndCapture, PreAuth |
| `recurrencyCycle` | `string \| undefined` | Optional | Defines whether the card has been used one or more times. |
| `payload` | [`CreateCardPayloadRequest \| undefined`](../../doc/models/create-card-payload-request.md) | Optional | - |
| `initiatedType` | `string \| undefined` | Optional | - |
| `recurrenceModel` | `string \| undefined` | Optional | - |

## Example (as JSON)

Expand Down
2 changes: 2 additions & 0 deletions doc/models/create-debit-card-payment-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ The settings for creating a debit card payment
| `recurrence` | `boolean \| undefined` | Optional | Indicates a recurrence |
| `authentication` | [`CreatePaymentAuthenticationRequest \| undefined`](../../doc/models/create-payment-authentication-request.md) | Optional | The payment authentication request |
| `token` | [`CreateCardPaymentContactlessRequest \| undefined`](../../doc/models/create-card-payment-contactless-request.md) | Optional | The Debit card payment token request |
| `initiatedType` | `string \| undefined` | Optional | - |
| `recurrenceModel` | `string \| undefined` | Optional | - |

## Example (as JSON)

Expand Down
6 changes: 5 additions & 1 deletion doc/models/update-charge-card-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Request for updating card data
| `cardId` | `string` | Required | Card id |
| `card` | [`CreateCardRequest`](../../doc/models/create-card-request.md) | Required | Card data |
| `recurrence` | `boolean` | Required | Indicates a recurrence |
| `initiatedType` | `string \| undefined` | Optional | - |
| `recurrenceModel` | `string \| undefined` | Optional | - |

## Example (as JSON)

Expand All @@ -30,7 +32,9 @@ Request for updating card data
"exp_year": 68,
"cvv": "cvv4"
},
"recurrence": false
"recurrence": false,
"initiated_type": "initiated_type8",
"recurrence_model": "recurrence_model6"
}
```

6 changes: 2 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
module.exports = {
testEnvironment: 'node',
preset: 'ts-jest',
globals: {
'ts-jest': {
tsConfig: 'tsconfig.base.json',
},
transform: {
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.base.json' }],
},
};
26 changes: 11 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "6.8.10",
"version": "6.8.11",
"license": "MIT",
"sideEffects": false,
"main": "dist/cjs/index.js",
Expand All @@ -14,9 +14,9 @@
},
"scripts": {
"build": "rm -rf dist & tsc -p tsconfig.esm.json & tsc -p tsconfig.cjs.json",
"test": "jest --coverage --passWithNoTests",
"lint": "eslint --ignore-path .eslintignore --ext .js,.ts .",
"prepare": "rm -rf dist & tsc -p tsconfig.esm.json & tsc -p tsconfig.cjs.json"
"prepare": "rm -rf dist & tsc -p tsconfig.esm.json & tsc -p tsconfig.cjs.json",
"lint": "eslint **/*.ts --ignore-path .eslintignore",
"lint:fix": "eslint **/*.ts --ignore-path .eslintignore --fix"
},
"peerDependencies": {},
"prettier": {
Expand All @@ -26,12 +26,12 @@
"trailingComma": "es5",
"quoteProps": "preserve"
},
"name": "@pagarme/pagarme-nodejs-sdk",
"name": "pagarmeapisdklib",
"description": "Pagarme API",
"author": {
"name": "Pagar.me Pagamentos S/A",
"email": "suporte@pagar.me",
"url": "https://github.com/pagarme/pagarme-nodejs-sdk/issues"
"url": "https://github.com/pagarme/"
},
"devDependencies": {
"@types/jest": "^29.4.0",
Expand All @@ -44,17 +44,13 @@
"typescript": "^4.9.5"
},
"dependencies": {
"@apimatic/authentication-adapters": "^0.5.0",
"@apimatic/axios-client-adapter": "^0.3.0",
"@apimatic/core": "^0.10.0",
"@apimatic/schema": "^0.7.0"
"@apimatic/authentication-adapters": "^0.5.4",
"@apimatic/axios-client-adapter": "^0.3.4",
"@apimatic/core": "^0.10.12",
"@apimatic/schema": "^0.7.12"
},
"bugs": {
"url": "https://github.com/pagarme/pagarme-nodejs-sdk/issues",
"url": "https://github.com/pagarme/",
"email": "suporte@pagar.me"
},
"repository": {
"type": "git",
"url": "git://github.com/pagarme/pagarme-nodejs-sdk.git"
}
}
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Client implements ClientInterface {
},
};

this._userAgent = updateUserAgent('PagarmeApiSDK - TypeScript 6.8.10');
this._userAgent = updateUserAgent('PagarmeApiSDK - TypeScript 6.8.11');
this._requestBuilderFactory = createRequestHandlerFactory(
(server) => getBaseUri(server, this._config),
createAuthProviderFromConfig(clonedConfig),
Expand Down
4 changes: 4 additions & 0 deletions src/models/createCreditCardPaymentRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export interface CreateCreditCardPaymentRequest {
/** Defines whether the card has been used one or more times. */
recurrencyCycle?: string;
payload?: CreateCardPayloadRequest;
initiatedType?: string;
recurrenceModel?: string;
}

export const createCreditCardPaymentRequestSchema: Schema<CreateCreditCardPaymentRequest> = object(
Expand All @@ -89,5 +91,7 @@ export const createCreditCardPaymentRequestSchema: Schema<CreateCreditCardPaymen
operationType: ['operation_type', optional(string())],
recurrencyCycle: ['recurrency_cycle', optional(string())],
payload: ['payload', optional(lazy(() => createCardPayloadRequestSchema))],
initiatedType: ['initiated_type', optional(string())],
recurrenceModel: ['recurrence_model', optional(string())],
}
);
4 changes: 4 additions & 0 deletions src/models/createDebitCardPaymentRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface CreateDebitCardPaymentRequest {
authentication?: CreatePaymentAuthenticationRequest;
/** The Debit card payment token request */
token?: CreateCardPaymentContactlessRequest;
initiatedType?: string;
recurrenceModel?: string;
}

export const createDebitCardPaymentRequestSchema: Schema<CreateDebitCardPaymentRequest> = object(
Expand All @@ -51,5 +53,7 @@ export const createDebitCardPaymentRequestSchema: Schema<CreateDebitCardPaymentR
'token',
optional(lazy(() => createCardPaymentContactlessRequestSchema)),
],
initiatedType: ['initiated_type', optional(string())],
recurrenceModel: ['recurrence_model', optional(string())],
}
);
6 changes: 5 additions & 1 deletion src/models/updateChargeCardRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
*/

import { boolean, lazy, object, Schema, string } from '../schema';
import { boolean, lazy, object, optional, Schema, string } from '../schema';
import {
CreateCardRequest,
createCardRequestSchema,
Expand All @@ -20,6 +20,8 @@ export interface UpdateChargeCardRequest {
card: CreateCardRequest;
/** Indicates a recurrence */
recurrence: boolean;
initiatedType?: string;
recurrenceModel?: string;
}

export const updateChargeCardRequestSchema: Schema<UpdateChargeCardRequest> = object(
Expand All @@ -28,5 +30,7 @@ export const updateChargeCardRequestSchema: Schema<UpdateChargeCardRequest> = ob
cardId: ['card_id', string()],
card: ['card', lazy(() => createCardRequestSchema)],
recurrence: ['recurrence', boolean()],
initiatedType: ['initiated_type', optional(string())],
recurrenceModel: ['recurrence_model', optional(string())],
}
);

0 comments on commit 525629b

Please sign in to comment.