Class: Ksef::Auth::OperationStatus

Inherits:
Data
  • Object
show all
Defined in:
lib/ksef/auth/operation_status.rb

Overview

The response to GET /auth/{referenceNumber} — the contract's AuthenticationOperationStatusResponse.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authentication_method ⇒ Object (readonly)

Returns the value of attribute authentication_method

Returns:

  • (Object) —

    the current value of authentication_method



7
8
9
# File 'lib/ksef/auth/operation_status.rb', line 7

def authentication_method
  @authentication_method
end

#code ⇒ Object (readonly)

Returns the value of attribute code

Returns:

  • (Object) —

    the current value of code



7
8
9
# File 'lib/ksef/auth/operation_status.rb', line 7

def code
  @code
end

#description ⇒ Object (readonly)

Returns the value of attribute description

Returns:

  • (Object) —

    the current value of description



7
8
9
# File 'lib/ksef/auth/operation_status.rb', line 7

def description
  @description
end

#details ⇒ Object (readonly)

Returns the value of attribute details

Returns:

  • (Object) —

    the current value of details



7
8
9
# File 'lib/ksef/auth/operation_status.rb', line 7

def details
  @details
end

#last_refresh_at ⇒ Object (readonly)

Returns the value of attribute last_refresh_at

Returns:

  • (Object) —

    the current value of last_refresh_at



7
8
9
# File 'lib/ksef/auth/operation_status.rb', line 7

def last_refresh_at
  @last_refresh_at
end

#refresh_token_valid_until ⇒ Object (readonly)

Returns the value of attribute refresh_token_valid_until

Returns:

  • (Object) —

    the current value of refresh_token_valid_until



7
8
9
# File 'lib/ksef/auth/operation_status.rb', line 7

def refresh_token_valid_until
  @refresh_token_valid_until
end

#started_at ⇒ Object (readonly)

Returns the value of attribute started_at

Returns:

  • (Object) —

    the current value of started_at



7
8
9
# File 'lib/ksef/auth/operation_status.rb', line 7

def started_at
  @started_at
end

#token_redeemed ⇒ Object (readonly)

Returns the value of attribute token_redeemed

Returns:

  • (Object) —

    the current value of token_redeemed



7
8
9
# File 'lib/ksef/auth/operation_status.rb', line 7

def token_redeemed
  @token_redeemed
end

Class Method Details

.from(payload) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ksef/auth/operation_status.rb', line 11

def self.from(payload)
  status = payload["status"] || {}
  new(
    code: status["code"],
    description: status["description"],
    details: Array(status["details"]).freeze,
    authentication_method: payload["authenticationMethod"],
    started_at: Ksef::Auth.time(payload["startDate"]),
    token_redeemed: payload["isTokenRedeemed"],
    last_refresh_at: Ksef::Auth.time(payload["lastTokenRefreshDate"]),
    refresh_token_valid_until: Ksef::Auth.time(payload["refreshTokenValidUntil"])
  )
end

Instance Method Details

#explain ⇒ Object

Prefers the server's own wording; falls back to our table when it sends none.



31
# File 'lib/ksef/auth/operation_status.rb', line 31

def explain = description.to_s.empty? ? Status.describe(code) : description

#in_progress? ⇒ Boolean

Returns:

  • (Boolean)


25
# File 'lib/ksef/auth/operation_status.rb', line 25

def in_progress? = Status.in_progress?(code)

#retryable? ⇒ Boolean

Returns:

  • (Boolean)


28
# File 'lib/ksef/auth/operation_status.rb', line 28

def retryable? = Status.retryable?(code)

#success? ⇒ Boolean

Returns:

  • (Boolean)


26
# File 'lib/ksef/auth/operation_status.rb', line 26

def success? = Status.success?(code)

#terminal? ⇒ Boolean

Returns:

  • (Boolean)


27
# File 'lib/ksef/auth/operation_status.rb', line 27

def terminal? = Status.terminal?(code)