/// <summary>Initializes a new instance of the <see cref="RebrandlyRequest"/> class.</summary> /// <param name="client">The client creating the request.</param> /// <param name="method">The HTTP method.</param> /// <param name="path">The path of the request.</param> /// <param name="options">The parameters of the request.</param> /// <param name="requestOptions">The special modifiers of the request.</param> public RebrandlyRequest(IRebrandlyClient client, HttpMethod method, string path, BaseOptions options, RequestOptions requestOptions) { if (client == null) { throw new ArgumentNullException(nameof(client)); } this.options = options; Method = method; Uri = BuildUri(client, method, path, options, requestOptions); AuthorizationHeader = BuildAuthorizationHeader(client); }
private static AuthenticationHeaderValue BuildAuthorizationHeader(IRebrandlyClient client) { string apiKey = client.ApiKey; if (apiKey == null) { var message = "No API key provided. Set your API key using " + "`RebrandlyConfiguration.ApiKey = \"<API-KEY>\"`. You can generate API keys " + "from the Rebrandly Dashboard. See " + "https://developers.rebrandly.com/docs/api-key-authentication for details or contact support " + "at https://support.rebrandly.com/hc/en-us/requests/new if you have any questions."; throw new RebrandlyException(message); } return(new AuthenticationHeaderValue("apikey", apiKey)); }
private static Uri BuildUri( IRebrandlyClient client, HttpMethod method, string path, BaseOptions options, RequestOptions requestOptions) { StringBuilder sb = new StringBuilder(); sb.Append(requestOptions?.BaseUrl ?? client.ApiBase); sb.Append(path); if ((method != HttpMethod.Post) && (options != null)) { string queryString = FormEncoder.CreateQueryString(options); if (!string.IsNullOrEmpty(queryString)) { sb.Append("?"); sb.Append(queryString); } } return(new Uri(sb.ToString())); }
/// <summary> /// Initializes a new instance of the <see cref="Service{EntityReturned}"/> class with a /// custom <see cref="IRebrandlyClient"/>. /// </summary> /// <param name="client">The client used by the service to send requests.</param> protected Service(IRebrandlyClient client) { this.client = client; }
public LinkService(IRebrandlyClient client) : base(client) { }
public ScriptService(IRebrandlyClient client) : base(client) { }
public TagService(IRebrandlyClient client) : base(client) { }
public AccountService(IRebrandlyClient client) : base(client) { }
public DomainService(IRebrandlyClient client) : base(client) { }