Sha256: 7986b2eae6fa3d1aec8f4f14366bdacc361b69cb635e0d439062fa591929150d

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Cardknox
  module API
    class Client
      attr_reader :agent
      attr_accessor :config

      def initialize(key)
        @agent = Agent.new(Cardknox::BASE_URL)
        @config = Cardknox::Configuration.new.tap do |config|
          config.api_key = key
        end
        yield(config) if block_given?
      end

      def transaction(command, params = {})
        @agent.post("/gatewayjson", params.merge({
          xKey: config.api_key,
          xVersion: config.gateway_version,
          xSoftwareName: config.software_name,
          xSoftwareVersion: config.software_version,
          xCommand: command,
        }))
      end

      def report(command, params = {})
        @agent.post("/reportjson", params.merge({
          xKey: config.api_key,
          xVersion: config.gateway_version,
          xSoftwareName: config.software_name,
          xSoftwareVersion: config.software_version,
          xCommand: command,
        }))
      end

      def status
        @agent.get("/status")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cardknox-0.3.0 lib/cardknox/api.rb