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</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()</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</p> Signup and view all the answers

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

    <p>500</p> Signup and view all the answers

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

    <p>DependencyName</p> Signup and view all the answers

    What does the CustomGetCartLineMapper class extend from?

    <p>GetCartLineMapper</p> Signup and view all the answers

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

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

    Which method is overridden in the CustomGetCartLineMapper class?

    <p>MapResult</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</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.</p> Signup and view all the answers

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

    <p>999</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</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.</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.</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.</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</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.</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.</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.</p> Signup and view all the answers

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

    <p>ICartService</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.</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.</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.</p> Signup and view all the answers

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

    <p>AddObjectToResultProperties</p> Signup and view all the answers

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

    <p>JSON.parse</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</p> Signup and view all the answers

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

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

    Which property of the CartLine object holds promotional information?

    <p>PromotionResult</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</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</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</p> Signup and view all the answers

    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