コード例 #1
0
 /// <summary>
 /// Call method exposed to user
 /// </summary>
 /// <param name="apiCallHandler"></param>
 /// <returns></returns>
 public string Call(IAPICallPreHandler apiCallHandler)
 {
     APIService apiServ = new APIService();
     this.lastRequest = apiCallHandler.GetPayLoad();
     this.lastResponse = apiServ.MakeRequestUsing(apiCallHandler);
     return this.lastResponse;
 }
コード例 #2
0
ファイル: APIServiceTest.cs プロジェクト: kashyapkk/SDKs
 public void makeRequestWithSpecificAccount()
 {
     APIService service = new APIService("Invoice", "1.0.0");
     string request = "requestEnvelope.detailLevel=ReturnAll&requestEnvelope.errorLanguage=en_US&invoiceID=INV2-PCWG-P78G-7EYV-94QY";
     string response = service.makeRequest("SendInvoice", request, "jb-us-seller_api1.paypal.com", null, null);
     StringAssert.Contains("responseEnvelope.ack", response);
 }
コード例 #3
0
ファイル: APIServiceTest.cs プロジェクト: kashyapkk/SDKs
 public void makeRequestWithDefaultAccount()
 {
     APIService service = new APIService("Invoice", "1.7.0");
     string request = "requestEnvelope.detailLevel=ReturnAll&requestEnvelope.errorLanguage=en_US&invoiceID=INV2-PCWG-P78G-7EYV-94QY";
     string response = service.makeRequest("SendInvoice", request, null, null, null);
     StringAssert.Contains("responseEnvelope.ack", response);
 }
コード例 #4
0
ファイル: Notary.cs プロジェクト: venugec/codekit-csharp
                /// <summary>
                /// Notary Constructor
                /// </summary>
                /// <param name="endPoint">endPoint</param>
                /// <param name="apiKey">apiKey</param>
                /// <param name="secretKey">secretKey</param>
                public Notary(string endPoint)
                {
                    signedData = String.Empty;
                    signedPayload = String.Empty;
                    signedSignature = String.Empty;

                    apiService = new APIService(endPoint, "", "/Security/Notary/Rest/1/");
                }
コード例 #5
0
 public void MakeRequestUsingSOAPSignatureCredential()
 {
     defaultSOAPHandler = new DefaultSOAPAPICallHandler(UnitTestConstants.PayloadSOAP, null, null);
     handler = new MerchantAPICallPreHandler(defaultSOAPHandler, UnitTestConstants.APIUserName, null, null);
     service = new APIService();
     string response = service.MakeRequestUsing(handler);
     Assert.IsNotNull(response);
     Assert.IsTrue(response.Contains("<Ack xmlns=\"urn:ebay:apis:eBLBaseComponents\">Success</Ack>"));
 }
コード例 #6
0
 public void MakeRequestUsingNVPSignatureCredential()
 {
     handler = new PlatformAPICallPreHandler(UnitTestConstants.PayloadNVP, "AdaptivePayments", "ConvertCurrency", UnitTestConstants.APIUserName, null, null);
     Thread.Sleep(5000);
     service = new APIService();
     string response = service.MakeRequestUsing(handler);
     Assert.IsNotNull(response);
     Assert.IsTrue(response.Contains("responseEnvelope.ack=Success"));
 }
コード例 #7
0
 public void MakeRequestUsingNVPCertificateCredential()
 {
     handler = new PlatformAPICallPreHandler(ConfigManager.Instance.GetProperties(), Constants.PayloadNVP, "AdaptivePayments", "ConvertCurrency", Constants.CertificateAPIUserName, null, null);
     Thread.Sleep(5000);
     APIService service = new APIService(ConfigManager.Instance.GetProperties());
     string response = service.MakeRequestUsing(handler);
     Assert.IsNotNull(response);
     Assert.IsTrue(response.Contains("responseEnvelope.ack=Success"));
 }
コード例 #8
0
ファイル: Payment.cs プロジェクト: venugec/codekit-csharp
                /// <summary>
                /// Constructor
                /// </summary>
                public Payment(string endPoint, string accessToken)
                {
                    apiService = new APIService(endPoint, accessToken, "/rest/3/Commerce/Payment/");

                    subNotary = new Notary(endPoint);

                    tranNotary = new Notary(endPoint);

                    this.endPoint = endPoint;
                }
コード例 #9
0
        public Task<Token> AcquireTokenForApplicationAsync()
        {
            string uri = string.Format("{0}/{1}/oauth2/token", authUrl, tenant_name);
            string contentType = "application/x-www-form-urlencoded";
            string content = string.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&resource={2}", app_id, HttpUtility.UrlEncode(app_key), HttpUtility.UrlEncode(graphApiUrl));

            APIService service = new APIService(uri, contentType);

            return service.SendAsync<Token>(content);
        }
