class Belvo::WidgetToken

A WidgetToken is a limited scope with short time to live token, that contains access and refresh keys to allow you embedding Belvo's Connect Widget into your app.

Public Class Methods

new(session) click to toggle source
Calls superclass method Belvo::Resource::new
# File lib/belvo/resources.rb, line 471
def initialize(session)
  super(session)
  @endpoint = 'token/'
end

Public Instance Methods

create(options: nil) click to toggle source
# File lib/belvo/resources.rb, line 476
def create(options: nil)
  options = WidgetTokenOptions.from(options)
  link_id = options.link
  widget = options.widget
  options.delete('link')
  options.delete('widget')
  body = {
    id: @session.key_id,
    password: @session.key_password,
    scopes: 'read_institutions,write_links,read_links',
    link_id: link_id,
    widget: widget
  }.merge(options)
  body = clean body: body
  @session.post(@endpoint, body)
end