Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update category #105

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ category_list.each_with_index do |category, index|
end
```

### Updating a category

```ruby
require('seatsio')
client = Seatsio::Client.new(Seatsio::Region.EU(), "my-company-admin-key", "my-workspace-public-key")
@seatsio.charts.update_category(chart_key: '<the chart key>', category_key: '<the category key>', label: "New label", color: "#bbbbbb", accessible: true)
```


### Listing all charts

```ruby
Expand Down
8 changes: 8 additions & 0 deletions lib/seatsio/charts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def list_categories(chart_key)
Category.create_list(response['categories'])
end

def update_category(chart_key:, category_key:, label: nil, color: nil, accessible: nil)
payload = {}
payload['label'] = label if label != nil
payload['color'] = color if color != nil
payload['accessible'] = accessible if accessible != nil
@http_client.post("/charts/#{chart_key}/categories/#{category_key}", payload)
end

def add_tag(key, tag)
@http_client.post("charts/#{key}/tags/#{CGI::escape(tag)}")
end
Expand Down
14 changes: 14 additions & 0 deletions test/charts/manage_categories_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,18 @@ def test_list_categories
assert_equal(categories[index]['key'], category.key)
end
end

def test_update_category
categories = [
{ 'key' => 1, 'label' => 'Category 1', 'color' => '#aaaaaa', 'accessible' => false }
]
chart = @seatsio.charts.create categories: categories

@seatsio.charts.update_category(chart_key: chart.key, category_key: 1, label: "New label", color: "#bbbbbb", accessible: true)

category_list = @seatsio.charts.list_categories(chart.key)
assert_equal(category_list[0].label, "New label")
assert_equal(category_list[0].color, "#bbbbbb")
assert_equal(category_list[0].accessible, true)
end
end
Loading