Class: SnapTrade::AuthenticationApi

Inherits:
Object
  • Object
show all
Defined in:
lib/snaptrade/api/authentication_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ AuthenticationApi

Returns a new instance of AuthenticationApi.



16
17
18
# File 'lib/snaptrade/api/authentication_api.rb', line 16

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



14
15
16
# File 'lib/snaptrade/api/authentication_api.rb', line 14

def api_client
  @api_client
end

Instance Method Details

#delete_snap_trade_user(user_id:, extra: {}) ⇒ Object

Delete user

Deletes a registered user and all associated data. This action is irreversible. This API is asynchronous and will return a 200 status code if the request is accepted. The user and all associated data will be queued for deletion. Once deleted, a ‘USER_DELETED` webhook will be sent.

Parameters:

  • user_id (String)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



26
27
28
29
# File 'lib/snaptrade/api/authentication_api.rb', line 26

def delete_snap_trade_user(user_id:, extra: {})
  data, _status_code, _headers = delete_snap_trade_user_with_http_info_impl(user_id, extra)
  data
end

#delete_snap_trade_user_with_http_info(user_id:, extra: {}) ⇒ Object

Delete user

Deletes a registered user and all associated data. This action is irreversible. This API is asynchronous and will return a 200 status code if the request is accepted. The user and all associated data will be queued for deletion. Once deleted, a ‘USER_DELETED` webhook will be sent.

Parameters:

  • user_id (String)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



37
38
39
# File 'lib/snaptrade/api/authentication_api.rb', line 37

def delete_snap_trade_user_with_http_info(user_id:, extra: {})
  delete_snap_trade_user_with_http_info_impl(user_id, extra)
end

#list_snap_trade_users(extra: {}) ⇒ Object

List all users

Returns a list of all registered user IDs. Please note that the response is not currently paginated.

Parameters:

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

    additional parameters to pass along through :header_params, :query_params, or parameter name



111
112
113
114
# File 'lib/snaptrade/api/authentication_api.rb', line 111

def list_snap_trade_users(extra: {})
  data, _status_code, _headers = list_snap_trade_users_with_http_info_impl(extra)
  data
end

#list_snap_trade_users_with_http_info(extra: {}) ⇒ Object

List all users

Returns a list of all registered user IDs. Please note that the response is not currently paginated.

Parameters:

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

    additional parameters to pass along through :header_params, :query_params, or parameter name



121
122
123
# File 'lib/snaptrade/api/authentication_api.rb', line 121

def list_snap_trade_users_with_http_info(extra: {})
  list_snap_trade_users_with_http_info_impl(extra)
end

#login_snap_trade_user(user_id:, user_secret:, broker: SENTINEL, immediate_redirect: SENTINEL, custom_redirect: SENTINEL, reconnect: SENTINEL, connection_type: 'read', show_close_button: SENTINEL, dark_mode: SENTINEL, connection_portal_version: 'v4', extra: {}) ⇒ Object

Generate Connection Portal URL

Authenticates a SnapTrade user and returns the Connection Portal URL used for connecting brokerage accounts. Please check [this guide](/docs/implement-connection-portal) for how to integrate the Connection Portal into your app.

Please note that the returned URL expires in 5 minutes.

Parameters:

  • user_id (String)
  • user_secret (String)
  • broker (String) (defaults to: SENTINEL)

    Slug of the brokerage to connect the user to. See [the integrations page](snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=3cfea70ef4254afc89704e47275a7a9a&pvs=4) for a list of supported brokerages and their slugs.

  • immediate_redirect (Boolean) (defaults to: SENTINEL)

    When set to ‘true`, user will be redirected back to the partner’s site instead of the connection portal. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](/docs/implement-connection-portal) for more information.

  • custom_redirect (String) (defaults to: SENTINEL)

    URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](/docs/implement-connection-portal) for more information.

  • reconnect (String) (defaults to: SENTINEL)

    The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the [guide on fixing broken connections](/docs/fix-broken-connections) for more information.

  • connection_type (ConnectionType) (defaults to: 'read')

    Determines connection permissions (default: read) - ‘read`: Data access only. - `trade`: Data and trading access. - `trade-if-available`: Attempts to establish a trading connection if the brokerage supports it, otherwise falls back to read-only access automatically.

  • show_close_button (Boolean) (defaults to: SENTINEL)

    Controls whether the close (X) button is displayed in the connection portal. When false, you control closing behavior from your app. Defaults to true.

  • dark_mode (Boolean) (defaults to: SENTINEL)

    Enable dark mode for the connection portal. Defaults to false.

  • connection_portal_version (ConnectionPortalVersion) (defaults to: 'v4')

    Sets the connection portal version to render. Currently only v4 is supported and is the default. All other versions are deprecated and will automatically be set to v4.

  • body (SnapTradeLoginUserRequestBody)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/snaptrade/api/authentication_api.rb', line 201

