Class: SnapTrade::ConnectionsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ConnectionsApi

Returns a new instance of ConnectionsApi.



16
17
18
# File 'lib/snaptrade/api/connections_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/connections_api.rb', line 14

def api_client
  @api_client
end

Instance Method Details

#delete_connection(connection_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Delete connection

Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is asynchronous, a 200 response indicates that a task has been queued to delete the connection. Listen for the [‘CONNECTION_DELETED` webhook](docs.snaptrade.com/docs/webhooks#webhooks-connection_deleted) webhook to know when the deletion has been completed and the data has been removed.

Parameters:

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

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



28
29
30
31
# File 'lib/snaptrade/api/connections_api.rb', line 28

def delete_connection(connection_id:, user_id:, user_secret:, extra: {})
  data, _status_code, _headers = delete_connection_with_http_info_impl(connection_id, user_id, user_secret, extra)
  data
end

#delete_connection_with_http_info(connection_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Delete connection

Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is asynchronous, a 200 response indicates that a task has been queued to delete the connection. Listen for the [‘CONNECTION_DELETED` webhook](docs.snaptrade.com/docs/webhooks#webhooks-connection_deleted) webhook to know when the deletion has been completed and the data has been removed.

Parameters:

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

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



41
42
43
# File 'lib/snaptrade/api/connections_api.rb', line 41

def delete_connection_with_http_info(connection_id:, user_id:, user_secret:, extra: {})
  delete_connection_with_http_info_impl(connection_id, user_id, user_secret, extra)
end

#detail_brokerage_authorization(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Get connection detail

Returns a single connection for the specified ID.

Parameters:

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

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



131
132
133
134
# File 'lib/snaptrade/api/connections_api.rb', line 131

def detail_brokerage_authorization(authorization_id:, user_id:, user_secret:, extra: {})
  data, _status_code, _headers = detail_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
  data
end

#detail_brokerage_authorization_with_http_info(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Get connection detail

Returns a single connection for the specified ID.

Parameters:

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

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



144
145
146
# File 'lib/snaptrade/api/connections_api.rb', line 144

def detail_brokerage_authorization_with_http_info(authorization_id:, user_id:, user_secret:, extra: {})
  detail_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
end

#disable_brokerage_authorization(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Force disable connection

Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [‘CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection.

This endpoint is available on test keys. If you would like it enabled on production keys as well, please contact support as it is disabled by default.

Parameters:

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

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



237
238
239
240
# File 'lib/snaptrade/api/connections_api.rb', line 237

def disable_brokerage_authorization(authorization_id:, user_id:, user_secret:, extra: {})
  data, _status_code, _headers = disable_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
  data
end

#disable_brokerage_authorization_with_http_info(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Force disable connection

Manually force the specified connection to become disabled. This should only be used for testing a reconnect flow, and never used on production connections. Will trigger a disconnect as if it happened naturally, and send a [‘CONNECTION_BROKEN` webhook](/docs/webhooks#webhooks-connection_broken) for the connection.

This endpoint is available on test keys. If you would like it enabled on production keys as well, please contact support as it is disabled by default.

Parameters:

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

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



253
254
255
# File 'lib/snaptrade/api/connections_api.rb', line 253

def disable_brokerage_authorization_with_http_info(authorization_id:, user_id:, user_secret:, extra: {})
  disable_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
end

#list_brokerage_authorization_accounts(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

List accounts for a connection

Returns all brokerage accounts that belong to the specified connection for the authenticated user.

On real-time plans, this endpoint refreshes each account’s opening date, funding date, and total value live from the brokerage on each call.

On delayed plans, this endpoint returns cached data that is refreshed once a day. To force a refresh, use the [manual refresh endpoint](/reference/Connections/Connections_refreshBrokerageAuthorization).

Check your API key on the [Customer Dashboard billing page](dashboard.snaptrade.com/settings/billing) to see whether your plan includes real-time data.

Parameters:

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

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



349
350
351
352
# File 'lib/snaptrade/api/connections_api.rb', line 349

def list_brokerage_authorization_accounts(authorization_id:, user_id:, user_secret:, extra: {})
  data, _status_code, _headers = list_brokerage_authorization_accounts_with_http_info_impl(authorization_id, user_id, user_secret, extra)
  data
end

#list_brokerage_authorization_accounts_with_http_info(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

List accounts for a connection

Returns all brokerage accounts that belong to the specified connection for the authenticated user.

On real-time plans, this endpoint refreshes each account’s opening date, funding date, and total value live from the brokerage on each call.

On delayed plans, this endpoint returns cached data that is refreshed once a day. To force a refresh, use the [manual refresh endpoint](/reference/Connections/Connections_refreshBrokerageAuthorization).

Check your API key on the [Customer Dashboard billing page](dashboard.snaptrade.com/settings/billing) to see whether your plan includes real-time data.

Parameters:

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

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



368
369
370
# File 'lib/snaptrade/api/connections_api.rb', line 368

def list_brokerage_authorization_accounts_with_http_info(authorization_id:, user_id:, user_secret:, extra: {})
  list_brokerage_authorization_accounts_with_http_info_impl(authorization_id, user_id, user_secret, extra)
end

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

List all connections

Returns a list of all connections for the specified user. Note that ‘Connection` and `Brokerage Authorization` are interchangeable, but the term `Connection` is preferred and used in the doc for consistency.

A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts.

SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one.

Parameters:

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

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



461
462
463
464
# File 'lib/snaptrade/api/connections_api.rb', line 461

def list_brokerage_authorizations(user_id:, user_secret:, extra: {})
  data, _status_code, _headers = list_brokerage_authorizations_with_http_info_impl(user_id, user_secret, extra)
  data
end

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

List all connections

Returns a list of all connections for the specified user. Note that ‘Connection` and `Brokerage Authorization` are interchangeable, but the term `Connection` is preferred and used in the doc for consistency.

A connection is usually tied to a single login at a brokerage. A single connection can contain multiple brokerage accounts.

SnapTrade performs de-duping on connections for a given user. If the user has an existing connection with the brokerage, when connecting the brokerage with the same credentials, SnapTrade will return the existing connection instead of creating a new one.

Parameters:

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

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



477
478
479
# File 'lib/snaptrade/api/connections_api.rb', line 477

def list_brokerage_authorizations_with_http_info(user_id:, user_secret:, extra: {})
  list_brokerage_authorizations_with_http_info_impl(user_id, user_secret, extra)
end

#refresh_brokerage_authorization(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Refresh holdings for a connection

Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [‘ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred.

**Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](dashboard.snaptrade.com/settings/billing)** **Please note this endpoint is disabled for real-time plans (ex: PayGo). Real-time plans do not benefit from this feature since data is refreshed when calls are made**

Parameters:

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

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



565
566
567
568
# File 'lib/snaptrade/api/connections_api.rb', line 565

def refresh_brokerage_authorization(authorization_id:, user_id:, user_secret:, extra: {})
  data, _status_code, _headers = refresh_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
  data
end

#refresh_brokerage_authorization_with_http_info(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Refresh holdings for a connection

Trigger a holdings update for all accounts under this connection. Updates will be queued asynchronously. [‘ACCOUNT_HOLDINGS_UPDATED` webhook](/docs/webhooks#webhooks-account_holdings_updated) will be sent once the sync completes for each account under the connection. This endpoint will also trigger a transaction sync for the past day if one has not yet occurred.

**Because of the cost of refreshing a connection, each call to this endpoint incurs an additional charge. You can find the exact cost for your API key on the [Customer Dashboard billing page](dashboard.snaptrade.com/settings/billing)** **Please note this endpoint is disabled for real-time plans (ex: PayGo). Real-time plans do not benefit from this feature since data is refreshed when calls are made**

Parameters:

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

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



582
583
584
# File 'lib/snaptrade/api/connections_api.rb', line 582

def refresh_brokerage_authorization_with_http_info(authorization_id:, user_id:, user_secret:, extra: {})
  refresh_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
end

#remove_brokerage_authorization(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Delete connection

Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted.

Parameters:

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

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



672
673
674
675
# File 'lib/snaptrade/api/connections_api.rb', line 672

def remove_brokerage_authorization(authorization_id:, user_id:, user_secret:, extra: {})
  remove_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
  nil
end

#remove_brokerage_authorization_with_http_info(authorization_id:, user_id:, user_secret:, extra: {}) ⇒ Object

Delete connection

Deletes the SnapTrade connection specified by the ID. This will also remove the accounts and holdings data associated with the connection from SnapTrade. This action is irreversible. This endpoint is synchronous, a 204 response indicates that the data has been successfully deleted.

Parameters:

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

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



685
686
687
# File 'lib/snaptrade/api/connections_api.rb', line 685

def remove_brokerage_authorization_with_http_info(authorization_id:, user_id:, user_secret:, extra: {})
  remove_brokerage_authorization_with_http_info_impl(authorization_id, user_id, user_secret, extra)
end

#return_rates(user_id:, user_secret:, authorization_id:, timeframes: SENTINEL, extra: {}) ⇒ Object

List connection rate of returns

Returns a list of rate of return percents for a given connection.

Parameters:

  • user_id (String)
  • user_secret (String)
  • authorization_id (String)
  • timeframes (String) (defaults to: SENTINEL)

    Optional comma separated list of rate-of-return timeframes to return. Supported values are ‘ALL`, `1Y`, `YTD`, `1M`, `1W`, and `1D`. If omitted, SnapTrade returns all six supported timeframes.

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

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



774
775
776
777
778
# File 'lib/snaptrade/api/connections_api.rb', line 774

def return_rates(user_id:, user_secret:, authorization_id:, timeframes: SENTINEL, extra: {})
  extra[:timeframes] = timeframes if timeframes != SENTINEL
  data, _status_code, _headers = return_rates_with_http_info_impl(user_id, user_secret, authorization_id, extra)
  data
end

#return_rates_with_http_info(user_id:, user_secret:, authorization_id:, timeframes: SENTINEL, extra: {}) ⇒ Object

List connection rate of returns

Returns a list of rate of return percents for a given connection.

Parameters:

  • user_id (String)
  • user_secret (String)
  • authorization_id (String)
  • timeframes (String) (defaults to: SENTINEL)

    Optional comma separated list of rate-of-return timeframes to return. Supported values are ‘ALL`, `1Y`, `YTD`, `1M`, `1W`, and `1D`. If omitted, SnapTrade returns all six supported timeframes.

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

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



789
790
791
792
# File 'lib/snaptrade/api/connections_api.rb', line 789

def return_rates_with_http_info(user_id:, user_secret:, authorization_id:, timeframes: SENTINEL, extra: {})
  extra[:timeframes] = timeframes if timeframes != SENTINEL
  return_rates_with_http_info_impl(user_id, user_secret, authorization_id, extra)
end

#session_events(partner_client_id:, user_id: SENTINEL, session_id: SENTINEL, extra: {}) ⇒ Object

Get all session events for a user

Returns a list of session events associated with a user.

Parameters:

  • partner_client_id (String)
  • user_id (String) (defaults to: SENTINEL)

    Optional comma separated list of user IDs used to filter the request on specific users

  • session_id (String) (defaults to: SENTINEL)

    Optional comma separated list of session IDs used to filter the request on specific users

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

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



883
884
885
886
887
888
# File 'lib/snaptrade/api/connections_api.rb', line 883

def session_events(partner_client_id:, user_id: SENTINEL, session_id: SENTINEL, extra: {})
  extra[:user_id] = user_id if user_id != SENTINEL
  extra[:session_id] = session_id if session_id != SENTINEL
  data, _status_code, _headers = session_events_with_http_info_impl(partner_client_id, extra)
  data
end

#session_events_with_http_info(partner_client_id:, user_id: SENTINEL, session_id: SENTINEL, extra: {}) ⇒ Object

Get all session events for a user

Returns a list of session events associated with a user.

Parameters:

  • partner_client_id (String)
  • user_id (String) (defaults to: SENTINEL)

    Optional comma separated list of user IDs used to filter the request on specific users

  • session_id (String) (defaults to: SENTINEL)

    Optional comma separated list of session IDs used to filter the request on specific users

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

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



898
899
900
901
902
# File 'lib/snaptrade/api/connections_api.rb', line 898

def session_events_with_http_info(partner_client_id:, user_id: SENTINEL, session_id: SENTINEL, extra: {})
  extra[:user_id] = user_id if user_id != SENTINEL
  extra[:session_id] = session_id if session_id != SENTINEL
  session_events_with_http_info_impl(partner_client_id, extra)
end