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) ⇒ CatalogItems

Returns a new instance of CatalogItems.



36
37
38
39
40
# File 'lib/iterable/catalog_items.rb', line 36

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.



18
19
20
# File 'lib/iterable/catalog_items.rb', line 18

def catalog
  @catalog
end

#item_idObject (readonly)

Returns the value of attribute item_id.



18
19
20
# File 'lib/iterable/catalog_items.rb', line 18

def item_id
  @item_id
end

Instance Method Details

#all(params = {}) ⇒ Object



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

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

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



62
63
64
65
# File 'lib/iterable/catalog_items.rb', line 62

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

#deleteObject



97
98
99
# File 'lib/iterable/catalog_items.rb', line 97

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

#getObject



87
88
89
# File 'lib/iterable/catalog_items.rb', line 87

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

#update(item_attrs = {}) ⇒ Object



76
77
78
79
# File 'lib/iterable/catalog_items.rb', line 76

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