Class: Belvo::WidgetToken

Inherits:
Resource show all
Defined in:
lib/belvo/resources.rb

Overview

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.

Instance Attribute Summary

Attributes inherited from Resource

#endpoint

Instance Method Summary collapse

Methods inherited from Resource

#clean, #delete, #detail, #list, #resume

Constructor Details

#initialize(session) ⇒ WidgetToken

Returns a new instance of WidgetToken.



604
605
606
607
# File 'lib/belvo/resources.rb', line 604

def initialize(session)
  super(session)
  @endpoint = 'api/token/'
end

Instance Method Details

#create(options: nil) ⇒ Object



609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
# File 'lib/belvo/resources.rb', line 609

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',
    link_id: link_id,
    widget: widget
  }.merge(options)
  body = clean body: body
  @session.post(@endpoint, body)
end