Skip to content

Commit

Permalink
Added call to override the season object status (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroloux authored Oct 27, 2023
1 parent 27995e6 commit e58264a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/seatsio/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ def update(key:, chart_key: nil, event_key: nil, name: nil, date: nil, table_boo
@http_client.post("/events/#{key}", payload)
end

def override_season_object_status(key:, objects:)
request = {}
request[:objects] = objects
@http_client.post("events/#{key}/actions/override-season-status", request)
end

def use_season_object_status(key:, objects:)
request = {}
request[:objects] = objects
@http_client.post("events/#{key}/actions/use-season-status", request)
end

def update_extra_data(key:, object:, extra_data: nil)
payload = build_extra_data_request(extra_data)
@http_client.post("events/#{key}/objects/#{object}/actions/update-extra-data", payload)
Expand Down
19 changes: 19 additions & 0 deletions test/events/override_season_object_status_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'test_helper'
require 'util'
require 'seatsio/domain'

class OverrideSeasonObjectStatusTest < SeatsioTestClient
def test_override_season_object_status
chart_key = create_test_chart
season = @seatsio.seasons.create chart_key: chart_key, event_keys: %w[event1]
@seatsio.events.book(season.key, ["A-1", "A-2"])

@seatsio.events.override_season_object_status(key: "event1", objects: %w(A-1 A-2))

a1_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-1').status
a2_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-2').status

assert_equal(Seatsio::EventObjectInfo::FREE, a1_status)
assert_equal(Seatsio::EventObjectInfo::FREE, a2_status)
end
end
20 changes: 20 additions & 0 deletions test/events/use_season_object_status_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'test_helper'
require 'util'
require 'seatsio/domain'

class UseSeasonObjectStatusTest < SeatsioTestClient
def test_use_season_object_status
chart_key = create_test_chart
season = @seatsio.seasons.create chart_key: chart_key, event_keys: %w[event1]
@seatsio.events.book(season.key, ["A-1", "A-2"])
@seatsio.events.override_season_object_status(key: "event1", objects: %w(A-1 A-2))

@seatsio.events.use_season_object_status(key: "event1", objects: %w(A-1 A-2))

a1_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-1').status
a2_status = @seatsio.events.retrieve_object_info(key: "event1", label: 'A-2').status

assert_equal(Seatsio::EventObjectInfo::BOOKED, a1_status)
assert_equal(Seatsio::EventObjectInfo::BOOKED, a2_status)
end
end

0 comments on commit e58264a

Please sign in to comment.