Class: Iterable::CatalogFieldMappings

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

Overview

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

Examples:

Creating catalog field mappings endpoint object

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

# With custom config
conf = Iterable::Config.new(token: 'new-token')
catalog = Iterable::CatalogFieldMappings.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 CatalogFieldMappings with a catalog name **currently in Beta only**

Parameters:

  • catalog (String)

    The name of the catalog to interact with

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

    A config to optionally pass for requests



26
27
28
29
# File 'lib/iterable/catalog_field_mappings.rb', line 26

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/catalog_field_mappings.rb', line 16

def catalog
  @catalog
end

Instance Method Details

#getIterable::Response

Get field mappings for a catalog

Returns:



36
37
38
# File 'lib/iterable/catalog_field_mappings.rb', line 36

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

#update(mappings_updates = []) ⇒ Iterable::Response

Set a catalog’s field mappings (data types)

Examples:

Supplying field mappings

# Fields to update with field types
field_mappings = [{fieldName: 'test-field', fieldType: 'string'}]
catalog = Iterable::CatalogFieldMappings.new "catalog-name"
catalog.update_field_mappings(field_mappings)

Parameters:

  • Array (Array)

    of field mapping hashes e.g [“fieldName”:“exampleString”,“fieldType”:“string”]}

Returns:



53
54
55
56
# File 'lib/iterable/catalog_field_mappings.rb', line 53

def update(mappings_updates = [])
  body = { mappingsUpdates: mappings_updates }
  Iterable.request(conf, base_path).put(body)
end