App

Contracts

Overview of Laravel Contracts in ECOM-Api

The ECOM-Api project includes several key contracts within the contracts folder. Each contract defines a set of methods that implementations must adhere to, ensuring consistency and flexibility in the application's architecture. Below is an overview of each contract, including their purpose and the methods they define.

Contracts List


ChatbotService.php

Purpose

The ChatbotService contract defines the interface for interacting with a chatbot service. It provides a method to retrieve verification information from the chatbot, which can be crucial for various functionalities within the ECOM-Api.

Key Method

  • getIdentifyVerification(): string
    • Description: Retrieves identification verification information from the chatbot service.
    • Returns: A string containing verification details.
    • Throws: \LogicException if there is an issue retrieving the verification information.

Example Usage

This contract might be used in services that need to verify user identities or interact with chatbot functionality to fetch verification details.

CreatePartnerOrderRequest.php

Purpose

The CreatePartnerOrderRequest contract outlines the methods necessary for handling requests to create orders from partner systems. It ensures that any implementation for processing partner orders adheres to a standard interface.

Key Methods

  • authorize(): bool
    • Description: Determines if the user is authorized to make this request.
    • Returns: A boolean indicating authorization status.
  • rules(): array
    • Description: Provides validation rules that apply to the request.
    • Returns: An array of validation rules.
  • getRequestData(): array
    • Description: Returns a formatted array containing the request's form data.
    • Returns: An array of request data.

Example Usage

This contract might be used in controllers or services that handle incoming orders from partners, ensuring that the requests are authorized, validated, and properly formatted.

JwtService.php

Purpose

The JwtService contract defines methods for encoding and decoding JSON Web Tokens (JWTs). JWTs are used for secure authentication and session management within the ECOM-Api.

Key Methods

  • encodeCustomerToken($payload, $existingJwt = null)
    • Description: Encodes a customer payload into a JWT. Optionally, an existing JWT can be provided to update it.
    • Returns: The encoded JWT.
  • decodeCustomerToken($jwt)
    • Description: Decodes a customer JWT to retrieve the payload.
    • Returns: The decoded payload.
  • encodeSessionToken($payload)
    • Description: Encodes a session payload into a JWT.
    • Returns: The encoded JWT.
  • decodeSessionToken($jwt)
    • Description: Decodes a session JWT to retrieve the payload.
    • Returns: The decoded payload.

Example Usage

This contract might be used in authentication services to manage user sessions and tokens securely.

SignedUrlService.php

Purpose

The SignedUrlService contract defines the method for generating signed URLs that can be used for secure access to resources, such as uploading customer documents. Signed URLs ensure that access is granted only for a limited time and under specific conditions.

Key Method

  • getSignedUrlForCustomerDocument(string $object, DateTime $timeout, array $options): string
    • Description: Generates a signed URL for uploading customer documents.
    • Parameters:
      • $object: The identifier for the object or document.
      • $timeout: The expiration time of the signed URL.
      • $options: Additional options for generating the URL.
    • Returns: The signed URL.

Example Usage

This contract might be used in document management services to provide secure URLs for uploading and accessing sensitive customer documents.

TradeCreditService.php

Purpose

The TradeCreditService contract defines methods for managing trade credit applications and generating authentication data. This contract is crucial for handling credit-based transactions and account management.

Key Methods

  • submitNewApplication(array $applicationData): ResponseInterface|null
    • Description: Submits a new trade credit application with the provided data.
    • Parameters:
      • $applicationData: An array containing the application details.
    • Returns: A ResponseInterface object or null if submission fails.
  • generateAuthenticationData(Customer $customer)
    • Description: Generates authentication data for a specified customer.
    • Parameters:
      • $customer: The customer for whom to generate authentication data.
    • Returns: The generated authentication data.

Example Usage

This contract might be used in financial services to handle trade credit applications and manage customer authentication.

Conclusion

Each contract in the contracts folder of the ECOM-Api project plays a crucial role in defining the standard interfaces for various services. By adhering to these contracts, the ECOM-Api ensures consistency, flexibility, and ease of integration across different components of the application.

For more information on how these contracts are implemented and used in the ECOM-Api, you can refer to the relevant implementation classes and the overall project documentation.


Copyright © 2026