Sha256: 3699f00e0473fdc193bd946ead2c1f0638382b79fdd7c292534e9738d6c2ba3a

Contents?: true

Size: 1.49 KB

Versions: 9

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require "seam/helpers/action_attempt"

module Seam
  module Clients
    class AcsEncoders
      def initialize(client:, defaults:)
        @client = client
        @defaults = defaults
      end

      def encode_card(acs_credential_id:, device_id:, wait_for_action_attempt: nil)
        res = @client.post("/acs/encoders/encode_card", {acs_credential_id: acs_credential_id, device_id: device_id}.compact)

        wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt

        Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
      end

      def list(acs_system_ids: nil, device_ids: nil, limit: nil)
        res = @client.post("/acs/encoders/list", {acs_system_ids: acs_system_ids, device_ids: device_ids, limit: limit}.compact)

        Seam::Resources::Device.load_from_response(res.body["devices"])
      end

      def scan_card(acs_system_id:, device_id:, wait_for_action_attempt: nil)
        res = @client.post("/acs/encoders/scan_card", {acs_system_id: acs_system_id, device_id: device_id}.compact)

        wait_for_action_attempt = wait_for_action_attempt.nil? ? @defaults.wait_for_action_attempt : wait_for_action_attempt

        Helpers::ActionAttempt.decide_and_wait(Seam::Resources::ActionAttempt.load_from_response(res.body["action_attempt"]), @client, wait_for_action_attempt)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
seam-2.0.1 lib/seam/routes/clients/acs_encoders.rb
seam-2.0.0 lib/seam/routes/clients/acs_encoders.rb
seam-2.0.0rc0 lib/seam/routes/clients/acs_encoders.rb
seam-2.0.0b5 lib/seam/routes/clients/acs_encoders.rb
seam-2.0.0b4 lib/seam/routes/clients/acs_encoders.rb
seam-2.0.0b3 lib/seam/routes/clients/acs_encoders.rb
seam-2.0.0b2 lib/seam/routes/clients/acs_encoders.rb
seam-2.0.0b1 lib/seam/routes/clients/acs_encoders.rb
seam-2.0.0b0 lib/seam/routes/clients/acs_encoders.rb