forked from acumenbrands/rest_suite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathload.js.html
212 lines (179 loc) · 5.75 KB
/
load.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: load.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: load.js</h1>
<section>
<article>
<pre class="prettyprint source"><code>/**
* Loader Class
* @class Loader
* @param {object} request The body of the HTTP Post request from the client
* @return {Loader} A new instance of Loader
*/
this.Loader = (function() {
/** @constructor */
function Loader(request) {
this.params = request;
this.result_list = [];
this.exception = null;
};
/**
* Iterate through the supplied parameters and load their related
* records from NetSuite. Populate result_list or exception accordingly.
*
* @method
* @memberof Loader
* @return {null}
*/
Loader.prototype.loadRecords = function() {
try {
for(index in this.params) {
load_params = this.params[index];
this.executeLoadRequest(load_params);
}
} catch(exception) {
this.exception = exception;
}
}
/**
* Instantiate a new LoadRequest given load parameters and accumulate its result
* on result_list.
*
* @method
* @memberof Loader
* @param {object} Data representing load request parameters
* @return {null}
*/
Loader.prototype.executeLoadRequest = function(load_params) {
load_request = new LoadRequest(load_params['record_type'], load_params['internalid']);
this.accumulateResult(load_request.execute());
}
/**
* Push a result onto the result_list.
*
* @method
* @memberof Loader
* @return {null}
*/
Loader.prototype.accumulateResult = function(result) {
this.result_list.push(result);
}
/**
* Generate and return Loader reply for the requestor.
*
* @method
* @memberof Loader
* @return {object} A formatted reply object from NetsuiteToolkit
*/
Loader.prototype.generateReply = function() {
return NetsuiteToolkit.formatReply(this.params, this.result_list, this.exception);
}
return Loader;
})();
/**
* LoadRequest Class
* @class LoadRequest
* @param {string} record_type the String representing a NetSuite record type
* @param {string} internalid the String representing a NetSuite internal id
* @return {LoadRequest} A new instance of LoadRequest
*/
this.LoadRequest = (function() {
/** @constructor */
function LoadRequest(record_type, internalid) {
this.record_type = record_type;
this.internalid = internalid;
this.record = null;
this.exception = null;
}
/**
* Load a record for a LoadRequest and generate a reply for it.
*
* @method
* @memberof LoadRequest
* @return {null}
*/
LoadRequest.prototype.execute = function() {
this.loadRecord();
return this.generateReply();
}
/**
* Load a record for a LoadRequest and catch any exceptions.
*
* @method
* @memberof LoadRequest
* @return {null}
*/
LoadRequest.prototype.loadRecord = function() {
try {
this.record = NetsuiteToolkit.loadRecord(this.record_type, this.internalid);
} catch(exception) {
this.exception = exception;
}
}
/**
* Set parameters for a LoadRequest.
*
* @method
* @memberof LoadRequest
* @return {object} The parameter object
*/
LoadRequest.prototype.generateParams = function() {
params = {
'internalid': this.internalid,
'record_type': this.record_type
};
return params;
}
/**
* Generate a LoadRequest reply for the requestor.
*
* @method
* @memberof LoadRequest
* @return {object} A formatted reply object from NetsuiteToolkit
*/
LoadRequest.prototype.generateReply = function() {
params = this.generateParams();
return NetsuiteToolkit.formatReply(params, this.record, this.exception);
}
return LoadRequest;
})();
/** @namespace global */
/**
* The script function that Netsuite will call to execute the Loader process
*
* @method
* @param {object} request The HTTP request body
* @memberof global
* @return {object} The formatted results of the request
*/
var loadPostHandler = function(request) {
loader = new Loader(request);
loader.loadRecords();
return loader.generateReply();
}
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="Deleter.html">Deleter</a></li><li><a href="DeleteRequest.html">DeleteRequest</a></li><li><a href="Initializer.html">Initializer</a></li><li><a href="Loader.html">Loader</a></li><li><a href="LoadRequest.html">LoadRequest</a></li><li><a href="NetsuiteToolkit.SublistProcessor.html">SublistProcessor</a></li><li><a href="SavedSearch.html">SavedSearch</a></li><li><a href="Searcher.html">Searcher</a></li><li><a href="Transformer.html">Transformer</a></li><li><a href="TransformRequest.html">TransformRequest</a></li><li><a href="Upserter.html">Upserter</a></li><li><a href="UpsertRequest.html">UpsertRequest</a></li></ul><h3>Namespaces</h3><ul><li><a href="global.html">global</a></li><li><a href="NetsuiteToolkit.html">NetsuiteToolkit</a></li><li><a href="NetsuiteToolkit.RecordProcessor.html">RecordProcessor</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.1.1</a> on Thu May 16 2013 11:16:09 GMT-0500 (CDT)
</footer>
<script> prettyPrint(); </script>
</body>
</html>