Method: Mints::Contact#send_magic_link

Defined in:
lib/contact.rb

Send magic link to contact by email. That magic link will be used in magic_link_login method.

Parameters

email_or_phone

(String) – Contact’s email.

template_slug

(String) – Email template’s slug to be used in the email.

redirectUrl

(String) – Url to be redirected in the implemented page.

lifeTime

(Integer) – Maximum time of use in minutes.

maxVisits

(Integer) – The maximum number of uses of a token.

First Example

@mints_contact.send_magic_link('[email protected]', 'template_slug')

Second Example

@mints_contact.send_magic_link('+526561234567', 'template_slug', '', 1440, 3, 'whatsapp')


146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/contact.rb', line 146

def send_magic_link(email_or_phone, template_slug, redirect_url = '', life_time = 1440, max_visits = nil, driver = 'email')
  data = {
    driver: driver,
    lifeTime: life_time,
    maxVisits: max_visits,
    redirectUrl: redirect_url,
    templateId: template_slug
  }
  if %w[sms whatsapp].include? driver
    data['phone'] = email_or_phone
  else
    data['email'] = email_or_phone
  end
  @client.raw('post', '/contacts/magic-link', nil, data_transform(data), '/api/v1')
end