All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tinypass.client.common.Event Maven / Gradle / Ivy

There is a newer version: 16.331.0
Show newest version
package com.tinypass.client.common;

import com.fasterxml.jackson.annotation.*;

/**
* It is base class for all events
*/
@JsonTypeInfo(
    use = JsonTypeInfo.Id.NAME,
    include = JsonTypeInfo.As.PROPERTY,
    property = "type",
    visible = true, defaultImpl = UnknownEvent.class
)
@JsonSubTypes({
    @JsonSubTypes.Type(value = UnknownEvent.class, name = "unknown") , 
    @JsonSubTypes.Type(value = TestEvent.class, name = "test") , 
    @JsonSubTypes.Type(value = UserPaymentMethodEvent.class, name = "user_payment_method") , 
    @JsonSubTypes.Type(value = UnsupportedEvent.class, name = "unsupported") , 
    @JsonSubTypes.Type(value = PaymentRefundEvent.class, name = "payment_refund") , 
    @JsonSubTypes.Type(value = AddressUpdatedEvent.class, name = "address_updated") , 
    @JsonSubTypes.Type(value = TermChangeEvent.class, name = "term_change") , 
    @JsonSubTypes.Type(value = KeyingEvent.class, name = "content_algorithm") , 
    @JsonSubTypes.Type(value = TermChangedEvent.class, name = "term_changed") , 
    @JsonSubTypes.Type(value = SubscriptionAutoRenewChangedByEndUserEvent.class, name = "subscription_auto_renew_changed") , 
    @JsonSubTypes.Type(value = UserAddressUpdatedEvent.class, name = "user_address_updated") , 
    @JsonSubTypes.Type(value = VoucherRedeemedEvent.class, name = "voucher_redeemed") , 
    @JsonSubTypes.Type(value = VoucherDeliveredEvent.class, name = "voucher_delivered") , 
    @JsonSubTypes.Type(value = VoucherRevokedEvent.class, name = "voucher_revoked") , 
    @JsonSubTypes.Type(value = VoucherPurchasedEvent.class, name = "voucher_purchased") , 
    @JsonSubTypes.Type(value = UserUpdatedEvent.class, name = "user_updated") , 
    @JsonSubTypes.Type(value = UserEmailConfirmedEvent.class, name = "user_email_confirmed") , 
    @JsonSubTypes.Type(value = UserCreatedEvent.class, name = "user_created") , 
    @JsonSubTypes.Type(value = UserDisabledEvent.class, name = "user_disabled") , 
    @JsonSubTypes.Type(value = ContractUpdatedEvent.class, name = "contract_updated") , 
    @JsonSubTypes.Type(value = ContractCreatedEvent.class, name = "contract_created") , 
    @JsonSubTypes.Type(value = ContractUserCreatedEvent.class, name = "contract_user_created") , 
    @JsonSubTypes.Type(value = ContractUserInvitedEvent.class, name = "licensee_invite_to_contract") , 
    @JsonSubTypes.Type(value = ContractDeletedEvent.class, name = "contract_deleted") , 
    @JsonSubTypes.Type(value = SubscriptionRenewalEvent.class, name = "subscription_renewal") , 
    @JsonSubTypes.Type(value = AccessGrantedEvent.class, name = "access_granted") , 
    @JsonSubTypes.Type(value = AccessRevokedEvent.class, name = "access_revoked") , 
    @JsonSubTypes.Type(value = AccessModifiedEvent.class, name = "access_modified") , 
    @JsonSubTypes.Type(value = LicenseeCreatedEvent.class, name = "licensee_created") , 
    @JsonSubTypes.Type(value = LicenseeUpdatedEvent.class, name = "licensee_updated") , 
    @JsonSubTypes.Type(value = TermChangeFinishedEvent.class, name = "term_change_finished") , 
    @JsonSubTypes.Type(value = ContractUserAccessExpiredEvent.class, name = "contract_user_access_expired") , 
    @JsonSubTypes.Type(value = ContractUserAccessRevokedEvent.class, name = "contract_user_access_revoked") , 
    @JsonSubTypes.Type(value = ContractRedeemedEvent.class, name = "contract_redeemed") , 
    @JsonSubTypes.Type(value = ContractRenewedEvent.class, name = "contract_renewed") , 
    @JsonSubTypes.Type(value = SharedSubscriptionChildAccessGrantedEvent.class, name = "shared_subscription_child") 
})
public class Event {

    // TODO do we need to expose these constants?
    public final static String TEST_EVENT = "test";

    public final static String ACCESS_EVENT = "access"; // TODO deprecated?
    public final static String ACCESS_GRANTED = "access_granted";
    public final static String ACCESS_MODIFIED = "access_modified";
    public final static String ACCESS_REVOKED = "access_revoked";
    public final static String SUBSCRIPTION_EVENT = "subscription"; // TODO deprecated?
    public final static String KEYING_CONTENT_EVENT = "content_algorithm"; // TODO deprecated?

    private Integer version;
    private String eventType;
    private String type;
    private String event;

    /*
    for version 2 "type" field should be used
    */
    @Deprecated
    public String getEventType() {
        return eventType;
    }

    /*
    1 or 2 version. 1 version is deprecated
    */
    public int getVersion() {
        return (version == null || version == 1) ? 1 : version;
    }

    /*
    for version 2 "event" field should be used instead
    */
    public String getType() {
        return type;
    }

    public String getEvent() {
        return event;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy