/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static string GET()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            //KEYS

            //const string consumerKey = "f69a90cbedeca911176fb94fe698844d8d9c454e0ecee0199fc684c9b904c1eb";
            //const string consumerSecret = "3507739ded4db7a084866c8d321f210f3e32782ee6ab7684a824f7862bc6594a";
            //const string accessToken = "3b9b59f3279861339769a191148139c82622f7dead96992a247f8fb3051ec0a7";
            //const string tokenSecret = "6c56bc39d230c5ceaa5e59ef2da41214f3fd39edb7a8dd46c05711edae601eba";
            const string consumerKey    = "f705c6b2a43a7acfe9e6dda2a24389b139daab3195c6eb6418031c44e5c465ab";
            const string consumerSecret = "10e254e3158b31eea1e3f8034cbe0a3c3c0c4553639a8b81047e55afb06c8f83";
            const string accessToken    = "62e84ef0542bdaf8343b469d9c703c59007577659be31a6b48928aed9132ea8a";
            const string tokenSecret    = "3157071cdee78d4a438c062db9b8134d0da1ffb376957e7e8c3b6bfeec4b248d";

            //Endereço base

            const string baseUrl = "https://5022901.restlets.api.netsuite.com/app/site/hosting/restlet.nl";
            //const string baseUrl = "https://5022901-sb1.restlets.api.netsuite.com/app/site/hosting/restlet.nl";
            //https://5022901.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=511&deploy=1&pag_start=2&pag_end=4
            //https://5022901-sb1.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=469&deploy=1&pag_start=2&pag_end=4

            //criando a chamada com seus parametros
            var client = new RestClient(baseUrl);

/*            client.AddDefaultQueryParameter("script", "469");
 *          client.AddDefaultQueryParameter("deploy", "1");
 *          //client.AddDefaultQueryParameter("qtd", "7000");
 *          client.AddDefaultQueryParameter("pag_start", "2");
 *          client.AddDefaultQueryParameter("pag_end", "4");
 */
            client.AddDefaultQueryParameter("script", "511");
            client.AddDefaultQueryParameter("deploy", "1");
            client.AddDefaultQueryParameter("pag_start", "2");
            client.AddDefaultQueryParameter("pag_end", "4");
            var request = new RestRequest(Method.GET);

            request.AddHeader("Content-Type", "application/json");

            //usando as chaves para criar o authorization
            OAuth1Authenticator auth = OAuth1Authenticator.ForProtectedResource(consumerKey, consumerSecret, accessToken, tokenSecret);

            auth.SignatureMethod = OAuthSignatureMethod.HmacSha1;
            auth.Realm           = "5022901";
//            auth.Realm = "5022901_SB1";
            auth.ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader;
            client.Authenticator   = auth;

            //chamada da api

            IRestResponse response  = client.Execute(request);
            var           _resposta = response.Content;

            //return  JsonConvert.DeserializeObject<List<Clientes>>(_resposta);

            return(response.Content);
        }
示例#2
0
        public FluxClient(FluxConnectionOptions options) : base(new RestClient(), new FluxResultMapper())
        {
            _loggingHandler = new LoggingHandler(LogLevel.None);

            var version = AssemblyHelper.GetVersion(typeof(FluxClient));

            RestClient.BaseUrl = new Uri(options.Url);
            RestClient.Timeout = options.Timeout.Milliseconds;
            RestClient.AddDefaultHeader("Accept", "application/json");
            if (!string.IsNullOrEmpty(options.Username))
            {
                if (FluxConnectionOptions.AuthenticationType.BasicAuthentication.Equals(options.Authentication))
                {
                    var auth = Encoding.UTF8.GetBytes(options.Username + ":" + new string(options.Password));
                    RestClient.AddDefaultHeader("Authorization", "Basic " + Convert.ToBase64String(auth));
                }
                else
                {
                    RestClient.AddDefaultQueryParameter("u", options.Username);
                    RestClient.AddDefaultQueryParameter("p", new string(options.Password));
                }
            }
            RestClient.UserAgent = $"influxdb-client-csharp/{version}";
            RestClient.Proxy     = options.WebProxy;
        }
