/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *   http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.fineract.cn.deposit.service.internal.command;

import org.apache.fineract.cn.deposit.api.v1.collection.domain.data.CollectionsRequest;

public class UpdateCollectionsCommand {
    private final String collectionsReference;
    private final CollectionsRequest collectionRequest;

    public UpdateCollectionsCommand(String collectionsReference, CollectionsRequest collectionRequest) {
        this.collectionsReference = collectionsReference;
        this.collectionRequest = collectionRequest;
    }

    public CollectionsRequest getCollectionRequest() {
        return collectionRequest;
    }

    public String getCollectionsReference() {
        return collectionsReference;
    }
}
