Class: Iterable::CatalogItems

Inherits:
ApiResource show all
Defined in:
lib/iterable/catalog_items.rb

Overview

Interact with /catalogs/catalogName/itemID API endpoints **currently in Beta only**

Examples:

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)

Instance Attribute Summary collapse

Attributes inherited from ApiResource

#conf

Instance Method Summary collapse

Methods inherited from ApiResource

default_config, #default_config

Constructor Details

#initialize(catalog, item_id = nil, conf = nil) ⇒ Iterable::Catalog

Initialize CatalogItems with a catalog name and item ID **currently in Beta only**



27
28
29
30
31
# 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

Instance Attribute Details

#catalogObject (readonly)

Returns the value of attribute catalog.



16
17
18
# File 'lib/iterable/catalog_items.rb', line 16

def catalog
  @catalog
end

#item_idObject (readonly)

Returns the value of attribute item_id.



16
17
18
# File 'lib/iterable/catalog_items.rb', line 16

def item_id
  @item_id
end

Instance Method Details

#all(params = {}) ⇒ Iterable::Response

Get all items for a catalog



40
41
42
# File 'lib/iterable/catalog_items.rb', line 40

def all(params = {})
  Iterable.request(conf, base_path, params).get
end

#create(item_attrs = {}) ⇒ Iterable::Response Also known as: replace

Create a catalog item



51
52
53
54
# File 'lib/iterable/catalog_items.rb', line 51

def create(item_attrs = {})
  body = { value: item_attrs }
  Iterable.request(conf, base_path).put(body)
end

#deleteIterable::Response

Delete a catalog item



83
84
85
# File 'lib/iterable/catalog_items.rb', line 83

def delete
  Iterable.request(conf, base_path).delete
end

#getIterable::Response

Get a specific catalog item



74
75
76
# File 'lib/iterable/catalog_items.rb', line 74

def get
  Iterable.request(conf, base_path).get
end

#update(item_attrs = {}) ⇒ Iterable::Response

Update a catalog item



64
65
66
67
# File 'lib/iterable/catalog_items.rb', line 64

def update(item_attrs = {})
  body = { update: item_attrs }
  Iterable.request(conf, base_path).patch(body)
end