diff --git a/src/main/java/ru/evotor/framework/core/action/event/receipt/ready_for_payment/ReceiptReadyForPaymentEvent.java b/src/main/java/ru/evotor/framework/core/action/event/receipt/ready_for_payment/ReceiptReadyForPaymentEvent.java new file mode 100644 index 0000000000..40e51d355c --- /dev/null +++ b/src/main/java/ru/evotor/framework/core/action/event/receipt/ready_for_payment/ReceiptReadyForPaymentEvent.java @@ -0,0 +1,48 @@ +package ru.evotor.framework.core.action.event.receipt.ready_for_payment; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import ru.evotor.IBundlable; + +public class ReceiptReadyForPaymentEvent implements IBundlable { + + public static final String NAME_PERMISSION = "evo.v2.receipt.payment.DISABLE"; + + public static final String NAME_SELL_RECEIPT = "evo.v2.receipt.sell.receiptReadyForPayment"; + public static final String NAME_PAYBACK_RECEIPT = "evo.v2.receipt.payback.receiptReadyForPayment"; + public static final String NAME_BUY_RECEIPT = "evo.v2.receipt.buy.receiptReadyForPayment"; + public static final String NAME_BUYBACK_RECEIPT = "evo.v2.receipt.buyback.receiptReadyForPayment"; + + private static final String KEY_RECEIPT_UUID = "receiptUuid"; + + @Nullable + public static ReceiptReadyForPaymentEvent create(@Nullable Bundle bundle) { + if (bundle == null) { + return null; + } + String receiptUuid = bundle.getString(KEY_RECEIPT_UUID, null); + return new ReceiptReadyForPaymentEvent(receiptUuid); + } + + @NonNull + private final String receiptUuid; + + @NonNull + public String getReceiptUuid() { + return receiptUuid; + } + + public ReceiptReadyForPaymentEvent(@NonNull String receiptUuid) { + this.receiptUuid = receiptUuid; + } + + @NonNull + public Bundle toBundle() { + Bundle result = new Bundle(); + result.putString(KEY_RECEIPT_UUID, receiptUuid); + return result; + } + +} \ No newline at end of file diff --git a/src/main/java/ru/evotor/framework/core/action/event/receipt/ready_for_payment/ReceiptReadyForPaymentEventProcessor.java b/src/main/java/ru/evotor/framework/core/action/event/receipt/ready_for_payment/ReceiptReadyForPaymentEventProcessor.java new file mode 100644 index 0000000000..e11e81f574 --- /dev/null +++ b/src/main/java/ru/evotor/framework/core/action/event/receipt/ready_for_payment/ReceiptReadyForPaymentEventProcessor.java @@ -0,0 +1,23 @@ +package ru.evotor.framework.core.action.event.receipt.ready_for_payment; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import ru.evotor.framework.core.action.processor.ActionProcessor; + +public abstract class ReceiptReadyForPaymentEventProcessor extends ActionProcessor { + @Override + public void process(@NonNull String action, @Nullable Bundle bundle, @NonNull Callback callback) { + ReceiptReadyForPaymentEvent event = ReceiptReadyForPaymentEvent.create(bundle); + if (event == null) { + return; + } + call(action, event, callback); + } + + public abstract void call(@NonNull String action, + @NonNull ReceiptReadyForPaymentEvent event, + @NonNull Callback callback); +} + diff --git a/src/main/java/ru/evotor/framework/core/action/event/receipt/ready_for_payment/ReceiptReadyForPaymentEventResult.java b/src/main/java/ru/evotor/framework/core/action/event/receipt/ready_for_payment/ReceiptReadyForPaymentEventResult.java new file mode 100644 index 0000000000..7e0afa05fd --- /dev/null +++ b/src/main/java/ru/evotor/framework/core/action/event/receipt/ready_for_payment/ReceiptReadyForPaymentEventResult.java @@ -0,0 +1,39 @@ +package ru.evotor.framework.core.action.event.receipt.ready_for_payment; + +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; + +import ru.evotor.IBundlable; + +public class ReceiptReadyForPaymentEventResult implements IBundlable { + + private static final String KEY_RECEIPT_PAYMENT_ENABLED = "receiptPaymentEnabled"; + + @Nullable + public static ReceiptReadyForPaymentEventResult create(@Nullable Bundle bundle) { + if (bundle == null) { + return null; + } + boolean sendUtmDocEnabled = bundle.getBoolean(KEY_RECEIPT_PAYMENT_ENABLED); + + return new ReceiptReadyForPaymentEventResult(sendUtmDocEnabled); + } + + private final boolean receiptPaymentEnabled; + + public ReceiptReadyForPaymentEventResult(boolean receiptPaymentEnabled) { + this.receiptPaymentEnabled = receiptPaymentEnabled; + } + + @NonNull + public Bundle toBundle() { + Bundle bundle = new Bundle(); + bundle.putBoolean(KEY_RECEIPT_PAYMENT_ENABLED, receiptPaymentEnabled); + return bundle; + } + + public boolean isReceiptPaymentEnabled() { + return receiptPaymentEnabled; + } +} \ No newline at end of file