@dotdev/apparel21-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.0.72 • Public • Published

Apparel21 SDK

This SDK wraps AP21 API and returns the response formatted as regular JavaScript objects.

Wrapped endpoints

The following endpoints are wrapped by this SDK:

Core endpoints (All required)

  • [x] GET /ReferenceTypes
  • [x] GET /ReferenceTypes/{id}
  • [x] GET /Products
  • [x] GET /Products/{id}
  • [x] GET /ProductsSimple
  • [x] GET /ProductsSimpleWithPagination
  • [x] GET /ProductsSimple/{id}
  • [x] GET /ProductNotes/{id}
  • [x] GET /ProductColourNotes/{id}
  • [x] GET /Colours
  • [x] GET /Sizes
  • [x] GET /Persons
  • [x] GET /Persons/{id}
  • [x] POST /Persons
  • [x] PUT /Persons/{id}
  • [x] GET /Persons/{id}/Orders
  • [x] GET /Persons/{id/Orders/{id}
  • [x] GET /Persons/{id}/Shipments/{orderId}
  • [x] POST /Persons/{id}/Orders
  • [x] GET /Persons/{id}/RetailTransactions
  • [x] POST /Persons/{id}/Orders/{id}/Returns
  • [x] GET /Persons/{id}/Orders/{id}/Returns/{id}
  • [x] GET /Vouchers/{number}/?pin={pin}
  • [x] GET /Voucher/GVValid/{number}?pin={pin}&amount={amount}
  • [x] GET /Voucher/Lock/{number}?ValidationId={id}&LockSeconds={seconds}
  • [x] GET /Freestock/style/{id}
  • [x] GET /Freestock/clr/{id}
  • [x] GET /Freestock/sku/{id}
  • [x] GET /StockChanged?ChangedSince={date}
  • [x] GET /Stores
  • [x] GET /Stores/{id}
  • [x] GET /Orders?UpdatedAfter={date}

Loyalty (Low priority)

We have implemented these for Tony Bianco loyalty. However, they're the only ones currently using this module. We will need to support it at some point but not a top priority for now.

  • [x] GET /Rewards/Programs
  • [x] GET /Rewards/Accounts/{id}
  • [x] POST /Rewards/Accounts

Loyalty (Extra-low priority)

These ones will be great to support but not currently needed (we don't "change" the loyalty account in any way right now, it's all done internally at AP21).

  • [x] PUT /Rewards/Accounts
  • [x] GET /Rewards/Accounts/{id}/Transactions
  • [x] POST /Rewards/Accounts/{id}/Rewards
  • [x] POST /Rewards/Accounts/{id}/Gifts
  • [x] POST /Rewards/Accounts/{id}/Points
  • [x] POST /Rewards/Accounts/{id}/Rewards/Redemptions
  • [x] POST /Rewards/Accounts/{id}/Gifts/Redemptions
  • [x] POST /Rewards/Accounts/{id}/Points/Redemptions
  • [x] POST /Rewards/Confirmation?requestId={id}
  • [x] POST /Rewards/Reversal?requestId={id}

For more details on these endpoints see the wiki page

Tests

The SDK has automatic tests for each exposed method of the AP21 instance and its modules. There is an integration test file, however, coverage is not full. Most integration tests are commented out since details of the tests are tied to particual AP21 instances (such as person, product etc ids). To run the integration tests you first need to add a secret config (use credentials from 1password), see the example config file.

Each endpoint is mocked in the ./src/__mocks__/axios.ts file. There are mock XML payloads in the ExamplePayloads folder. These are based on a combination of real payloads and AP21 documentation examples

Next steps

This SDK has primarily been developed against the AP21 documentation.

  • Most safe endpoints (GET) have also been verified against a few live instances of AP21.
  • Most non-safe endpoints (POST, PUT) have been tested against the AP21 test instance DotDev has access to (check 1password for credentials).

However, a lot of endpoints listed above are lacking proper setup in the AP21 test instance meaning they have not been verified to work against a live environment (see list below).

The AP21 documentation example payloads are full of errors and are often invalid XML. Meaning some of the covered endpoints may need updates once tested against a live environment and real payloads.

The first step should be to battle test the SDK against various live environments to ensure it reads and remaps the required data from XML to JS.

To test and verify the non-safe endpoints the AP21 test instance should be configured for gift vouchers and rewards.

Unverified

The following have not been possible to verify against a live environment:

Entity Reason
Rewards No rewards set up in test instance
Vouchers No vouchers set up in test instace
Returns Not able to create a return. Could be due to order status?
Shipments Need to run against real instance or have status updated in test instance

Package Sidebar

Install

npm i @dotdev/apparel21-sdk

Weekly Downloads

6,202

Version

0.0.72

License

UNLICENSED

Unpacked Size

217 kB

Total Files

101

Last publish

Collaborators

  • dotdev-richard
  • dotdev-joel
  • dotdev-alex
  • p_tul
  • brendon-dotdev
  • psj
  • 8eecf0d2
  • oscarstranger
  • dotdev-bo
  • dotdev-support
  • dotdev-eric