Class: Iterable::MetadataTable

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

Overview

Interact with /metadata/table API endpoints

Examples:

Creating metadata table endpoint object

# With default config
templates = Iterable::MetadataTable.new "table-name"
templates.get

# With custom config
conf = Iterable::Config.new(token: 'new-token')
templates = Iterable::MetadataTable.new("table-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(name, conf = nil) ⇒ Iterable::MetadataTable

Initialize a MetadataTable with a table name

Parameters:

  • name (String)

    The name of the table to interact with

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

    A config to optionally pass for requests



25
26
27
28
# File 'lib/iterable/metadata_table.rb', line 25

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/iterable/metadata_table.rb', line 15

def name
  @name
end

Instance Method Details

#add(key, value = {}) ⇒ Iterable::Response

Add metadata for table

Parameters:

  • key (String)

    Key of metadata to add

  • value (Hash) (defaults to: {})

    Value of metadata key as a hash of key/value data

Returns:



60
61
62
# File 'lib/iterable/metadata_table.rb', line 60

def add(key, value = {})
  Iterable.request(conf, base_path(key)).put(value: value)
end

#deleteIterable::Response

Delete metadata table

Returns:



48
49
50
# File 'lib/iterable/metadata_table.rb', line 48

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

#get(key) ⇒ Iterable::Response

Get metadata key for table

Parameters:

  • key (String)

    Key of metadata to get

Returns:



71
72
73
# File 'lib/iterable/metadata_table.rb', line 71

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

#list_keys(next_marker = nil) ⇒ Iterable::Response

Get metadata table keys

Returns:



37
38
39
40
41
# File 'lib/iterable/metadata_table.rb', line 37

def list_keys(next_marker = nil)
  params = {}
  params['nextMarker'] = next_marker if next_marker
  Iterable.request(conf, base_path, params).get
end

#remove(key) ⇒ Iterable::Response

Remove metadata key for table

Parameters:

  • key (String)

    Key of metadata to delete

Returns:



82
83
84
# File 'lib/iterable/metadata_table.rb', line 82

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