Sha256: 129d412cc0ef5b41534719d8c62fc3a05fb6806cec8894e0cbdf3a2dbe4c847d

Contents?: true

Size: 1.31 KB

Versions: 6

Compression:

Stored size: 1.31 KB

Contents

module Mrkt
  module CrudCustomObjects
    def get_list_of_custom_objects(names = nil)
      params = {}
      params[:names] = names if names

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

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

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

    def createupdate_custom_objects(name, input, action: 'createOrUpdate', dedupe_by: 'dedupeFields')
      post_json("/rest/v1/customobjects/#{name}.json") do
        {
          input: input,
          action: action,
          dedupeBy: dedupe_by
        }
      end
    end

    def delete_custom_objects(name, input, delete_by: 'dedupeFields')
      post_json("/rest/v1/customobjects/#{name}/delete.json") do
        {
          input: input,
          deleteBy: delete_by
        }
      end
    end

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

        optional = {
          fields: fields,
          nextPageToken: next_page_token,
          batchSize: batch_size
        }

        merge_params(params, optional)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mrkt-1.2.2 lib/mrkt/concerns/crud_custom_objects.rb
mrkt-1.2.1 lib/mrkt/concerns/crud_custom_objects.rb
mrkt-1.2.0 lib/mrkt/concerns/crud_custom_objects.rb
mrkt-1.1.1 lib/mrkt/concerns/crud_custom_objects.rb
mrkt-1.1.0 lib/mrkt/concerns/crud_custom_objects.rb
mrkt-1.0.1 lib/mrkt/concerns/crud_custom_objects.rb