public PostGetMessagesRequest(int accountId, string propertyHref, string idfaStatus, string requestUUID, CampaignsPostGetMessagesRequest campaigns, LocalState localState, IncludeDataPostGetMessagesRequest includeData)
 {
     this.accountId    = accountId;
     this.propertyHref = propertyHref;
     this.idfaStatus   = idfaStatus;
     this.requestUUID  = requestUUID;
     this.campaigns    = campaigns;
     this.localState   = localState;
     this.includeData  = includeData;
 }
Ejemplo n.º 2
0
    public void GetMessages(int accountId, string propertyHref, CampaignsPostGetMessagesRequest campaigns, Action <string> onSuccessAction, Action <Exception> onErrorAction, int environment, int millisTimeout)
    {
        msTimeout = millisTimeout;
        instance.client.Timeout = TimeSpan.FromMilliseconds(millisTimeout);
        string idfaStatus = "unknown";
        var    dict       = new Dictionary <string, string> {
            { "type", "RecordString" }
        };
        var includeData = new IncludeDataPostGetMessagesRequest()
        {
            localState      = dict,
            messageMetaData = dict,
            TCData          = dict
        };
        var requestBody = new PostGetMessagesRequest(accountId, propertyHref, idfaStatus, GUID.Value, campaigns,
                                                     SaveContext.GetLocalState(),
                                                     // new LocalState(), // TODO: remove & uncomment line above
                                                     includeData);

        Task.Factory.StartNew(async delegate { await PostGetMessages(requestBody, environment, onSuccessAction, onErrorAction); });
    }
Ejemplo n.º 3
0
    public void Consent(/*CONSENT_ACTION_TYPE == */ int actionType,
                        int environment,
                        string language,
                        string privacyManagerId,
                        Action <string> onSuccessAction,
                        Action <Exception> onErrorAction,
                        ConsentSaveAndExitVariables pmSaveAndExitVariables = null)
    {
        var dict = new Dictionary <string, string> {
            { "type", "RecordString" }
        };
        var includeData = new IncludeDataPostGetMessagesRequest()
        {
            localState = dict,
            TCData     = dict
                         // messageMetaData = dict,
        };
        ConsentSaveAndExitVariables concretePmSaveAndExitVariables;
        PostConsentRequest          body = null;

        switch (CmpCampaignPopupQueue.CurrentCampaignToShow())
        {
        case 0:
            if (pmSaveAndExitVariables != null)
            {
                concretePmSaveAndExitVariables = pmSaveAndExitVariables as ConsentGdprSaveAndExitVariables;
            }
            else
            {
                concretePmSaveAndExitVariables = new ConsentGdprSaveAndExitVariables(
                    language: language,
                    privacyManagerId: privacyManagerId,
                    categories: new ConsentGdprSaveAndExitVariablesCategory[] { },
                    vendors: new ConsentGdprSaveAndExitVariablesVendor[] { },
                    specialFeatures: new ConsentGdprSaveAndExitVariablesSpecialFeature[] { }
                    );
            }
            body = new PostConsentGdprRequest(
                requestUUID: GUID.Value,
                idfaStatus: "accepted",
                localState: SaveContext.GetLocalState(),
                includeData: includeData,
                pmSaveAndExitVariables: (ConsentGdprSaveAndExitVariables)concretePmSaveAndExitVariables
                );
            break;

        case 2:
            if (pmSaveAndExitVariables != null)
            {
                //remove if vendor._id == null
                concretePmSaveAndExitVariables = pmSaveAndExitVariables as ConsentCcpaSaveAndExitVariables;
                List <ConsentGdprSaveAndExitVariablesVendor> rej = new List <ConsentGdprSaveAndExitVariablesVendor>();
                foreach (var rejected in (pmSaveAndExitVariables as ConsentCcpaSaveAndExitVariables).rejectedVendors)
                {
                    if (!string.IsNullOrEmpty(rejected._id))
                    {
                        rej.Add(rejected);
                    }
                }
                (concretePmSaveAndExitVariables as ConsentCcpaSaveAndExitVariables).rejectedVendors = rej.ToArray();
            }
            else
            {
                concretePmSaveAndExitVariables = new ConsentCcpaSaveAndExitVariables(
                    language: language,
                    privacyManagerId: privacyManagerId,
                    rejectedCategories: new ConsentGdprSaveAndExitVariablesCategory[] { },
                    rejectedVendors: new ConsentGdprSaveAndExitVariablesVendor[] { },
                    specialFeatures: new ConsentGdprSaveAndExitVariablesSpecialFeature[] { }
                    );
            }
            body = new PostConsentCcpaRequest(
                requestUUID: GUID.Value,
                idfaStatus: "accepted",
                localState: SaveContext.GetLocalState(),
                includeData: includeData,
                pmSaveAndExitVariables: (ConsentCcpaSaveAndExitVariables)concretePmSaveAndExitVariables
                );
            break;
        }

        if (body == null)
        {
            onErrorAction?.Invoke(new Exception("Message body is null!!!"));
        }
        else
        {
            Task.Factory.StartNew(async delegate { await PostConsent(actionType, environment, body, onSuccessAction, onErrorAction); });
        }
    }
 public PostConsentCcpaRequest(string requestUUID, string idfaStatus, LocalState localState, IncludeDataPostGetMessagesRequest includeData, ConsentCcpaSaveAndExitVariables pmSaveAndExitVariables)
 {
     this.requestUUID            = requestUUID;
     this.idfaStatus             = idfaStatus;
     this.localState             = localState;
     this.includeData            = includeData;
     this.pmSaveAndExitVariables = pmSaveAndExitVariables;
 }