コード例 #10
0
        public List<Contract> GetContracts()
        {
            string uri = string.Format("{0}/{1}/contracts?api-version=1.6", graphApiUrl, tenant_name);

            APIService service = new APIService(uri);

            service.Request.Headers.Add("Authorization", "Bearer " + oauth_token.access_token);

            dynamic result = service.Get<dynamic>();

            return result.value.ToObject<List<Contract>>();
        }
コード例 #11
0
        public Token AcquireTokenForReseller()
        {
            string uri = string.Format("{0}/{1}", cspApiUrl, "my-org/tokens");
            string contentType = "application/x-www-form-urlencoded";
            string content = "grant_type=client_credentials";

            APIService service = new APIService(uri, contentType);

            service.Request.Headers.Add("api-version", "2015-03-31");
            service.Request.Headers.Add("x-ms-correlation-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("Authorization", "Bearer " + oauth_token);

            return service.Send<Token>(content);
        }
コード例 #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            const string endpoint = "http://enterprise.majesticseo.com/api_command";

            Console.WriteLine("\n***********************************************************"
                              + "*****************");

            Console.WriteLine("\nEndpoint: " + endpoint);

            if ("http://enterprise.majesticseo.com/api_command".Equals(endpoint))
            {
                Console.WriteLine("\nThis program is hard-wired to the Enterprise API.");

                Console.WriteLine("\nIf you do not have access to the Enterprise API, "
                                  + "change the endpoint to: \nhttp://developer.majesticseo.com/api_command.");
            }
            else
            {
                Console.WriteLine("\nThis program is hard-wired to the Developer API "
                                  + "and hence the subset of data \nreturned will be substantially "
                                  + "smaller than that which will be returned from \neither the "
                                  + "Enterprise API or the Majestic SEO website.");

                Console.WriteLine("\nTo make this program use the Enterprise API, change "
                                  + "the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.");
            }

            Console.WriteLine("\n***********************************************************"
                              + "*****************");

            Console.WriteLine(
                "\n\nThis example program will return key information about \"index items\"."
                + "\n\nThe following must be provided in order to run this program: "
                + "\n1. OpenApp \"private key\"\n2. Access Token\n3. List of items to query"
                + "\n\nPlease enter your OpenApp \"private key\":");

            string privateKey = Console.ReadLine();

            Console.WriteLine("Enter your access token:");
            string accessToken = Console.ReadLine();

            Console.WriteLine(
                "\nPlease enter the list of items you wish to query seperated by "
                + "commas: \n(e.g. majesticseo.com, majestic12.co.uk)");

            string itemsToQuery = Console.ReadLine();
            string[] items = Regex.Split(itemsToQuery, ", ");

            /* create a Dictionary from the resulting array with the key being
             * "item0 => first item to query, item1 => second item to query" etc */
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            for (int i = 0; i < items.Length; i++)
            {
                parameters.Add("item" + i, items[i]);
            }

            // add the total number of items to the Dictionary with the key being "items"
            parameters.Add("items", items.Length.ToString());
            parameters.Add("datasource", "fresh");

            APIService apiService = new APIService(privateKey, endpoint);
            Response response = apiService.ExecuteOpenAppRequest("GetIndexItemInfo", parameters, accessToken);

            // check the response code
            if (response.IsOK())
            {
                // print the results table
                DataTable results = response.GetTableForName("Results");

                foreach (Dictionary<string, string> row in results.GetTableRows())
                {
                    string item = row["Item"];
                    Console.WriteLine("\n<" + item + ">");

                    List<string> keys = new List<string>(row.Keys);
                    keys.Sort();

                    foreach (string key in keys)
                    {
                        if (!key.Equals("item"))
                        {
                            string value = row[key];
                            Console.WriteLine(" " + key + " ... " + value);
                        }
                    }
                }

                if ("http://developer.majesticseo.com/api_command".Equals(endpoint))
                {
                    Console.WriteLine("\n\n***********************************************************"
                                      + "*****************");

                    Console.WriteLine("\nEndpoint: " + endpoint);

                    Console.WriteLine("\nThis program is hard-wired to the Developer API "
                                      + "and hence the subset of data \nreturned will be substantially "
                                      + "smaller than that which will be returned from \neither the "
                                      + "Enterprise API or the Majestic SEO website.");

                    Console.WriteLine("\nTo make this program use the Enterprise API, change "
                                      + "the endpoint to: \nhttp://enterprise.majesticseo.com/api_command.");

                    Console.WriteLine("\n***********************************************************"
                                      + "*****************");
                }
            }
            else
            {
                Console.WriteLine("\nERROR MESSAGE:");
                Console.WriteLine(response.GetErrorMessage());

                Console.WriteLine("\n\n***********************************************************"
                                  + "*****************");

                Console.WriteLine("\nDebugging Info:");
                Console.WriteLine("\n  Endpoint: \t" + endpoint);
                Console.WriteLine("  OpenApp \"private key\": \t" + privateKey);
                Console.WriteLine("  Access Token: \t" + accessToken);

                if ("http://enterprise.majesticseo.com/api_command".Equals(endpoint))
                {
                    Console.WriteLine("\n  Is this API Key valid for this Endpoint?");

                    Console.WriteLine("\n  This program is hard-wired to the Enterprise API.");

                    Console.WriteLine("\n  If you do not have access to the Enterprise API, "
                                      + "change the endpoint to: \n  http://developer.majesticseo.com/api_command.");
                }

                Console.WriteLine("\n***********************************************************"
                                  + "*****************");
            }

            Console.Read();
        }
