Class: Iterable::BulkCatalogItems

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

Overview

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

Examples:

Creating catalog items endpoint object

# With default config
catalog = Iterable::BulkCatalogItems.new "catalog-name"
catalog.items

# With custom config
conf = Iterable::Config.new(token: 'new-token')
catalog = Iterable::BulkCatalogItems.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, conf = nil) ⇒ Iterable::Catalog

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

Parameters:

  • catalog (String)

    The name of the catalog to interact with

  • item_id (String)

    The string ID of the item to interact with

  • conf (Iterable::Config) (defaults to: nil)

    A config to optionally pass for requests



27
28
29
30
# File 'lib/iterable/bulk_catalog_items.rb', line 27

def initialize(catalog, conf = nil)
  @catalog = catalog
  super conf
end

Instance Attribute Details

#catalogObject (readonly)

Returns the value of attribute catalog.



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

def catalog
  @catalog
end

Instance Method Details

#create(items = {}, replace_uploaded_fields_only: false) ⇒ Iterable::Response

Bulk create catalog items

Parameters:

  • documents (Hash)

    Hash of item ID to item attributes e.g. { ‘123456’: { name: ‘foo’, state: ‘open’ } }

  • replace_uploaded_fields_only (Boolean) (defaults to: false)

    Whether to replace only the upload fields within each document, not each entire document. Defaults to false and will replace existing.

Returns:



53
54
55
56
57
58
59
# File 'lib/iterable/bulk_catalog_items.rb', line 53

def create(items = {}, replace_uploaded_fields_only: false)
  body = {
    documents: items,
    replaceUploadedFieldsOnly: replace_uploaded_fields_only
  }
  Iterable.request(conf, base_path).post(body)
end

#delete(item_ids = []) ⇒ Iterable::Response

Bulk delete catalog items

Parameters:

  • keys (Array)

    Array of catalog items ids to delete

Returns:



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

def delete(item_ids = [])
  body = { itemIds: item_ids }
  Iterable.request(conf, base_path).delete(body)
end