| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | /** * @name Company * @description This module exposes functions * related to the `/company` and * `/companies` paths. * * @module company **/ import routes from '../routes' import request from '../request' /** * `POST /companies` * Creates a company from the given payload. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @param {Object} body The payload for the request * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const create = (opts, body) => request.post(opts, routes.company.basePlural, body) /** * `POST /companies/temporary` * Creates a test-only temporary company. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @param {Object} body The payload for the request * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const createTemporary = (opts, body) => request.post(opts, routes.company.temporary, body) /** * `POST /companies/activate` * Activates a company. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const activate = (opts, body) => request.post(opts, routes.company.activate, body) /** * `PUT /company` * Updates a company from the given payload. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @param {Object} body The payload for the request * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const update = (opts, body) => request.put(opts, routes.company.base, body) /** * `GET /company` * Return a company from the given payload. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const current = opts => request.get(opts, routes.company.base) /** * `PUT /company/reset_keys` * Reset the company API keys. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @param {Object} body The payload for the request * * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const resetKeys = (opts, body) => request.put(opts, routes.company.resetKeys, body) /** * `GET /company/affiliation_progress` * Information about the affiliation progress. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const affiliationProgress = opts => request.get(opts, routes.company.affiliationProgress, {}) /** * `PUT /company/branding/:id` * Updates a company branding from the given payload. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @param {Object} body The payload for the request * * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const updateBranding = (opts, body) => request.put(opts, routes.company.branding(body.id), body) const emailTemplates = { /** * `GET /company/email_templates/:id` * Get emails templates * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @param {Number} body.id The ID of the email template. * * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ find: (opts, body) => request.get(opts, routes.company.emailTemplates(body.id), {}), /** * `PUT /company/email_templates/:id` * Updates a company from the given payload. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @param {Object} body The payload for the request * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ update: (opts, body) => request.put(opts, routes.company.emailTemplates(body.id), body), } /** * `POST /company/email_confirmation` * Resend account confirmation email to a previously registered company. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @param {String} body.email The email address to resend the account confirmation * @returns {Promise} A promise that resolves to * the send email confirmation company's * data or to an error. **/ const emailConfirmation = (opts, body) => request.post(opts, routes.company.emailConfirmation, body) /** * `GET /company/fees` * Return company fees configuration available. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const fees = opts => request.get(opts, routes.company.fees) /** * `PUT /company/anticipation` * Sets the delay for the automatic anticipation based on the options * available. It's also possible to disable the automatic anticipation. * * Check GET /company/anticipation/options for the options available. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @param {Boolean} body.enabled Enables the automatic anticipation. * @param {Number} body.delay Days for the anticipation delay. * * @returns {Promise} A promise that resolves to * a confirmation or to an error. **/ const updateAnticipation = (opts, body) => request.put(opts, routes.company.anticipation.base, body) /** * `GET /company/anticipation/options` * Available anticipation options that can be set using PUT /company/anticipation. * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @returns {Promise} A promise that resolves to * the available anticipation options * or to an error. **/ const anticipationOptions = opts => request.get(opts, routes.company.anticipation.options) /** * `GET /company/api_key` * Return company api key (sandbox and live) * * @param {Object} opts An options params which * is usually already bound * by `connect` functions. * * @returns {Promise} A promise that resolves to * the newly created company's * data or to an error. **/ const apiKey = (opts, params) => request.get(opts, routes.company.apiKey, params) export default { create, createTemporary, activate, emailConfirmation, update, current, resetKeys, affiliationProgress, updateBranding, emailTemplates, fees, updateAnticipation, anticipationOptions, apiKey, } |