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

catalog[R]
item_id[R]

Public Class Methods

new(catalog, item_id = nil, conf = nil) click to toggle source

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]

Calls superclass method 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

all(params = {}) click to toggle source

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(item_attrs = {}) click to toggle source

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
Also aliased as: replace
delete() click to toggle source

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() click to toggle source

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
replace(item_attrs = {})
Alias for: create
update(item_attrs = {}) click to toggle source

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

base_path() click to toggle source
# File lib/iterable/catalog_items.rb, line 89
def base_path
  path = "/catalogs/#{@catalog}/items"
  path += "/#{@item_id}" if @item_id
  path
end