public SmartThingsClient(string accessToken)
        {
            var configuration = new Configuration();

            configuration.AccessToken = accessToken ?? throw new ArgumentNullException(accessToken);
            _accessToken = accessToken;

            _devicesApi        = new DevicesApi(configuration);
            _locationsApi      = new LocationsApi(configuration);
            _roomsApi          = new RoomsApi(configuration);
            _scenesApi         = new ScenesApi(configuration);
            _rulesApi          = new RulesApi(configuration);
            _schedulesApi      = new SchedulesApi(configuration);
            _appsApi           = new AppsApi(configuration);
            _subscriptionsApi  = new SubscriptionsApi(configuration);
            _installedAppsApi  = new InstalledappsApi(configuration);
            _deviceProfilesApi = new ProfilesApi(configuration);
            _capabilitiesApi   = new CapabilitiesApi(configuration);
            _presentationApi   = new PresentationsApi(configuration);

            //_accessToken = accessToken;
            //_devicesApi = new DevicesApi();
            //_locationsApi = new LocationsApi();
            //_roomsApi = new RoomsApi();
            //_scenesApi = new ScenesApi();
            //_rulesApi = new RulesApi();
            //_schedulesApi = new SchedulesApi();
            //_appsApi = new AppsApi();
            //_subscriptionsApi = new SubscriptionsApi();
            //_installedAppsApi = new InstalledappsApi();
            //_deviceProfilesApi = new ProfilesApi();
            //_capabilitiesApi = new CapabilitiesApi();
            //_presentationApi = new PresentationsApi();
        }
Exemple #2
0
        public IActionResult Get()
        {
            var locationsApi = new LocationsApi();
            var locations    = locationsApi.ListLocations();

            return(new JsonResult(locations));
        }
 public void GetLocationsByUser()
 {
     var locationApi = new LocationsApi();
     locationApi.BaseUrl = "http://wingis.geodan.nl/location/api/";
     var result = locationApi.GetLocations("bert");
     Assert.True(result.Count > 0);
 }
Exemple #4
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposedValue)
            {
                if (disposing)
                {
                    _allDevices        = null;
                    _allLocations      = null;
                    _allRooms          = null;
                    _allScenes         = null;
                    _allRules          = null;
                    _allSchedules      = null;
                    _allApps           = null;
                    _allSubscriptions  = null;
                    _allInstalledApps  = null;
                    _allDeviceProfiles = null;

                    _devicesApi        = null;
                    _locationsApi      = null;
                    _roomsApi          = null;
                    _scenesApi         = null;
                    _rulesApi          = null;
                    _schedulesApi      = null;
                    _appsApi           = null;
                    _subscriptionsApi  = null;
                    _installedAppsApi  = null;
                    _deviceProfilesApi = null;
                }
                _disposedValue = true;
            }
        }
Exemple #5
0
 private static IList <Location> GetApplicationLocations(SquareSettings squareSettings, ILogger logger)
 {
     try
     {
         var config            = GetConfiguration(squareSettings);
         var locationsApi      = new LocationsApi(config);
         var locationsResponse = locationsApi.ListLocations();
         if (locationsResponse?.Locations == null)
         {
             throw new Exception("Empty locations response received");
         }
         if (locationsResponse.Errors?.Any() ?? false)
         {
             throw new Exception("Errors occurred while retrieving locations." +
                                 string.Join(",", locationsResponse.Errors));
         }
         //filter active locations that can process cards
         var activeLocations = locationsResponse.Locations
                               .Where(x => x.Status == "ACTIVE" && (x.Capabilities == null || x.Capabilities.Contains("CREDIT_CARD_PROCESSING"))).ToList();
         return(activeLocations);
     }
     catch (Exception ex)
     {
         logger.Log <SquareHelper>(LogLevel.Error, ex.Message, ex);
         return(new List <Location>());
     }
 }
Exemple #6
0
        static public async Task <ListLocationsResponse> GetLocations()
        {
            LocationsApi api = new LocationsApi();

            ListLocationsResponse resp = await api.ListLocationsAsync();

            return(resp);
        }
 public void GetTrackeeTrail()
 {
     //http://wingis/location/api/trail?username=NS&trackeename=2143&starttime=2013-03-11T09%3A43%3A29&endTime=2013-03-11T10%3A13%3A29
     var locationApi = new LocationsApi();
     locationApi.BaseUrl = "http://wingis.geodan.nl/location/api/";
     var result = locationApi.GetTrail("NS", "2143", new DateTime(2013, 3, 11,9,0,0), new DateTime(2013, 3, 12,9,30,0));
     Assert.True(result.Count > 0);
 }
Exemple #8
0
        public void Init()
        {
            instance     = new LocationsApi();
            testAccounts = new TestAccounts();
            var sandboxAccount = testAccounts["US-Prod-Sandbox"];

            Configuration.Default.AccessToken = sandboxAccount.AccessToken;
        }
Exemple #9
0
        private static LocationsApi LocationsApiFactory(IServiceProvider arg)
        {
            IHttpClientFactory factory       = arg.GetRequiredService <IHttpClientFactory>();
            HttpClient         httpClient    = factory.CreateClient("cocApi");
            TokenProvider      tokenProvider = arg.GetRequiredService <TokenProvider>();
            LocationsApi       locationsApi  = new LocationsApi(httpClient, tokenProvider);

            return(locationsApi);
        }
Exemple #10
0
        public ClansClient(
            Cache.ClientConfiguration cacheConfiguration,
            ClansApi clansApi, PlayersClient playersCache, LocationsApi locationsApi, PlayersApi playersApi)
            : base(cacheConfiguration, clansApi, playersCache)
        {
            _playersCache = playersCache;
            _locationsApi = locationsApi;
            _playersApi   = playersApi;

            ClanUpdated       += OnClanUpdated;
            ClanWarAdded      += OnClanWarAdded;
            ClanWarLogUpdated += OnClanWarLogUpdated;
            ClanWarUpdated    += OnClanWarUpdated;
            Log += OnLog;
        }
