Sha256: d616675cd357e025f4d925d3d2ee641a76bd5d71481abc6422cabc7a668a35c4

Contents?: true

Size: 513 Bytes

Versions: 2

Compression:

Stored size: 513 Bytes

Contents

module Telesignature
  module Helpers
    def random_with_N_digits n
      range_start = 10 ** (n - 1)
      range_end = (10 ** n) - 1
      Random.new.rand(range_start...range_end)
    end

    def validate_response response
      resp_obj = JSON.load response.body
      if response.status != 200
        if response.status == 401
          raise AuthorizationError.new resp_obj, response
        else
          raise TelesignError.new resp_obj, response
        end
      end

      resp_obj
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
telesignature-0.0.11 lib/telesignature/helpers.rb
telesignature-0.0.10 lib/telesignature/helpers.rb