Orders resources
- Copyright:
- 2015–2020 RewardOps Inc.
Methods
# protected inner cancelOrder(orderContext) → {module:resources/orders~CancelFunc}
Higher order function for creating a cancelOrder
function in context.
Parameters:
Name | Type | Description |
---|---|---|
orderContext |
module:resources/orders~OrderContext
|
Order context object |
- See:
-
module:resources/orders~CancelFunc
for examples.
cancelOrder
function in context
# protected inner createOrder(orderContext) → {module:resources/orders~CreateFunc}
Higher order function for creating a create
order function in context.
NOTE: If the program is configured to use geographic-specific PII storage
,
the SDK handles the storeOrderRecipient
call under
the hood by making this function an alias for module:resources/order-recipients~StoreOrderRecipientFunc
.
Parameters:
Name | Type | Description |
---|---|---|
orderContext |
module:resources/orders~OrderContext
|
Order context object.
NOTE: If using geographic-specific PII storage, use
|
- See:
-
module:resources/orders~CreateFunc
for examples.
create
order function in context
# protected inner getAllOrders(orderContext) → {module:resources/orders~GetAllFunc}
Higher order function for creating a getAll
orders function in context.
Parameters:
Name | Type | Description |
---|---|---|
orderContext |
module:resources/orders~OrderContext
|
Order context object |
- See:
-
module:resources/orders~GetAllFunc
for examples.
getAll
orders function in context
# protected inner getOrder(orderContext) → {module:resources/orders~GetFunc}
Higher order function for creating a get
order function in context.
Parameters:
Name | Type | Description |
---|---|---|
orderContext |
module:resources/orders~OrderContext
|
Order context object |
- See:
-
module:resources/orders~GetFunc
for examples.
get
order function in context
# protected inner getOrderSummary(orderContext) → {module:resources/orders~GetSummaryFunc}
Higher order function for creating a getOrderSummary
function in context.
Parameters:
Name | Type | Description |
---|---|---|
orderContext |
module:resources/orders~OrderContext
|
Order context object |
- See:
-
module:resources/orders~GetSummaryFunc
for examples.
getSummary
orders function in context
# protected inner ordersFactory(contextTypeName, contextId) → {module:resources/orders~Orders}
Factory for creating orders
methods and properties.
Parameters:
Name | Type | Description |
---|---|---|
contextTypeName |
string
|
The type of the parent context ('programs') |
contextId |
number
|
The ID of the order's parent program |
Orders object
Example
// Used in the context of a program
const orders = ro.program(12).orders;
# protected inner updateOrder(orderContext) → {module:resources/orders~UpdateFunc}
Higher order function for creating a update
order function in context.
Parameters:
Name | Type | Description |
---|---|---|
orderContext |
module:resources/orders~OrderContext
|
Order context object |
- See:
-
module:resources/orders~UpdateFunc
for examples.
update
order function in context
# protected inner updateOrderItemsInContext(orderContext) → {module:resources/orders~UpdateFunc}
Higher order function for creating a updateOrderItems
function in context.
Parameters:
Name | Type | Description |
---|---|---|
orderContext |
module:resources/orders~OrderContext
|
Order context object |
- See:
-
module:resources/orders~UpdateFunc
for examples.
updateOrderItems
function in context
Type Definitions
# CancelFunc
Cancel an order function.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
orderId |
string
|
RewardOps order ID. |
|
refundReasonDescription |
string
|
Reason for cancelling the order. |
|
params |
object
|
<optional> |
Request params to pass to the API call. |
callback |
module:api~requestCallback
|
Callback that handles the response. |
Example
// Make a post request to the API for the order with the ID of 'abc123' for program 12
ro.program(12).order.cancel(
'abc123',
'reason',
{
// params
},
(error, data) => {
// ...
}
);
# CreateFunc
Create an order function.
NOTE: The params
object is required and must include a reward_id
and a member
object.
Properties:
Name | Type | Description |
---|---|---|
params |
object
|
Request params to pass to the create order API call. |
callback |
module:api~requestCallback
|
Callback that handles the response. |
Example
// Create new order for program `12`, with reward `45231` for member 'jb0987'
const program = ro.program(12);
program.order.create(
{
reward_id: 45231,
member: {
id: 'jb0987',
full_name: 'Jolanta Banicki',
email: 'jolanta.b@example.com',
},
},
(error, responseBody, response) => {
if (error) {
console.log(error);
} else {
console.log(result);
}
}
);
# GetAllFunc
Get an array of order JSON objects function.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
memberId |
number
|
Member ID |
|
params |
object
|
<optional> |
Request params to pass to the API call |
callback |
module:api~requestCallback
|
Callback that handles the response |
Example
// Get an array of order details for the program with id 12 and member with ID 'abc123'
ro.program(12).orders.getAll('abc123', (error, responseBody, response) => {
if (error) {
console.log(error);
} else {
console.log(result);
}
});
# GetFunc
Get an order JSON object function.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
orderId |
string
|
Order ID |
|
params |
object
|
<optional> |
Request params to pass to the API call |
callback |
module:api~requestCallback
|
Callback that handles the response |
Example
// Gets JSON for the order with ID 938
ro.program(12).orders.get(938, (error, responseBody, response) => {
if (error) {
console.log(error);
} else {
console.log(result);
}
});
# GetSummaryFunc
Get an order summary JSON objects function.
Properties:
Name | Type | Description |
---|---|---|
params |
object
|
Request params to pass to the API call |
callback |
module:api~requestCallback
|
Callback that handles the response |
Example
ro.program(12).orders.getSummary({},
(error, responseBody, response) => {
if (error) {
console.log(error);
} else {
console.log(result);
}
});
# OrderContext
Order options object
Properties:
Name | Type | Description |
---|---|---|
contextTypeName |
string
|
The type of the parent context ('programs') |
contextId |
number
|
The ID of the order's parent program |
# OrderRecipients
Order recipients methods object
Properties:
Name | Type | Description |
---|---|---|
getOrderRecipient |
module:resources/order-recipients~GetOrderRecipientFunc
|
Get order recipient function |
create |
module:resources/order-recipients~CreateFunc
|
Create order recipients function |
# Orders
Orders methods object
Properties:
Name | Type | Description |
---|---|---|
contextTypeName |
string
|
The type of the parent context ('programs') |
contextId |
number
|
The ID of the order's parent program |
get |
module:resources/orders~GetFunc
|
Get order function |
getAll |
module:resources/orders~GetAllFunc
|
Get all orders function |
getSummary |
module:resources/orders~GetSummaryFunc
|
Get summary function |
create |
module:resources/orders~CreateFunc
|
Create order function |
update |
module:resources/orders~UpdateFunc
|
Update order function |
updateOrderItems |
module:resources/orders~UpdateOrderItemsFunc
|
Update order items function |
# UpdateFunc
Update an order function.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
orderExternalId |
string
|
External order ID. |
|
params |
object
|
<optional> |
Request params to pass to the API call. |
callback |
module:api~requestCallback
|
Callback that handles the response. |
Example
// Make a patch request to the API for the order with the (external) ID of 'abc123' for program 12
ro.program(12).order.update('abc123', {
// params
}, (error, data) => {
// ...
});
# UpdateOrderItemsFunc
Function for updating all the items in an order.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
externalOrderId |
string
|
External order ID. |
|
params |
object
|
<optional> |
Request params to pass to the API call |
callback |
module:api~requestCallback
|
Callback that handles the response |
Example
// Make a patch request to the API for the order on an orderItem level with the (external) ID of 'abc123' for program 12
ro.program(12).order.updateOrderItems('abc123', {
// params
}, (error, data) => {
// ...
});