-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAppStore_InfoApp.class.cs
66 lines (59 loc) · 1.71 KB
/
AppStore_InfoApp.class.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Developer by : Azozz ALFiras
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
public class AppStoreInfoApp
{
private readonly HttpClient httpClient = new HttpClient();
public async Task<JObject> SentRequest(string bundleId)
{
string url = $"http://itunes.apple.com/lookup?bundleId={bundleId}";
string response = await httpClient.GetStringAsync(url);
JObject data = JObject.Parse(response);
return data["results"][0] as JObject;
}
public async Task<JObject> GetInfoApp(string bundleId, string version)
{
JObject data = await SentRequest(bundleId);
string vAppStore = data["version"].ToString();
string appLink = data["trackViewUrl"].ToString();
if (vAppStore == version)
{
return ResponseApi("Yes", appLink);
}
else
{
return ResponseApi("No", appLink);
}
}
public JObject ResponseApi(string status, string url)
{
if (status == "Yes")
{
return new JObject
{
{ "status", "success" },
{ "status_message", "There is no application update" }
};
}
else
{
return new JObject
{
{ "status", "failed" },
{ "status_message", "The version does not match. An update is required" },
{ "app_link", url }
};
}
}
}
public class Program
{
public static async Task Main()
{
var app = new AppStoreInfoApp();
var result = await app.GetInfoApp("your_bundle_id", "your_version");
Console.WriteLine(result);
}
}