Exemple #11
0
        public SmartThingsClient(string accessToken)
        {
            var configuration = new Configuration();

            configuration.AccessToken = accessToken ?? throw new ArgumentNullException(accessToken);
            //configuration.BasePath = "https://graph-eu01-euwest1.api.smartthings.com/v1";

            _devicesApi        = new DevicesApi(configuration);
            _locationsApi      = new LocationsApi(configuration);
            _roomsApi          = new RoomsApi(configuration);
            _scenesApi         = new ScenesApi(configuration);
            _rulesApi          = new RulesApi(configuration);
            _schedulesApi      = new SchedulesApi(configuration);
            _appsApi           = new AppsApi(configuration);
            _subscriptionsApi  = new SubscriptionsApi(configuration);
            _installedAppsApi  = new InstalledAppsApi(configuration);
            _deviceProfilesApi = new DeviceProfilesApi(configuration);
        }
Exemple #12
0
        /// <summary>
        /// Get active business locations
        /// </summary>
        /// <returns>List of location</returns>
        public IList <Location> GetActiveLocations()
        {
            try
            {
                //create location API
                var configuration = CreateApiConfiguration();
                var locationsApi  = new LocationsApi(configuration);

                //get list of all locations
                var listLocationsResponse = locationsApi.ListLocations();
                if (listLocationsResponse == null)
                {
                    throw new NopException("No service response");
                }

                //check whether there are errors in the service response
                if (listLocationsResponse.Errors?.Any() ?? false)
                {
                    var errorsMessage = string.Join(";", listLocationsResponse.Errors.Select(error => error.ToString()));
                    throw new NopException($"There are errors in the service response. {errorsMessage}");
                }

                //filter active locations and locations that can process credit cards
                var activeLocations = listLocationsResponse.Locations?.Where(location => location?.Status == Location.StatusEnum.ACTIVE &&
                                                                             (location.Capabilities?.Contains(Location.CapabilitiesEnum.PROCESSING) ?? false)).ToList();
                if (!activeLocations?.Any() ?? true)
                {
                    throw new NopException("There are no active locations for the account");
                }

                return(activeLocations);
            }
            catch (Exception exception)
            {
                //log full error
                _logger.Error($"Square payment error: {exception.Message}.", exception, _workContext.CurrentCustomer);

                return(new List <Location>());
            }
        }
        /// <summary>
        /// Get active business locations
        /// </summary>
        /// <returns>List of location</returns>
        public IList<Location> GetActiveLocations()
        {
            try
            {
                //create location API
                var configuration = CreateApiConfiguration();
                var locationsApi = new LocationsApi(configuration);

                //get list of all locations
                var listLocationsResponse = locationsApi.ListLocations();
                if (listLocationsResponse == null)
                    throw new NopException("No service response");

                //check whether there are errors in the service response
                if (listLocationsResponse.Errors?.Any() ?? false)
                {
                    var errorsMessage = string.Join(";", listLocationsResponse.Errors.Select(error => error.ToString()));
                    throw new NopException($"There are errors in the service response. {errorsMessage}");
                }

                //filter active locations
                var activeLocations = listLocationsResponse.Locations?.Where(location => location?.Status == Location.StatusEnum.ACTIVE).ToList();
                if (!activeLocations?.Any() ?? true)
                    throw new NopException("There are no active locations for the account");

                return activeLocations;
            }
            catch (Exception exception)
            {
                var errorMessage = $"Square payment error: {exception.Message}.";
                if (exception is ApiException apiException)
                    errorMessage = $"{errorMessage} Details: {apiException.ErrorCode} - {apiException.ErrorContent}";

                //log errors
                _logger.Error(errorMessage, exception, _workContext.CurrentCustomer);

                return new List<Location>();
            }
        }
Exemple #14
0
        public static List <Transaction> GetTransactions(string apiKey, DateTime startDate, DateTime endDate)
        {
            Configuration.Default.AccessToken = apiKey;

            var locationClient    = new LocationsApi();
            var transactionClient = new V1TransactionsApi();

            var locations = locationClient.ListLocations();
            var payments  = new List <V1Payment>();

            foreach (var location in locations.Locations)
            {
                payments.AddRange(transactionClient.ListPayments(
                                      location.Id,
                                      null,
                                      startDate.ToString("yyyy-MM-ddTHH:mm:ssZ"),
                                      endDate.ToString("yyyy-MM-ddTHH:mm:ssZ")));
            }

            var transactions = payments.Select(SquareMapping.MapToTransaction).ToList();

            return(transactions);
        }
Exemple #15
0
        public ListLocationsResponse GetLocations()
        {
            var locations = new LocationsApi();

            return(locations.ListLocations());
        }
 public override void Initialize()
 {
     base.Initialize();
     locationsApi = new LocationsApi(this.subscription);
 }
 public void Init()
 {
     instance = new LocationsApi();
 }
Exemple #18
0
 internal LocationCallerBase(LocationsApi locationsApi)
 {
     this.locationsApi = locationsApi;
 }
 public CallGetLocations(LocationsApi locationsApi) : base(locationsApi)
 {
 }
 public override void Initialize()
 {
     base.Initialize();
     locationsApi = new LocationsApi(this.subscription);
 }
Exemple #21
0
 public SquareLocationsService(SquareConfig config, SquareMerchantCredentials credentials) : base(config, credentials)
 {
     _locationsApi = new LocationsApi(base.ApiConfiguration);
 }