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.



611
612
613
614
# File 'lib/belvo/resources.rb', line 611

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

Instance Method Details

#create(options: nil) ⇒ Object



616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
# File 'lib/belvo/resources.rb', line 616

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