Пример #1
0
    public static MailChimpCore Instance()
    {
        MailChimpCore _instance = null;
        GameObject    anchor    = GameObject.Find("MailChimpBlob");

        if (anchor == null)
        {
            anchor    = new GameObject("MailChimpBlob");
            _instance = anchor.AddComponent <MailChimpCore>();
        }
        else if (anchor.GetComponent <MailChimpCore>() == null)
        {
            _instance = anchor.AddComponent <MailChimpCore>();
        }
        else
        {
            _instance = anchor.GetComponent <MailChimpCore>();
        }

        return(_instance);
    }
Пример #2
0
    /*
     * private IEnumerator Alert (string message, Callback cb)
     * {
     *      this.alertMessage = message;
     *      this.isShowingAlert = true;
     *      this.isDrawn = false;
     *      yield return new WaitForSeconds(3f);
     *      this.isShowingAlert = false;
     *      this.isDrawn = true;
     *      this.alertMessage = "";
     *      if (cb != null) {
     *              cb();
     *      }
     * }
     */

    void Connect(GameObject SignUp)
    {
        //if (GUILayout.Button("Sign Up!")) {
        // do the thing
        if (Validate())
        {
            //StartCoroutine(Alert("Sit Tight", null));
            UI_Alert.text = "Connecting";
            MailChimpCore mc = MailChimpCore.Instance();
            mc.apiKey        = this.apiKey;
            mc.listId        = this.listId;
            mc.dataCenter    = this.dataCenter;
            mc.groupValue    = this.groupValue;
            mc.groupingsName = this.groupingsName;

            mc.Subscribe(
                options["FNAME"].ToString(),
                options["LNAME"].ToString(),
                options["email_address"].ToString(),
                delegate(System.Xml.XmlDocument doc) {
                if (mc.isErrored)
                {
                    // Display alert box.
                    System.Xml.XmlNodeList codes = doc.GetElementsByTagName("code");
                    int errCode = 0;
                    if (codes.Count > 0)
                    {
                        errCode = int.Parse(codes[0].InnerText);
                    }

                    switch (errCode)
                    {
                    case 214:
                        //StartCoroutine(Alert("According to our records, you're already registered. Also, You Rock!", null));
                        UI_Alert.text = "According to our records, you're already registered. \n Also, You Rock!";
                        break;

                    default:
                        //StartCoroutine(Alert("There was a problem with your submission, try again later.", null));
                        UI_Alert.text = "There was a problem with your submission, try again later.";
                        break;
                    }
                }
                else
                {
                    // Test out
                    // Show thanks
                    UI_Alert.text = "Thank you for signing up! \n Check your inbox to confirm your subscription.";
//						this.isDrawn = false;
//						StartCoroutine(Alert("You are awesome (and good looking.) We'll be in touch.", delegate () {
//							if (this.loadLevelOnSuccess != "") {
//								Application.LoadLevel(this.loadLevelOnSuccess);
//							} else {
//								this.isDrawn = false;
//							}
//						}));
                }
            }
                );
        }
        else
        {
            // Display alert that fields need values.
            //StartCoroutine(Alert("There seems to be a problem with some of the values you entered, did you fill out the whole form?", null));
            UI_Alert.text = "There seems to be a problem with some of the values you entered,\n did you fill out the whole form?";
        }
        //}
    }