=begin #MoneyKit API #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) The version of the OpenAPI document: 2023-02-18 Generated by: https://openapi-generator.tech OpenAPI Generator version: 7.1.0 =end require 'cgi' module MoneyKit class AccessTokenApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # /auth/token # Create a new short-lived access token by validating your `client_id` and `client_secret`. The `access_token` is to be forwarded with all subsequent requests as `Authorization: Bearer {access_token}` HTTP header. When the token expires you must regenerate your `access_token`. The `client_id` and `client_secret` can be supplied as POST body parameters, or as a HTTP basic auth header. # @param [Hash] opts the optional parameters # @option opts [String] :grant_type Token grant type. Only `client_credentials` supported. # @option opts [String] :scope Actions to be allowed for this token, given as one or more strings separated by spaces. If omitted, all actions allowed for your application will be granted to this token. (default to '') # @option opts [String] :client_id Your application's MoneyKit client ID. # @option opts [String] :client_secret Your application's MoneyKit client secret. # @return [CreateAccessTokenResponse] def create_access_token(opts = {}) data, _status_code, _headers = create_access_token_with_http_info(opts) data end # /auth/token # Create a new short-lived access token by validating your `client_id` and `client_secret`. The `access_token` is to be forwarded with all subsequent requests as `Authorization: Bearer {access_token}` HTTP header. When the token expires you must regenerate your `access_token`. The `client_id` and `client_secret` can be supplied as POST body parameters, or as a HTTP basic auth header. # @param [Hash] opts the optional parameters # @option opts [String] :grant_type Token grant type. Only `client_credentials` supported. # @option opts [String] :scope Actions to be allowed for this token, given as one or more strings separated by spaces. If omitted, all actions allowed for your application will be granted to this token. (default to '') # @option opts [String] :client_id Your application's MoneyKit client ID. # @option opts [String] :client_secret Your application's MoneyKit client secret. # @return [Array<(CreateAccessTokenResponse, Integer, Hash)>] CreateAccessTokenResponse data, response status code and response headers def create_access_token_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AccessTokenApi.create_access_token ...' end pattern = Regexp.new(/^(client_credentials|refresh_token)$/) if @api_client.config.client_side_validation && !opts[:'grant_type'].nil? && opts[:'grant_type'] !~ pattern fail ArgumentError, "invalid value for 'opts[:\"grant_type\"]' when calling AccessTokenApi.create_access_token, must conform to the pattern #{pattern}." end # resource path local_var_path = '/auth/token' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['grant_type'] = opts[:'grant_type'] if !opts[:'grant_type'].nil? form_params['scope'] = opts[:'scope'] if !opts[:'scope'].nil? form_params['client_id'] = opts[:'client_id'] if !opts[:'client_id'].nil? form_params['client_secret'] = opts[:'client_secret'] if !opts[:'client_secret'].nil? # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CreateAccessTokenResponse' # auth_names auth_names = opts[:debug_auth_names] || ['HTTPBasic'] new_options = opts.merge( :operation => :"AccessTokenApi.create_access_token", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AccessTokenApi#create_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # JSON Web Key Set # The JSON Web Key Set (JWKS) is a set of keys containing the public keys used to verify webhook JSON Web Tokens (JWT) issued by MoneyKit webhooks. # @param [Hash] opts the optional parameters # @option opts [String] :x_client_id Your client ID. # @return [JWKSet] def get_app_jwks(opts = {}) data, _status_code, _headers = get_app_jwks_with_http_info(opts) data end # JSON Web Key Set # The JSON Web Key Set (JWKS) is a set of keys containing the public keys used to verify webhook JSON Web Tokens (JWT) issued by MoneyKit webhooks. # @param [Hash] opts the optional parameters # @option opts [String] :x_client_id Your client ID. # @return [Array<(JWKSet, Integer, Hash)>] JWKSet data, response status code and response headers def get_app_jwks_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AccessTokenApi.get_app_jwks ...' end # resource path local_var_path = '/.well-known/jwks.json' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) header_params[:'X-Client-Id'] = opts[:'x_client_id'] if !opts[:'x_client_id'].nil? # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'JWKSet' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2ClientCredentials'] new_options = opts.merge( :operation => :"AccessTokenApi.get_app_jwks", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AccessTokenApi#get_app_jwks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # /auth/introspect # Get details about the client and application associated with your `access_token`. # @param [Hash] opts the optional parameters # @return [AppClientResponse] def instrospect_client(opts = {}) data, _status_code, _headers = instrospect_client_with_http_info(opts) data end # /auth/introspect # Get details about the client and application associated with your `access_token`. # @param [Hash] opts the optional parameters # @return [Array<(AppClientResponse, Integer, Hash)>] AppClientResponse data, response status code and response headers def instrospect_client_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AccessTokenApi.instrospect_client ...' end # resource path local_var_path = '/auth/introspect' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'AppClientResponse' # auth_names auth_names = opts[:debug_auth_names] || ['OAuth2ClientCredentials'] new_options = opts.merge( :operation => :"AccessTokenApi.instrospect_client", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: AccessTokenApi#instrospect_client\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end