Skip to content

Commit

Permalink
Support new async methods (#93)
Browse files Browse the repository at this point in the history
* Support new async methods

* CR fixes

* Update 2 last links

* Update all links
  • Loading branch information
awilczek authored Nov 15, 2021
1 parent 71a1b63 commit c5c8b97
Show file tree
Hide file tree
Showing 31 changed files with 353 additions and 292 deletions.
30 changes: 30 additions & 0 deletions .changeset/popular-comics-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
'@voucherify/sdk': major
---

Support new async API methods

Changes:
- Campaign vouchers import
- added CampaignsVouchersImportResponse
- Vouchers import
- added VouchersImportResponse
- Vouchers bulkUpdate
- using new API method
- **BREAKING** change of VouchersBulkUpdateResponse
- **BREAKING** obligatory 'metadata' field in VouchersBulkUpdateObject
- Vouchers bulkUpdateMetadata
- using new API method
- **BREAKING** change of VouchersBulkUpdateMetadataResponse
- **BREAKING** obligatory 'metadata' field in VouchersBulkUpdateMetadata
- Products bulkUpdate
- using [new API method](https://docs.voucherify.io/reference/post-products-in-bulk)
- **BREAKING** change of ProductsBulkUpdateResponse
- Products bulkUpdateMetadata
- using [new API method](https://docs.voucherify.io/reference/async-update-products-metadata-in-bulk)
- **BREAKING** change of method name
- **BREAKING** change of ProductsBulkUpdateMetadataResponse
- Products getSku
- using [new API method](https://docs.voucherify.io/reference/get-sku-v20210726)
- **BREAKING** change of method params
- changed in CR fixes
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.vscode
.old
.DS_Store
*.iml

# Logs
logs
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="https://vf-asset.s3-eu-west-1.amazonaws.com/voucherify-js-sdk/logo.png" />
</p>

<h3 align="center">Official <a href="http://voucherify.io?utm_source=github&utm_medium=sdk&utm_campaign=acq">Voucherify</a> JS SDK and React Widget</h3>
<h3 align="center">Official <a href="https://www.voucherify.io">Voucherify</a> JS SDK and React Widget</h3>

<p>
<a href="#"><img src="https://github.com/voucherifyio/voucherify-js-sdk/workflows/Release/badge.svg?branch=main" alt="Build Status"/></a>
Expand Down Expand Up @@ -40,15 +40,15 @@ Packages:

Voucherify empowers marketers and developers with flexible building blocks to come up with, implement, and track targeted promotional campaigns.

Learn more about Voucherify by visiting [our site](http://voucherify.io?utm_source=github&utm_medium=sdk&utm_campaign=acq).
Learn more about Voucherify by visiting [our site](https://www.voucherify.io).

# <a name="documentation"></a>📝 Documentation

You will find detailed description and example responses at our [official documentation](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq). Most method headers point to more detailed descriptions of arguments you can use.
You will find detailed description and example responses at our [official documentation](https://docs.voucherify.io/reference). Most method headers point to more detailed descriptions of arguments you can use.

You can also use our detailed documentation provided by our package [here](https://voucherifyio.github.io/voucherify-js-sdk/).

📚 Want to learn more? Visit our [official site](https://voucherify.io) or our [Success Portal](https://success.voucherify.io).
📚 Want to learn more? Visit our [official site](https://www.voucherify.io) or our [Success Portal](https://success.voucherify.io).

👽 Having troubles? Check our [Help center](https://support.voucherify.io/).

Expand Down Expand Up @@ -113,7 +113,7 @@ You can find TS example in [examples/sdk/with-nodejs-typescript](/examples/sdk/w

# <a name="error-handling"></a>😨 Error handling

Voucherify `error` object always has consistent structure, described in details in our [API reference](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#errors).
Voucherify `error` object always has consistent structure, described in details in our [API reference](https://docs.voucherify.io/reference/errors).

# <a name="legacy"></a>👴 Legacy Voucherify JS SDKs

Expand Down
12 changes: 6 additions & 6 deletions packages/react-widget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="https://vf-asset.s3-eu-west-1.amazonaws.com/voucherify-js-sdk/logo_react.png" />
</p>

<h3 align="center">Official <a href="http://voucherify.io?utm_source=github&utm_medium=sdk&utm_campaign=acq">Voucherify</a> React Widget</h3>
<h3 align="center">Official <a href="https://www.voucherify.io">Voucherify</a> React Widget</h3>

<p>
<a href="#"><img src="https://github.com/voucherifyio/voucherify-js-sdk/workflows/Release/badge.svg?branch=main" alt="Build Status"/></a>
Expand Down Expand Up @@ -44,15 +44,15 @@ Voucherify React Widget contains several client-side Voucherify methods, which a

Voucherify React Widget uses Voucherify JS SDK which is fully consistent with restful API Voucherify provides and has fully integrated TypeScript support. It also combines together our previously maintained [Voucherify Node.js SDK](https://github.com/voucherifyio/voucherify-nodejs-sdk) and [Voucherify.js](https://github.com/rspective/voucherify.js/).

Learn more about Voucherify by visiting [our site](http://voucherify.io?utm_source=github&utm_medium=sdk&utm_campaign=acq).
Learn more about Voucherify by visiting [our site](https://www.voucherify.io).

# <a name="documentation"></a>📝 Documentation

You will find detailed description and example responses at our [official documentation](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq). Most method headers point to more detailed descriptions of arguments you can use.
You will find detailed description and example responses at our [official documentation](https://docs.voucherify.io/reference). Most method headers point to more detailed descriptions of arguments you can use.

You can also use our detailed documentation provided by our package [here](https://voucherifyio.github.io/voucherify-js-sdk/).

📚 Want to learn more? Visit our [official site](https://voucherify.io) or our [Success Portal](https://success.voucherify.io).
📚 Want to learn more? Visit our [official site](https://www.voucherify.io) or our [Success Portal](https://success.voucherify.io).

👽 Having troubles? Check our [Help center](https://support.voucherify.io/).

Expand Down Expand Up @@ -92,7 +92,7 @@ CDN installation:
</body>
```

Then, [login](http://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/login) to your Voucherify Dashboard and get your API keys from [Configuration](https://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/app/core/projects/current/general) and allow client requests from your domain.
Then, [login](https://app.voucherify.io/#/login) to your Voucherify Dashboard and get your API keys from [Configuration](https://app.voucherify.io/#/app/core/projects/current/general) and allow client requests from your domain.

If you want to use Redeem or Publish Widget, remember to allow client-side redemption and publication.

Expand Down Expand Up @@ -378,7 +378,7 @@ Voucherify React Widget includes TypeScript declarations.

# <a name="error-handling"></a>😨 Error handling

Voucherify `error` object always has consistent structure, described in details in our [API reference](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#errors).
Voucherify `error` object always has consistent structure, described in details in our [API reference](https://docs.voucherify.io/reference/errors).

# <a name="alternatives"></a>🖼️ Alternatives - iframe

Expand Down
38 changes: 33 additions & 5 deletions packages/sdk/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,37 @@

# 🔖 Table of contents

- [Migration to version 2.x](#voucherify-js-sdk-2)
- [Migration from Voucherify Node.js SDK](#voucherify-node-js)
- [Migration from Voucherify.js](#voucherify-js)

## <a name="voucherify-js-sdk-2"></a>Migration to version 2.x

Core change in version 2.x was using async methods instead of sync versions.
Sync API methods became deprecated, and will be removed in the future.
Therefore breaking changes were introduced in this SDK, so that new API methods are used instead of the old ones.

The following methods return now only the `async_action_id` field, instead of the response with the results:
- Vouchers bulkUpdate (additional breaking change: obligatory 'metadata' field in VouchersBulkUpdateObject)
- Vouchers bulkUpdateMetadata (additional breaking change: obligatory 'metadata' field in VouchersBulkUpdateMetadata)
- Products bulkUpdate
- Products bulkUpdateMetadata (additional breaking change of the method name)

In order to get the final results, one needs to fetch it using [the API method for getting the async-action result](https://docs.voucherify.io/reference/get-async-actions-1).
Using the SDK method it would look like:
```
voucherify.asyncActions.get(async_action_id)
.then(response => {
console.log('Status: ', response.status);
if (result.status === "DONE") {
console.log('Result: ', response.result);
}
})
```

<b>Additionally</b>, there is a breaking change in getSku method params.
New API method is used, where ID of the product is no longer required.

## <a name="voucherify-node-js"></a>Migration from [Voucherify Node.js SDK](https://github.com/voucherifyio/voucherify-nodejs-sdk)

<table>
Expand Down Expand Up @@ -62,7 +90,7 @@ client.vouchers.get('v1GiJYuuS', (error, result) => {
</td>
<td>
Dropped support for callbacks, use promises instead

</td>
</tr>
<tr>
Expand All @@ -76,7 +104,7 @@ client.validationRules.validate(validationRuleId)
</td>
<td>
Dropped support

</td>
</tr>
<tr>
Expand Down Expand Up @@ -179,8 +207,8 @@ client.validate(params).then(console.log).catch(console.log)

</td>
</tr>



</tbody>
</table>
Loading

0 comments on commit c5c8b97

Please sign in to comment.