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.



19
20
21
# File 'lib/moneykit/api/access_token_api.rb', line 19

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



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

def api_client
  @api_client
end

Instance Method Details

#create_access_token(opts = {}) ⇒ CreateAccessTokenResponse

/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):

  • :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 create_access_token(opts = {})
  data, _status_code, _headers = create_access_token_with_http_info(opts)
  data
end

#create_access_token_with_http_info(opts = {}) ⇒ Array<(CreateAccessTokenResponse, 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):

  • :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<(CreateAccessTokenResponse, Integer, Hash)>)

    CreateAccessTokenResponse data, response status code and response headers



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

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

#get_app_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):

  • :x_client_id (String)

    Your client ID.

Returns:



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

def get_app_jwks(opts = {})
  data, _status_code, _headers = get_app_jwks_with_http_info(opts)
  data
end

#get_app_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):

  • :x_client_id (String)

    Your client ID.

Returns:

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

    JWKSet data, response status code and response headers



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

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

#instrospect_client(opts = {}) ⇒ AppClientResponse

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

Parameters:

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

    the optional parameters

Returns:



165
166
167
168
# File 'lib/moneykit/api/access_token_api.rb', line 165

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

#instrospect_client_with_http_info(opts = {}) ⇒ Array<(AppClientResponse, 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

Returns:

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

    AppClientResponse data, response status code and response headers



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

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