Class: TrueTrial::Resources::Temporal

Inherits:
Object
  • Object
show all
Defined in:
lib/truetrial/resources/temporal.rb

Overview

Provides access to temporal element API endpoints (trials, warranties, etc.).

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Temporal

Returns a new instance of Temporal.



7
8
9
# File 'lib/truetrial/resources/temporal.rb', line 7

def initialize(http_client)
  @http = http_client
end

Instance Method Details

#adjust(order_id, data) ⇒ Hash

Adjusts a temporal element (modify start/end dates).

Parameters:

  • order_id (String)

    the order ULID

  • data (Hash)

    adjustment attributes

Returns:

  • (Hash)

    the updated temporal element



33
34
35
# File 'lib/truetrial/resources/temporal.rb', line 33

def adjust(order_id, data)
  @http.post("/orders/#{order_id}/temporal/adjust", body: data)
end

#claim(order_id, data) ⇒ Hash

Initiates a warranty or guarantee claim.

Parameters:

  • order_id (String)

    the order ULID

  • data (Hash)

    claim attributes (reason, description)

Returns:

  • (Hash)

    the created claim



42
43
44
# File 'lib/truetrial/resources/temporal.rb', line 42

def claim(order_id, data)
  @http.post("/orders/#{order_id}/temporal/claim", body: data)
end

#extend(order_id, data) ⇒ Hash

Extends a temporal element duration.

Parameters:

  • order_id (String)

    the order ULID

  • data (Hash)

    extension attributes (duration, unit, reason)

Returns:

  • (Hash)

    the updated temporal element



24
25
26
# File 'lib/truetrial/resources/temporal.rb', line 24

def extend(order_id, data)
  @http.post("/orders/#{order_id}/temporal/extend", body: data)
end

#get(order_id) ⇒ Hash

Retrieves the temporal element for an order.

Parameters:

  • order_id (String)

    the order ULID

Returns:

  • (Hash)

    the temporal element



15
16
17
# File 'lib/truetrial/resources/temporal.rb', line 15

def get(order_id)
  @http.get("/orders/#{order_id}/temporal")
end

#resolve_claim(order_id, data) ⇒ Hash

Resolves a warranty or guarantee claim.

Parameters:

  • order_id (String)

    the order ULID

  • data (Hash)

    resolution attributes (status, notes)

Returns:

  • (Hash)

    the resolved claim



51
52
53
# File 'lib/truetrial/resources/temporal.rb', line 51

def resolve_claim(order_id, data)
  @http.post("/orders/#{order_id}/temporal/resolve-claim", body: data)
end