Module: Mrkt::CrudCustomObjects

Included in:
Client
Defined in:
lib/mrkt/concerns/crud_custom_objects.rb

Instance Method Summary collapse

Instance Method Details

#createupdate_custom_objects(name, input, action: 'createOrUpdate', dedupe_by: 'dedupeFields') ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/mrkt/concerns/crud_custom_objects.rb', line 16

def createupdate_custom_objects(name, input, action: 'createOrUpdate', dedupe_by: 'dedupeFields')
  post("/rest/v1/customobjects/#{name}.json") do |req|
    params = {
      input: input,
      action: action,
      dedupeBy: dedupe_by
    }
    json_payload(req, params)
  end
end

#delete_custom_objects(name, input, delete_by: 'dedupeFields') ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/mrkt/concerns/crud_custom_objects.rb', line 27

def delete_custom_objects(name, input, delete_by: 'dedupeFields')
  post("/rest/v1/customobjects/#{name}/delete.json") do |req|
    params = {
      input: input,
      deleteBy: delete_by
    }

    json_payload(req, params)
  end
end

#describe_custom_object(name) ⇒ Object



10
11
12
13
14
# File 'lib/mrkt/concerns/crud_custom_objects.rb', line 10

def describe_custom_object(name)
  fail Mrkt::Errors::Unknown unless name

  get("/rest/v1/customobjects/#{name}/describe.json")
end

#get_custom_objects(name, input, filter_type: 'dedupeFields', fields: nil, next_page_token: nil, batch_size: nil) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/mrkt/concerns/crud_custom_objects.rb', line 38

def get_custom_objects(name, input, filter_type: 'dedupeFields', fields: nil, next_page_token: nil, batch_size: nil)
  post("/rest/v1/customobjects/#{name}.json?_method=GET") do |req|
    params = {
      input: input,
      filterType: filter_type
    }

    params[:fields] = fields if fields
    params[:nextPageToken] = next_page_token if next_page_token
    params[:batchSize] = batch_size if batch_size

    json_payload(req, params)
  end
end

#get_list_of_custom_objects(names = nil) ⇒ Object



3
4
5
6
7
8
# File 'lib/mrkt/concerns/crud_custom_objects.rb', line 3

def get_list_of_custom_objects(names = nil)
  params = {}
  params[:names] = names.join(',') if names

  get('/rest/v1/customobjects.json', params)
end