|
| 1 | +## Getting started |
| 2 | + |
| 3 | +### Installation |
| 4 | + |
| 5 | +Before you start, make sure you have a fresh version of [Node.js](https://nodejs.org/en/) installed. The current Long Term Support (LTS) release is an ideal starting point. |
| 6 | + |
| 7 | +```bash |
| 8 | +# Run this command in your project root folder. |
| 9 | +# yarn |
| 10 | +yarn add dun-js |
| 11 | + |
| 12 | +# npm |
| 13 | +npm install --save dun-js |
| 14 | +``` |
| 15 | + |
| 16 | +Then you can simply import or require the module. |
| 17 | + |
| 18 | +```javascript |
| 19 | +// ES module |
| 20 | +import { AuthClient } from 'dun-js'; |
| 21 | +const authClient = new AuthClient(/* configOptions */); |
| 22 | +``` |
| 23 | + |
| 24 | +```javascript |
| 25 | +// CommonJS |
| 26 | +var AuthClient = require('dun-js').AuthClient; |
| 27 | +var authClient = new AuthClient(/* configOptions */); |
| 28 | +``` |
| 29 | + |
| 30 | +## Usage guide |
| 31 | + |
| 32 | +### Example Client |
| 33 | + |
| 34 | +```javascript |
| 35 | +const config = { |
| 36 | + mode: 'development', |
| 37 | + brandUrl: 'jframework.io', |
| 38 | +}; |
| 39 | + |
| 40 | +const authClient = new AuthClient(config); |
| 41 | +``` |
| 42 | + |
| 43 | +### Usage with Typescript |
| 44 | + |
| 45 | +Type definitions are provided implicitly through the `types` entry in `package.json`. Types can also be referenced explicitly by importing them. |
| 46 | + |
| 47 | +```typescript |
| 48 | +import { AuthClient, DunConfig } from 'dun-js'; |
| 49 | + |
| 50 | +const config: DunConfig = { |
| 51 | + mode: 'development', |
| 52 | + brandUrl: 'jframework.io', |
| 53 | +}; |
| 54 | + |
| 55 | +const authClient: AuthClient = new AuthClient(config); |
| 56 | +``` |
| 57 | + |
| 58 | +### Using API |
| 59 | + |
| 60 | +You can easily utilize the API by importing it and then invoking its methods. |
| 61 | + |
| 62 | +Example: |
| 63 | + |
| 64 | +```typescript |
| 65 | +import { ISignInPayload, signInAPI } from 'dun-js'; |
| 66 | + |
| 67 | +const payload: ISignInPayload = { |
| 68 | + username: formValues.username, |
| 69 | + password: formValues.password, |
| 70 | +}; |
| 71 | + |
| 72 | +const response = await signInAPI(payload); |
| 73 | +``` |
| 74 | + |
| 75 | +## Configuration reference |
| 76 | + |
| 77 | +### Configuration options |
| 78 | + |
| 79 | +These options can be included when instantiating DUN Auth JS (`new AuthClient(config)`). |
| 80 | + |
| 81 | +#### `brandUrl` |
| 82 | + |
| 83 | +> :warning: This option is required |
| 84 | +
|
| 85 | +The url for your DUN brand. |
| 86 | + |
| 87 | +#### `mode` |
| 88 | + |
| 89 | +The default environment for your application is set to 'production'. To switch to a development environment, set the environment to 'development'. |
| 90 | + |
| 91 | +### Methods |
| 92 | + |
| 93 | +#### `setAuthKey()` |
| 94 | + |
| 95 | +Upon logging in, you will receive an `authKey` from the server. Use the following method to set the `authKey` in the request header. |
| 96 | + |
| 97 | +Example: |
| 98 | + |
| 99 | +```javascript |
| 100 | +authClient.setAuthKey(authKey); |
| 101 | +``` |
| 102 | + |
| 103 | +#### `setHeaders()` |
| 104 | + |
| 105 | +If you want to set headers for all APIs, use this method. |
| 106 | + |
| 107 | +Example: |
| 108 | + |
| 109 | +```javascript |
| 110 | +const userHeaders = { |
| 111 | + UrlRequest: window.location.href, |
| 112 | +}; |
| 113 | + |
| 114 | +authClient.setHeaders(userHeaders); |
| 115 | +``` |
| 116 | + |
| 117 | +## API Reference |
| 118 | + |
| 119 | +- [auth](https://developers.jframework.io/references/api-reference/authentication) |
| 120 | + - [signInUsingUsernameAPI](https://developers.jframework.io/references/api-reference/endpoints/users/authentication) |
| 121 | + - [signInUsingEmailAPI](https://developers.jframework.io/references/api-reference/endpoints/users/authentication-by-email) |
| 122 | + - [getGoogleLinkAPI](https://developers.jframework.io/guide/login-with-google#get-a-google-login-url-from-dun) |
| 123 | +- [brand](https://developers.jframework.io/references/api-reference/endpoints/brands) |
| 124 | + - [getListBrandEmailsAPI](https://developers.jframework.io/references/api-reference/endpoints/brands/get-emails) |
| 125 | + - [getBrandByUrlAPI](https://developers.jframework.io/references/api-reference/endpoints/brands/get-a-brand#api-v1-brands-by-url-brandurl) |
| 126 | + - [getListBrandLinksAPI](https://developers.jframework.io/references/api-reference/endpoints/brands/get-links) |
| 127 | +- [cdn](https://developers.jframework.io/references/api-reference/endpoints/cdn) |
| 128 | + - [cdnUploadFileAPI](https://developers.jframework.io/references/api-reference/endpoints/cdn) |
| 129 | +- currency |
| 130 | + - [getListCurrenciesAPI] |
| 131 | + - [getListExchangeRatesAPI] |
| 132 | +- [device](https://developers.jframework.io/references/api-reference/endpoints/devices) |
| 133 | + - [checkUserAccessAPI](https://developers.jframework.io/references/api-reference/endpoints/devices#api-v1-devices-user-access) |
| 134 | +- [integration](https://developers.jframework.io/references/api-reference/endpoints/app-integrations) |
| 135 | + - [getPushNotificationsAPI](https://developers.jframework.io/references/api-reference/endpoints/app-integrations/push-notification#api-integrations-push-notification-1) |
| 136 | +- [invoice](https://developers.jframework.io/references/api-reference/endpoints/invoices) |
| 137 | + - [getListInvoicesAPI](https://developers.jframework.io/references/api-reference/endpoints/invoices/get-invoices) |
| 138 | + - [exportInvoiceAPI](https://developers.jframework.io/references/api-reference/endpoints/invoices/export-a-invoice) |
| 139 | +- [issue](https://developers.jframework.io/references/api-reference/endpoints/issues) |
| 140 | + - [createIssueAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/create-an-issue) |
| 141 | + - [getListIssuesAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/get-issues) |
| 142 | + - [deleteIssueAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/remove-an-issue) |
| 143 | + - [createIssueReactionAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/create-an-issue-reaction) |
| 144 | + - [deleteIssueReactionAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/remove-a-issue-reaction) |
| 145 | + - [getListIssuesByIdsAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/get-issues-by-list-id) |
| 146 | + - [getListIssueChildrenAPI](https://developers.jframework.io/references/api-reference/endpoints/issues/get-children-issues) |
| 147 | + - [getListIssueCategoriesAPI](https://developers.jframework.io/references/api-reference/endpoints/issue-categories/get-issue-categories) |
| 148 | +- [language](https://developers.jframework.io/references/api-reference/endpoints/languages) |
| 149 | + - [getListLanguagesAPI](https://developers.jframework.io/references/api-reference/endpoints/languages) |
| 150 | +- [license](https://developers.jframework.io/references/api-reference/endpoints/licenses) |
| 151 | + - [checkValidLicenseAPI](https://developers.jframework.io/references/api-reference/endpoints/licenses/checks-a-license) |
| 152 | + - [applyLicenseAPI](https://developers.jframework.io/references/api-reference/endpoints/licenses/applies-a-license-to-the-logged-user) |
| 153 | +- [notification](https://developers.jframework.io/references/api-reference/endpoints/notifications) |
| 154 | + - [getNotificationsAPI](https://developers.jframework.io/references/api-reference/endpoints/notifications/get-notifications-by-the-user-authorized) |
| 155 | + - [updateNotificationStatusAPI](https://developers.jframework.io/references/api-reference/endpoints/notifications/updates-status-of-the-notification) |
| 156 | + - [deleteNotificationsAPI](https://developers.jframework.io/references/api-reference/endpoints/notifications/delete-a-notification) |
| 157 | + - [updateAllNotificationsAPI](https://developers.jframework.io/references/api-reference/endpoints/notifications/updates-all-notification) |
| 158 | +- [organization](https://developers.jframework.io/references/api-reference/endpoints/organizations) |
| 159 | + - [getListOrganizationsAPI] |
| 160 | + - [getOrganizationDetailAPI](https://developers.jframework.io/references/api-reference/endpoints/organizations/get-an-organization) |
| 161 | + - [getListOrganizationsByViewerAPI] |
| 162 | + - [createOrganizationUserAPI] |
| 163 | + - [updateOrganizationUserAPI](https://developers.jframework.io/references/api-reference/endpoints/organizations/update-a-user-status-in-an-organization) |
| 164 | + - [deleteOrganizationUserAPI](https://developers.jframework.io/references/api-reference/endpoints/organizations/remove-a-user-in-an-organization) |
| 165 | + - [getListUsersOfOrganizationAPI](https://developers.jframework.io/references/api-reference/endpoints/organizations/list-users-of-an-organization) |
| 166 | +- [package](https://developers.jframework.io/references/api-reference/endpoints/packages) |
| 167 | + - [getListPackagesAPI](https://developers.jframework.io/references/api-reference/endpoints/packages) |
| 168 | +- payment-provider |
| 169 | + - [getListPaymentProvidersAPI] |
| 170 | +- [price](https://developers.jframework.io/references/api-reference/endpoints/prices) |
| 171 | + - [generateCheckoutLink](https://developers.jframework.io/references/api-reference/endpoints/prices#api-prices-id-direct-checkout-link) |
| 172 | +- [role](https://developers.jframework.io/references/api-reference/endpoints/roles) |
| 173 | + - [getListRolesAPI](https://developers.jframework.io/references/api-reference/endpoints/roles#api-roles) |
| 174 | +- [timezone](https://developers.jframework.io/references/api-reference/endpoints/time-zones) |
| 175 | + - [getListTimezonesAPI](https://developers.jframework.io/references/api-reference/endpoints/time-zones) |
| 176 | +- [user](https://developers.jframework.io/references/api-reference/endpoints/users) |
| 177 | + - [getUserInfoAPI](https://developers.jframework.io/references/api-reference/endpoints/users/gets-the-current-user-logged-in) |
| 178 | + - [getListUsersByIdsAPI] |
| 179 | + - [getUserInfoByIdAPI](https://developers.jframework.io/references/api-reference/endpoints/users/get-a-user) |
| 180 | + - [updateUserAPI](https://developers.jframework.io/references/api-reference/endpoints/users/update-a-user) |
| 181 | + - [signUpAPI](https://developers.jframework.io/references/api-reference/endpoints/users/register-a-new-user) |
| 182 | + - [forgotPasswordAPI](https://developers.jframework.io/references/api-reference/endpoints/users/forgot-password) |
| 183 | + - [resetPasswordAPI] |
| 184 | + - [changePasswordAPI](https://developers.jframework.io/references/api-reference/endpoints/users/change-password) |
| 185 | + - [getRefereesAPI](https://developers.jframework.io/references/api-reference/endpoints/users/gets-the-referees-of-a-user) |
| 186 | + - [checkCodeValidAPI] |
| 187 | + - [applyCodeAPI](https://developers.jframework.io/references/api-reference/endpoints/users/applies-the-referral-code-to-a-user) |
| 188 | + - [getListUserConfigurationsAPI] |
| 189 | + - [createUserConfigurationsAPI] |
| 190 | + - [updateUserConfigurationsAPI] |
| 191 | +- [wallet](https://developers.jframework.io/references/api-reference/endpoints/wallets) |
| 192 | + - [getWalletAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/get-wallets) |
| 193 | + - [getWalletHistoriesAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/get-the-wallet-histories) |
| 194 | + - [createWalletAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/create-a-wallet-default) |
| 195 | + - [exchangeWalletAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/convert-wallet-money) |
| 196 | + - [addMoneyAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/add-money-to-a-wallet-with-checkout-link) |
| 197 | + - [closeWalletAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/close-wallet) |
| 198 | + - [getListEarnEventsAPI] |
| 199 | + - [applyRedeemAPI](https://developers.jframework.io/references/api-reference/endpoints/wallets/apply-redeem) |
0 commit comments