# Update Cashback Rule

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/managers/loyalty-program/points-collection/update:
    post:
      summary: Update Cashback Rule
      deprecated: false
      description: >-
        Updates the configuration of a cashback rule within a store's loyalty
        program.


        <Accordion title="🔑Scopes" defaultOpen>
            
         `loyalty_program.read_write` - Loyalty Program Read & Write
         
        </Accordion>
      operationId: post-managers-loyalty-program-points-collection-update
      tags:
        - Default module/Apps/Merchant APIs/Marketing/Loyalty Program
        - Loyalty Program
      parameters:
        - name: Authorization
          in: header
          description: >-
            The Authorization token is a unique key given to the third-party
            application (Partner) by Zid. It is used to authenticate the API
            requests made by the Partner application. The token verifies the
            partner's identity and ensures they have permission to access Zid's
            API but does not provide any specific user or store information. It
            should be included in the header of API requests when the partner
            application needs to access Zid's API.
          required: true
          example: '{{Autherization}}'
          schema:
            type: string
        - name: X-Manager-Token
          in: header
          description: >-
            This token is used to authenticate and access information related to
            the store. It is obtained through an OAuth mechanism and is required
            to perform operations on the store's data. The `X-Manager-Token`
            should be included in the header of API requests that require
            store-related information.
          required: false
          example: '{{Access-Token}}'
          schema:
            type: string
        - name: Accept
          in: header
          description: >-
            Specifies the Media Types acceptable for the client. In this case,
            it signals that the client expects a response in the JSON format.
          required: true
          example: application/json
          schema:
            type: string
            default: application/json
        - name: Accept-Language
          in: header
          description: >-
            Preferred language for the response. Defaults to `en` if not
            specified.
          required: false
          example: en
          schema:
            type: string
            enum:
              - en
              - ar
            examples:
              - en
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                ruleId:
                  example: ''
                  type: string
                config[money]:
                  type: number
                  example:
                    - ''
                config[points]:
                  type: integer
                  example: 0
              required:
                - ruleId
                - config[money]
                - config[points]
            examples: {}
      responses:
        '200':
          description: The cashback rule method status is updated successfully.
          content:
            application/json:
              schema:
                type: object
                x-examples:
                  Example 1:
                    status: object
                    data:
                      status: true
                      message: Points collection updated successfully
                      is_cashback_enabled: false
                      points_collection_methods_list:
                        - id: b1e3ca5d-2a89-4993-89bf-0f31a4b70b00
                          external_id: pos
                          store_id: 3dfc16e6-ad19-4126-9c2a-5e4a7fb73051
                          points_rewarded: 1
                          amount_to_spend: 100
                          available_to: null
                          is_active: false
                          created_at: '2023-12-28T10:32:13.000000Z'
                          updated_at: '2024-08-19T06:59:51.000000Z'
                          deleted_at: null
                        - id: efc450a4-3f09-4544-bcdd-80ddcbde23c8
                          external_id: '15362'
                          store_id: 3dfc16e6-ad19-4126-9c2a-5e4a7fb73051
                          points_rewarded: 1
                          amount_to_spend: 100
                          available_to:
                            tags: []
                            level:
                              levelId: null
                              levelName: null
                          is_active: true
                          created_at: '2023-03-29T10:55:07.000000Z'
                          updated_at: '2024-08-19T06:59:51.000000Z'
                          deleted_at: null
                    message:
                      type: object
                      code: MSG_POPUP_OK
                      name: Points collection
                      description: Points collection updated successfully
                properties:
                  status:
                    type: object
                    description: Indicates the overall status of the API response.
                    x-apidog-orders: []
                    properties: {}
                    x-apidog-ignore-properties: []
                  data:
                    type: object
                    description: >-
                      The data section provides details about the status of the
                      points collection update and the specifics of the points
                      collection methods.
                    properties:
                      status:
                        type: boolean
                        description: >-
                          Indicates that the points collection method has been
                          successfully updated.
                        default: true
                      message:
                        type: string
                        description: >-
                          A confirmation message indicating that the points
                          collection method was updated without any issues.
                        examples:
                          - Points collection updated successfully
                      is_cashback_enabled:
                        type: boolean
                        description: Indicates whether the cashback feature is enabled.
                        default: false
                      points_collection_methods_list:
                        type: array
                        description: >-
                          This is a list of the different methods available for
                          collecting points, detailing the specifics of each
                          method.
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              description: >-
                                A unique identifier for each specific points
                                collection method.
                              examples:
                                - b1e3ca5d-2a89-4993-89bf-0f31a4b70b00
                            external_id:
                              type: string
                              description: >-
                                An identifier used by external systems to track
                                or reference the points.
                              examples:
                                - pos
                            store_id:
                              type: string
                              description: >-
                                The unique identifier of the store where this
                                points collection method is applied.
                              examples:
                                - 3dfc16e6-ad19-4126-9c2a-5e4a7fb73051
                            points_rewarded:
                              type: integer
                              description: >-
                                The number of points awarded for spending a
                                certain amount.
                              examples:
                                - 1
                            amount_to_spend:
                              type: integer
                              description: >-
                                The amount of money that needs to be spent to
                                earn the points.
                              examples:
                                - 100
                            available_to:
                              type: 'null'
                              description: >-
                                Specifies if the rule is available to certain
                                tags or levels, or it might be null if available
                                to all customers.
                            is_active:
                              type: boolean
                              description: >-
                                A boolean value (true or false) indicating
                                whether this points collection method is
                                currently active.
                              default: false
                            created_at:
                              type: string
                              description: >-
                                The timestamp indicating when the points
                                collection method was created.
                              examples:
                                - '2023-12-28T10:32:13.000000Z'
                            updated_at:
                              type: string
                              description: >-
                                The timestamp indicating when the points
                                collection method was last updated.
                              examples:
                                - '2023-08-28T10:32:13.000000Z'
                            deleted_at:
                              type: 'null'
                              description: >-
                                The timestamp indicating when the points
                                collection method was deleted, or null if it
                                hasn’t been deleted.
                          x-apidog-orders:
                            - id
                            - external_id
                            - store_id
                            - points_rewarded
                            - amount_to_spend
                            - available_to
                            - is_active
                            - created_at
                            - updated_at
                            - deleted_at
                          x-apidog-ignore-properties: []
                    x-apidog-orders:
                      - status
                      - message
                      - is_cashback_enabled
                      - points_collection_methods_list
                    x-apidog-ignore-properties: []
                  message:
                    type: object
                    description: Contains detailed information about the message.
                    properties:
                      type:
                        type: string
                        description: Specifies the type of message.
                      code:
                        type: string
                        description: A specific code representing the type.
                        examples:
                          - MSG_POPUP_OK
                      name:
                        type: string
                        description: A short, human-readable title or name for the message.
                        examples:
                          - Points collection
                      description:
                        type: string
                        description: >-
                          A detailed description of the message, providing more
                          context.
                        examples:
                          - Points collection updated successfully
                    x-apidog-orders:
                      - type
                      - code
                      - name
                      - description
                    x-apidog-ignore-properties: []
                x-apidog-orders:
                  - status
                  - data
                  - message
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: OK
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                x-examples:
                  Example 1:
                    payload:
                      status: false
                      status_code: 0
                      message: >-
                        No query results for model
                        [Zid\Modules\Loyalty\Models\LoyaltyCashbackRule]
                        7656e0f6-0259-4bcf-90d6-b7ad1fcdcb2f
                properties:
                  payload:
                    type: object
                    description: Contains detailed information about the error encountered.
                    properties:
                      status:
                        type: boolean
                        description: >-
                          Indicates the success or failure of the operation. In
                          this case, it is false, signifying that the operation
                          failed.
                        default: false
                      status_code:
                        type: integer
                        description: >-
                          A code representing the specific status of the
                          operation.
                        examples:
                          - 0
                      message:
                        type: string
                        description: >-
                          A detailed message providing more context about the
                          error.
                        examples:
                          - >-
                            No query results for model
                            [Zid\\Modules\\Loyalty\\Models\\LoyaltyCashbackRule]
                            7656e0f6-0259-4bcf-90d6-b7ad1fcdcb2f
                    x-apidog-orders:
                      - status
                      - status_code
                      - message
                    x-apidog-ignore-properties: []
                x-apidog-orders:
                  - payload
                x-apidog-ignore-properties: []
          headers: {}
          x-apidog-name: Bad Request
        '401':
          description: ''
          content:
            application/json:
              schema:
                type: object
                description: >-
                  Response returned when the request cannot be authenticated
                  because the required credentials are missing, invalid, or
                  expired.
                properties:
                  status:
                    type: string
                    description: Indicates the overall status of the API response.
                    examples:
                      - error
                  message:
                    type: object
                    description: >-
                      Contains structured details explaining why the request
                      could not be authenticated.
                    properties:
                      type:
                        type: string
                        description: Indicates the category of the response message.
                        examples:
                          - error
                      code:
                        type: string
                        description: >-
                          A machine-readable code identifying the authentication
                          error. Returns null when no specific code is
                          available.
                        examples:
                          - UNAUTHORIZED
                        nullable: true
                      name:
                        type: string
                        description: >-
                          A short, human-readable title describing the
                          authentication error. Returns null when no title is
                          available.
                        examples:
                          - Unauthorized
                        nullable: true
                      description:
                        type: string
                        description: >-
                          A human-readable explanation of why the request could
                          not be authenticated. Returns null when no detailed
                          explanation is available.
                        examples:
                          - >-
                            Authentication credentials are missing, invalid, or
                            expired.
                        nullable: true
                    required:
                      - type
                      - code
                      - name
                      - description
                    x-apidog-orders:
                      - type
                      - code
                      - name
                      - description
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                examples:
                  - status: error
                    message:
                      type: error
                      code: UNAUTHORIZED
                      name: Unauthorized
                      description: >-
                        Authentication credentials are missing, invalid, or
                        expired.
                x-apidog-ignore-properties: []
              examples:
                '2':
                  summary: Example 1
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_MISSING
                      name: Sorry
                      description: Please login first.
                '3':
                  summary: Example 2
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_INVALID
                      name: Sorry
                      description: Login session expired. Please login again.
                '4':
                  summary: Example 3
                  value:
                    status: error
                    message:
                      type: error
                      code: ERROR_SESSION_INVALID
                      name: Sorry
                      description: Invalid authentication
          headers: {}
          x-apidog-name: Unauthorized
        '422':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      name:
                        type: string
                      description:
                        type: string
                      validations:
                        type: array
                        items:
                          type: object
                          properties:
                            field:
                              type: string
                            errors:
                              type: array
                              items:
                                type: string
                          required:
                            - field
                            - errors
                          x-apidog-orders:
                            - field
                            - errors
                          x-apidog-ignore-properties: []
                    required:
                      - type
                      - code
                      - name
                      - description
                      - validations
                    x-apidog-orders:
                      - type
                      - code
                      - name
                      - description
                      - validations
                    x-apidog-ignore-properties: []
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                x-apidog-ignore-properties: []
              example:
                status: validation_error
                message:
                  type: validation_errors
                  code: ERROR_POPUP_OK
                  name: Inputs
                  description: Input errors!
                  validations:
                    - field: ruleId
                      errors:
                        - The rule id field is required.
                    - field: config.money
                      errors:
                        - The config.money field is required.
                    - field: config.points
                      errors:
                        - The config.points field is required.
          headers: {}
          x-apidog-name: Unprocessable Entity
        '500':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Status of the error.
                  message:
                    $ref: '#/components/schemas/ResponseEnvelopMessage'
                required:
                  - status
                  - message
                x-apidog-orders:
                  - status
                  - message
                x-apidog-ignore-properties: []
              example:
                status: error
                message:
                  type: error
                  code: MSG_HIDDEN
                  name: Error
                  description: Internal Server Error
          headers: {}
          x-apidog-name: Internal Server error
      security: []
      x-apidog-folder: Default module/Apps/Merchant APIs/Marketing/Loyalty Program
      x-apidog-status: released
      x-run-in-apidog: https://app.apidog.com/web/project/613905/apis/api-9148630-run
components:
  schemas:
    ResponseEnvelopMessage:
      type: object
      properties:
        type:
          type: string
          description: Type of response message returned by the API.
          examples:
            - success
        code:
          type: string
          description: Response code returned by the API, if available.
          examples:
            - MSG_POPUP_OK
          nullable: true
        name:
          type: string
          description: Name or title of the response message, if available.
          examples:
            - Coupons
          nullable: true
        description:
          type: string
          description: Detailed description of the response message, if available.
          examples:
            - Coupons created successfully
          nullable: true
      required:
        - type
        - code
        - name
        - description
      description: Additional response metadata.
      x-apidog-orders:
        - type
        - code
        - name
        - description
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes: {}
servers:
  - url: https://api.zid.sa/
    description: Prod Env
security: []

```
