Class: Emarsys::Field

Inherits:
DataObject show all
Defined in:
lib/emarsys/data_objects/field.rb

Overview

Methods for the Field API

Class Method Summary collapse

Methods inherited from DataObject

delete, get, parameterize_params, post, put, #request

Class Method Details

.choice(id, account: nil) ⇒ Hash

Query the choice option for a specific field

Examples:

Emarsys::Field.choice(3)

Parameters:

  • id (Integer, String)

    id of the field

Returns:

  • (Hash)

    Result Data



33
34
35
# File 'lib/emarsys/data_objects/field.rb', line 33

def choice(id, account: nil)
  get , "field/#{id}/choice", {}
end

.collection(account: nil, **params) ⇒ Hash

List data fields

Examples:

Emarsys::Field.collection
Emarsys::Field.collection(:translate => 'en')

Parameters:

  • params (Hash)

    optional translation params

Options Hash (**params):

  • :translate (Integer, String)

    translate to another language

Returns:

  • (Hash)

    List of fields



18
19
20
21
22
23
24
25
# File 'lib/emarsys/data_objects/field.rb', line 18

def collection(account: nil, **params)
  params = params.stringify_keys
  if params['translate']
    get , "field/translate/#{params['translate'].to_s}", {}
  else
    get , 'field', {}
  end
end