Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 55a4efd

Browse files
committed
OutSystems Now v1.0.0
1 parent 6995220 commit 55a4efd

File tree

1,259 files changed

+259592
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,259 files changed

+259592
-0
lines changed

PushSDK/Classes/JsonHelpers.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Newtonsoft.Json.Linq;
2+
3+
namespace PushSDK.Classes
4+
{
5+
internal static class JsonHelpers
6+
{
7+
internal static int GetStatusCode(JObject jRoot)
8+
{
9+
return jRoot.Value<int>("status_code");
10+
}
11+
12+
internal static string GetStatusMessage(JObject jRoot)
13+
{
14+
return jRoot.Value<string>("status_message");
15+
}
16+
}
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Newtonsoft.Json;
2+
3+
namespace PushSDK.Classes
4+
{
5+
[JsonObject]
6+
internal class AppEventRequest : BaseRequest
7+
{
8+
[JsonProperty("goal")]
9+
public string Goal { get; set; }
10+
11+
[JsonProperty("count")]
12+
public int Count { get; set; }
13+
14+
public override string GetMethodName() { return "applicationEvent"; }
15+
}
16+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace PushSDK.Classes
4+
{
5+
[JsonObject]
6+
internal class AppOpenRequest : BaseRequest
7+
{
8+
public override string GetMethodName() { return "applicationOpen"; }
9+
}
10+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
3+
4+
namespace PushSDK.Classes
5+
{
6+
[JsonObject]
7+
internal abstract class BaseRequest
8+
{
9+
[JsonProperty("application")]
10+
public string AppId { get; set; }
11+
12+
// Note: this requires ID_CAP_IDENTITY_DEVICE
13+
// to be added to the capabilities of the WMAppManifest
14+
// this will then warn users in marketplace
15+
[JsonProperty("hwid")]
16+
public string HardwareId
17+
{
18+
get { return SDKHelpers.GetDeviceUniqueId(); }
19+
}
20+
21+
[JsonProperty("v")]
22+
public string SDKVersion
23+
{
24+
//returns SDK version
25+
get { return "2.3"; }
26+
}
27+
28+
[JsonIgnore]
29+
public string ErrorMessage { get; set; }
30+
31+
public virtual void ParseResponse(JObject jRoot) { }
32+
33+
public abstract string GetMethodName();
34+
}
35+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Newtonsoft.Json;
2+
3+
namespace PushSDK.Classes
4+
{
5+
[JsonObject]
6+
internal class GeozoneRequest : BaseRequest
7+
{
8+
[JsonProperty("lat")]
9+
public double Lat { get; set; }
10+
11+
[JsonProperty("lng")]
12+
public double Lon { get; set; }
13+
14+
public override string GetMethodName() { return "getNearestZone"; }
15+
}
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
3+
4+
namespace PushSDK.Classes
5+
{
6+
[JsonObject]
7+
internal class GetTagsRequest : BaseRequest
8+
{
9+
[JsonIgnore]
10+
public JObject Tags { get; set; }
11+
12+
public override void ParseResponse(JObject jRoot)
13+
{
14+
Tags = jRoot["response"].Value<JObject>("result");
15+
}
16+
17+
public override string GetMethodName() { return "getTags"; }
18+
}
19+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Threading;
3+
using Newtonsoft.Json;
4+
using System.Threading.Tasks;
5+
using Windows.UI.Xaml.Controls;
6+
using System.Text.RegularExpressions;
7+
using Windows.ApplicationModel.Core;
8+
using Windows.UI.Core;
9+
using Windows.ApplicationModel;
10+
11+
namespace PushSDK.Classes
12+
{
13+
[JsonObject]
14+
internal class RegistrationRequest : BaseRequest
15+
{
16+
[JsonProperty("device_type")]
17+
public int DeviceType
18+
{
19+
get { return Constants.DeviceType; }
20+
}
21+
22+
[JsonProperty("push_token")]
23+
public string PushToken { get; set; }
24+
25+
[JsonProperty("language")]
26+
public string Language
27+
{
28+
get { return System.Globalization.CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; }
29+
}
30+
31+
[JsonProperty("timezone")]
32+
public double Timezone
33+
{
34+
get { return TimeZoneInfo.Local.BaseUtcOffset.TotalSeconds; }
35+
}
36+
37+
[JsonProperty("app_version")]
38+
public string AppVersion
39+
{
40+
get
41+
{
42+
var version = Package.Current.Id.Version;
43+
return String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
44+
}
45+
}
46+
47+
public override string GetMethodName() { return "registerDevice"; }
48+
}
49+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using Newtonsoft.Json;
2+
3+
namespace PushSDK.Classes
4+
{
5+
[JsonObject]
6+
internal class SendBadgeRequest : BaseRequest
7+
{
8+
[JsonProperty("badge")]
9+
public int Badge { get; set; }
10+
11+
public override string GetMethodName() { return "setBadge"; }
12+
}
13+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Newtonsoft.Json;
2+
3+
namespace PushSDK.Classes
4+
{
5+
[JsonObject]
6+
internal class SendPurchaseRequest : BaseRequest
7+
{
8+
[JsonProperty("productIdentifier")]
9+
public string ProductIdentifier { get; set; }
10+
11+
[JsonProperty("quantity")]
12+
public int Quantity { get; set; }
13+
14+
[JsonProperty("transactionDate")]
15+
public int DateTimeStamp { get; set; }
16+
17+
[JsonProperty("price")]
18+
public double Price { get; set; }
19+
20+
[JsonProperty("currency")]
21+
public string Currency { get; set; }
22+
23+
public override string GetMethodName() { return "setPurchase"; }
24+
}
25+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
3+
using System;
4+
using System.Collections.Generic;
5+
6+
namespace PushSDK.Classes
7+
{
8+
[JsonObject]
9+
internal class SetTagsRequest : BaseRequest
10+
{
11+
[JsonProperty("tags")]
12+
public JObject Tags { get; set; }
13+
14+
public void BuildTags(IEnumerable<KeyValuePair<string, object>> tagList)
15+
{
16+
JObject tags = new JObject();
17+
foreach (var tag in tagList)
18+
{
19+
tags.Add(new JProperty(tag.Key, tag.Value));
20+
}
21+
22+
Tags = tags;
23+
}
24+
25+
public void BuildTags(String[] key, object[] values)
26+
{
27+
JObject tags = new JObject();
28+
29+
int lenght = key.Length >= values.Length ? values.Length : key.Length;
30+
for (int i = 0; i < lenght; i++)
31+
{
32+
tags.Add(new JProperty(key[i], values[i]));
33+
}
34+
35+
Tags = tags;
36+
}
37+
38+
public override string GetMethodName() { return "setTags"; }
39+
}
40+
}

0 commit comments

Comments
 (0)