internal HttpWebRequest CreatePostHttpWebRequest(CloudFlareCredentials credentials, ApiAction action, HttpPostDataCollection postDataCollection) { var request = (HttpWebRequest)HttpWebRequest.Create(cloudFlareApiUrl); request.ContentType = formUrlEndodedContentType; request.Method = WebRequestMethods.Http.Post; if (postDataCollection != null && postDataCollection.Count > 0) { postDataCollection = AppendApiActionToPostDataCollection(postDataCollection, action); postDataCollection = AppendCredentialsToPostDataCollection(postDataCollection, credentials); var postData = postDataCollection.ToString(); var postDataStream = Encoding.UTF8.GetBytes(postData); request.ContentLength = postData.Length; using (var requestStream = request.GetRequestStream()) { requestStream.Write(postDataStream, 0, postDataStream.Length); } } return(request); }
internal HttpPostDataCollection AppendCredentialsToPostDataCollection(HttpPostDataCollection postDataCollection, CloudFlareCredentials credentials) { postDataCollection.Add("tkn", credentials.ApiKey); postDataCollection.Add("email", credentials.EmailAddress); return(postDataCollection); }
public Client(string emailAddress, string apiKey) { this.credentials = new CloudFlareCredentials(emailAddress, apiKey); }
public Client(CloudFlareCredentials credentials) { this.credentials = credentials; }