コード例 #13
0
        public Task<Customer> GetResellerAsync()
        {
            string uri = string.Format("{0}/customers/get-by-identity?provider=AAD&type=tenant&tid={1}", cspApiUrl, reseller_id);

            APIService service = new APIService(uri);

            service.Request.Headers.Add("api-version", "2015-03-31");
            service.Request.Headers.Add("x-ms-correlation-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("x-ms-tracking-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("Authorization", "Bearer " + sa_token.access_token);

            return service.GetAsync<Customer>();
        }
コード例 #14
0
        public Task<List<Entitlement>> GetEntitlementsAsync(string CustomerId, Token cus_token)
        {
            string uri = string.Format("{0}/{1}/Entitlements", cspApiUrl, CustomerId);

            APIService service = new APIService(uri);

            service.Request.Headers.Add("api-version", "2015-03-31");
            service.Request.Headers.Add("x-ms-correlation-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("Authorization", "Bearer " + cus_token.access_token);

            dynamic result = service.GetAsync<dynamic>();

            return result.items.ToObject<List<Entitlement>>();
        }
コード例 #15
0
        public Task<UsageRecord> GetUsageAsync(string SubscriptionId, DateTime StartDate, DateTime EndDate, string Granularity, bool ShowDetails, int Count)
        {
            string[] args = new string[] { cspApiUrl, reseller_id, SubscriptionId, StartDate.ToString("yyyy-MM-dd HH:mm:ssZ"), EndDate.ToString("yyyy-MM-dd HH:mm:ssZ"), Granularity, ShowDetails.ToString(), Count.ToString() };
            string uri = string.Format("{0}/{1}/usage-records?entitlement_id={2}&reported_start_time={3}&reported_end_time={4}&granularity={5}&show_details={6}&count={7}", args);

            APIService service = new APIService(uri);

            service.Request.Headers.Add("api-version", "2015-03-31");
            service.Request.Headers.Add("x-ms-correlation-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("Authorization", "Bearer " + sa_token.access_token);

            return service.GetAsync<UsageRecord>();
        }
コード例 #16
0
        public Task<List<Subscription>> GetSubscriptionsByCustomerAsync(string CustomerId)
        {
            string[] args = new string[] { cspApiUrl, reseller_id, CustomerId };
            string uri = string.Format("{0}/{1}/subscriptions?recipient_customer_id={2}", args);

            APIService service = new APIService(uri);

            service.Request.Headers.Add("api-version", "2015-03-31");
            service.Request.Headers.Add("x-ms-correlation-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("Authorization", "Bearer " + sa_token.access_token);

            dynamic result = service.GetAsync<dynamic>();

            return result.items.ToObject<List<Subscription>>();
        }
コード例 #17
0
        public Task<Subscription> GetSubscriptionAsync(string SubscriptionId)
        {
            string[] args = new string[] { cspApiUrl, reseller_id, SubscriptionId };
            string uri = string.Format("{0}/{1}/subscriptions/{2}", args);

            APIService service = new APIService(uri);

            service.Request.Headers.Add("api-version", "2015-03-31");
            service.Request.Headers.Add("x-ms-correlation-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("Authorization", "Bearer " + sa_token.access_token);

            return service.GetAsync<Subscription>();
        }
コード例 #18
0
        public Task<Customer> GetCustomerAsync(string CustomerAADId)
        {
            string[] args = new string[] { cspApiUrl, CustomerAADId, reseller_id };
            string uri = string.Format("{0}/customers/get-by-identity?provider=AAD&type=external_group&tid={1}&etid={2}", args);

            APIService service = new APIService(uri);

            service.Request.Headers.Add("api-version", "2015-03-31");
            service.Request.Headers.Add("x-ms-correlation-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("x-ms-tracking-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("Authorization", "Bearer " + sa_token.access_token);

            return service.GetAsync<Customer>();
        }
コード例 #19
0
        public Task<RateCard> GetRateCardAsync()
        {
            string uri = string.Format("{0}/{1}/rate-card?OfferDurableId=MS-AZR-0145P", cspApiUrl, reseller_id);

            APIService service = new APIService(uri);

            service.Request.Headers.Add("api-version", "2015-03-31");
            service.Request.Headers.Add("x-ms-correlation-id", Guid.NewGuid().ToString());
            service.Request.Headers.Add("Authorization", "Bearer " + sa_token.access_token);

            return service.GetAsync<RateCard>();
        }