Sha256: d1da9b11848ca5f930bebe5a94567cc0afba12adc11c7e228e81fe3ab3502edf

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

module ArgyleHelper
  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)
  end

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

  def plaid_link_script(id, name, product, env)
    javascript_tag '', src: Argyle.configuration.plaid_src, data: {'client-name' => name, 'form-id' => id, 'key' => Argyle.configuration.key, 'product' => product, 'env' => env }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
argyle-0.0.1 app/helpers/argyle_helper.rb