aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Web/MachineStudioService.cs
blob: 8b43146e11c0e9ae30b069fcb14f666e36470770 (plain)
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.MachineStudio.Common.Authentication;
using Tango.Settings;
using Tango.Transport.Web;
using Tango.Web;

namespace Tango.MachineStudio.Common.Web
{
    public class MachineStudioService : IMachineStudioService
    {
        private WebTransportClient _client;

        public DeploymentSlot Environment { get; set; }

        public MachineStudioService()
        {
            Environment = SettingsManager.Default.GetOrCreate<MachineStudioSettings>().DeploymentSlot;
            _client = new WebTransportClient();
        }

        public Task<CheckForUpdatesResponse> CheckForUpdates(CheckForUpdatesRequest request)
        {
            return _client.PostJson<CheckForUpdatesRequest, CheckForUpdatesResponse>(GetAddress() + "CheckForUpdates", request);
        }

        public Task<UploadVersionResponse> UploadVersion(UploadVersionRequest request)
        {
            return _client.PostJson<UploadVersionRequest, UploadVersionResponse>(GetAddress() + "UploadVersion", request);
        }

        public Task<UploadCompletedResponse> NotifyUploadCompleted(UploadCompletedRequest request)
        {
            return _client.PostJson<UploadCompletedRequest, UploadCompletedResponse>(GetAddress() + "NotifyUploadCompleted", request);
        }

        public Task<LatestVersionResponse> GetLatestVersion(LatestVersionRequest request)
        {
            return _client.PostJson<LatestVersionRequest, LatestVersionResponse>(GetAddress() + "GetLatestVersion", request);
        }

        public Task<DownloadLatestVersionResponse> DownloadLatestVersion(DownloadLatestVersionRequest request)
        {
            return _client.PostJson<DownloadLatestVersionRequest, DownloadLatestVersionResponse>(GetAddress() + "DownloadLatestVersion", request);
        }

        public Task<LoginResponse> Login(LoginRequest request)
        {
            return _client.PostJson<LoginRequest, LoginResponse>(GetAddress() + "Login", request);
        }

        private String GetAddress()
        {
            return Environment.ToAddress() + "/api/MachineStudio/";
        }
    }
}