示例#3
0
    public AirQualityRestService(string apiToken)
    {
        restClient = new RestClient("https://api.waqi.info");
        restClient.AddDefaultQueryParameter("token", apiToken);

        restClient.UseNewtonsoftJson();
    }
示例#4
0
        public GoogleMapService(string apiKey)
        {
            if (string.IsNullOrEmpty(nameof(apiKey)))
            {
                throw new ArgumentNullException(nameof(apiKey));
            }

            _client = new RestClient("https://maps.googleapis.com/maps/api/geocode/json");
            _client.AddDefaultQueryParameter("key", apiKey);
        }
示例#5
0
 public EnphaseClient()
 {
     SystemId = Environment.GetEnvironmentVariable("ENPHASE_SYSTEM_ID") ?? DEMO_SYSTEM_ID;
     UserId   = Environment.GetEnvironmentVariable("ENPHASE_USER_ID") ?? DEMO_USER_ID;
     ApiKey   = Environment.GetEnvironmentVariable("ENPHASE_API_KEY") ?? DEMO_API_KEY;
     Client   = new RestClient
     {
         BaseUrl       = new Uri(BASE_URL),
         Authenticator = new SimpleAuthenticator("user_id", UserId, "key", ApiKey)
     };
     Client.UseNewtonsoftJson();
     Client.AddDefaultQueryParameter("datetime_format", "iso8601");
 }
示例#6
0
        private static string POST(string json)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            //KEYS

            const string consumerKey    = "f705c6b2a43a7acfe9e6dda2a24389b139daab3195c6eb6418031c44e5c465ab";
            const string consumerSecret = "10e254e3158b31eea1e3f8034cbe0a3c3c0c4553639a8b81047e55afb06c8f83";
            const string accessToken    = "62e84ef0542bdaf8343b469d9c703c59007577659be31a6b48928aed9132ea8a";
            const string tokenSecret    = "3157071cdee78d4a438c062db9b8134d0da1ffb376957e7e8c3b6bfeec4b248d";

            //Endereço base
            const string baseUrl = "https://5022901.restlets.api.netsuite.com/app/site/hosting/restlet.nl";

            //criando a chamada com seus parametros
            var client = new RestClient(baseUrl);

            client.AddDefaultQueryParameter("script", "463");
            client.AddDefaultQueryParameter("deploy", "1");
            var request = new RestRequest(Method.POST);

            //Parametros
            request.AddHeader("Content-Type", "application/json");
            request.AddParameter("cobranca", json, ParameterType.RequestBody);//tanto faz o primeiro campo, é só para identificar


            //usando as chaves para criar o authorization
            OAuth1Authenticator auth = OAuth1Authenticator.ForProtectedResource(consumerKey, consumerSecret, accessToken, tokenSecret);

            auth.SignatureMethod   = OAuthSignatureMethod.HmacSha1;
            auth.Realm             = "5022901";
            auth.ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader;
            client.Authenticator   = auth;

            //chamada da api
            IRestResponse response = client.Execute(request);

            return(response.Content);
        }
