-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #45
- Loading branch information
Showing
7 changed files
with
3,965 additions
and
664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,309 @@ | ||
import Restful from '../../'; | ||
import {SellFeedParams} from '../../../../types'; | ||
|
||
/** | ||
* The <strong>Feed API</strong> lets sellers upload input files, download reports and files including their status, filter reports using URI parameters, and retrieve customer service metrics task details. | ||
*/ | ||
export default class Feed extends Restful { | ||
get basePath(): string { | ||
return '/sell/feed/v1'; | ||
} | ||
|
||
/** | ||
* This method returns the details and status for an array of order tasks based on a specified feed_type or scheduled_id. | ||
* | ||
* @param dateRange The order tasks creation date range. | ||
* @param feedType The feed type associated with the task. | ||
* @param limit The maximum number of order tasks that can be returned on each page of the paginated response. | ||
* @param lookBackDays The number of previous days in which to search for tasks. Do not use with the date_range parameter. | ||
* @param offset The number of order tasks to skip in the result set before returning the first order in the paginated response. | ||
* @param scheduleId The schedule ID associated with the order task. | ||
*/ | ||
public getOrderTasks({ | ||
dateRange, | ||
feedType, | ||
limit, | ||
lookBackDays, | ||
offset, | ||
scheduleId | ||
}: SellFeedParams) { | ||
return this.get(`/order_task`, { | ||
params: { | ||
date_range: dateRange, | ||
feed_type: feedType, | ||
limit, | ||
look_back_days: lookBackDays, | ||
offset, | ||
schedule_id: scheduleId | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* This method creates an order download task with filter criteria for the order report. | ||
* | ||
* @param marketplaceId The ID of the eBay marketplace where the item is hosted. | ||
* @param data The CreateOrderTaskRequest | ||
*/ | ||
public createOrderTask(marketplaceId: string, data: any) { | ||
return this.post(`/order_task`, data, { | ||
headers: { | ||
'X-EBAY-C-MARKETPLACE-ID': marketplaceId | ||
} | ||
}) | ||
} | ||
|
||
/** | ||
* This method retrieves the task details and status of the specified task. | ||
* | ||
* @param taskId The ID of the task. This ID is generated when the task was created by the createOrderTask method. | ||
*/ | ||
public getOrderTask(taskId: string,) { | ||
taskId = encodeURIComponent(taskId); | ||
|
||
return this.get(`/order_task/${taskId}`); | ||
} | ||
|
||
/** | ||
* This method retrieves an array containing the details and status of all schedules based on the specified feed_type. | ||
* | ||
* @param feedType The feedType associated with the schedule. | ||
* @param limit The maximum number of schedules that can be returned on each page of the paginated response. | ||
* @param offset The number of schedules to skip in the result set before returning the first schedule in the paginated response. | ||
*/ | ||
public getSchedules({ | ||
feedType, | ||
limit, | ||
offset, | ||
}: SellFeedParams) { | ||
return this.get(`/schedule`, { | ||
params: { | ||
feed_type: feedType, | ||
limit, | ||
offset | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* This method creates a schedule, which is a subscription to the specified schedule template. | ||
* | ||
* @params data The CreateUserScheduleRequest | ||
*/ | ||
public createSchedule(data: any) { | ||
return this.post(`/schedule`, data) | ||
} | ||
|
||
/** | ||
* This method retrieves schedule details and status of the specified schedule. | ||
* | ||
* @param scheduleId The ID of the schedule for which to retrieve the details. | ||
*/ | ||
public getSchedule(scheduleId: string) { | ||
scheduleId = encodeURIComponent(scheduleId) | ||
return this.get(`/schedule/${scheduleId}`); | ||
} | ||
|
||
/** | ||
* This method updates an existing schedule. | ||
* | ||
* @param scheduleId The ID of the schedule to update. | ||
* @param data The UpdateUserScheduleRequest. | ||
*/ | ||
public updateSchedule(scheduleId: string, data?: any) { | ||
scheduleId = encodeURIComponent(scheduleId) | ||
return this.put(`/schedule/${scheduleId}`, data); | ||
} | ||
|
||
/** | ||
* This method deletes an existing schedule. | ||
* | ||
* @param scheduleId The schedule_id of the schedule to delete. | ||
*/ | ||
public deleteSchedule(scheduleId: string) { | ||
scheduleId = encodeURIComponent(scheduleId) | ||
return this.delete(`/schedule/${scheduleId}`); | ||
} | ||
|
||
/** | ||
* This method downloads the latest result file generated by the schedule. | ||
* | ||
* @param scheduleId The ID of the schedule for which to retrieve the latest result file. | ||
*/ | ||
public getLatestResultFile(scheduleId: string) { | ||
scheduleId = encodeURIComponent(scheduleId) | ||
return this.get(`/schedule/${scheduleId}/download_result_file`); | ||
} | ||
|
||
/** | ||
* This method downloads the latest result file generated by the schedule. | ||
* | ||
* @param scheduleTemplateId The ID of the template to retrieve. | ||
*/ | ||
public getScheduleTemplate(scheduleTemplateId: string) { | ||
scheduleTemplateId = encodeURIComponent(scheduleTemplateId) | ||
return this.get(`/schedule_template/${scheduleTemplateId}`); | ||
} | ||
|
||
/** | ||
* This method retrieves an array containing the details and status of all schedule templates based on the specified feed_type. | ||
* | ||
* @param feedType The feedType associated with the schedule. | ||
* @param limit The maximum number of schedules that can be returned on each page of the paginated response. | ||
* @param offset The number of schedules to skip in the result set before returning the first schedule in the paginated response. | ||
*/ | ||
public getScheduleTemplates({ | ||
feedType, | ||
limit, | ||
offset, | ||
}: SellFeedParams) { | ||
return this.get(`/schedule_template`, { | ||
params: { | ||
feed_type: feedType, | ||
limit, | ||
offset | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* This method returns the details and status for an array of tasks based on a specified feed_type or scheduledId. | ||
* | ||
* @param dateRange The order tasks creation date range. | ||
* @param feedType The feed type associated with the task. | ||
* @param limit The maximum number of order tasks that can be returned on each page of the paginated response. | ||
* @param lookBackDays The number of previous days in which to search for tasks. Do not use with the date_range parameter. | ||
* @param offset The number of order tasks to skip in the result set before returning the first order in the paginated response. | ||
* @param scheduleId The schedule ID associated with the task. | ||
*/ | ||
public getTasks({ | ||
dateRange, | ||
feedType, | ||
limit, | ||
lookBackDays, | ||
offset, | ||
scheduleId | ||
}: SellFeedParams) { | ||
return this.get(`/task`, { | ||
params: { | ||
date_range: dateRange, | ||
feed_type: feedType, | ||
limit, | ||
look_back_days: lookBackDays, | ||
offset, | ||
schedule_id: scheduleId | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* This method creates an upload task or a download task without filter criteria. | ||
* | ||
* @param marketplaceId The ID of the eBay marketplace where the item is hosted. | ||
* @param data The CreateTaskRequest. | ||
*/ | ||
public createTask(marketplaceId: string, data: any) { | ||
return this.post(`/task`, data, { | ||
headers: { | ||
'X-EBAY-C-MARKETPLACE-ID': marketplaceId | ||
} | ||
}) | ||
} | ||
|
||
/** | ||
* This method downloads the file previously uploaded using uploadFile. | ||
* | ||
* @param taskId The task ID associated with the file to be downloaded. | ||
*/ | ||
public getInputFile(taskId: string) { | ||
taskId = encodeURIComponent(taskId) | ||
return this.get(`/task/${taskId}/download_input_file`); | ||
} | ||
|
||
/** | ||
* This method retrieves the generated file that is associated with the specified task ID. | ||
* | ||
* @param taskId The task ID associated with the file to be downloaded. | ||
*/ | ||
public getResultFile(taskId: string) { | ||
taskId = encodeURIComponent(taskId) | ||
return this.get(`/task/${taskId}/download_result_file`); | ||
} | ||
|
||
/** | ||
* This method retrieves the details and status of the specified task. | ||
* | ||
* @param taskId The ID of the task. | ||
*/ | ||
public getTask(taskId: string) { | ||
taskId = encodeURIComponent(taskId) | ||
return this.get(`/task/${taskId}`); | ||
} | ||
|
||
/** | ||
* This method associates the specified file with the specified task ID and uploads the input file. | ||
* | ||
* @param taskId The task_id associated with the file that will be uploaded. | ||
* @param data FormDataContentDisposition. | ||
*/ | ||
public uploadFile(taskId: string, data?: any) { | ||
taskId = encodeURIComponent(taskId) | ||
return this.post(`/task/${taskId}/upload_file`, data, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
}, | ||
}); | ||
} | ||
|
||
/** | ||
* Use this method to return an array of customer service metric tasks. | ||
* | ||
* @param dateRange The order tasks creation date range. | ||
* @param feedType The feed type associated with the task. | ||
* @param limit The maximum number of order tasks that can be returned on each page of the paginated response. | ||
* @param lookBackDays The number of previous days in which to search for tasks. Do not use with the date_range parameter. | ||
* @param offset The number of order tasks to skip in the result set before returning the first order in the paginated response. | ||
* @param scheduleId The schedule ID associated with the task. | ||
*/ | ||
public getCustomerServiceMetricTasks({ | ||
dateRange, | ||
feedType, | ||
limit, | ||
lookBackDays, | ||
offset, | ||
}: SellFeedParams) { | ||
return this.get(`/customer_service_metric_task`, { | ||
params: { | ||
date_range: dateRange, | ||
feed_type: feedType, | ||
limit, | ||
look_back_days: lookBackDays, | ||
offset, | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Use this method to create a customer service metrics download task with filter criteria for the customer service metrics report. | ||
* | ||
* @params acceptLanguage Use this header to specify the natural language in which the authenticated user desires the response. | ||
* @params data The CreateServiceMetricsTaskRequest | ||
*/ | ||
public createCustomerServiceMetricTask(acceptLanguage: string, data: any) { | ||
return this.post(`/customer_service_metric_task`, data, { | ||
headers: { | ||
'accept-language': acceptLanguage | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Use this method to retrieve customer service metric task details for the specified task. | ||
* | ||
* @param taskId Use this path parameter to specify the task ID value for the customer service metric task to retrieve. | ||
*/ | ||
public getCustomerServiceMetricTask(taskId: string) { | ||
taskId = encodeURIComponent(taskId) | ||
return this.get(`/customer_service_metric_task/${taskId}`); | ||
} | ||
} |
Oops, something went wrong.