Skip to content

Commit

Permalink
Merge pull request #10 from Foxy/beta
Browse files Browse the repository at this point in the history
Release V1
“Without deviation from the norm, progress is not possible.” Frank Zappa
  • Loading branch information
brettflorio authored Mar 24, 2021
2 parents 574e14c + e84695e commit 6b45a97
Show file tree
Hide file tree
Showing 250 changed files with 18,151 additions and 2,250 deletions.
Binary file removed .DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,7 @@ docs
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# misc
.DS_Store
.vscode
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
!dist/
src/
test/
tests/
.vscode/
.coverage/
.eslintrc.json
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,23 @@ import * as FoxySDK from '@foxy.io/sdk';

## Getting started

Our SDK consists of 4 main parts available via the main file:
Our SDK consists of 3 main parts available via the main file:

1. **Integration** is for building integrations that connect to hAPI directly from a safe **server-side** environment. Apart from the API client, you'll also find a number of useful utilities for HMAC signing, removing sensitive info from responses and webhook verification under this export alias.
1. **Backend** is for building Node.JS apps that connect to hAPI directly from a safe **server-side** environment. Apart from the API client, you'll also find a number of useful utilities for HMAC signing, removing sensitive info from responses and webhook verification under this export alias.
2. **Customer** is for building **universal** apps and websites that interact with a subset of hAPI available to customers of a particular store. This export is also available as a pre-built library on our CDN.
3. **Admin** is for building **universal** apps and websites that interact with a subset of hAPI available to store admins. This export is also available as a pre-built library on our CDN.
4. **Core**: is for building custom API clients that interact with Hypermedia API endpoints. This is the most advanced part of the SDK that every other built-in API client depends on. You can run it server and client-side.
3. **Core**: is for building custom API clients that interact with Hypermedia API endpoints. This is the most advanced part of the SDK that every other built-in API client depends on. You can run it server and client-side.

Integration, Customer and Admin all export API client classes for working with the respective endpoints. If you're using TypeScript, you'll also see the type exports for API-specific hypermedia relations and graphs named `Rels` and `Graph`. Let's connect to hAPI using `FoxySDK.Integration.API` class:
Backend and Customer export API client classes for working with the respective endpoints. If you're using TypeScript, you'll also see the type exports for API-specific hypermedia relations and graphs named `Rels` and `Graph`. Let's connect to hAPI using `FoxySDK.Backend.API` class:

```js
const api = new FoxySDK.Integration.API({
const api = new FoxySDK.Backend.API({
refreshToken: 'your refresh token',
clientSecret: 'your client secret',
clientId: 'your client id',
});
```

This will create a hAPI version 1 client connecting to `https://api.foxycart.com/` with the given credentials, using in-memory storage for access token and URL resolution, logging errors, warnings and informational messages to console. You can customize each one of these defaults in constructor params and you'll see similar options for Customer and Admin API as well.
This will create a hAPI version 1 client connecting to `https://api.foxycart.com/` with the given credentials, using in-memory storage for access token and URL resolution, logging errors, warnings and informational messages to console. You can customize each one of these defaults in constructor params and you'll see similar options for Customer API as well.

Regardless of the API type you're working with, you'll see the same methods on each node: `.follow()`, `.get()`, `.put()`, `.post()`, `.patch()` and `.delete()`. Here's how you can use them in 3 steps:

Expand Down Expand Up @@ -119,4 +118,11 @@ You can also build this package and test it locally in another project by runnin
npm pack
```

Use the following commands to run tests:

```bash
npm test # run all tests
npm run test:watch # watch files for changes and re-run relevant tests
```

All the latest features are published from the [beta](https://github.com/Foxy/foxy-sdk/tree/beta) branch to the `beta` distribution channel. If you submit a PR, please target `beta` as well. Releases are published from [main](https://github.com/Foxy/foxy-sdk/tree/main).
8 changes: 8 additions & 0 deletions backend.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @module
*
* Workaround to enable types for Node v13.2+ exports until
* https://github.com/microsoft/TypeScript/issues/33079 is resolved.
*/

export * from './dist/types/backend';
8 changes: 8 additions & 0 deletions core.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @module
*
* Workaround to enable types for Node v13.2+ exports until
* https://github.com/microsoft/TypeScript/issues/33079 is resolved.
*/

export * from './dist/types/core';
8 changes: 8 additions & 0 deletions customer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @module
*
* Workaround to enable types for Node v13.2+ exports until
* https://github.com/microsoft/TypeScript/issues/33079 is resolved.
*/

export * from './dist/types/customer';
3 changes: 0 additions & 3 deletions index.js

This file was deleted.

Loading

0 comments on commit 6b45a97

Please sign in to comment.