Sha256: 1c1aed923549f5dfd13152a2dd3c982db4fc4af1b98ff742b57573eaff14ed92
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true require_relative 'request_helper' module Stytch class OTPs include Stytch::RequestHelper attr_reader :sms PATH = '/v1/otps' def initialize(connection) @connection = connection @sms = Stytch::OTPs::SMS.new(@connection) end def authenticate( method_id:, code:, attributes: {}, options: {} ) request = { method_id: method_id, code: code } request[:attributes] = attributes if attributes != {} request[:options] = options if options != {} post_request("#{PATH}/authenticate", request) end class SMS include Stytch::RequestHelper PATH = "#{Stytch::OTPs::PATH}/sms" def initialize(connection) @connection = connection end def send( phone_number:, expiration_minutes: nil, attributes: {} ) request = { phone_number: phone_number, expiration_minutes: expiration_minutes } request[:attributes] = attributes if attributes != {} post_request("#{PATH}/send", request) end def login_or_create( phone_number:, expiration_minutes: nil, attributes: {}, create_user_as_pending: false ) request = { phone_number: phone_number, expiration_minutes: expiration_minutes, create_user_as_pending: create_user_as_pending } request[:attributes] = attributes if attributes != {} post_request("#{PATH}/login_or_create", request) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stytch-2.0.0 | lib/stytch/otps.rb |