Module: ArgyleHelper

Defined in:
app/helpers/argyle_helper.rb

Instance Method Summary collapse

Instance Method Details

Raises:



2
3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/argyle_helper.rb', line 2

def plaid_link(options)
  raise Argyle::Error, "Public key must be set in Argyle configuration" unless Argyle.configuration.key
  raise Argyle::Error, "options[:name] is required for Plaid Link" unless options[:name]
  raise Argyle::Error, "options[:action] is required for Plaid Link" unless options[:action]

  id = options[:form_id] || 'plaidForm'
  product = options[:product] || Argyle.configuration.product
  env = options[:env] || Argyle.configuration.env

  plaid_link_form(id, options[:action]) + plaid_link_script(id, options[:name], product, env, options)
end


14
15
16
# File 'app/helpers/argyle_helper.rb', line 14

def plaid_link_form(id, action)
  form_tag action, method: 'POST', id: id
end


18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/argyle_helper.rb', line 18

def plaid_link_script(id, name, product, env, options)
  data = {
    'client-name' => name,
    'form-id' => id,
    'key' => Argyle.configuration.key,
    'product' => product,
    'env' => env
  }
  data['webhook'] = options[:webhook] if options[:webhook]
  data['token'] = options[:token] if options[:token]
  data.merge!(options[:data]) if options[:data]

  javascript_tag '', src: Argyle.configuration.plaid_src, data: data
end