Exemplo n.º 1
0
        /// <summary>
        /// Creates a new context using the supplied settings.
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentException"></exception>
        public ApiContext(string apiBaseUrl, string apiKey)
        {
            ApiBaseUrl = apiBaseUrl ?? throw new ArgumentNullException(nameof(apiBaseUrl));
            ApiKey     = apiKey ?? throw new ArgumentNullException(nameof(apiKey));
            if (string.IsNullOrWhiteSpace(ApiBaseUrl))
            {
                throw new ArgumentException("Cannot be blank.", nameof(apiBaseUrl));
            }
            if (string.IsNullOrWhiteSpace(ApiKey))
            {
                throw new ArgumentException("Cannot be blank.", nameof(apiKey));
            }

            if (!ApiBaseUrl.EndsWith("/"))
            {
                ApiBaseUrl += "/";
            }

            Customers     = new CustomerApiEndpoint(this);
            Contacts      = new ContactApiEndpoint(this);
            Agents        = new AgentApiEndpoint(this);
            Alerts        = new AlertApiEndpoint(this);
            Invoices      = new InvoiceApiEndpoint(this);
            ProductRates  = new RateApiEndpoint(this, "products");
            ExpenseRates  = new RateApiEndpoint(this, "expenses");
            Contracts     = new ContractApiEndpoint(this);
            KnowledgeBase = new KnowledgeBaseApiEndpoint(this);
            Tickets       = new TicketApiEndpoint(this);
            CustomValues  = new CustomValueApiEndpoint(this);
        }