public BatchSubRequest UpsertExternal(string objectName, string externalFieldName, string externalId, object record)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }
            if (string.IsNullOrEmpty(externalId))
            {
                throw new ArgumentNullException(nameof(externalId));
            }
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            var richInput = Dnf.UnFlatten(JObject.FromObject(record));
            var request   = new BatchSubRequest
            {
                RichInput = Dnf.Omit(richInput, externalFieldName),
                Method    = "PATCH",
                Url       = $"sobjects/{objectName}/{externalFieldName}/{Uri.EscapeDataString(externalId)}"
            };

            BatchRequests.Add(request);
            return(request);
        }
        public BatchSubRequest Search(string query)
        {
            if (string.IsNullOrEmpty(query))
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (!query.Contains("FIND"))
            {
                throw new ArgumentException("query does not contain FIND");
            }
            if (!query.Contains("{") || !query.Contains("}"))
            {
                throw new ArgumentException("search term must be wrapped in braces");
            }

            var request = new BatchSubRequest
            {
                ResponseType = "query",
                Method       = "GET",
                Url          = $"search?q={Dnf.EscapeDataString(query)}"
            };

            BatchRequests.Add(request);
            return(request);
        }
        public BatchSubRequest Relationships(string objectName, string recordId, string relationshipFieldName, string[]?fields = null)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }
            if (string.IsNullOrEmpty(recordId))
            {
                throw new ArgumentNullException(nameof(recordId));
            }
            if (string.IsNullOrEmpty(relationshipFieldName))
            {
                throw new ArgumentNullException(nameof(relationshipFieldName));
            }

            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = fields?.Length > 0
                    ? $"sobjects/{objectName}/{recordId}/{relationshipFieldName}?fields={string.Join(",", fields.Select(Uri.EscapeDataString))}"
                    : $"sobjects/{objectName}/{recordId}/{relationshipFieldName}"
            };

            BatchRequests.Add(request);
            return(request);
        }
        public BatchSubRequest Update(string objectName, string recordId, object record)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }
            if (string.IsNullOrEmpty(recordId))
            {
                throw new ArgumentNullException(nameof(recordId));
            }
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            var richInput = Dnf.UnFlatten(JObject.FromObject(record));
            var request   = new BatchSubRequest
            {
                RichInput = Dnf.Omit(richInput, "Id"),
                Method    = "PATCH",
                Url       = $"sobjects/{objectName}/{recordId}"
            };

            BatchRequests.Add(request);
            return(request);
        }
        public BatchSubRequest RetrieveExternal(string objectName, string externalFieldName, string externalId, params string[] fields)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }
            if (string.IsNullOrEmpty(externalFieldName))
            {
                throw new ArgumentNullException(nameof(externalFieldName));
            }
            if (string.IsNullOrEmpty(externalId))
            {
                throw new ArgumentNullException(nameof(externalId));
            }

            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = fields.Length > 0
                    ? $"sobjects/{objectName}/{externalFieldName}/{Uri.EscapeDataString(externalId)}?fields={string.Join(",", fields.Select(Uri.EscapeDataString))}"
                    : $"sobjects/{objectName}/{externalFieldName}"
            };

            BatchRequests.Add(request);
            return(request);
        }
        public BatchSubRequest GetObjects()
        {
            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = "sobjects"
            };

            BatchRequests.Add(request);
            return(request);
        }
        public BatchSubRequest Limits()
        {
            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = "limits"
            };

            BatchRequests.Add(request);
            return(request);
        }
        public BatchSubRequest PlatformAction()
        {
            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = "sobjects/PlatformAction"
            };

            BatchRequests.Add(request);
            return(request);
        }
        public BatchSubRequest GetUpdated(string objectName, DateTime startDateTime, DateTime endDateTime)
        {
            var sdt = Uri.EscapeDataString(startDateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss+00:00", CultureInfo.InvariantCulture));
            var edt = Uri.EscapeDataString(endDateTime.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss+00:00", CultureInfo.InvariantCulture));

            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = $"sobjects/{objectName}/updated/?start={sdt}&end={edt}"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #10
0
        public BatchSubRequest ExplainAll(string query)
        {
            if (string.IsNullOrEmpty(query))
            {
                throw new ArgumentNullException(nameof(query));
            }

            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = $"queryAll?explain={Dnf.EscapeDataString(query)}"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #11
0
        public BatchSubRequest BasicInformation(string objectName)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }

            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = $"sobjects/{objectName}"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #12
0
        public BatchSubRequest QuickActions(string objectName, string actionName = "")
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }

            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = $"sobjects/{objectName}/quickActions/{actionName}"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #13
0
        public BatchSubRequest DescribeLayouts(string objectName = "Global")
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }

            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = $"sobjects/{objectName}/describe/layouts/"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #14
0
        public BatchSubRequest ApprovalLayouts(string objectName, string approvalProcessName = "")
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }

            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = $"sobjects/{objectName}/describe/approvalLayouts/{approvalProcessName}"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #15
0
        public BatchSubRequest Query(string query)
        {
            if (string.IsNullOrEmpty(query))
            {
                throw new ArgumentNullException(nameof(query));
            }

            var request = new BatchSubRequest
            {
                ResponseType = "query",
                Method       = "GET",
                Url          = $"query?q={Dnf.EscapeDataString(query)}"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #16
0
        public BatchSubRequest Delete(string objectName, string recordId)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }
            if (string.IsNullOrEmpty(recordId))
            {
                throw new ArgumentNullException(nameof(recordId));
            }

            var request = new BatchSubRequest
            {
                Method = "DELETE",
                Url    = $"sobjects/{objectName}/{recordId}"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #17
0
        public BatchSubRequest Create(string objectName, object record)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            var request = new BatchSubRequest
            {
                RichInput = Dnf.UnFlatten(JObject.FromObject(record)),
                Url       = $"sobjects/{objectName}"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #18
0
        public BatchSubRequest QuickActionsDefaultValues(string objectName, string actionName, string contextId)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }
            if (string.IsNullOrEmpty(actionName))
            {
                throw new ArgumentNullException(nameof(actionName));
            }
            if (string.IsNullOrEmpty(contextId))
            {
                throw new ArgumentNullException(nameof(contextId));
            }

            var request = new BatchSubRequest
            {
                Method = "GET",
                Url    = $"sobjects/{objectName}/quickActions/{actionName}/defaultValues/{contextId}"
            };

            BatchRequests.Add(request);
            return(request);
        }
Exemple #19
0
        public BatchSubRequest DeleteExternal(string objectName, string externalFieldName, string externalId)
        {
            if (string.IsNullOrEmpty(objectName))
            {
                throw new ArgumentNullException(nameof(objectName));
            }
            if (string.IsNullOrEmpty(externalFieldName))
            {
                throw new ArgumentNullException(nameof(externalFieldName));
            }
            if (string.IsNullOrEmpty(externalId))
            {
                throw new ArgumentNullException(nameof(externalId));
            }

            var request = new BatchSubRequest
            {
                Method = "DELETE",
                Url    = $"sobjects/{objectName}/{externalFieldName}/{Uri.EscapeDataString(externalId)}"
            };

            BatchRequests.Add(request);
            return(request);
        }