Skip to content

Commit

Permalink
Remove transaction response type (#51)
Browse files Browse the repository at this point in the history
* remove overlay

* ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.299.4 (#50)

Co-authored-by: speakeasybot <[email protected]>

* remove overlay and hook which adds responseType; update tests

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: speakeasybot <[email protected]>
  • Loading branch information
3 people authored May 31, 2024
1 parent 5653e2e commit a960611
Show file tree
Hide file tree
Showing 26 changed files with 106 additions and 486 deletions.
19 changes: 7 additions & 12 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
lockVersion: 2.0.0
id: 4f7e8ab5-4c00-496a-9710-e7c707e4ee78
management:
docChecksum: 9f7d04d5659ec0b9eeb44850ff26491c
docChecksum: 609002aee5b1500e5e73ec2eb80f268d
docVersion: "2018-02-08"
speakeasyVersion: 1.299.3
speakeasyVersion: 1.299.4
generationVersion: 2.338.7
releaseVersion: 2.2.8
configChecksum: df16a2469a90b46036c859ec2059eb61
releaseVersion: 2.2.9
configChecksum: 3986607c3ac0c16bdd19c8879b4e7dc5
repoURL: https://github.com/goshippo/shippo-javascript-sdk.git
installationURL: https://github.com/goshippo/shippo-javascript-sdk
published: true
Expand Down Expand Up @@ -195,9 +195,7 @@ generatedFiles:
- src/models/components/transactionpaginatedlist.ts
- src/models/components/transaction.ts
- src/models/components/transactionstatusenum.ts
- src/models/components/transactioncreateresponse.ts
- src/models/components/instanttransactioncreateresponse.ts
- src/models/components/instanttransactionrate.ts
- src/models/components/corerate.ts
- src/models/components/transactioncreaterequest.ts
- src/models/components/instanttransactioncreaterequest.ts
- src/models/components/userparceltemplatelist.ts
Expand Down Expand Up @@ -464,13 +462,10 @@ generatedFiles:
- docs/models/components/trackingstatuslocationbase.md
- docs/models/components/tracksrequest.md
- docs/models/components/transactionpaginatedlist.md
- docs/models/components/responsetype.md
- docs/models/components/transactionrate.md
- docs/models/components/transaction.md
- docs/models/components/transactionstatusenum.md
- docs/models/components/transactioncreateresponse.md
- docs/models/components/instanttransactioncreateresponseresponsetype.md
- docs/models/components/instanttransactioncreateresponse.md
- docs/models/components/instanttransactionrate.md
- docs/models/components/corerate.md
- docs/models/components/transactioncreaterequest.md
- docs/models/components/labelfiletype.md
- docs/models/components/instanttransactioncreaterequest.md
Expand Down
2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
typescript:
version: 2.2.8
version: 2.2.9
additionalDependencies:
dependencies: {}
devDependencies:
Expand Down
14 changes: 6 additions & 8 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
speakeasyVersion: 1.299.3
speakeasyVersion: 1.299.4
sources:
openapi:
sourceNamespace: openapi
sourceRevisionDigest: sha256:14930e2b5e8fff496c38443e78806ba68c35da0da310e3b035c7d2d48955b159
sourceBlobDigest: sha256:6c5cca209b61d8a07637cd9b482d4bb1ef4eb8c59141b79fc2b12b42b65b999a
sourceRevisionDigest: sha256:809852a1888d2a908db04ce03869b0574aa407b7852244bf26c7de05e9c6ae91
sourceBlobDigest: sha256:cb40025f1badac09cf5837db332862318944783ab4c57e2c37e8cfc698ca7793
tags:
- latest
- main
- remove-transaction-response-type
targets:
first-target:
source: openapi
sourceNamespace: openapi
sourceRevisionDigest: sha256:14930e2b5e8fff496c38443e78806ba68c35da0da310e3b035c7d2d48955b159
sourceBlobDigest: sha256:6c5cca209b61d8a07637cd9b482d4bb1ef4eb8c59141b79fc2b12b42b65b999a
sourceRevisionDigest: sha256:809852a1888d2a908db04ce03869b0574aa407b7852244bf26c7de05e9c6ae91
sourceBlobDigest: sha256:cb40025f1badac09cf5837db332862318944783ab4c57e2c37e8cfc698ca7793
outLocation: /github/workspace/repo
workflow:
workflowVersion: 1.0.0
Expand All @@ -21,8 +21,6 @@ workflow:
openapi:
inputs:
- location: https://docs.goshippo.com/spec/shippoapi/public-api.yaml
overlays:
- location: https://docs.goshippo.com/spec/shippoapi/client-sdk-overlay.yaml
registry:
location: registry.speakeasyapi.dev/shippo/shippo/openapi
targets:
Expand Down
2 changes: 0 additions & 2 deletions .speakeasy/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ sources:
openapi:
inputs:
- location: https://docs.goshippo.com/spec/shippoapi/public-api.yaml
overlays:
- location: https://docs.goshippo.com/spec/shippoapi/client-sdk-overlay.yaml
registry:
location: registry.speakeasyapi.dev/shippo/shippo/openapi
targets:
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,14 @@ Based on:
### Generated
- [typescript v2.2.8] .
### Releases
- [NPM v2.2.8] https://www.npmjs.com/package/shippo/v/2.2.8 - .
- [NPM v2.2.8] https://www.npmjs.com/package/shippo/v/2.2.8 - .

## 2024-05-31 16:41:56
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.299.4 (2.338.7) https://github.com/speakeasy-api/speakeasy
### Generated
- [typescript v2.2.9] .
### Releases
- [NPM v2.2.9] https://www.npmjs.com/package/shippo/v/2.2.9 - .
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# InstantTransactionRate
# CoreRate


## Fields
Expand Down
26 changes: 0 additions & 26 deletions docs/models/components/instanttransactioncreateresponse.md

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions docs/models/components/responsetype.md

This file was deleted.

41 changes: 20 additions & 21 deletions docs/models/components/transaction.md

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/models/components/transactioncreateresponse.md

This file was deleted.

7 changes: 7 additions & 0 deletions docs/models/components/transactionrate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# TransactionRate

ID of the Rate object for which a Label has to be obtained.
If you purchase a label by calling the transaction endpoint without a rate (instalabel),
this field will be a simplified Rate object in the Transaction model returned from the POST request.
</br>Note, only rates less than 7 days old can be purchased to ensure up-to-date pricing.

2 changes: 1 addition & 1 deletion docs/sdks/transactions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ run();

### Response

**Promise\<[components.TransactionCreateResponse](../../models/components/transactioncreateresponse.md)\>**
**Promise\<[components.Transaction](../../models/components/transaction.md)\>**
### Errors

| Error Object | Status Code | Content Type |
Expand Down
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
"name": "shippo",
"version": "2.2.8",
"version": "2.2.9",
"exports": {
".": "./src/index.ts",
"./models/errors": "./src/models/errors/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shippo",
"version": "2.2.8",
"version": "2.2.9",
"author": "Shippo",
"license": "MIT",
"main": "./index.js",
Expand Down
27 changes: 0 additions & 27 deletions src/hooks/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,37 +61,10 @@ export class ConvertNullToUndefinedAfterSuccessHook implements AfterSuccessHook

}

export class TransactionCreateResponseAddDiscriminatorAfterSuccessHook implements AfterSuccessHook {

async afterSuccess(hookCtx: AfterSuccessContext, response: Response): Promise<Response> {
if (hookCtx.operationID == "CreateTransaction" && response.status == 201) {
const content = await response.json();
const rate = content.rate;
let responseType = undefined;
if (typeof rate === 'string') {
responseType = "standard";
} else if (rate?.object_id) {
responseType = "instant";
}
if (responseType != undefined) {
content.responseType = responseType;
}
return new Response(JSON.stringify(content), {
status: response.status,
statusText: response.statusText,
headers: response.headers
});
}
return response;
}

}

export function initHooks(hooks: Hooks) {
// Add hooks by calling hooks.register{ClientInit/BeforeRequest/AfterSuccess/AfterError}Hook
// with an instance of a hook that implements that specific Hook interface
// Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance
hooks.registerBeforeRequestHook(new PrefixApiKeyBeforeRequestHook());
hooks.registerAfterSuccessHook(new ConvertNullToUndefinedAfterSuccessHook());
hooks.registerAfterSuccessHook(new TransactionCreateResponseAddDiscriminatorAfterSuccessHook());
}
4 changes: 2 additions & 2 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
export const SDK_METADATA = {
language: "typescript",
openapiDocVersion: "2018-02-08",
sdkVersion: "2.2.8",
sdkVersion: "2.2.9",
genVersion: "2.338.7",
userAgent: "speakeasy-sdk/typescript 2.2.8 2.338.7 2018-02-08 shippo",
userAgent: "speakeasy-sdk/typescript 2.2.9 2.338.7 2018-02-08 shippo",
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import * as z from "zod";

export type InstantTransactionRate = {
export type CoreRate = {
/**
* Final Rate price, expressed in the currency used in the sender's country.
*/
Expand Down Expand Up @@ -58,8 +58,8 @@ export type InstantTransactionRate = {
};

/** @internal */
export namespace InstantTransactionRate$ {
export const inboundSchema: z.ZodType<InstantTransactionRate, z.ZodTypeDef, unknown> = z
export namespace CoreRate$ {
export const inboundSchema: z.ZodType<CoreRate, z.ZodTypeDef, unknown> = z
.object({
amount: z.string().optional(),
amount_local: z.string().optional(),
Expand Down Expand Up @@ -101,7 +101,7 @@ export namespace InstantTransactionRate$ {
servicelevel_token?: string | undefined;
};

export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, InstantTransactionRate> = z
export const outboundSchema: z.ZodType<Outbound, z.ZodTypeDef, CoreRate> = z
.object({
amount: z.string().optional(),
amountLocal: z.string().optional(),
Expand Down
4 changes: 1 addition & 3 deletions src/models/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export * from "./carrierparceltemplatelist";
export * from "./carriersenum";
export * from "./cod";
export * from "./connectexistingownaccountrequest";
export * from "./corerate";
export * from "./customerreference";
export * from "./customsdeclaration";
export * from "./customsdeclarationb13afilingoptionenum";
Expand All @@ -69,8 +70,6 @@ export * from "./distanceunitenum";
export * from "./dryice";
export * from "./fedexconnectexistingownaccountparameters";
export * from "./instanttransactioncreaterequest";
export * from "./instanttransactioncreateresponse";
export * from "./instanttransactionrate";
export * from "./insurance";
export * from "./invoicenumber";
export * from "./labelfiletypeenum";
Expand Down Expand Up @@ -129,7 +128,6 @@ export * from "./trackingstatussubstatus";
export * from "./tracksrequest";
export * from "./transaction";
export * from "./transactioncreaterequest";
export * from "./transactioncreateresponse";
export * from "./transactionpaginatedlist";
export * from "./transactionstatusenum";
export * from "./upsconnectexistingownaccountparameters";
Expand Down
Loading

0 comments on commit a960611

Please sign in to comment.