Class: Tripwire::Server::GateSessionsResource

Inherits:
BaseResource
  • Object
show all
Defined in:
lib/tripwire/server/client.rb

Instance Method Summary collapse

Methods inherited from BaseResource

#initialize

Constructor Details

This class inherits a constructor from Tripwire::Server::BaseResource

Instance Method Details

#acknowledge(gate_session_id, poll_token:, ack_token:) ⇒ Object



431
432
433
434
435
436
437
438
# File 'lib/tripwire/server/client.rb', line 431

def acknowledge(gate_session_id, poll_token:, ack_token:)
  @client.request_json(
    "POST",
    "/v1/gate/sessions/#{CGI.escape(gate_session_id)}/ack",
    body: { ack_token: ack_token },
    auth: { kind: :bearer, token: poll_token }
  )[:data]
end

#create(service_id:, account_name:, delivery:, metadata: nil) ⇒ Object



412
413
414
415
416
417
418
419
420
421
# File 'lib/tripwire/server/client.rb', line 412

def create(service_id:, account_name:, delivery:, metadata: nil)
  body = {
    service_id: service_id,
    account_name: ,
    delivery: delivery
  }
  body[:metadata] =  unless .nil?

  @client.request_json("POST", "/v1/gate/sessions", body: body, auth: { kind: :none })[:data]
end

#poll(gate_session_id, poll_token:) ⇒ Object



423
424
425
426
427
428
429
# File 'lib/tripwire/server/client.rb', line 423

def poll(gate_session_id, poll_token:)
  @client.request_json(
    "GET",
    "/v1/gate/sessions/#{CGI.escape(gate_session_id)}",
    auth: { kind: :bearer, token: poll_token }
  )[:data]
end