|
| 1 | +/** |
| 2 | + * OAuth2 API |
| 3 | + * OAuth2 Token Service (OAuth2) |
| 4 | + * |
| 5 | + * OpenAPI spec version: v3 |
| 6 | + * |
| 7 | + * NOTE: This class is auto generated by the swagger code generator program. |
| 8 | + * https://github.com/swagger-api/swagger-codegen.git |
| 9 | + * |
| 10 | + * Swagger Codegen version: 2.3.0 |
| 11 | + * |
| 12 | + * Do not edit the class manually. |
| 13 | + * |
| 14 | + */ |
| 15 | + |
| 16 | +(function(root, factory) { |
| 17 | + if (typeof define === 'function' && define.amd) { |
| 18 | + // AMD. Register as an anonymous module. |
| 19 | + define(['ApiClient', 'model/AccessTokenResponse', 'model/BadRequestError', 'model/CreateAccessTokenRequest', 'model/ResourceNotFoundError', 'model/UnauthorizedClientError'], factory); |
| 20 | + } else if (typeof module === 'object' && module.exports) { |
| 21 | + // CommonJS-like environments that support module.exports, like Node. |
| 22 | + module.exports = factory(require('../ApiClient'), require('../model/AccessTokenResponse'), require('../model/BadRequestError'), require('../model/CreateAccessTokenRequest'), require('../model/ResourceNotFoundError'), require('../model/UnauthorizedClientError')); |
| 23 | + } else { |
| 24 | + // Browser globals (root is window) |
| 25 | + if (!root.CyberSource) { |
| 26 | + root.CyberSource = {}; |
| 27 | + } |
| 28 | + root.CyberSource.OAuthApi = factory(root.CyberSource.ApiClient, root.CyberSource.AccessTokenResponse, root.CyberSource.BadRequestError, root.CyberSource.CreateAccessTokenRequest, root.CyberSource.ResourceNotFoundError, root.CyberSource.UnauthorizedClientError); |
| 29 | + } |
| 30 | +}(this, function(ApiClient, AccessTokenResponse, BadRequestError, CreateAccessTokenRequest, ResourceNotFoundError, UnauthorizedClientError) { |
| 31 | + 'use strict'; |
| 32 | + |
| 33 | + /** |
| 34 | + * OAuth service. |
| 35 | + * @module api/OAuthApi |
| 36 | + * @version v3 |
| 37 | + */ |
| 38 | + |
| 39 | + /** |
| 40 | + * Constructs a new OAuthApi. |
| 41 | + * @alias module:api/OAuthApi |
| 42 | + * @class |
| 43 | + * @param {module:ApiClient} apiClient Optional API client implementation to use, |
| 44 | + * default to {@link module:ApiClient#instance} if unspecified. |
| 45 | + */ |
| 46 | + var exports = function(configObject, apiClient) { |
| 47 | + this.apiClient = apiClient || ApiClient.instance; |
| 48 | + |
| 49 | + this.apiClient.setConfiguration(configObject); |
| 50 | + |
| 51 | + |
| 52 | + /** |
| 53 | + * Callback function to receive the result of the createAccessToken operation. |
| 54 | + * @callback module:api/OAuthApi~createAccessTokenCallback |
| 55 | + * @param {String} error Error message, if any. |
| 56 | + * @param {module:model/AccessTokenResponse} data The data returned by the service call. |
| 57 | + * @param {String} response The complete HTTP response. |
| 58 | + */ |
| 59 | + |
| 60 | + /** |
| 61 | + * Create access token and refresh token |
| 62 | + * This request is used by technology partners to obtain an access token and a refresh token, which are contained in the response. The partner can then use the access token for authentication when submitting API requests to CyberSource on behalf of the merchant. The request must include the authorization code that was included in the URL redirect response from CyberSource (see [full documentation](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro.html)). Access tokens expire after 15 minutes. The refresh token is used to create a new access token, it expires after one year. |
| 63 | + * @param {module:model/CreateAccessTokenRequest} createAccessTokenRequest Request payload |
| 64 | + * @param {Object} opts Optional parameters |
| 65 | + * @param {String} opts.vCClientCorrelationId We recommended that you submit this header with a unique value in every client request to this endpoint. It is sent back in the response header and logged both in the request log and response log. |
| 66 | + * @param {module:api/OAuthApi~createAccessTokenCallback} callback The callback function, accepting three arguments: error, data, response |
| 67 | + * data is of type: {@link module:model/AccessTokenResponse} |
| 68 | + */ |
| 69 | + this.createAccessToken = function(createAccessTokenRequest, opts, callback) { |
| 70 | + opts = opts || {}; |
| 71 | + var postBody = createAccessTokenRequest; |
| 72 | + |
| 73 | + // verify the required parameter 'createAccessTokenRequest' is set |
| 74 | + if (createAccessTokenRequest === undefined || createAccessTokenRequest === null) { |
| 75 | + throw new Error("Missing the required parameter 'createAccessTokenRequest' when calling createAccessToken"); |
| 76 | + } |
| 77 | + |
| 78 | + |
| 79 | + var pathParams = { |
| 80 | + }; |
| 81 | + var queryParams = { |
| 82 | + }; |
| 83 | + var headerParams = { |
| 84 | + 'v-c-client-correlation-id': opts['vCClientCorrelationId'] |
| 85 | + }; |
| 86 | + var formParams = { |
| 87 | + }; |
| 88 | + |
| 89 | + var authNames = []; |
| 90 | + var contentTypes = ['application/x-www-form-urlencoded']; |
| 91 | + var accepts = ['application/json;charset=utf-8']; |
| 92 | + var returnType = AccessTokenResponse; |
| 93 | + |
| 94 | + return this.apiClient.callApi( |
| 95 | + '/oauth2/v3/token', 'POST', |
| 96 | + pathParams, queryParams, headerParams, formParams, postBody, |
| 97 | + authNames, contentTypes, accepts, returnType, callback |
| 98 | + ); |
| 99 | + } |
| 100 | + }; |
| 101 | + |
| 102 | + return exports; |
| 103 | +})); |
0 commit comments