Rules & Mappers	Mappers
34 Questions
5 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the primary function of services within a module in Configured Commerce?

  • To manage user permissions and access
  • To define the order of execution for handlers
  • To operate the handler factory (correct)
  • To initiate the core business logic of handlers

What does the Order property in a handler signify?

  • It determines the time taken for the handler to execute
  • It sets the maximum number of handlers allowed in a chain
  • It assigns a unique identifier to the handler
  • It represents the execution priority of the handler in the chain (correct)

Which of the following is essential when adding a new handler to the chain?

  • Including a DependencyName attribute that is unique (correct)
  • Registering the handler as a NullHandler
  • Setting the handler's Order property to 100
  • Defining multiple Execute methods within the handler

What must be overridden in a handler to implement its core functionality?

<p>The Execute method (A)</p> Signup and view all the answers

How can a handler chain be broken when adding a new handler?

<p>By returning the result without calling this.NextHandler.Execute() (C)</p> Signup and view all the answers

What should be done when overriding an existing handler in the chain?

<p>Use the same DependencyName as the handler being overridden (A)</p> Signup and view all the answers

What is the default order number for all Configured Commerce handlers?

<p>500 (D)</p> Signup and view all the answers

Which attribute is necessary for a handler when replacing an existing handler?

<p>DependencyName (C)</p> Signup and view all the answers

What does the CustomGetCartLineMapper class extend from?

<p>GetCartLineMapper (A)</p> Signup and view all the answers

What is added to the Properties collection in the MapResult method?

<p>promotionName from serviceResult (B)</p> Signup and view all the answers

Which method is overridden in the CustomGetCartLineMapper class?

<p>MapResult (D)</p> Signup and view all the answers

What is the purpose of the cartId variable in the custom mapper for promotions?

<p>To access the current cart (D)</p> Signup and view all the answers

What does the absence of the 'orderLineId' in the response signify?

<p>The promotion applies to the cart level. (A)</p> Signup and view all the answers

What is the default order of handlers registered in a namespace that starts with 'Insite'?

<p>999 (C)</p> Signup and view all the answers

How can custom data be sent on a REST call's query string?

<p>By using <code>properties</code> followed by a JSON object (A)</p> Signup and view all the answers

What happens when multiple handlers with the same DependencyName are registered?

<p>The one with the lower dependency order will be used. (B)</p> Signup and view all the answers

What is the purpose of the Properties dictionary in the context of REST calls?

<p>To pass additional data to handlers. (D)</p> Signup and view all the answers

How are property values treated when they are sent with a REST call?

<p>They are automatically included in the response. (A)</p> Signup and view all the answers

Which method allows for the addition of arbitrary data to the Properties collection to return from a REST call?

<p>Properties.Add (A)</p> Signup and view all the answers

What is generally advised against when sending custom data on the query string?

<p>Implementing this requires custom code and overrides. (C)</p> Signup and view all the answers

What happens to child objects when properties data is passed in the parent object?

<p>They inherit the properties data automatically. (D)</p> Signup and view all the answers

What does the 'orderLineId' property indicate when it has a null value in the promotion object?

<p>The promotion was applied at the order level. (C)</p> Signup and view all the answers

Which service is used to retrieve the cart information during the mapping process?

<p>ICartService (C)</p> Signup and view all the answers

In the provided class, what is the purpose of the 'MapResult' method?

<p>To map service results to a specific promotion model. (B)</p> Signup and view all the answers

How does the implementation determine which promotion is applied to an order line?

<p>By comparing promotion IDs from the cart line and service results. (C)</p> Signup and view all the answers

What is the role of the 'cartId' variable within the 'MapResult' method?

<p>It identifies the cart being processed. (D)</p> Signup and view all the answers

What method should be used to pass back complex objects in HandlerBase?

<p>AddObjectToResultProperties (C)</p> Signup and view all the answers

Which JavaScript function is used to deserialize complex objects on the client side?

<p>JSON.parse (A)</p> Signup and view all the answers

When retrieving promotions for a specific shopping cart, what API endpoint should be used?

<p>GET /api/v1/carts/{cartId}/promotions (A)</p> Signup and view all the answers

What is the first step when creating a custom mapper class from GetCartLineMapper?

<p>Inherit from GetCartLineResult (D)</p> Signup and view all the answers

Which property of the CartLine object holds promotional information?

<p>PromotionResult (A)</p> Signup and view all the answers

What action does the POST /api/v1/carts/{cartId}/promotions endpoint perform?

<p>Apply promotions to a shopping cart (A)</p> Signup and view all the answers

In the context of promotions, what should be reported alongside applied promotions?

<p>Order level vs. order line level promotions (D)</p> Signup and view all the answers

What must be done before adding additional information to the Properties collection in the custom mapper?

<p>Call the base method (D)</p> Signup and view all the answers

Flashcards

Configured Commerce Handlers

Components for processing business logic in Configured Commerce, derived from HandlerBase. Loaded dynamically, ordered by DependencyName, and executed sequentially.

Handler Order

The execution sequence of handlers, determined by the 'Order' property. Lower numbers have higher precedence.

DependencyName

Unique identifier for a handler, used for dynamic loading and overriding. Crucial for adding or replacing handlers.

