-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from tranpl/1.1.0
1.1.0
- Loading branch information
Showing
25 changed files
with
1,758 additions
and
959 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
language: csharp | ||
mono: none | ||
dotnet: 2.1.810 | ||
dotnet: 5.0.2 | ||
script: | ||
- dotnet restore | ||
- dotnet build ./RedcapApi/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Net.Http; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using RestSharp; | ||
|
||
using Serilog; | ||
|
||
namespace Redcap.Broker | ||
{ | ||
public partial class ApiBroker: IApiBroker | ||
{ | ||
protected readonly HttpClient httpClient; | ||
protected readonly IRestClient restClient; | ||
public ApiBroker(HttpClient httpClient, IRestClient restClient) | ||
{ | ||
this.httpClient = httpClient; | ||
this.restClient = restClient; | ||
} | ||
public void LogException(Exception ex, | ||
[CallerMemberName] string method = null, | ||
[CallerFilePath] string filePath = null, | ||
[CallerLineNumber] int lineNumber = 0) | ||
{ | ||
var errorMessage = $"Message: {ex.Message}. Method: {method} File: {filePath} LineNumber: {lineNumber}"; | ||
Log.Error($"Message: {ex.Message}. Method: {method} File: {filePath} LineNumber: {lineNumber}"); | ||
throw new Exception(errorMessage); | ||
} | ||
public async Task<T> PostAsync<T>(IRestRequest request, CancellationToken cancellationToken = default) | ||
{ | ||
var response = await restClient.PostAsync<T>(request, cancellationToken); | ||
|
||
return response; | ||
} | ||
public async Task<T> ExecuteAsync<T>(RestRequest request) where T : new() | ||
{ | ||
var response = await restClient.ExecuteAsync<T>(request); | ||
if(response.ErrorException != null) | ||
{ | ||
LogException(response.ErrorException); | ||
} | ||
return response.Data; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
using RestSharp; | ||
|
||
namespace Redcap.Broker | ||
{ | ||
public interface IApiBroker | ||
{ | ||
Task<T> ExecuteAsync<T>(RestRequest request) where T : new(); | ||
void LogException(Exception ex, [CallerMemberName] string method = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int lineNumber = 0); | ||
Task<T> PostAsync<T>(IRestRequest request, CancellationToken cancellationToken = default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Redcap.Models | ||
{ | ||
/// <summary> | ||
/// Simplified demographics instrument that we can test with. | ||
/// </summary> | ||
public class Demographic | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonRequired] | ||
[JsonProperty("record_id")] | ||
public string RecordId { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("first_name")] | ||
public string FirstName { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("last_name")] | ||
public string LastName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace Redcap.Models | ||
{ | ||
/// <summary> | ||
/// Logging type | ||
/// </summary> | ||
public enum LogType | ||
{ | ||
/// <summary> | ||
/// Data Export | ||
/// </summary> | ||
[Display(Name = "export")] | ||
Export, | ||
|
||
/// <summary> | ||
/// Manage/Design | ||
/// </summary> | ||
[Display(Name = "manage")] | ||
Manage, | ||
|
||
/// <summary> | ||
/// User or role created-updated-deleted | ||
/// </summary> | ||
[Display(Name = "user")] | ||
User, | ||
|
||
/// <summary> | ||
/// Record created-updated-deleted | ||
/// </summary> | ||
[Display(Name = "record")] | ||
Record, | ||
|
||
/// <summary> | ||
/// Record created (only) | ||
/// </summary> | ||
[Display(Name = "record_add")] | ||
RecordAdd, | ||
|
||
/// <summary> | ||
/// Record updated (only) | ||
/// </summary> | ||
[Display(Name = "record_edit")] | ||
RecordEdit, | ||
|
||
/// <summary> | ||
/// Record deleted (only) | ||
/// </summary> | ||
[Display(Name = "record_delete")] | ||
RecordDelete, | ||
|
||
/// <summary> | ||
/// Record locking and e-signatures | ||
/// </summary> | ||
[Display(Name ="lock_record")] | ||
LockRecord, | ||
/// <summary> | ||
/// Page views | ||
/// </summary> | ||
/// | ||
[Display(Name = "page_view")] | ||
PageView, | ||
/// <summary> | ||
/// All event types (excluding page views) | ||
/// </summary> | ||
[Display(Name = "")] | ||
All | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
using Newtonsoft.Json; | ||
|
||
namespace Redcap.Models | ||
{ | ||
/// <summary> | ||
/// Data Access Group | ||
/// Example: | ||
/// [{"data_access_group_name":"CA Site","unique_group_name":"ca_site"} | ||
/// {"data_access_group_name":"FL Site","unique_group_name":"fl_site"}, | ||
/// { "data_access_group_name":"New Site","unique_group_name":""}] | ||
/// </summary> | ||
public class RedcapDag | ||
{ | ||
/// <summary> | ||
/// group name | ||
/// </summary> | ||
/// | ||
[JsonProperty("data_access_group_name")] | ||
public string GroupName { get; set; } | ||
/// <summary> | ||
/// auto-generated unique group name | ||
/// </summary> | ||
/// | ||
[JsonProperty("unique_group_name")] | ||
|
||
public string UniqueGroupName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.