Sha256: 24a7b2f10949b03b104b02fb8f95f16e5a0f46d64709350ed6993b55526205f0

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

# Performs token operation
require_relative "termii"
require_relative "client"

module TermiiRuby
  class Token < TermiiRuby::Termii
    def initialize(api_key)
      super()
      @client = TermiiRuby::Client.new(api_key)
    end

    def send_otp_token(to, from, message_text)
      data = {
        to: to,
        from: from,
        message_text: message_text,
        channel: @channel,
        message_type: @message_type,
        pin_attempts: @pin_attempts,
        pin_length: @pin_length,
        pin_placeholder: @pin_placeholder,
        pin_time_to_live: @pin_time_to_live,
        pin_type: @pin_type
      }
      @client.make_post_request(SEND_OTP_TOKEN, data)
    end

    def send_voice_token(phone_number)
      data = {
        phone_number: phone_number,
        pin_attempts: @pin_attempts,
        pin_length: @pin_length,
        pin_time_to_live: @pin_time_to_live
      }
      @client.make_post_request(SEND_VOICE_TOKEN, data)
    end

    def send_voice_call(phone_number, code)
      data = {
        phone_number: phone_number,
        code: code
      }

      @client.make_post_request(SEND_VOICE_CALL, data)
    end

    def send_in_app_token(phone_number)
      data = {
        phone_number: phone_number,
        pin_attempts: @pin_attempts,
        pin_time_to_live: @pin_time_to_live,
        pin_length: @pin_length,
        pin_type: @pin_type
      }
      @client.make_post_request(SEND_IN_APP_TOKEN, data)
    end

    def verify(pin_id, pin)
      data = {
        pin_id: pin_id,
        pin: pin
      }
      @client.make_post_request(VERIFY_TOKEN, data)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
termii_ruby-0.1.0 lib/termii_ruby/token.rb