Playbasis Helpers
Methods
-
<static> appendAndJoinIfNotNullAsUrlParam(param)
-
Join variable url param together as query string, then prefix it with "&" if there's at least one non-null key-value pair.
Parameters:
Name Type Argument Description paramparam <repeatable>
url param as part of url
Returns:
query string
- Type
- string
-
<static> appendAndJoinIfNotNullAsUrlParam2(keys, defaultValues, inputObj)
-
Join variable url param together as query string, then prefix it with "&" if there's at least one non-null key-value pair.
Parameters:
Name Type Description keysArray Array containing all keys string
defaultValuesArray Array containing all default values string
inputObjObject Input optional object parameter, inside there're key-value pairs according to key and values of final query string
Returns:
query string
- Type
- String
-
<static> combinedObjects(objA, objB)
-
Combine two objects together but skip key-value pair whose either key or value is null. If both of objects are null, then return empty object. If object B has same keys as in object A, object A's values will be replaced by values of object B.
Parameters:
Name Type Description objAObject object A to combine
objBObject object B to combine
Returns:
Combined object A and B but skipped key-value pair whose either key or value is null
- Type
- Object
-
<static> createApiUrl(method, param)
-
Create api url for used with Playbasis's API modules. If you use this, make sure you know what you're doing.
Parameters:
Name Type Argument Description methodstring method url for target API
paramparam <repeatable>
url param as part of url
Returns:
url ready to be used to make a qurey for Playbasis's API modules
- Type
- string
-
<static> createObjectFromTarget(obj, keysLimit)
-
Create object with keys and values from specified object. If 'keysLimit' is specified then it will only copy for those matching keys only, and ignore the less. It will ignore and skip key-value pair whose either key or value is null. It specified object is null, then it will create an empty object.
Parameters:
Name Type Description objObject target object to get keys and values from in order to create a new object
keysLimitArray (optional) keys as array to limit the copying process from target object
Returns:
new object created with non-null keys and values from specified object
- Type
- Object
-
<static> joinIfNotNullAsUrlParam(param)
-
Join variable url param together as query string.
Parameters:
Name Type Argument Description paramparam <repeatable>
url param as part of url
Returns:
query string
- Type
- string
-
<static> joinParams(paramKvp)
-
Join each key of object into querystring and return it. It will iterate for all keys of its object, and process each pair of KVP making into final querystring.
Parameters:
Name Type Description paramKvpobject options object
Returns:
query string
- Type
- string