Ejemplo n.º 1
0
        public static string Geturl(ForteOptions createOptions)
        {
            if (string.IsNullOrEmpty(createOptions.Server))
            {
                serverName = "";
                switch (createOptions.Environment.ToString().ToUpper())
                {
                case "LIVE":
                    serverName = "https://api.forte.net/API/v3";
                    break;

                case "SANDBOX":
                    serverName = "https://sandbox.forte.net/API/v3";
                    break;

                default:
                    serverName = "https://sandbox.forte.net/API/v3";
                    break;
                }
            }
            else if ((createOptions.Server.ToLower().IndexOf("http") == 0))
            {
                serverName = createOptions.Server;
            }

            return(serverName);
        }
Ejemplo n.º 2
0
        public ForteService(ForteOptions createOptions, string resource, string resourceName)
        {
            createOptions.Resource = resource;
            _serverName            = GetServerDetails.Geturl(createOptions);
            _strUser               = createOptions.UserId;
            _strPassword           = createOptions.Password;
            _strAuthOrganizationID = createOptions.AuthOrganizationId;
            string urlparam = ParameterBuilder.ApplyAllParameters(createOptions);

            _url          = _serverName + urlparam;
            _resourceName = resourceName;
        }
 public ForteScheduleService(ForteOptions createOptions) : base(createOptions, "schedules", "Schedule")
 {
 }
 public FortePaymethodsService(ForteOptions createOptions) : base(createOptions, "paymethods", "Paymethod")
 {
 }
Ejemplo n.º 5
0
        public static string ApplyAllParameters(ForteOptions obj)
        {
            if (obj != null)
            {
                newUrl = "";
                foreach (var property in obj.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance))
                {
                    foreach (var attribute in property.GetCustomAttributes(false))
                    {
                        if (attribute.GetType() != typeof(JsonPropertyAttribute))
                        {
                            continue;
                        }

                        var JsonPropertyAttribute = (JsonPropertyAttribute)attribute;

                        var value = property.GetValue(obj, null);
                        if (value == null)
                        {
                            continue;
                        }
                        if (string.IsNullOrWhiteSpace(value.ToString()))
                        {
                            continue;
                        }

                        switch ((JsonPropertyAttribute.PropertyName).ToLower())
                        {
                        case "organization_id":
                            newUrl = newUrl + "/organizations/" + (value.ToString().StartsWith("org_") ? value.ToString() : "org_" + value.ToString());
                            break;

                        case "location_id":
                            newUrl = newUrl + "/locations/" + (value.ToString().StartsWith("loc_") ? value.ToString() : "loc_" + value.ToString());
                            break;

                        case "customer_token":
                            newUrl = newUrl + "/customers/" + (value.ToString().StartsWith("cst_") ? value.ToString() : "cst_" + value.ToString());
                            break;

                        case "address_id":
                            newUrl = newUrl + "/addresses/" + (value.ToString().StartsWith("add_") ? value.ToString() : "add_" + value.ToString());
                            break;

                        case "paymethod_token":
                            newUrl = newUrl + "/paymethods/" + (value.ToString().StartsWith("mth_") ? value.ToString() : "mth_" + value.ToString());
                            break;

                        case "transaction_id":
                            newUrl = newUrl + "/transactions/" + (value.ToString().StartsWith("trn_") ? value.ToString() : "trn_" + value.ToString());
                            break;

                        case "schedule_id":
                            newUrl = newUrl + "/schedules/" + (value.ToString().StartsWith("sch_") ? value.ToString() : "sch_" + value.ToString());
                            break;

                        case "schedule_item_id":
                            newUrl = newUrl + "/scheduleitems/" + (value.ToString().StartsWith("sci_") ? value.ToString() : "sci_" + value.ToString());
                            break;

                        case "resource":
                            if (!newUrl.Contains(value.ToString()))
                            {
                                newUrl = newUrl + "/" + value.ToString() + "/";
                            }

                            break;

                        default:
                            break;
                        }
                    }
                }
                return(newUrl);
            }
            else
            {
                return("Error");
            }
        }
Ejemplo n.º 6
0
 public ForteScheduleItemService(ForteOptions createOptions) : base(createOptions, "scheduleitems", "Scheduleitem")
 {
 }
Ejemplo n.º 7
0
 public ForteAddressService(ForteOptions createOptions) : base(createOptions, "addresses", "Address")
 {
 }
 public ForteTransactionService(ForteOptions createOptions) : base(createOptions, "transactions", "Transaction")
 {
 }
 public ForteCustomerService(ForteOptions createOptions) : base(createOptions, "customers", "Customer")
 {
 }