コード例 #1
0
        public static String prepareMapPayload(String prepend, EgoiMap values)
        {
            StringBuilder q = new StringBuilder();
            foreach (String key in values.Keys)
            {
                Object value = values[key];
                String result = null;

                String prefix = String.Format("{0}[{1}]", prepend, key);

                if (value is EgoiMap)
                {
                    EgoiMap map = (EgoiMap)value;
                    result = prepareMapPayload(prefix, map);
                }
                else if (value is EgoiMapList)
                {
                    EgoiMapList list = (EgoiMapList)value;
                    result = prepareListPayload(prefix, list);
                }
                else
                {
                    result = String.Format("{0}={1}&", prefix, value.ToString());
                }

                q.Append(result);
            }
            return q.ToString();
        }
コード例 #2
0
        public String buildPayload(EgoiMap values)
        {
            if (values != null)
                return values.ToString();

            return "";
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: Veneroso/e-goi-wrappers
 private void processCall_Click(object sender, EventArgs e)
 {
     status.Text = "";
     output.Clear();
     Protocol p = (Protocol) protocol.SelectedItem;
     try
     {
         EgoiApi api = EgoiApiFactory.getApi(p);
         EgoiMap arguments = new EgoiMap();
         arguments.Add("apikey", apiKey.Text);
         EgoiMap result = api.getUserData(arguments);
         output.Text = result.ToString();
     } catch(EgoiException ex) {
         status.Text = ex.Message;
     }
 }
コード例 #4
0
        public String buildPayload(EgoiMap values)
        {
            StringBuilder url = new StringBuilder();

            int i = 0;

            foreach (String key in values.Keys)
            {
                Object value = values[key];

                if (i > 0)
                    url.Append("&");

                if(value is Array)
                {
                    string valueToAppend = string.Empty;

                    foreach(var val in (Array)value)
                    {
                        valueToAppend += val.ToString() + ",";
                    }

                    if (!string.IsNullOrEmpty(valueToAppend))
                    {
                        valueToAppend = valueToAppend.Trim(',');
                        url.Append(String.Format("{0}={1}", key, valueToAppend));
                    }

                }
                else
                {
                    url.Append(String.Format("{0}={1}", key, value.ToString()));
                }

                i++;
            }

            return url.ToString();
        }
コード例 #5
0
 ///////////////////////////////////////////////////////////////////////////////////////
 public string getPartnersProducts(EgoiMap arguments)
 {
     return processResult("partners/products", "GET", arguments);
 }
コード例 #6
0
 public EgoiMap checklogin(EgoiMap arguments)
 {
     return decodeMapResult("checklogin", arguments);
 }
コード例 #7
0
 public EgoiMap getUserData(EgoiMap arguments)
 {
     return decodeMapResult("getUserData", arguments);
 }
コード例 #8
0
 public string getSubaccountsProperties(EgoiMap arguments)
 {
     return processResult("subaccounts/properties", "GET", arguments);
 }
コード例 #9
0
        public string processResult(string method, string methodType, EgoiMap arguments)
        {
            string payload = buildPayload(arguments);
            string json = fetchResponse(payload, method, methodType);

            return json;
        }
コード例 #10
0
 public EgoiMap subscriberData(EgoiMap arguments)
 {
     return decodeMapResult("subscriberData", arguments);
 }
コード例 #11
0
 public EgoiMap updateList(EgoiMap arguments)
 {
     return decodeMapResult("updateList", arguments);
 }
コード例 #12
0
 public EgoiMap sendFAX(EgoiMap arguments)
 {
     return decodeMapResult("sendFAX", arguments);
 }
コード例 #13
0
 public EgoiMap sendSMS(EgoiMap arguments)
 {
     return decodeMapResult("sendSMS", arguments);
 }
コード例 #14
0
 public EgoiMap sendEmail(EgoiMap arguments)
 {
     return decodeMapResult("sendEmail", arguments);
 }
コード例 #15
0
 public EgoiMap removeSubscriber(EgoiMap arguments)
 {
     return decodeMapResult("removeSubscriber", arguments);
 }
コード例 #16
0
        public Dictionary<string, object> processResult(string method, EgoiMap arguments)
        {
            string payload = buildPayload(method, arguments);
            string json = fetchResponse(payload);
            JavaScriptSerializer s = new JavaScriptSerializer();

            /**
             * IT's A TRAP!
             */
            Dictionary<string, object> response = s.Deserialize<Dictionary<string, object>>(json);
            Dictionary<string, object> r2 = response["Egoi_Api"] as Dictionary<string, object>;
            Dictionary<string, object> map = r2[method] as Dictionary<string, object>;

            if (map.ContainsKey("response"))
                throw new EgoiException(EgoiException.idToMessage(map["response"] as string));

            // Status not used
            map.Remove("status");

            return map;
        }
コード例 #17
0
 public string getPartnersProductsById(string id, EgoiMap arguments)
 {
     return processResult("partners/products/" + id, "GET", arguments);
 }
コード例 #18
0
        protected EgoiMap walkValues(EgoiMap map)
        {
            List<string> keys = map.Keys.ToList<string>();
            foreach(string key in keys) {
                object obj = map[key];
                if (obj is Dictionary<string, object>) {
                    Dictionary<string, object> sm = obj as Dictionary<string, object>;
                    map[key] = walkMap(sm);
                }

                if(obj is object[]) {
                    List<Dictionary<string, object>> mapList = extractMapList((Object[]) obj);
                    map[key] = walkArray(mapList);
                }
            }
            return map;
        }
コード例 #19
0
 public string getSubaccountsBalanceById(string id, EgoiMap arguments)
 {
     return processResult("subaccounts/balance/" + id, "GET", arguments);
 }
コード例 #20
0
 public string updateSubaccounts(string id, EgoiMap arguments)
 {
     return processResult("subaccounts/" + id, "PUT", arguments);
 }
コード例 #21
0
 public string getSubaccountsPropertiesById(string id, EgoiMap arguments)
 {
     return processResult("subaccounts/properties/" + id, "GET", arguments);
 }
コード例 #22
0
 public string addSubaccountsProducts(EgoiMap arguments)
 {
     return processResult("subaccounts/products/assign", "POST", arguments);
 }
コード例 #23
0
 public string topupSubaccountsProducts(EgoiMap arguments)
 {
     return processResult("subaccounts/products/topup", "GET", arguments);
 }
コード例 #24
0
 public EgoiMapList getSenders(EgoiMap arguments)
 {
     return decodeMapListResult("getSenders", arguments);
 }
コード例 #25
0
 public string addSubaccounts(EgoiMap arguments)
 {
     return processResult("subaccounts", "POST", arguments);
 }
コード例 #26
0
 ///////////////////////////////////////////////////////////////////////////////////////
 public EgoiMap addExtraField(EgoiMap arguments)
 {
     return decodeMapResult("addExtraField", arguments);
 }
コード例 #27
0
 public string blockSubaccounts(EgoiMap arguments)
 {
     return processResult("subaccounts/block", "POST", arguments);
 }
コード例 #28
0
 public EgoiMap addSubscriberBulk(EgoiMap arguments)
 {
     return decodeMapResult("addSubscriberBulk", arguments);
 }
コード例 #29
0
 public string deleteSubaccountsProducts(string id, EgoiMap arguments)
 {
     return processResult("subaccounts/products/assign/" + id, "DELETE", arguments);
 }
コード例 #30
0
 public String buildPayload(String method, EgoiMap values)
 {
     StringBuilder url = new StringBuilder();
     url
         .Append("type=json&")
         .Append("method=").Append(method).Append("&")
         .Append(prepareMapPayload("functionOptions", values));
     return url.ToString();
 }