Esempio n. 1
0
        /// <summary>
        /// Applies the default store id, terminal id and operator if appropriate.
        /// </summary>
        /// <param name="config">A <see cref="ZipClientConfiguration"/> instance containing the default values to use.</param>
        public override void ApplyDefaults(ZipClientConfiguration config)
        {
            if (config == null)
            {
                return;
            }

            this.Terminal ??= config.DefaultTerminalId;

            base.ApplyDefaults(config);
        }
Esempio n. 2
0
        /// <summary>
        /// Applies the default store id, terminal id and operator if appropriate.
        /// </summary>
        /// <param name="config">A <see cref="ZipClientConfiguration"/> instance containing the default values to use.</param>
        public override void ApplyDefaults(ZipClientConfiguration config)
        {
            if (config == null)
            {
                return;
            }
            if (this.Order == null)
            {
                return;
            }

            this.Order.Operator = this.Order.Operator ?? config.DefaultOperator;
            this.StoreId ??= config.DefaultStoreId;
            this.TerminalId ??= config.DefaultTerminalId;

            base.ApplyDefaults(config);
        }
 /// <summary>
 /// Applies default values from the <see cref="ZipClientConfiguration"/> specified to this request, where appropriate.
 /// </summary>
 /// <param name="config">A <see cref="ZipClientConfiguration"/> to read default values from.</param>
 /// <remarks>
 /// <para>Defaults should only be used for values that are not otherwise set (null).</para>
 /// <para>The base version of this method is a no-op, it must be overridden by derived classes to implement the defaults specific to their request format.</para>
 /// <para>This method is called (by <see cref="ZipClient"/>) before the <see cref="Validate"/> method, and should be robust to null/missing/out of range values.</para>
 /// </remarks>
 public virtual void ApplyDefaults(ZipClientConfiguration config)
 {
 }
Esempio n. 4
0
 /// <summary>
 /// Full constructor.
 /// </summary>
 /// <remarks>
 /// <para>If you are injecting an instance of <see cref="HttpClient"/> via the <paramref name="httpClient"/> make sure the 'AllowAutoRedirect' property on the inner most handler (and any intermediate ones)
 /// is set to false. The Zip API returns redirect responses in some situations that must be handled manually by the <see cref="ZipClient"/> instance for correct behaviour to be applied.</para>
 /// </remarks>
 /// <param name="httpClient">See the method remarks for important information. An <see cref="HttpClient"/> instance to use to access the Zip API, or null to have the ZipClient create it's own internally. Supply your own if you wish to apply handlers for logging, retry logic etc.</param>
 /// <param name="configuration">A <see cref="ZipClientConfiguration"/> instance providing client credentials, the API environment to access and other required details.</param>
 public ZipClient(HttpClient?httpClient, ZipClientConfiguration configuration)
 {
     _Configuration          = configuration.GuardNull(nameof(configuration));
     _HttpClient             = httpClient ?? CreateNewHttpClient();
     _HttpClient.BaseAddress = _Configuration.Environment.BaseUrl;
 }
Esempio n. 5
0
 /// <summary>
 /// Partial constructor.
 /// </summary>
 /// <param name="configuration">A <see cref="ZipClientConfiguration"/> instance providing client credentials, the API environment to access and other required details.</param>
 public ZipClient(ZipClientConfiguration configuration) : this(null, configuration)
 {
 }