Class: MoneyKit::AccessTokenApi

Inherits:
Object
  • Object
show all
Defined in:
lib/moneykit/api/access_token_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AccessTokenApi

Returns a new instance of AccessTokenApi.



17
18
19
# File 'lib/moneykit/api/access_token_api.rb', line 17

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



15
16
17
# File 'lib/moneykit/api/access_token_api.rb', line 15

def api_client
  @api_client
end

Instance Method Details

#generate_access_token(opts = {}) ⇒ GenerateAccessTokenResponse

/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.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :moneykit_version (String) — default: default to '2023-02-18'
  • :grant_type (String)

    Token grant type. Only `client_credentials` supported.

  • :scope (String)

    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 ”)

  • :client_id (String)

    Your application's MoneyKit client ID.

  • :client_secret (String)

    Your application's MoneyKit client secret.

Returns:



30
31
32
33
# File 'lib/moneykit/api/access_token_api.rb', line 30

def generate_access_token(opts = {})
  data, _status_code, _headers = generate_access_token_with_http_info(opts)
  data
end

#generate_access_token_with_http_info(opts = {}) ⇒ Array<(GenerateAccessTokenResponse, Integer, Hash)>

/auth/token Create a new short-lived access token by validating your &#x60;client_id&#x60; and &#x60;client_secret&#x60;. The &#x60;access_token&#x60; is to be forwarded with all subsequent requests as &#x60;Authorization: Bearer access_token&#x60; HTTP header. When the token expires you must regenerate your &#x60;access_token&#x60;. The &#x60;client_id&#x60; and &#x60;client_secret&#x60; can be supplied as POST body parameters, or as a HTTP basic auth header.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :moneykit_version (String) — default: default to '2023-02-18'
  • :grant_type (String)

    Token grant type. Only &#x60;client_credentials&#x60; supported.

  • :scope (String)

    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 ”)

  • :client_id (String)

    Your application&#39;s MoneyKit client ID.

  • :client_secret (String)

    Your application&#39;s MoneyKit client secret.

Returns:

  • (Array<(GenerateAccessTokenResponse, Integer, Hash)>)

    GenerateAccessTokenResponse data, response status code and response headers



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
# File 'lib/moneykit/api/access_token_api.rb', line 44

def generate_access_token_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AccessTokenApi.generate_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
    raise ArgumentError,
          "invalid value for 'opts[:\"grant_type\"]' when calling AccessTokenApi.generate_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'])
  header_params['Content-Type'] = content_type unless content_type.nil?
  header_params[:'moneykit-version'] = opts[:moneykit_version] unless opts[:moneykit_version].nil?

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['grant_type'] = opts[:grant_type] unless opts[:grant_type].nil?
  form_params['scope'] = opts[:scope] unless opts[:scope].nil?
  form_params['client_id'] = opts[:client_id] unless opts[:client_id].nil?
  form_params['client_secret'] = opts[:client_secret] unless opts[:client_secret].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GenerateAccessTokenResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBasic']

  new_options = opts.merge(
    operation: :"AccessTokenApi.generate_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#generate_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#get_well_known_jwks(opts = {}) ⇒ JWKSet

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.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :moneykit_version (String) — default: default to '2023-02-18'

Returns:



107
108
109
110
# File 'lib/moneykit/api/access_token_api.rb', line 107

def get_well_known_jwks(opts = {})
  data, _status_code, _headers = get_well_known_jwks_with_http_info(opts)
  data
end

#get_well_known_jwks_with_http_info(opts = {}) ⇒ Array<(JWKSet, Integer, Hash)>

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.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :moneykit_version (String) — default: default to '2023-02-18'

Returns:

  • (Array<(JWKSet, Integer, Hash)>)

    JWKSet data, response status code and response headers



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
# File 'lib/moneykit/api/access_token_api.rb', line 117

def get_well_known_jwks_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: AccessTokenApi.get_well_known_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[:'moneykit-version'] = opts[:moneykit_version] unless opts[:moneykit_version].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_well_known_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_well_known_jwks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  [data, status_code, headers]
end

#instrospect_client(opts = {}) ⇒ IntrospectClientResponse

/auth/introspect Get details about the client and application associated with your ‘access_token`.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :moneykit_version (String) — default: default to '2023-02-18'

Returns:



167
168
169
170
# File 'lib/moneykit/api/access_token_api.rb', line 167

def instrospect_client(opts = {})
  data, _status_code, _headers = instrospect_client_with_http_info(opts)
  data
end

#instrospect_client_with_http_info(opts = {}) ⇒ Array<(IntrospectClientResponse, Integer, Hash)>

/auth/introspect Get details about the client and application associated with your &#x60;access_token&#x60;.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :moneykit_version (String) — default: default to '2023-02-18'

Returns:

  • (Array<(IntrospectClientResponse, Integer, Hash)>)

    IntrospectClientResponse data, response status code and response headers



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
# File 'lib/moneykit/api/access_token_api.rb', line 177

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'])
  header_params[:'moneykit-version'] = opts[:moneykit_version] unless opts[:moneykit_version].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'IntrospectClientResponse'

  # 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
  [data, status_code, headers]
end