@@ -36,7 +36,7 @@ MemoryProperties.prototype.getKeys = function() {
36
36
* @see {@link https://developers.google.com/apps-script/reference/properties/properties#getproperties }
37
37
*/
38
38
MemoryProperties . prototype . getProperties = function ( ) {
39
- return _ . clone ( this . properties ) ;
39
+ return extend_ ( { } , this . properties ) ;
40
40
} ;
41
41
42
42
/**
@@ -84,10 +84,6 @@ MemoryProperties.prototype.setProperty = function(key, value) {
84
84
* required setup.
85
85
*/
86
86
87
- // Load the Underscore.js library. This library was added using the script ID
88
- // "1I21uLOwDKdyF3_W_hvh6WXiIKWJWno8yG9lB8lf1VBnZFQ6jAAhyNTRG".
89
-
90
-
91
87
/**
92
88
* Creates a new OAuth1 service with the name specified. It's usually best to
93
89
* create and configure your service once at the start of your script, and then
@@ -551,14 +547,15 @@ Service_.prototype.fetchInternal_ = function(url, params, opt_token,
551
547
}
552
548
switch ( this . paramLocation_ ) {
553
549
case 'auth-header' :
554
- params . headers = _ . extend ( { } , params . headers ,
555
- signer . toHeader ( oauthParams ) ) ;
550
+ params . headers =
551
+ assign_ ( { } , params . headers , signer . toHeader ( oauthParams ) ) ;
556
552
break ;
557
553
case 'uri-query' :
558
554
url = buildUrl_ ( url , oauthParams ) ;
559
555
break ;
560
556
case 'post-body' :
561
- params . payload = _ . extend ( { } , params . payload , oauthParams ) ;
557
+ // Clone the payload.
558
+ params . payload = assign_ ( { } , params . payload , oauthParams ) ;
562
559
break ;
563
560
default :
564
561
throw 'Unknown param location: ' + this . paramLocation_ ;
@@ -1047,30 +1044,52 @@ function buildUrl_(url, params) {
1047
1044
1048
1045
/**
1049
1046
* Validates that all of the values in the object are non-empty. If an empty
1050
- * value is found, an error is thrown using the key as the name.
1047
+ * value is found, and error is thrown using the key as the name.
1051
1048
* @param {Object.<string, string> } params The values to validate.
1052
1049
* @private
1053
1050
*/
1054
1051
function validate_ ( params ) {
1055
1052
Object . keys ( params ) . forEach ( function ( name ) {
1056
1053
var value = params [ name ] ;
1057
- if ( isEmpty_ ( value ) ) {
1058
- throw Utilities . formatString ( '%s is required.', name ) ;
1054
+ if ( ! value ) {
1055
+ throw new Error ( name + ' is required.') ;
1059
1056
}
1060
1057
} ) ;
1061
1058
}
1062
1059
1063
1060
/**
1064
- * Returns true if the given value is empty, false otherwise. An empty value
1065
- * is one of null, undefined, a zero-length string, a zero-length array or an
1066
- * object with no keys.
1067
- * @param {? } value The value to test.
1068
- * @returns {boolean } True if the value is empty, false otherwise.
1069
- * @private
1061
+ * Polyfill for Object.assign, which isn't available on the legacy runtime.
1062
+ * Not assigning to Object to avoid overwriting behavior in the parent
1063
+ * script(s).
1064
+ * @param {Object } target The target object to apply the sources’ properties to,
1065
+ * which is returned after it is modified.
1066
+ * @param {...Object } sources The source object(s) containing the properties you
1067
+ * want to apply.
1068
+ * @returns {Object } The target object.
1069
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill }
1070
+ * @license Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/
1070
1071
*/
1071
- function isEmpty_ ( value ) {
1072
- return value === null || value === undefined ||
1073
- ( ( _ . isObject ( value ) || _ . isString ( value ) ) && _ . isEmpty ( value ) ) ;
1072
+ function assign_ ( target , varArgs ) {
1073
+ if ( typeof Object . assign === 'function' ) {
1074
+ return Object . assign . apply ( null , arguments ) ;
1075
+ }
1076
+ if ( target === null || target === undefined ) {
1077
+ throw new TypeError ( 'Cannot convert undefined or null to object' ) ;
1078
+ }
1079
+ var to = Object ( target ) ;
1080
+ for ( var index = 1 ; index < arguments . length ; index ++ ) {
1081
+ var nextSource = arguments [ index ] ;
1082
+
1083
+ if ( nextSource !== null && nextSource !== undefined ) {
1084
+ for ( var nextKey in nextSource ) {
1085
+ // Avoid bugs when hasOwnProperty is shadowed
1086
+ if ( Object . prototype . hasOwnProperty . call ( nextSource , nextKey ) ) {
1087
+ to [ nextKey ] = nextSource [ nextKey ] ;
1088
+ }
1089
+ }
1090
+ }
1091
+ }
1092
+ return to ;
1074
1093
}
1075
1094
1076
1095
/**
0 commit comments