Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Commit

Permalink
adding the functionality to perform record transformations for transa…
Browse files Browse the repository at this point in the history
…ctions, also fixing indentation on the restlet file
  • Loading branch information
James Christie committed Oct 24, 2012
1 parent b368610 commit 0bafaf1
Show file tree
Hide file tree
Showing 2 changed files with 273 additions and 219 deletions.
36 changes: 28 additions & 8 deletions lib/netsuite-rest-client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
require 'json'
require 'uri'

BASE_URL = "https://rest.netsuite.com/app/site/hosting/restlet.nl"
DEFAULT_SCRIPT_ID = 12
DEFAULT_DEPLOY_ID = 1
DEFAULT_SEARCH_BATCH_SIZE = 1000
DEFAULT_RETRY_LIMIT = 5
DEFAULT_REQUEST_TIMEOUT = -1
DEFAULT_UPSERT_BATCH_SIZE = 40
DEFAULT_DELETE_BATCH_SIZE = 60
BASE_URL = "https://rest.netsuite.com/app/site/hosting/restlet.nl"
DEFAULT_SCRIPT_ID = 12
DEFAULT_DEPLOY_ID = 1
DEFAULT_SEARCH_BATCH_SIZE = 1000
DEFAULT_RETRY_LIMIT = 5
DEFAULT_REQUEST_TIMEOUT = -1
DEFAULT_UPSERT_BATCH_SIZE = 40
DEFAULT_DELETE_BATCH_SIZE = 60
DEFAULT_TRANSFORM_BATCH_SIZE = 10

module Netsuite
class Client
Expand Down Expand Up @@ -123,6 +124,25 @@ def delete(record_type, internal_ids, options={})
results
end

def transform_records(initial_record_type, result_record_type, internal_ids, options={})
results = Array.new
params = { 'script' => @script_id,
'deploy' => @deploy_id }

internal_ids = internal_ids.map { |id| id.to_s }

internal_ids.each_slice(options[:batch_size] || DEFAULT_TRANSFORM_BATCH_SIZE) do |internal_ids_chunk|
payload = { 'operation' => 'TRANSFORM',
'initial_record_type' => initial_record_type,
'result_record_type' => result_record_type,
'internal_ids' => internal_ids }

results += parse_json_result_from_rest(:post, params, :payload=>payload)
end

results
end

def get_saved_search(record_type, search_id, options={})
results = Array.new
params = { 'script' => @script_id,
Expand Down
Loading

0 comments on commit 0bafaf1

Please sign in to comment.