Which is a valid set of REST endpoints for payroll transactions as described?

Prepare for the FAST Enterprises IC Interview. Enhance your skills with flashcards and multiple-choice questions. Each question provides hints and detailed explanations. Excel in your interview!

Multiple Choice

Which is a valid set of REST endpoints for payroll transactions as described?

Explanation:
The key idea is modeling payroll transactions as a clear RESTful resource with conventional CRUD-style endpoints. For payroll transactions, you want to expose a collection to create new items, a way to fetch a specific item, and a way to access related data or update an existing item, using intuitive paths and HTTP methods. The best option does exactly that. It uses the payroll-transactions resource for creation with POST, retrieves a specific transaction with GET /payroll-transactions/{id}, and fetches all payrolls for a given employee with GET /employees/{id}/payrolls. It also updates an existing transaction with PUT /payroll-transactions/{id}. This combination follows standard REST patterns: nouns for resources, HTTP methods indicating the action, and a logical hierarchy for related data (employee → payrolls). The other choices mix inappropriately named resources, update or query patterns that don’t align with payroll concepts (such as handling employees or payments when the focus is payroll transactions), or use inconsistent or singular resource paths that break the uniform resource design. This makes them harder to reason about and less RESTful for payroll transactions.

The key idea is modeling payroll transactions as a clear RESTful resource with conventional CRUD-style endpoints. For payroll transactions, you want to expose a collection to create new items, a way to fetch a specific item, and a way to access related data or update an existing item, using intuitive paths and HTTP methods.

The best option does exactly that. It uses the payroll-transactions resource for creation with POST, retrieves a specific transaction with GET /payroll-transactions/{id}, and fetches all payrolls for a given employee with GET /employees/{id}/payrolls. It also updates an existing transaction with PUT /payroll-transactions/{id}. This combination follows standard REST patterns: nouns for resources, HTTP methods indicating the action, and a logical hierarchy for related data (employee → payrolls).

The other choices mix inappropriately named resources, update or query patterns that don’t align with payroll concepts (such as handling employees or payments when the focus is payroll transactions), or use inconsistent or singular resource paths that break the uniform resource design. This makes them harder to reason about and less RESTful for payroll transactions.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy