Skip to content

Commit

Permalink
Excluded from git ignore Debug folder
Browse files Browse the repository at this point in the history
  • Loading branch information
ion-sapoval committed Dec 13, 2018
1 parent 76434f9 commit dfa5988
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*.userprefs

# Build results
[Dd]ebug/
#[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Threading.Tasks;
using GoogleMeasurementProtocol.Parameters.User;
using Newtonsoft.Json;

namespace GoogleMeasurementProtocol.Requests.Debug
{
public class DebugRequest : IDebugRequest
{
private readonly RequestBase _requestToDebug;

public DebugRequest(RequestBase requestToDebug)
{
_requestToDebug = requestToDebug;
}

public async Task<RequestValidationResponse> PostAsync(ClientId clientId)
{
var response =
await _requestToDebug.PostAsync(clientId, GoogleEndpointAddresses.DebugCollect);

return JsonConvert.DeserializeObject<RequestValidationResponse>(response);
}

public async Task<RequestValidationResponse> PostAsync(UserId userId)
{
var response =
await _requestToDebug.PostAsync(userId, GoogleEndpointAddresses.DebugCollect);

return JsonConvert.DeserializeObject<RequestValidationResponse>(response);
}

public async Task<RequestValidationResponse> GetAsync(ClientId clientId)
{
var response =
await _requestToDebug.GetAsync(clientId, GoogleEndpointAddresses.DebugCollect);

return JsonConvert.DeserializeObject<RequestValidationResponse>(response);
}

public async Task<RequestValidationResponse> GetAsync(UserId userId)
{
var response =
await _requestToDebug.GetAsync(userId, GoogleEndpointAddresses.DebugCollect);

return JsonConvert.DeserializeObject<RequestValidationResponse>(response);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace GoogleMeasurementProtocol.Requests.Debug
{
public class HitParsingResult
{
[JsonProperty(PropertyName = "valid")]
public bool Valid { get; set; }

[JsonProperty(PropertyName = "hit")]
public string Hit { get; set; }

[JsonProperty(PropertyName = "parserMessage")]
public List<ParserMessage> ParserMessages { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Threading.Tasks;
using GoogleMeasurementProtocol.Parameters.User;

namespace GoogleMeasurementProtocol.Requests.Debug
{
public interface IDebugRequest
{
/// <summary>
/// Makes an async Post request to Google Analytics Hit Validation
/// </summary>
/// <param name="clientId">Anonymously identifies a particular user, device, or browser instance</param>
/// <returns>The response root, hitParsingResult, is an array whose length will correspond to the number of hits sent in the original request.
/// Each object in the array will contain the keys valid, hit, and parserMessage.
/// If a hit is invalid, parserMessage will contain an array of objects describing the validation issues.
/// If a hit is valid, parserMessage will be an empty array.</returns>
Task<RequestValidationResponse> PostAsync(ClientId clientId);

/// <summary>
/// Makes an async Post request to Google Analytics
/// </summary>
/// <param name="userId">This is intended to be a known identifier for a user provided by the site owner/tracking library user</param>
/// <returns>The response root, hitParsingResult, is an array whose length will correspond to the number of hits sent in the original request.
/// Each object in the array will contain the keys valid, hit, and parserMessage.
/// If a hit is invalid, parserMessage will contain an array of objects describing the validation issues.
/// If a hit is valid, parserMessage will be an empty array.</returns>
Task<RequestValidationResponse> PostAsync(UserId userId);

/// <summary>
/// Makes an async Get request to Google Analytics Hit Validation
/// </summary>
/// <param name="clientId">Anonymously identifies a particular user, device, or browser instance</param>
/// <returns>The response root, hitParsingResult, is an array whose length will correspond to the number of hits sent in the original request.
/// Each object in the array will contain the keys valid, hit, and parserMessage.
/// If a hit is invalid, parserMessage will contain an array of objects describing the validation issues.
/// If a hit is valid, parserMessage will be an empty array.</returns>
Task<RequestValidationResponse> GetAsync(ClientId clientId);

/// <summary>
/// Makes an async Get request to Google Analytics Hit Validation
/// </summary>
/// <param name="userId">This is intended to be a known identifier for a user provided by the site owner/tracking library user</param>
/// <returns>The response root, hitParsingResult, is an array whose length will correspond to the number of hits sent in the original request.
/// Each object in the array will contain the keys valid, hit, and parserMessage.
/// If a hit is invalid, parserMessage will contain an array of objects describing the validation issues.
/// If a hit is valid, parserMessage will be an empty array.</returns>
Task<RequestValidationResponse> GetAsync(UserId userId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace GoogleMeasurementProtocol.Requests.Debug
{
public class ParserMessage
{
[JsonProperty(PropertyName = "messageType")]
public string MessageType { get; set; }

[JsonProperty(PropertyName = "description")]
public string Description { get; set; }

[JsonProperty(PropertyName = "parameter")]
public string Parameter { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace GoogleMeasurementProtocol.Requests.Debug
{
public class RequestValidationResponse
{
[JsonProperty("hitParsingResult")]
public List<HitParsingResult> HitParsingResults { get; set; }
}
}

0 comments on commit dfa5988

Please sign in to comment.