Class: SeatLayer::Channels

Inherits:
Resource show all
Defined in:
lib/seatlayer/channels.rb

Overview

Private allocations, reporting, and origin-bound buyer access.

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from SeatLayer::Resource

Instance Method Details

#archive(event_key, channel_id, destination:, reason: nil) ⇒ Object



59
60
61
62
63
# File 'lib/seatlayer/channels.rb', line 59

def archive(event_key, channel_id, destination:, reason: nil)
  body = compact({ "reason" => reason })
  body["destination"] = destination
  @client.post(path(event_key, "/#{encode(channel_id)}/archive"), body)
end

#create_buyer_access_session(event_key, include_public:, allowed_origin:, channel_ids: nil, expires_in_seconds: nil, max_quantity: nil, buyer_ref: nil, partner_ref: nil, client_request_id: nil, idempotency_key: nil) ⇒ Object

Explicit keywords document each security boundary carried by the token. rubocop:disable Metrics/ParameterLists



67
68
69
70
71
72
73
74
75
76
# File 'lib/seatlayer/channels.rb', line 67

def create_buyer_access_session(event_key, include_public:, allowed_origin:, channel_ids: nil,
                                expires_in_seconds: nil, max_quantity: nil, buyer_ref: nil,
                                partner_ref: nil, client_request_id: nil, idempotency_key: nil)
  body = compact({ "channelIds" => channel_ids, "includePublic" => include_public,
                   "allowedOrigin" => allowed_origin, "expiresInSeconds" => expires_in_seconds,
                   "maxQuantity" => max_quantity, "buyerRef" => buyer_ref,
                   "partnerRef" => partner_ref, "clientRequestId" => client_request_id })
  @client.post("/v1/events/#{encode(event_key)}/buyer-access-sessions", body,
               idempotency_key: idempotency_key)
end

#create_channel(event_key, name:, color: nil, marker: nil, external_ref: nil, access_intent: nil, reason: nil, idempotency_key: nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/seatlayer/channels.rb', line 11

def create_channel(event_key, name:, color: nil, marker: nil, external_ref: nil,
                   access_intent: nil, reason: nil, idempotency_key: nil)
  body = compact({ "name" => name, "color" => color, "marker" => marker,
                   "externalRef" => external_ref, "accessIntent" => access_intent,
                   "reason" => reason })
  @client.post(path(event_key), body, idempotency_key: idempotency_key)
end

#list_allocation(event_key, after_label: nil, limit: nil) ⇒ Object



34
35
36
# File 'lib/seatlayer/channels.rb', line 34

def list_allocation(event_key, after_label: nil, limit: nil)
  @client.get(path(event_key, "/allocation"), compact({ "afterLabel" => after_label, "limit" => limit }))
end

#list_buyer_access_sessions(event_key, state: nil, limit: nil, cursor: nil) ⇒ Object

rubocop:enable Metrics/ParameterLists



79
80
81
82
# File 'lib/seatlayer/channels.rb', line 79

def list_buyer_access_sessions(event_key, state: nil, limit: nil, cursor: nil)
  @client.get("/v1/events/#{encode(event_key)}/buyer-access-sessions",
              compact({ "state" => state, "limit" => limit, "cursor" => cursor }))
end

#list_channels(event_key, include_archived: false) ⇒ Object



6
7
8
9
# File 'lib/seatlayer/channels.rb', line 6

def list_channels(event_key, include_archived: false)
  query = include_archived ? { "includeArchived" => "1" } : nil
  @client.get(path(event_key), query)
end

#pause(event_key, channel_id, reason: nil) ⇒ Object



51
52
53
# File 'lib/seatlayer/channels.rb', line 51

def pause(event_key, channel_id, reason: nil)
  @client.post(path(event_key, "/#{encode(channel_id)}/pause"), compact({ "reason" => reason }))
end

#retrieve_access_preview(event_key, channel_ids: nil, include_public: nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/seatlayer/channels.rb', line 38

def retrieve_access_preview(event_key, channel_ids: nil, include_public: nil)
  include_public_value = if include_public.nil?
                           nil
                         else
                           include_public ? "1" : "0"
                         end
  query = compact({ "channelIds" => channel_ids&.join(","),
                    "includePublic" => include_public_value })
  @client.get(path(event_key, "/preview"), query)
end

#retrieve_report(event_key) ⇒ Object



49
# File 'lib/seatlayer/channels.rb', line 49

def retrieve_report(event_key) = @client.get(path(event_key, "/report"))

#revoke_buyer_access_session(event_key, session_id) ⇒ Object



84
85
86
# File 'lib/seatlayer/channels.rb', line 84

def revoke_buyer_access_session(event_key, session_id)
  @client.delete("/v1/events/#{encode(event_key)}/buyer-access-sessions/#{encode(session_id)}")
end

#unpause(event_key, channel_id, reason: nil) ⇒ Object



55
56
57
# File 'lib/seatlayer/channels.rb', line 55

def unpause(event_key, channel_id, reason: nil)
  @client.post(path(event_key, "/#{encode(channel_id)}/unpause"), compact({ "reason" => reason }))
end

#update_assignments(event_key, labels:, assignment_version:, target_channel_id: nil, reason: nil, idempotency_key: nil) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/seatlayer/channels.rb', line 26

def update_assignments(event_key, labels:, assignment_version:, target_channel_id: nil,
                       reason: nil, idempotency_key: nil)
  body = compact({ "targetChannelId" => target_channel_id, "labels" => labels,
                   "assignmentVersion" => assignment_version, "reason" => reason })
  body["targetChannelId"] = nil if target_channel_id.nil?
  @client.post(path(event_key, "/assignments"), body, idempotency_key: idempotency_key)
end

#update_channel(event_key, channel_id, name: nil, access_intent: nil, acknowledge_live_access: nil, reason: nil) ⇒ Object



19
20
21
22
23
24
# File 'lib/seatlayer/channels.rb', line 19

def update_channel(event_key, channel_id, name: nil, access_intent: nil,
                   acknowledge_live_access: nil, reason: nil)
  body = compact({ "name" => name, "accessIntent" => access_intent,
                   "acknowledgeLiveAccess" => acknowledge_live_access, "reason" => reason })
  @client.patch(path(event_key, "/#{encode(channel_id)}"), body)
end