示例#7
0
        public static async Task <string> GetMSToken(string MScode)
        {
            var rest = new RestClient("https://login.live.com/oauth20_token.srf");

            rest.AddDefaultQueryParameter("client_id", "00000000402b5328");
            rest.AddDefaultQueryParameter("code", MScode);
            rest.AddDefaultQueryParameter("grant_type", "authorization_code");
            rest.AddDefaultQueryParameter("redirect_uri", "https://login.live.com/oauth20_desktop.srf");
            rest.AddDefaultQueryParameter("scope", "service::user.auth.xboxlive.com::MBI_SSL");

            rest.AddDefaultHeader("Content-Type", "application/x-www-form-urlencoded");

            var res = await rest.ExecuteGetAsync(new RestRequest());

            var json = JObject.Parse(res.Content);

            output("Response json is: ", json);

            var token = json["access_token"].ToString();

            output("Authorization token is: ", token);

            return(token);
        }
        public FluxClient(FluxConnectionOptions options) : base(new RestClient())
        {
            _loggingHandler = new LoggingHandler(LogLevel.None);

            var version = AssemblyHelper.GetVersion(typeof(FluxClient));

            RestClient.BaseUrl = new Uri(options.Url);
            RestClient.Timeout = options.Timeout.Milliseconds;
            RestClient.AddDefaultHeader("Accept", "application/json");
            if (!string.IsNullOrEmpty(options.Username))
            {
                RestClient.AddDefaultQueryParameter("u", options.Username);
                RestClient.AddDefaultQueryParameter("p", new string(options.Password));
            }
            RestClient.UserAgent = $"influxdb-client-csharp/{version}";
        }
示例#9
0
        /*
         *  project_id
         *  tracker_id
         *  status_id
         *  priority_id
         *  subject
         *  description
         *  category_id
         *  fixed_version_id - ID of the Target Versions (previously called 'Fixed Version' and still referred to as such in the API)
         *  assigned_to_id - ID of the user to assign the issue to (currently no mechanism to assign by name)
         *  parent_issue_id - ID of the parent issue
         *  custom_fields - See Custom fields
         *  watcher_user_ids - Array of user ids to add as watchers (since 2.3.0)
         *  is_private - Use true or false to indicate whether the issue is private or not
         *  estimated_hours - Number of hours estimated for issue
         *  notes - Comments about the update
         *  private_notes - true if notes are private
         */
        private bool UpdateRMTicket(string rmTicketId, Dictionary <string, string> valuesToUpdate)
        {
            if (valuesToUpdate.Count > 0)
            {
                string xmlBegin = "<?xml version=\"1.0\"?><issue>";
                string xmlEnd   = "</issue>";

                var    postUrl = string.Format("issues/{0}.xml", rmTicketId);
                string rawXml  = string.Empty;

                foreach (string key in valuesToUpdate.Keys)
                {
                    rawXml += string.Format("<{0}>{1}</{0}>", key, valuesToUpdate[key], key);
                }

                rawXml = xmlBegin + rawXml + xmlEnd;

                var client = new RestClient("http://pcredmine:3000");
                client.AddDefaultQueryParameter("key", "0533a992d0c093b3b1592e57e10281156ea6afde");
                IRestRequest request = new RestRequest
                {
                    Resource = postUrl
                };

                request.AddHeader("Content-Type", "text/xml");
                request.AddHeader("Accept", "text/xml");
                request.AddParameter("text/xml", rawXml, ParameterType.RequestBody);


                IRestResponse response = client.Put(request);


                Write("UpdateRMTicket: Status: {0} Description {1}", response.ResponseStatus, response.StatusDescription);
                return(response.ResponseStatus == ResponseStatus.Completed);
            }
            Write("UpdateRMTicket: No values provided!");
            return(false);
        }
示例#10
0
 public ComicVineService(string apiKey)
 {
     client = new RestClient(URL);
     client.AddDefaultQueryParameter("api_key", apiKey);
     client.AddDefaultQueryParameter("format", "json");
 }
示例#11
0
 public void GivenIWantToConvertTo(Decimal amount, string fromCurrency, string toCurrency)
 {
     RestClient.AddDefaultQueryParameter("from", fromCurrency);
     RestClient.AddDefaultQueryParameter("to", toCurrency);
     RestClient.AddDefaultQueryParameter("amount", amount.ToString());
 }
示例#12
0
        public GmapsBaseClient(string apiKey)
        {
            _client = new RestClient(_baseUrl);

            _client.AddDefaultQueryParameter("key", apiKey);
        }
示例#13
0
 public KeepaClient(string apiKey)
 {
     _restClient = new RestClient(_apiEndpoint);
     _restClient.AddDefaultQueryParameter("key", apiKey);
 }