class Iterable::CatalogItems
Interact with /catalogs/{catalogName}/{itemID} API endpoints **currently in Beta only**
@example Creating catalog items endpoint object
# With default config catalog = Iterable::CatalogItems.new "catalog-name" catalog.items # With custom config conf = Iterable::Config.new(token: 'new-token') catalog = Iterable::CatalogItems.new("catalog-name", config)
Attributes
Public Class Methods
Initialize CatalogItems
with a catalog name and item ID **currently in Beta only**
@param catalog [String] The name of the catalog to interact with @param item_id
[String] The string ID of the item to interact with @param conf [Iterable::Config] A config to optionally pass for requests
@return [Iterable::Catalog]
Iterable::ApiResource::new
# File lib/iterable/catalog_items.rb, line 27 def initialize(catalog, item_id = nil, conf = nil) @catalog = catalog @item_id = item_id super conf end
Public Instance Methods
Get all items for a catalog
@param params Attribute hash for item query (page, pageSize, orderBy, sortAscending)
@return [Iterable::Response] A response object
# File lib/iterable/catalog_items.rb, line 40 def all(params = {}) Iterable.request(conf, base_path, params).get end
Create a catalog item
@param item_attrs [Hash] Item attributes to save or replace with
@return [Iterable::Response] A response object
# File lib/iterable/catalog_items.rb, line 51 def create(item_attrs = {}) body = { value: item_attrs } Iterable.request(conf, base_path).put(body) end
Delete a catalog item
@return [Iterable::Response] A response object
# File lib/iterable/catalog_items.rb, line 83 def delete Iterable.request(conf, base_path).delete end
Get a specific catalog item
@return [Iterable::Response] A response object
# File lib/iterable/catalog_items.rb, line 74 def get Iterable.request(conf, base_path).get end
Update a catalog item
@param item_attrs [Hash] Item attributes to save or update with
@return [Iterable::Response] A response object
# File lib/iterable/catalog_items.rb, line 64 def update(item_attrs = {}) body = { update: item_attrs } Iterable.request(conf, base_path).patch(body) end
Private Instance Methods
# File lib/iterable/catalog_items.rb, line 89 def base_path path = "/catalogs/#{@catalog}/items" path += "/#{@item_id}" if @item_id path end