Sha256: ce3781a376310dd55a4e8efe08898f4876f87397420255ac330f5ca09eb00beb

Contents?: true

Size: 586 Bytes

Versions: 5

Compression:

Stored size: 586 Bytes

Contents

# frozen_string_literal: true

module Seam
  class ActionAttempt < BaseResource
    attr_accessor :action_attempt_id, :action_type, :status, :result

    SLEEP_TIME = 0.2
    MAX_ATTEMPTS = 10

    def wait_until_finished
      while @status == "pending"
        update!

        sleep(SLEEP_TIME)
      end

      self
    end

    def update!
      response = @client.request_seam(
        :post,
        "/action_attempts/get",
        body: {
          action_attempt_id: action_attempt_id
        }
      )

      update_from_response(response["action_attempt"])
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
seamapi-2.0.0 lib/seam/resources/action_attempt.rb
seamapi-1.17.0 lib/seam/resources/action_attempt.rb
seamapi-1.16.1 lib/seam/resources/action_attempt.rb
seamapi-1.16.0 lib/seam/resources/action_attempt.rb
seamapi-1.15.0 lib/seam/resources/action_attempt.rb