Class: Seatsio::ChartsClient
- Inherits:
-
Object
- Object
- Seatsio::ChartsClient
- Defined in:
- lib/seatsio/charts.rb
Overview
Seatsio Charts client
Instance Attribute Summary collapse
-
#archive ⇒ Object
readonly
Returns the value of attribute archive.
Instance Method Summary collapse
- #add_tag(key, tag) ⇒ Object
- #copy(key) ⇒ Object
- #copy_draft_version(key) ⇒ Object
- #copy_to_subaccount(chart_key, subaccount_id) ⇒ Object
- #create(name: nil, venue_type: nil, categories: nil) ⇒ Object
- #discard_draft_version(key) ⇒ Object
-
#initialize(secret_key, base_url) ⇒ ChartsClient
constructor
A new instance of ChartsClient.
- #list(chart_filter: nil, tag: nil, expand_events: nil) ⇒ Object
- #list_all_tags ⇒ Object
- #move_out_of_archive(chart_key) ⇒ Object
- #move_to_archive(chart_key) ⇒ Object
- #publish_draft_version(chart_key) ⇒ Object
- #remove_tag(key, tag) ⇒ Object
- #retrieve(chart_key) ⇒ Seatsio::Domain::Chart
- #retrieve_draft_version(key) ⇒ Object
- #retrieve_draft_version_thumbnail(key) ⇒ Object
- #retrieve_published_version(key) ⇒ Object
- #retrieve_published_version_thumbnail(key) ⇒ Object
- #retrieve_with_events(chart_key) ⇒ Object
- #update(key:, new_name: nil, categories: nil) ⇒ Object
Constructor Details
#initialize(secret_key, base_url) ⇒ ChartsClient
14 15 16 17 |
# File 'lib/seatsio/charts.rb', line 14 def initialize(secret_key, base_url) @http_client = Seatsio::HttpClient.new(secret_key, base_url) @archive = Pagination::Cursor.new(Domain::Chart, 'charts/archive', @http_client) end |
Instance Attribute Details
#archive ⇒ Object (readonly)
Returns the value of attribute archive.
12 13 14 |
# File 'lib/seatsio/charts.rb', line 12 def archive @archive end |
Instance Method Details
#add_tag(key, tag) ⇒ Object
41 42 43 |
# File 'lib/seatsio/charts.rb', line 41 def add_tag(key, tag) @http_client.post("charts/#{key}/tags/#{CGI::escape(tag)}") end |
#copy(key) ⇒ Object
49 50 51 52 |
# File 'lib/seatsio/charts.rb', line 49 def copy(key) response = @http_client.post("charts/#{key}/version/published/actions/copy") Domain::Chart.new(response) end |
#copy_draft_version(key) ⇒ Object
60 61 62 63 |
# File 'lib/seatsio/charts.rb', line 60 def copy_draft_version(key) response = @http_client.post("charts/#{key}/version/draft/actions/copy") Domain::Chart.new(response) end |
#copy_to_subaccount(chart_key, subaccount_id) ⇒ Object
54 55 56 57 58 |
# File 'lib/seatsio/charts.rb', line 54 def copy_to_subaccount(chart_key, subaccount_id) url = "charts/#{chart_key}/version/published/actions/copy-to/#{subaccount_id}" response = @http_client.post url Domain::Chart.new(response) end |
#create(name: nil, venue_type: nil, categories: nil) ⇒ Object
30 31 32 33 34 |
# File 'lib/seatsio/charts.rb', line 30 def create(name: nil, venue_type: nil, categories: nil) payload = build_chart_request name: name, venue_type: venue_type, categories: categories response = @http_client.post('charts', payload) Domain::Chart.new(response) end |
#discard_draft_version(key) ⇒ Object
83 84 85 |
# File 'lib/seatsio/charts.rb', line 83 def discard_draft_version(key) @http_client.post("charts/#{key}/version/draft/actions/discard") end |
#list(chart_filter: nil, tag: nil, expand_events: nil) ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'lib/seatsio/charts.rb', line 91 def list(chart_filter: nil, tag: nil, expand_events: nil) cursor = Pagination::Cursor.new(Domain::Chart, 'charts', @http_client) cursor.set_query_param('filter', chart_filter) cursor.set_query_param('tag', tag) cursor.set_query_param('expand', 'events') if cursor end |
#list_all_tags ⇒ Object
101 102 103 104 |
# File 'lib/seatsio/charts.rb', line 101 def response = @http_client.get('charts/tags') response['tags'] end |
#move_out_of_archive(chart_key) ⇒ Object
110 111 112 |
# File 'lib/seatsio/charts.rb', line 110 def move_out_of_archive(chart_key) @http_client.post("charts/#{chart_key}/actions/move-out-of-archive") end |
#move_to_archive(chart_key) ⇒ Object
106 107 108 |
# File 'lib/seatsio/charts.rb', line 106 def move_to_archive(chart_key) @http_client.post("charts/#{chart_key}/actions/move-to-archive") end |
#publish_draft_version(chart_key) ⇒ Object
87 88 89 |
# File 'lib/seatsio/charts.rb', line 87 def publish_draft_version(chart_key) @http_client.post("charts/#{chart_key}/version/draft/actions/publish") end |
#remove_tag(key, tag) ⇒ Object
45 46 47 |
# File 'lib/seatsio/charts.rb', line 45 def remove_tag(key, tag) @http_client.delete("charts/#{key}/tags/#{tag}") end |
#retrieve(chart_key) ⇒ Seatsio::Domain::Chart
20 21 22 23 |
# File 'lib/seatsio/charts.rb', line 20 def retrieve(chart_key) response = @http_client.get("charts/#{chart_key}") Domain::Chart.new(response) end |
#retrieve_draft_version(key) ⇒ Object
70 71 72 73 |
# File 'lib/seatsio/charts.rb', line 70 def retrieve_draft_version(key) response = @http_client.get("charts/#{key}/version/draft") Domain::ChartDraft.new(response) end |
#retrieve_draft_version_thumbnail(key) ⇒ Object
75 76 77 |
# File 'lib/seatsio/charts.rb', line 75 def retrieve_draft_version_thumbnail(key) @http_client.get_raw("charts/#{key}/version/draft/thumbnail") end |
#retrieve_published_version(key) ⇒ Object
65 66 67 68 |
# File 'lib/seatsio/charts.rb', line 65 def retrieve_published_version(key) response = @http_client.get("charts/#{key}/version/published") Domain::Chart.new(response) end |
#retrieve_published_version_thumbnail(key) ⇒ Object
79 80 81 |
# File 'lib/seatsio/charts.rb', line 79 def retrieve_published_version_thumbnail(key) @http_client.get_raw("charts/#{key}/version/published/thumbnail") end |
#retrieve_with_events(chart_key) ⇒ Object
25 26 27 28 |
# File 'lib/seatsio/charts.rb', line 25 def retrieve_with_events(chart_key) response = @http_client.get("charts/#{chart_key}?expand=events") Domain::Chart.new(response) end |
#update(key:, new_name: nil, categories: nil) ⇒ Object
36 37 38 39 |
# File 'lib/seatsio/charts.rb', line 36 def update(key:, new_name: nil, categories: nil) payload = build_chart_request name: new_name, categories: categories @http_client.post("charts/#{key}", payload) end |