Skip to content

Commit e46be2d

Browse files
committed
Add legacy SDK in legacy/
1 parent 62fdd26 commit e46be2d

File tree

1,178 files changed

+69607
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,178 files changed

+69607
-0
lines changed

legacy/CHANGELOG.md

Lines changed: 618 additions & 0 deletions
Large diffs are not rendered by default.

legacy/README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Square Legacy Node.js SDK
2+
3+
Use this JavaScript library to manage Square resources (such as payments, orders, items, and inventory) for your own Square account or on behalf of Square sellers.
4+
5+
* [Requirements](#requirements)
6+
* [Installation](#installation)
7+
* [Quickstart](#quickstart)
8+
* [Usage](#usage)
9+
* [Tests](#tests)
10+
* [SDK Reference](#sdk-reference)
11+
* [Deprecated APIs](#deprecated-apis)
12+
13+
## Requirements
14+
15+
Use of the Square Node.js SDK requires:
16+
17+
* Node.js 14 or higher
18+
19+
This SDK supports Node.js versions that are either current, or that are in long-term support status (LTS). The SDK does not support Node.js versions that have reached their end-of-life (EOL). For more information on Node.js versioning, see <https://nodejs.org/en/about/releases/>.
20+
21+
This SDK is for use with Node.js only. It does not support other usages, such as for web browsers or frontend applications.
22+
23+
## Installation
24+
25+
For more information, see [Set Up Your Square SDK for a Node.js Project](https://developer.squareup.com/docs/sdks/nodejs/setup-project).
26+
27+
## Quickstart
28+
29+
For more information, see [Square Node.js SDK Quickstart](https://developer.squareup.com/docs/sdks/nodejs/quick-start).
30+
31+
## Usage
32+
For more information, see [Using the Square Node.js SDK](https://developer.squareup.com/docs/sdks/nodejs/using-nodejs-sdk).
33+
34+
## SDK Reference
35+
36+
### Payments
37+
* [Payments]
38+
* [Refunds]
39+
* [Disputes]
40+
* [Checkout]
41+
* [Apple Pay]
42+
* [Cards]
43+
* [Payouts]
44+
45+
### Terminal
46+
* [Terminal]
47+
48+
### Orders
49+
* [Orders]
50+
* [Order Custom Attributes]
51+
52+
### Subscriptions
53+
* [Subscriptions]
54+
55+
### Invoices
56+
* [Invoices]
57+
58+
### Items
59+
* [Catalog]
60+
* [Inventory]
61+
62+
### Customers
63+
* [Customers]
64+
* [Customer Groups]
65+
* [Customer Segments]
66+
67+
### Loyalty
68+
* [Loyalty]
69+
70+
### Gift Cards
71+
* [Gift Cards]
72+
* [Gift Card Activities]
73+
74+
### Bookings
75+
* [Bookings]
76+
* [Booking Custom Attributes]
77+
78+
### Business
79+
* [Merchants]
80+
* [Merchant Custom Attributes]
81+
* [Locations]
82+
* [Location Custom Attributes]
83+
* [Devices]
84+
* [Cash Drawers]
85+
86+
### Team
87+
* [Team]
88+
* [Labor]
89+
90+
### Financials
91+
* [Bank Accounts]
92+
93+
### Online
94+
* [Sites]
95+
* [Snippets]
96+
97+
### Authorization
98+
* [Mobile Authorization]
99+
* [OAuth]
100+
101+
### Webhook Subscriptions
102+
* [Webhook Subscriptions]
103+
## Deprecated APIs
104+
105+
The following Square APIs are [deprecated](https://developer.squareup.com/docs/build-basics/api-lifecycle):
106+
107+
* [Employees] - replaced by the [Team] API. For more information, see [Migrate from the Employees API](https://developer.squareup.com/docs/team/migrate-from-v2-employees).
108+
109+
* [Transactions] - replaced by the [Orders] and [Payments] APIs. For more information, see [Migrate from the Transactions API](https://developer.squareup.com/docs/payments-api/migrate-from-transactions-api).
110+
111+
112+
[Developer Dashboard]: https://developer.squareup.com/apps
113+
[Square API]: https://squareup.com/developers
114+
[sign up for a developer account]: https://squareup.com/signup?v=developers
115+
[Locations overview]: https://developer.squareup.com/docs/locations-api
116+
[OAuth overview]: https://developer.squareup.com/docs/oauth-api/overview
117+
[Client]: doc/client.md
118+
[Devices]: doc/api/devices.md
119+
[Disputes]: doc/api/disputes.md
120+
[Terminal]: doc/api/terminal.md
121+
[Team]: doc/api/team.md
122+
[Cash Drawers]: doc/api/cash-drawers.md
123+
[Vendors]: doc/api/vendors.md
124+
[Customer Groups]: doc/api/customer-groups.md
125+
[Customer Segments]: doc/api/customer-segments.md
126+
[Bank Accounts]: doc/api/bank-accounts.md
127+
[Payments]: doc/api/payments.md
128+
[Checkout]: doc/api/checkout.md
129+
[Catalog]: doc/api/catalog.md
130+
[Customers]: doc/api/customers.md
131+
[Customer Custom Attributes]: doc/api/customer-custom-attributes.md
132+
[Inventory]: doc/api/inventory.md
133+
[Labor]: doc/api/labor.md
134+
[Loyalty]: doc/api/loyalty.md
135+
[Bookings]: doc/api/bookings.md
136+
[Booking Custom Attributes]: doc/api/booking-custom-attributes.md
137+
[Locations]: doc/api/locations.md
138+
[Location Custom Attributes]: doc/api/location-custom-attributes.md
139+
[Merchants]: doc/api/merchants.md
140+
[Merchant Custom Attributes]: doc/api/merchant-custom-attributes.md
141+
[Orders]: doc/api/orders.md
142+
[Order Custom Attributes]: doc/api/order-custom-attributes.md
143+
[Invoices]: doc/api/invoices.md
144+
[Apple Pay]: doc/api/apple-pay.md
145+
[Refunds]: doc/api/refunds.md
146+
[Subscriptions]: doc/api/subscriptions.md
147+
[Mobile Authorization]: doc/api/mobile-authorization.md
148+
[OAuth]: doc/api/o-auth.md
149+
[Sites]: doc/api/sites.md
150+
[Snippets]: doc/api/snippets.md
151+
[Cards]: doc/api/cards.md
152+
[Payouts]: doc/api/payouts.md
153+
[Gift Cards]: doc/api/gift-cards.md
154+
[Gift Card Activities]: doc/api/gift-card-activities.md
155+
[Employees]: doc/api/employees.md
156+
[Transactions]: doc/api/transactions.md
157+
[Webhook Subscriptions]: doc/api/webhook-subscriptions.md

legacy/doc/api-error.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
# ApiError
3+
4+
Thrown when the HTTP status code is not okay.
5+
6+
The ApiError extends the ApiResponse interface, so all ApiResponse properties are available.
7+
8+
## Properties
9+
10+
| Name | Type | Description |
11+
| --- | --- | --- |
12+
| request | HttpRequest | Original request that resulted in this response. |
13+
| statusCode | number | Response status code. |
14+
| headers | Record<string, string> | Response headers. |
15+
| result | T | Response data. |
16+
| body | string \| Blob \| NodeJS.ReadableStream | Original body from the response. |
17+
| errors? | Error[] | Represents an error encountered during a request to the Connect API |
18+

legacy/doc/api-response.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
# ApiResponse
3+
4+
An interface for the result of an API call.
5+
6+
## Properties
7+
8+
| Name | Type | Description |
9+
| --- | --- | --- |
10+
| request | HttpRequest | Original request that resulted in this response. |
11+
| statusCode | number | Response status codee. |
12+
| headers | Record<string, string> | Response headers. |
13+
| result | T | Response data. |
14+
| body | string \| Blob \| NodeJS.ReadableStream | Original body from the response. |
15+

legacy/doc/api/apple-pay.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Apple Pay
2+
3+
```ts
4+
const applePayApi = client.applePayApi;
5+
```
6+
7+
## Class Name
8+
9+
`ApplePayApi`
10+
11+
12+
# Register Domain
13+
14+
Activates a domain for use with Apple Pay on the Web and Square. A validation
15+
is performed on this domain by Apple to ensure that it is properly set up as
16+
an Apple Pay enabled domain.
17+
18+
This endpoint provides an easy way for platform developers to bulk activate
19+
Apple Pay on the Web with Square for merchants using their platform.
20+
21+
Note: You will need to host a valid domain verification file on your domain to support Apple Pay. The
22+
current version of this file is always available at https://app.squareup.com/digital-wallets/apple-pay/apple-developer-merchantid-domain-association,
23+
and should be hosted at `.well_known/apple-developer-merchantid-domain-association` on your
24+
domain. This file is subject to change; we strongly recommend checking for updates regularly and avoiding
25+
long-lived caches that might not keep in sync with the correct file version.
26+
27+
To learn more about the Web Payments SDK and how to add Apple Pay, see [Take an Apple Pay Payment](https://developer.squareup.com/docs/web-payments/apple-pay).
28+
29+
```ts
30+
async registerDomain(
31+
body: RegisterDomainRequest,
32+
requestOptions?: RequestOptions
33+
): Promise<ApiResponse<RegisterDomainResponse>>
34+
```
35+
36+
## Parameters
37+
38+
| Parameter | Type | Tags | Description |
39+
| --- | --- | --- | --- |
40+
| `body` | [`RegisterDomainRequest`](../../doc/models/register-domain-request.md) | Body, Required | An object containing the fields to POST for the request.<br><br>See the corresponding object definition for field details. |
41+
| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. |
42+
43+
## Response Type
44+
45+
[`RegisterDomainResponse`](../../doc/models/register-domain-response.md)
46+
47+
## Example Usage
48+
49+
```ts
50+
const body: RegisterDomainRequest = {
51+
domainName: 'example.com',
52+
};
53+
54+
try {
55+
const { result, ...httpResponse } = await applePayApi.registerDomain(body);
56+
// Get more response info...
57+
// const { statusCode, headers } = httpResponse;
58+
} catch (error) {
59+
if (error instanceof ApiError) {
60+
const errors = error.result;
61+
// const { statusCode, headers } = error;
62+
}
63+
}
64+
```
65+

legacy/doc/api/bank-accounts.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Bank Accounts
2+
3+
```ts
4+
const bankAccountsApi = client.bankAccountsApi;
5+
```
6+
7+
## Class Name
8+
9+
`BankAccountsApi`
10+
11+
## Methods
12+
13+
* [List Bank Accounts](../../doc/api/bank-accounts.md#list-bank-accounts)
14+
* [Get Bank Account by V1 Id](../../doc/api/bank-accounts.md#get-bank-account-by-v1-id)
15+
* [Get Bank Account](../../doc/api/bank-accounts.md#get-bank-account)
16+
17+
18+
# List Bank Accounts
19+
20+
Returns a list of [BankAccount](../../doc/models/bank-account.md) objects linked to a Square account.
21+
22+
```ts
23+
async listBankAccounts(
24+
cursor?: string,
25+
limit?: number,
26+
locationId?: string,
27+
requestOptions?: RequestOptions
28+
): Promise<ApiResponse<ListBankAccountsResponse>>
29+
```
30+
31+
## Parameters
32+
33+
| Parameter | Type | Tags | Description |
34+
| --- | --- | --- | --- |
35+
| `cursor` | `string \| undefined` | Query, Optional | The pagination cursor returned by a previous call to this endpoint.<br>Use it in the next `ListBankAccounts` request to retrieve the next set<br>of results.<br><br>See the [Pagination](https://developer.squareup.com/docs/working-with-apis/pagination) guide for more information. |
36+
| `limit` | `number \| undefined` | Query, Optional | Upper limit on the number of bank accounts to return in the response.<br>Currently, 1000 is the largest supported limit. You can specify a limit<br>of up to 1000 bank accounts. This is also the default limit. |
37+
| `locationId` | `string \| undefined` | Query, Optional | Location ID. You can specify this optional filter<br>to retrieve only the linked bank accounts belonging to a specific location. |
38+
| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. |
39+
40+
## Response Type
41+
42+
[`ListBankAccountsResponse`](../../doc/models/list-bank-accounts-response.md)
43+
44+
## Example Usage
45+
46+
```ts
47+
try {
48+
const { result, ...httpResponse } = await bankAccountsApi.listBankAccounts();
49+
// Get more response info...
50+
// const { statusCode, headers } = httpResponse;
51+
} catch (error) {
52+
if (error instanceof ApiError) {
53+
const errors = error.result;
54+
// const { statusCode, headers } = error;
55+
}
56+
}
57+
```
58+
59+
60+
# Get Bank Account by V1 Id
61+
62+
Returns details of a [BankAccount](../../doc/models/bank-account.md) identified by V1 bank account ID.
63+
64+
```ts
65+
async getBankAccountByV1Id(
66+
v1BankAccountId: string,
67+
requestOptions?: RequestOptions
68+
): Promise<ApiResponse<GetBankAccountByV1IdResponse>>
69+
```
70+
71+
## Parameters
72+
73+
| Parameter | Type | Tags | Description |
74+
| --- | --- | --- | --- |
75+
| `v1BankAccountId` | `string` | Template, Required | Connect V1 ID of the desired `BankAccount`. For more information, see<br>[Retrieve a bank account by using an ID issued by V1 Bank Accounts API](https://developer.squareup.com/docs/bank-accounts-api#retrieve-a-bank-account-by-using-an-id-issued-by-v1-bank-accounts-api). |
76+
| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. |
77+
78+
## Response Type
79+
80+
[`GetBankAccountByV1IdResponse`](../../doc/models/get-bank-account-by-v1-id-response.md)
81+
82+
## Example Usage
83+
84+
```ts
85+
const v1BankAccountId = 'v1_bank_account_id8';
86+
87+
try {
88+
const { result, ...httpResponse } = await bankAccountsApi.getBankAccountByV1Id(v1BankAccountId);
89+
// Get more response info...
90+
// const { statusCode, headers } = httpResponse;
91+
} catch (error) {
92+
if (error instanceof ApiError) {
93+
const errors = error.result;
94+
// const { statusCode, headers } = error;
95+
}
96+
}
97+
```
98+
99+
100+
# Get Bank Account
101+
102+
Returns details of a [BankAccount](../../doc/models/bank-account.md)
103+
linked to a Square account.
104+
105+
```ts
106+
async getBankAccount(
107+
bankAccountId: string,
108+
requestOptions?: RequestOptions
109+
): Promise<ApiResponse<GetBankAccountResponse>>
110+
```
111+
112+
## Parameters
113+
114+
| Parameter | Type | Tags | Description |
115+
| --- | --- | --- | --- |
116+
| `bankAccountId` | `string` | Template, Required | Square-issued ID of the desired `BankAccount`. |
117+
| `requestOptions` | `RequestOptions \| undefined` | Optional | Pass additional request options. |
118+
119+
## Response Type
120+
121+
[`GetBankAccountResponse`](../../doc/models/get-bank-account-response.md)
122+
123+
## Example Usage
124+
125+
```ts
126+
const bankAccountId = 'bank_account_id0';
127+
128+
try {
129+
const { result, ...httpResponse } = await bankAccountsApi.getBankAccount(bankAccountId);
130+
// Get more response info...
131+
// const { statusCode, headers } = httpResponse;
132+
} catch (error) {
133+
if (error instanceof ApiError) {
134+
const errors = error.result;
135+
// const { statusCode, headers } = error;
136+
}
137+
}
138+
```
139+

0 commit comments

Comments
 (0)