コード例 #1
0
        /// <summary>
        /// Queries records.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="pagingRequest"></param>
        /// <returns></returns>
        public async Task <ApiResponse <GetPagedRecordsResponse> > QueryRecordsAsync(QueryRecordsRequest request, PagingRequest pagingRequest = null)
        {
            Arg.IsNotNull(request, nameof(request));

            var path        = UrlHelper.GetQueryRecordsPath(pagingRequest);
            var apiResponse = await PostAsync <GetPagedRecordsResponse>(path, request);

            return(apiResponse);
        }
コード例 #2
0
        public static void Example1()
        {
            everymessageCredential credential = everymessageCredential.Create("demo", "2sd3ODILm5wXzcWPPKe4CwPK9gDEPk@JsAL7q9!pKANCJWtwN0!skDRta67z@NvY");
            WorkflowClient         client     = WorkflowClient.Create("https://api.everymessage.com/workflow/", credential);

            // SUBMIT example

            SubmitRecordsRequest submitRequest = new SubmitRecordsRequest()
            {
                InstanceName = "demo_simple_sms",
                Records      = new List <WorkflowRecord>()
                {
                    new WorkflowRecord()
                    {
                        PrimaryReference = "DEMO001",
                        FirstName        = "Mark",
                        PhoneNumber      = "07777777777",
                        Variables        = new List <WorkflowVariable>()
                        {
                            WorkflowVariable.Create("amount", 311.24M),
                            WorkflowVariable.Create("due", DateTime.Now.ToString("dd MMM yyyy"))
                        }
                    },
                    new WorkflowRecord()
                    {
                        PrimaryReference = "DEMO002",
                        FirstName        = "Hannah",
                        PhoneNumber      = "07777777778",
                        Variables        = new List <WorkflowVariable>()
                        {
                            WorkflowVariable.Create("amount", 16.07M),
                            WorkflowVariable.Create("due", DateTime.Now.ToString("dd MMM yyyy"))
                        }
                    }
                }
            };

            var submitResponse = client.SubmitRecords(submitRequest);

            // QUERY example

            QueryRecordsRequest queryRequest = new QueryRecordsRequest()
            {
                Records = new List <long>()
                {
                    submitResponse.Body.Records[0].WorkflowRecordId, submitResponse.Body.Records[1].WorkflowRecordId
                },
                IncludeActivities       = true,
                IncludeSmsInformation   = true,
                IncludeEmailInformation = true,
                IncludeRepositoryData   = true
            };

            var queryResponse = client.QueryRecords(queryRequest);

            // DELETE example

            DeleteRecordsRequest deleteRequest = new DeleteRecordsRequest()
            {
                Records = new List <long>()
                {
                    submitResponse.Body.Records[0].WorkflowRecordId, submitResponse.Body.Records[1].WorkflowRecordId
                }
            };

            var deleteResponse = client.DeleteRecords(deleteRequest);

            Console.Read();
        }
コード例 #3
0
        public async Task CrudAsync()
        {
            // Prepare initial record.
            var record = TestDataFactory.GetFullyFilledOutRecord(_appIdWithRecords, default);

            // Insert
            var insertResponse = await _apiClient.SaveRecordAsync(record);       // Used for single delete

            var secondInsertResponse = await _apiClient.SaveRecordAsync(record); // Used for batch delete

            AssertHelper.AssertSuccess(insertResponse);

            // Update
            record.RecordId = insertResponse.Value.Id;
            UpdateRecordFields(record);

            var updateResponse = await _apiClient.SaveRecordAsync(record);

            AssertHelper.AssertSuccess(updateResponse);

            // Reads
            // Get by ID
            var getRequest = new GetRecordRequest(_appIdWithRecords, insertResponse.Value.Id)
            {
                FieldIds = { _fieldId },
            };
            var getResponse = await _apiClient.GetRecordAsync(getRequest);

            AssertHelper.AssertSuccess(getResponse);
            AssertHelper.AssertCasting(getResponse.Value);

            // Get batch
            var getBatchRequest = new GetRecordsRequest
            {
                AppId     = _appIdWithRecords,
                RecordIds = { insertResponse.Value.Id, secondInsertResponse.Value.Id },
                FieldIds  = { _fieldId },
            };
            var batchGetResponse = await _apiClient.GetRecordsAsync(getBatchRequest);

            AssertHelper.AssertSuccess(batchGetResponse);
            AssertHelper.AssertCasting(batchGetResponse.Value.Items);

            // Get by app
            var pagingRequest   = new PagingRequest(1, 10);
            var getByAppRequest = new GetRecordsByAppRequest(_appIdWithRecords, pagingRequest)
            {
                FieldIds = { _fieldId },
            };
            var getByAppResponse = await _apiClient.GetRecordsForAppAsync(getByAppRequest);

            AssertHelper.AssertSuccess(getByAppResponse);
            AssertHelper.AssertCasting(getByAppResponse.Value.Items);

            // Query
            var queryRequest = new QueryRecordsRequest
            {
                AppId = _appIdWithRecords,
            };
            var queryResponse = await _apiClient.QueryRecordsAsync(queryRequest);

            AssertHelper.AssertSuccess(queryResponse);
            AssertHelper.AssertCasting(queryResponse.Value.Items);

            // Delete
            // Single delete
            var deleteResponse = await _apiClient.DeleteRecordAsync(_appIdWithRecords, insertResponse.Value.Id);

            AssertHelper.AssertSuccess(deleteResponse);

            // Batch delete
            var batchDeleteRequest  = new DeleteRecordsRequest(_appIdWithRecords, new[] { secondInsertResponse.Value.Id });
            var batchDeleteResponse = await _apiClient.DeleteRecordsAsync(batchDeleteRequest);

            AssertHelper.AssertSuccess(batchDeleteResponse);
        }
コード例 #4
0
        public IActionResult QueryRecords(QueryRecordsRequest request, [FromQuery] PagingRequest pagingRequest = null)
        {
            var apiResponse = new GetPagedRecordsResponse();

            return(Ok(apiResponse));
        }