Handler Chain Breaking

Stopping the execution of handlers, done by directly returning the result or setting the next handler to NullHandler.

Signup and view all the flashcards

Overriding Handlers

Modifying or replacing existing handler functionality by adding a new handler with the same DependencyName.

Signup and view all the flashcards

ParameterBase

Base class for parameter objects used to pass data into handlers. Includes a properties dictionary.

Signup and view all the flashcards

Result Object

Object used to send data back from a a handler. Can be used to collect data to use in a REST call.

Signup and view all the flashcards

properties field

A dictionary field within BaseModel to hold custom data for REST calls, accepting query string data implicitly. Also used in service parameter and result objects.

Signup and view all the flashcards

AddObjectToResultProperties

Method to ensure correct serialization for complex objects when returning data. Used to populate the result objects.

Signup and view all the flashcards

/api/v1/carts/{cartId}/promotions

Endpoint for retrieving a collection of promotions for a given cart.

Signup and view all the flashcards

GetCartLineMapper

Custom mapper for retrieving promotions applied to a specific order line item.

Signup and view all the flashcards

GetPromotionMapper

Custom mapper to retrieve promotions applied to an order.

Signup and view all the flashcards

PromotionModel

Representation of a promotion, can include order-level or line-level details.

Signup and view all the flashcards

orderLineId

Property in promotion response to indicate whether promotion applies to order or order line level.

Signup and view all the flashcards

Default DependencyOrder

Handlers within the "Insite" namespace have an order of 999; others have 500.

Signup and view all the flashcards

Study Notes

Configured Commerce Handlers

  • Handlers are used for processing business logic in Configured Commerce
  • They are derived from HandlerBase and use generics to utilize Parameter Object and Result Object pattern
  • Handlers are dynamically loaded using DependencyName attribute, which is essential for adding or replacing handlers
  • Order property determines the order of execution within the chain, lower number means higher precedence
  • Default order for handlers is 500

Adding Handlers to the Chain

  • The base code executes first followed by subsequent handlers in the chain
  • Handlers with an order less than 500 will execute before the base handlers
  • Ensure unique DependencyName for new handlers
  • Reuse the DependencyName of the base handler to override it
  • Breaking the handler chain can be done by returning the result directly instead of calling this.NextHandler.Execute() or setting the next handler to NullHandler

Overriding Handlers

  • It's recommended to add handlers to the chain unless base functionality needs modification for a given implementation
  • Set the DependencyName attribute on the handler class to the same name as the one intended to override
  • If multiple handlers with the same DependencyName are registered, the one with the lower DependencyOrder will be used
  • Handlers within the "Insite" namespace have a default DependencyOrder of 999, while those outside have 500
  • The DependencyOrder can be customized using the DependencyOrder attribute

Passing Data to and from Handlers

  • Every REST call can accept a dictionary of data in the properties field of BaseModel
  • Query string data is also implicitly accepted as a properties dictionary
  • To pass custom data to handlers use the properties dictionary within the ParameterBase derived service parameter object
  • Custom data can be sent using query strings but requires overrides and is not recommended for ease of upgrades
  • Child objects within resulting objects usually have the Properties dictionary populated with data from the corresponding service result child object
  • To return arbitrary data from a REST call, use the Properties.Add method
  • Use AddObjectToResultProperties to ensure the correct serialization for complex objects
  • On the client, use JSON.parse to deserialize complex objects

Working with Promotions and Discounts: Retrieval

  • The /api/v1/carts/{cartId}/promotions endpoint returns a collection of promotions applied to a cart
  • POS /api/v1/carts/{cartId}/promotions endpoint applies promotions to a cart
  • GET /api/v1/carts/{cartId}/promotions/{promotionId} endpoint returns a single promotion for a cart

Working with Promotions and Discounts: Custom Mappers and Line Level Data

  • Create a custom mapper inheriting from GetCartLineMapper to retrieve promotions applied to a given line item
  • Override the MapResult method and call the base method first
  • Access the PromotionResult and Promotion properties from the GetCartLineResult object
  • Add needed information to the Properties collection of the GetCartLineModel object

Working with Promotions and Discounts: Custom Mappers and Order Level vs. Line Level Data

  • Create a custom mapper inheriting from GetPromotionMapper to retrieve promotions applied to a specific order
  • Override the MapResult method and call the base method first
  • Access the cartid from the incoming request
  • Use the cartid to access the current cart using the CartService
  • Iterate through CartLineResults to find matching promotions based on PromotionId
  • Add orderLineId to the Properties collection of the PromotionModel if promotion applies to cart line level
  • The orderLineId property in the promotion response indicates if the promotion applies to order or order line level
  • If the property is null - the promotion applies at the order level
  • If the property contains orderLineId - the promotion applies at the order line level
  • The /api/v1/carts/current endpoint returns both order and order line level data
  • The orderLineId property in the response helps distinguish between order and order line level promotions

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Rules & Mappers - Mappers PDF

Description

This quiz covers the basic concepts of Configured Commerce Handlers used for processing business logic. It discusses how handlers are derived from HandlerBase, their execution order, and how to manage dependencies. Additionally, it includes information on adding and overriding handlers in the execution chain.

More Like This

Use Quizgecko on...
Browser
Browser