def (user_id:, user_secret:, broker: SENTINEL, immediate_redirect: SENTINEL, custom_redirect: SENTINEL, reconnect: SENTINEL, connection_type: 'read', show_close_button: SENTINEL, dark_mode: SENTINEL, connection_portal_version: 'v4', extra: {})
  _body = {}
  _body[:broker] = broker if broker != SENTINEL
  _body[:immediateRedirect] = immediate_redirect if immediate_redirect != SENTINEL
  _body[:customRedirect] = custom_redirect if custom_redirect != SENTINEL
  _body[:reconnect] = reconnect if reconnect != SENTINEL
  _body[:connectionType] = connection_type if connection_type != SENTINEL
  _body[:showCloseButton] = show_close_button if show_close_button != SENTINEL
  _body[:darkMode] = dark_mode if dark_mode != SENTINEL
  _body[:connectionPortalVersion] = connection_portal_version if connection_portal_version != SENTINEL
  extra[:snap_trade_login_user_request_body] = _body if !_body.empty?
  data, _status_code, _headers = (user_id, user_secret, extra)
  data
end

#login_snap_trade_user_with_http_info(user_id:, user_secret:, broker: SENTINEL, immediate_redirect: SENTINEL, custom_redirect: SENTINEL, reconnect: SENTINEL, connection_type: 'read', show_close_button: SENTINEL, dark_mode: SENTINEL, connection_portal_version: 'v4', extra: {}) ⇒ Object

Generate Connection Portal URL

Authenticates a SnapTrade user and returns the Connection Portal URL used for connecting brokerage accounts. Please check [this guide](/docs/implement-connection-portal) for how to integrate the Connection Portal into your app.

Please note that the returned URL expires in 5 minutes.

Parameters:

  • user_id (String)
  • user_secret (String)
  • broker (String) (defaults to: SENTINEL)

    Slug of the brokerage to connect the user to. See [the integrations page](snaptrade.notion.site/66793431ad0b416489eaabaf248d0afb?v=3cfea70ef4254afc89704e47275a7a9a&pvs=4) for a list of supported brokerages and their slugs.

  • immediate_redirect (Boolean) (defaults to: SENTINEL)

    When set to ‘true`, user will be redirected back to the partner’s site instead of the connection portal. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](/docs/implement-connection-portal) for more information.

  • custom_redirect (String) (defaults to: SENTINEL)

    URL to redirect the user to after the user connects their brokerage account. This parameter is ignored if the connection portal is loaded inside an iframe. See the [guide on ways to integrate the connection portal](/docs/implement-connection-portal) for more information.

  • reconnect (String) (defaults to: SENTINEL)

    The UUID of the brokerage connection to be reconnected. This parameter should be left empty unless you are reconnecting a disabled connection. See the [guide on fixing broken connections](/docs/fix-broken-connections) for more information.

  • connection_type (ConnectionType) (defaults to: 'read')

    Determines connection permissions (default: read) - ‘read`: Data access only. - `trade`: Data and trading access. - `trade-if-available`: Attempts to establish a trading connection if the brokerage supports it, otherwise falls back to read-only access automatically.

  • show_close_button (Boolean) (defaults to: SENTINEL)

    Controls whether the close (X) button is displayed in the connection portal. When false, you control closing behavior from your app. Defaults to true.

  • dark_mode (Boolean) (defaults to: SENTINEL)

    Enable dark mode for the connection portal. Defaults to false.

  • connection_portal_version (ConnectionPortalVersion) (defaults to: 'v4')

    Sets the connection portal version to render. Currently only v4 is supported and is the default. All other versions are deprecated and will automatically be set to v4.

  • body (SnapTradeLoginUserRequestBody)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/snaptrade/api/authentication_api.rb', line 234

def (user_id:, user_secret:, broker: SENTINEL, immediate_redirect: SENTINEL, custom_redirect: SENTINEL, reconnect: SENTINEL, connection_type: 'read', show_close_button: SENTINEL, dark_mode: SENTINEL, connection_portal_version: 'v4', extra: {})
  _body = {}
  _body[:broker] = broker if broker != SENTINEL
  _body[:immediateRedirect] = immediate_redirect if immediate_redirect != SENTINEL
  _body[:customRedirect] = custom_redirect if custom_redirect != SENTINEL
  _body[:reconnect] = reconnect if reconnect != SENTINEL
  _body[:connectionType] = connection_type if connection_type != SENTINEL
  _body[:showCloseButton] = show_close_button if show_close_button != SENTINEL
  _body[:darkMode] = dark_mode if dark_mode != SENTINEL
  _body[:connectionPortalVersion] = connection_portal_version if connection_portal_version != SENTINEL
  extra[:snap_trade_login_user_request_body] = _body if !_body.empty?
  (user_id, user_secret, extra)
end

#register_snap_trade_user(user_id:, extra: {}) ⇒ Object

Register user

Registers a new SnapTrade user under your Client ID. A user secret will be automatically generated for you and must be properly stored in your system. Most SnapTrade operations require a user ID and user secret to be passed in as parameters.

Parameters:

  • user_id (String)

    SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.

  • body (SnapTradeRegisterUserRequestBody)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



335
336
337
338
339
340
341
# File 'lib/snaptrade/api/authentication_api.rb', line 335

def register_snap_trade_user(user_id:, extra: {})
  _body = {}
  _body[:userId] = user_id if user_id != SENTINEL
  snap_trade_register_user_request_body = _body
  data, _status_code, _headers = register_snap_trade_user_with_http_info_impl(snap_trade_register_user_request_body, extra)
  data
end

#register_snap_trade_user_with_http_info(user_id:, extra: {}) ⇒ Object

Register user

Registers a new SnapTrade user under your Client ID. A user secret will be automatically generated for you and must be properly stored in your system. Most SnapTrade operations require a user ID and user secret to be passed in as parameters.

Parameters:

  • user_id (String)

    SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.

  • body (SnapTradeRegisterUserRequestBody)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



351
352
353
354
355
356
# File 'lib/snaptrade/api/authentication_api.rb', line 351

def register_snap_trade_user_with_http_info(user_id:, extra: {})
  _body = {}
  _body[:userId] = user_id if user_id != SENTINEL
  snap_trade_register_user_request_body = _body
  register_snap_trade_user_with_http_info_impl(snap_trade_register_user_request_body, extra)
end

#reset_snap_trade_user_secret(user_id: SENTINEL, user_secret: SENTINEL, extra: {}) ⇒ Object

Rotate user secret

Rotates the secret for a SnapTrade user. You might use this if ‘userSecret` is compromised. Please note that if you call this endpoint and fail to save the new secret, you’ll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect.

Parameters:

  • user_id (String) (defaults to: SENTINEL)

    SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.

  • user_secret (String) (defaults to: SENTINEL)

    SnapTrade User Secret. This is a randomly generated string and should be stored securely. If compromised, please rotate it via the [rotate user secret endpoint](/reference/Authentication/Authentication_resetSnapTradeUserSecret).

  • body (UserIDandSecret)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



435
436
437
438
439
440
441
442
# File 'lib/snaptrade/api/authentication_api.rb', line 435

def reset_snap_trade_user_secret(user_id: SENTINEL, user_secret: SENTINEL, extra: {})
  _body = {}
  _body[:userId] = user_id if user_id != SENTINEL
  _body[:userSecret] = user_secret if user_secret != SENTINEL
  user_i_dand_secret = _body
  data, _status_code, _headers = reset_snap_trade_user_secret_with_http_info_impl(user_i_dand_secret, extra)
  data
end

#reset_snap_trade_user_secret_with_http_info(user_id: SENTINEL, user_secret: SENTINEL, extra: {}) ⇒ Object

Rotate user secret

Rotates the secret for a SnapTrade user. You might use this if ‘userSecret` is compromised. Please note that if you call this endpoint and fail to save the new secret, you’ll no longer be able to access any data for this user, and your only option will be to delete and recreate the user, then ask them to reconnect.

Parameters:

  • user_id (String) (defaults to: SENTINEL)

    SnapTrade User ID. This is chosen by the API partner and can be any string that is a) unique to the user, and b) immutable for the user. It is recommended to NOT use email addresses for this property because they are usually not immutable.

  • user_secret (String) (defaults to: SENTINEL)

    SnapTrade User Secret. This is a randomly generated string and should be stored securely. If compromised, please rotate it via the [rotate user secret endpoint](/reference/Authentication/Authentication_resetSnapTradeUserSecret).

  • body (UserIDandSecret)
  • extra (Hash) (defaults to: {})

    additional parameters to pass along through :header_params, :query_params, or parameter name



452
453
454
455
456
457
458
# File 'lib/snaptrade/api/authentication_api.rb', line 452

def reset_snap_trade_user_secret_with_http_info(user_id: SENTINEL, user_secret: SENTINEL, extra: {})
  _body = {}
  _body[:userId] = user_id if user_id != SENTINEL
  _body[:userSecret] = user_secret if user_secret != SENTINEL
  user_i_dand_secret = _body
  reset_snap_trade_user_secret_with_http_info_impl(user_i_dand_secret, extra)
end