shopify-sdk 1.0.0

A Rust SDK for the Shopify API
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
//! Configuration types for the Shopify API SDK.
//!
//! This module provides the core configuration types used to initialize
//! and configure the SDK for API communication with Shopify.
//!
//! # Overview
//!
//! The main types in this module are:
//!
//! - [`ShopifyConfig`]: The main configuration struct holding all SDK settings
//! - [`ShopifyConfigBuilder`]: A builder for constructing [`ShopifyConfig`] instances
//! - [`ApiKey`]: A validated API key newtype
//! - [`ApiSecretKey`]: A validated API secret key newtype with masked debug output
//! - [`ShopDomain`]: A validated Shopify shop domain
//! - [`HostUrl`]: A validated application host URL
//! - [`ApiVersion`]: The Shopify API version to use
//! - [`DeprecationCallback`]: Callback type for API deprecation notices
//!
//! # Example
//!
//! ```rust
//! use shopify_sdk::{ShopifyConfig, ApiKey, ApiSecretKey, ApiVersion};
//!
//! let config = ShopifyConfig::builder()
//!     .api_key(ApiKey::new("my-api-key").unwrap())
//!     .api_secret_key(ApiSecretKey::new("my-secret").unwrap())
//!     .api_version(ApiVersion::latest())
//!     .build()
//!     .unwrap();
//! ```

mod newtypes;
mod version;

pub use newtypes::{ApiKey, ApiSecretKey, HostUrl, ShopDomain};
pub use version::ApiVersion;

// Re-export DeprecationCallback type (defined in this module)

use crate::auth::AuthScopes;
use crate::clients::ApiDeprecationInfo;
use crate::error::ConfigError;
use std::sync::Arc;

/// Callback type for handling API deprecation notices.
///
/// This callback is invoked whenever the SDK receives a response with the
/// `X-Shopify-API-Deprecated-Reason` header, indicating that the requested
/// endpoint or API version is deprecated.
///
/// The callback receives an [`ApiDeprecationInfo`] struct containing the
/// deprecation reason and the request path.
///
/// # Thread Safety
///
/// The callback must be `Send + Sync` to be safely shared across threads
/// and async tasks.
///
/// # Example
///
/// ```rust
/// use shopify_api::{ShopifyConfig, ApiKey, ApiSecretKey, DeprecationCallback};
/// use std::sync::Arc;
///
/// let callback: DeprecationCallback = Arc::new(|info| {
///     eprintln!("Deprecation warning: {} at {:?}", info.reason, info.path);
/// });
///
/// let config = ShopifyConfig::builder()
///     .api_key(ApiKey::new("key").unwrap())
///     .api_secret_key(ApiSecretKey::new("secret").unwrap())
///     .on_deprecation(|info| {
///         println!("API deprecation: {}", info.reason);
///     })
///     .build()
///     .unwrap();
/// ```
pub type DeprecationCallback = Arc<dyn Fn(&ApiDeprecationInfo) + Send + Sync>;

/// Configuration for the Shopify API SDK.
///
/// This struct holds all configuration needed for SDK operations, including
/// API credentials, OAuth scopes, and API version settings.
///
/// # Thread Safety
///
/// `ShopifyConfig` is `Clone`, `Send`, and `Sync`, making it safe to share
/// across threads and async tasks.
///
/// # Key Rotation
///
/// The `old_api_secret_key` field supports seamless key rotation. When
/// validating OAuth HMAC signatures, the SDK will try the primary key first,
/// then fall back to the old key if configured. This allows in-flight OAuth
/// flows to complete during key rotation.
///
/// # Example
///
/// ```rust
/// use shopify_sdk::{ShopifyConfig, ApiKey, ApiSecretKey};
///
/// let config = ShopifyConfig::builder()
///     .api_key(ApiKey::new("your-api-key").unwrap())
///     .api_secret_key(ApiSecretKey::new("your-secret").unwrap())
///     .is_embedded(true)
///     .build()
///     .unwrap();
///
/// assert!(config.is_embedded());
/// ```
#[derive(Clone)]
pub struct ShopifyConfig {
    api_key: ApiKey,
    api_secret_key: ApiSecretKey,
    old_api_secret_key: Option<ApiSecretKey>,
    scopes: AuthScopes,
    host: Option<HostUrl>,
    api_version: ApiVersion,
    is_embedded: bool,
    user_agent_prefix: Option<String>,
    deprecation_callback: Option<DeprecationCallback>,
}

impl std::fmt::Debug for ShopifyConfig {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("ShopifyConfig")
            .field("api_key", &self.api_key)
            .field("api_secret_key", &self.api_secret_key)
            .field("old_api_secret_key", &self.old_api_secret_key)
            .field("scopes", &self.scopes)
            .field("host", &self.host)
            .field("api_version", &self.api_version)
            .field("is_embedded", &self.is_embedded)
            .field("user_agent_prefix", &self.user_agent_prefix)
            .field(
                "deprecation_callback",
                &self.deprecation_callback.as_ref().map(|_| "<callback>"),
            )
            .finish()
    }
}

impl ShopifyConfig {
    /// Creates a new builder for constructing a `ShopifyConfig`.
    ///
    /// # Example
    ///
    /// ```rust
    /// use shopify_sdk::{ShopifyConfig, ApiKey, ApiSecretKey};
    ///
    /// let config = ShopifyConfig::builder()
    ///     .api_key(ApiKey::new("key").unwrap())
    ///     .api_secret_key(ApiSecretKey::new("secret").unwrap())
    ///     .build()
    ///     .unwrap();
    /// ```
    #[must_use]
    pub fn builder() -> ShopifyConfigBuilder {
        ShopifyConfigBuilder::new()
    }

    /// Returns the API key.
    #[must_use]
    pub const fn api_key(&self) -> &ApiKey {
        &self.api_key
    }

    /// Returns the API secret key.
    #[must_use]
    pub const fn api_secret_key(&self) -> &ApiSecretKey {
        &self.api_secret_key
    }

    /// Returns the old API secret key, if configured.
    ///
    /// This is used during key rotation to validate HMAC signatures
    /// created with the previous secret key.
    #[must_use]
    pub const fn old_api_secret_key(&self) -> Option<&ApiSecretKey> {
        self.old_api_secret_key.as_ref()
    }

    /// Returns the OAuth scopes.
    #[must_use]
    pub const fn scopes(&self) -> &AuthScopes {
        &self.scopes
    }

    /// Returns the host URL, if configured.
    #[must_use]
    pub const fn host(&self) -> Option<&HostUrl> {
        self.host.as_ref()
    }

    /// Returns the API version.
    #[must_use]
    pub const fn api_version(&self) -> &ApiVersion {
        &self.api_version
    }

    /// Returns whether the app is embedded.
    #[must_use]
    pub const fn is_embedded(&self) -> bool {
        self.is_embedded
    }

    /// Returns the user agent prefix, if configured.
    #[must_use]
    pub fn user_agent_prefix(&self) -> Option<&str> {
        self.user_agent_prefix.as_deref()
    }

    /// Returns the deprecation callback, if configured.
    ///
    /// This callback is invoked when the SDK receives a response indicating
    /// that an API endpoint is deprecated.
    #[must_use]
    pub fn deprecation_callback(&self) -> Option<&DeprecationCallback> {
        self.deprecation_callback.as_ref()
    }
}

// Verify ShopifyConfig is Send + Sync at compile time
const _: fn() = || {
    const fn assert_send_sync<T: Send + Sync>() {}
    assert_send_sync::<ShopifyConfig>();
};

/// Builder for constructing [`ShopifyConfig`] instances.
///
/// This builder provides a fluent API for configuring the SDK. Required fields
/// are `api_key` and `api_secret_key`. All other fields have sensible defaults.
///
/// # Defaults
///
/// - `api_version`: Latest stable version
/// - `is_embedded`: `true`
/// - `scopes`: Empty
/// - `host`: `None`
/// - `user_agent_prefix`: `None`
/// - `old_api_secret_key`: `None`
/// - `reject_deprecated_versions`: `false`
///
/// # Example
///
/// ```rust
/// use shopify_sdk::{ShopifyConfig, ApiKey, ApiSecretKey, ApiVersion, HostUrl};
///
/// let config = ShopifyConfig::builder()
///     .api_key(ApiKey::new("key").unwrap())
///     .api_secret_key(ApiSecretKey::new("secret").unwrap())
///     .api_version(ApiVersion::V2024_10)
///     .host(HostUrl::new("https://myapp.example.com").unwrap())
///     .is_embedded(false)
///     .user_agent_prefix("MyApp/1.0")
///     .build()
///     .unwrap();
/// ```
#[derive(Default)]
pub struct ShopifyConfigBuilder {
    api_key: Option<ApiKey>,
    api_secret_key: Option<ApiSecretKey>,
    old_api_secret_key: Option<ApiSecretKey>,
    scopes: Option<AuthScopes>,
    host: Option<HostUrl>,
    api_version: Option<ApiVersion>,
    is_embedded: Option<bool>,
    user_agent_prefix: Option<String>,
    reject_deprecated_versions: bool,
    deprecation_callback: Option<DeprecationCallback>,
}

impl std::fmt::Debug for ShopifyConfigBuilder {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("ShopifyConfigBuilder")
            .field("api_key", &self.api_key)
            .field("api_secret_key", &self.api_secret_key)
            .field("old_api_secret_key", &self.old_api_secret_key)
            .field("scopes", &self.scopes)
            .field("host", &self.host)
            .field("api_version", &self.api_version)
            .field("is_embedded", &self.is_embedded)
            .field("user_agent_prefix", &self.user_agent_prefix)
            .field("reject_deprecated_versions", &self.reject_deprecated_versions)
            .field(
                "deprecation_callback",
                &self.deprecation_callback.as_ref().map(|_| "<callback>"),
            )
            .finish()
    }
}

impl ShopifyConfigBuilder {
    /// Creates a new builder with default values.
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    /// Sets the API key (required).
    #[must_use]
    pub fn api_key(mut self, key: ApiKey) -> Self {
        self.api_key = Some(key);
        self
    }

    /// Sets the API secret key (required).
    #[must_use]
    pub fn api_secret_key(mut self, key: ApiSecretKey) -> Self {
        self.api_secret_key = Some(key);
        self
    }

    /// Sets the old API secret key for key rotation support.
    ///
    /// When validating OAuth HMAC signatures, the SDK will try the primary
    /// secret key first, then fall back to this old key if validation fails.
    /// This allows in-flight OAuth flows to complete during key rotation.
    ///
    /// # Example
    ///
    /// ```rust
    /// use shopify_sdk::{ShopifyConfig, ApiKey, ApiSecretKey};
    ///
    /// // During key rotation, configure both keys
    /// let config = ShopifyConfig::builder()
    ///     .api_key(ApiKey::new("key").unwrap())
    ///     .api_secret_key(ApiSecretKey::new("new-secret").unwrap())
    ///     .old_api_secret_key(ApiSecretKey::new("old-secret").unwrap())
    ///     .build()
    ///     .unwrap();
    /// ```
    #[must_use]
    pub fn old_api_secret_key(mut self, key: ApiSecretKey) -> Self {
        self.old_api_secret_key = Some(key);
        self
    }

    /// Sets the OAuth scopes.
    #[must_use]
    pub fn scopes(mut self, scopes: AuthScopes) -> Self {
        self.scopes = Some(scopes);
        self
    }

    /// Sets the host URL.
    #[must_use]
    pub fn host(mut self, host: HostUrl) -> Self {
        self.host = Some(host);
        self
    }

    /// Sets the API version.
    #[must_use]
    pub fn api_version(mut self, version: ApiVersion) -> Self {
        self.api_version = Some(version);
        self
    }

    /// Sets whether the app is embedded in the Shopify admin.
    #[must_use]
    pub const fn is_embedded(mut self, embedded: bool) -> Self {
        self.is_embedded = Some(embedded);
        self
    }

    /// Sets the user agent prefix for HTTP requests.
    #[must_use]
    pub fn user_agent_prefix(mut self, prefix: impl Into<String>) -> Self {
        self.user_agent_prefix = Some(prefix.into());
        self
    }

    /// Sets whether to reject deprecated API versions.
    ///
    /// When `true`, [`build()`](Self::build) will return a
    /// [`ConfigError::DeprecatedApiVersion`] error if the configured API version
    /// is past Shopify's support window.
    ///
    /// When `false` (the default), deprecated versions will log a warning via
    /// `tracing` but the configuration will still be created.
    ///
    /// # Example
    ///
    /// ```rust
    /// use shopify_api::{ShopifyConfig, ApiKey, ApiSecretKey, ApiVersion, ConfigError};
    ///
    /// // This will fail because V2024_01 is deprecated
    /// let result = ShopifyConfig::builder()
    ///     .api_key(ApiKey::new("key").unwrap())
    ///     .api_secret_key(ApiSecretKey::new("secret").unwrap())
    ///     .api_version(ApiVersion::V2024_01)
    ///     .reject_deprecated_versions(true)
    ///     .build();
    ///
    /// assert!(matches!(result, Err(ConfigError::DeprecatedApiVersion { .. })));
    /// ```
    #[must_use]
    pub const fn reject_deprecated_versions(mut self, reject: bool) -> Self {
        self.reject_deprecated_versions = reject;
        self
    }

    /// Sets a callback to be invoked when API deprecation notices are received.
    ///
    /// The callback is called whenever the SDK receives a response with the
    /// `X-Shopify-API-Deprecated-Reason` header. This allows you to track
    /// deprecated API usage in your monitoring systems.
    ///
    /// # Example
    ///
    /// ```rust
    /// use shopify_api::{ShopifyConfig, ApiKey, ApiSecretKey};
    /// use std::sync::atomic::{AtomicUsize, Ordering};
    /// use std::sync::Arc;
    ///
    /// let deprecation_count = Arc::new(AtomicUsize::new(0));
    /// let count_clone = Arc::clone(&deprecation_count);
    ///
    /// let config = ShopifyConfig::builder()
    ///     .api_key(ApiKey::new("key").unwrap())
    ///     .api_secret_key(ApiSecretKey::new("secret").unwrap())
    ///     .on_deprecation(move |info| {
    ///         count_clone.fetch_add(1, Ordering::SeqCst);
    ///         eprintln!("Deprecated: {} at {:?}", info.reason, info.path);
    ///     })
    ///     .build()
    ///     .unwrap();
    /// ```
    #[must_use]
    pub fn on_deprecation<F>(mut self, callback: F) -> Self
    where
        F: Fn(&ApiDeprecationInfo) + Send + Sync + 'static,
    {
        self.deprecation_callback = Some(Arc::new(callback));
        self
    }

    /// Builds the [`ShopifyConfig`], validating that required fields are set.
    ///
    /// # Errors
    ///
    /// Returns [`ConfigError::MissingRequiredField`] if `api_key` or
    /// `api_secret_key` are not set.
    ///
    /// Returns [`ConfigError::DeprecatedApiVersion`] if
    /// [`reject_deprecated_versions(true)`](Self::reject_deprecated_versions) is set
    /// and the configured API version is deprecated.
    pub fn build(self) -> Result<ShopifyConfig, ConfigError> {
        let api_key = self
            .api_key
            .ok_or(ConfigError::MissingRequiredField { field: "api_key" })?;
        let api_secret_key = self
            .api_secret_key
            .ok_or(ConfigError::MissingRequiredField {
                field: "api_secret_key",
            })?;

        let api_version = self.api_version.unwrap_or_else(ApiVersion::latest);

        // Check for deprecated API version
        if api_version.is_deprecated() {
            if self.reject_deprecated_versions {
                return Err(ConfigError::DeprecatedApiVersion {
                    version: api_version.to_string(),
                    latest: ApiVersion::latest().to_string(),
                });
            }
            tracing::warn!(
                version = %api_version,
                latest = %ApiVersion::latest(),
                "Using deprecated API version '{}'. Please upgrade to '{}' or a newer supported version.",
                api_version,
                ApiVersion::latest()
            );
        }

        Ok(ShopifyConfig {
            api_key,
            api_secret_key,
            old_api_secret_key: self.old_api_secret_key,
            scopes: self.scopes.unwrap_or_default(),
            host: self.host,
            api_version,
            is_embedded: self.is_embedded.unwrap_or(true),
            user_agent_prefix: self.user_agent_prefix,
            deprecation_callback: self.deprecation_callback,
        })
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_builder_requires_api_key() {
        let result = ShopifyConfigBuilder::new()
            .api_secret_key(ApiSecretKey::new("secret").unwrap())
            .build();

        assert!(matches!(
            result,
            Err(ConfigError::MissingRequiredField { field: "api_key" })
        ));
    }

    #[test]
    fn test_builder_requires_api_secret_key() {
        let result = ShopifyConfigBuilder::new()
            .api_key(ApiKey::new("key").unwrap())
            .build();

        assert!(matches!(
            result,
            Err(ConfigError::MissingRequiredField {
                field: "api_secret_key"
            })
        ));
    }

    #[test]
    fn test_builder_provides_sensible_defaults() {
        let config = ShopifyConfig::builder()
            .api_key(ApiKey::new("key").unwrap())
            .api_secret_key(ApiSecretKey::new("secret").unwrap())
            .build()
            .unwrap();

        assert_eq!(config.api_version(), &ApiVersion::latest());
        assert!(config.is_embedded());
        assert!(config.scopes().is_empty());
        assert!(config.host().is_none());
        assert!(config.user_agent_prefix().is_none());
        assert!(config.old_api_secret_key().is_none());
    }

    #[test]
    fn test_config_is_send_sync() {
        fn assert_send_sync<T: Send + Sync>() {}
        assert_send_sync::<ShopifyConfig>();
    }

    #[test]
    fn test_config_is_clone_and_debug() {
        let config = ShopifyConfig::builder()
            .api_key(ApiKey::new("key").unwrap())
            .api_secret_key(ApiSecretKey::new("secret").unwrap())
            .build()
            .unwrap();

        let cloned = config.clone();
        assert_eq!(cloned.api_key(), config.api_key());

        // Verify Debug works
        let debug_str = format!("{:?}", config);
        assert!(debug_str.contains("ShopifyConfig"));
    }

    #[test]
    fn test_builder_with_all_optional_fields() {
        let scopes: AuthScopes = "read_products,write_orders".parse().unwrap();
        let host = HostUrl::new("https://myapp.example.com").unwrap();

        let config = ShopifyConfig::builder()
            .api_key(ApiKey::new("key").unwrap())
            .api_secret_key(ApiSecretKey::new("secret").unwrap())
            .scopes(scopes.clone())
            .host(host.clone())
            .api_version(ApiVersion::V2024_10)
            .is_embedded(false)
            .user_agent_prefix("MyApp/1.0")
            .build()
            .unwrap();

        assert_eq!(config.api_version(), &ApiVersion::V2024_10);
        assert!(!config.is_embedded());
        assert_eq!(config.host(), Some(&host));
        assert_eq!(config.user_agent_prefix(), Some("MyApp/1.0"));
    }

    #[test]
    fn test_old_api_secret_key_configuration() {
        let config = ShopifyConfig::builder()
            .api_key(ApiKey::new("key").unwrap())
            .api_secret_key(ApiSecretKey::new("new-secret").unwrap())
            .old_api_secret_key(ApiSecretKey::new("old-secret").unwrap())
            .build()
            .unwrap();

        assert!(config.old_api_secret_key().is_some());
        assert_eq!(config.old_api_secret_key().unwrap().as_ref(), "old-secret");
    }

    #[test]
    fn test_old_api_secret_key_is_optional() {
        let config = ShopifyConfig::builder()
            .api_key(ApiKey::new("key").unwrap())
            .api_secret_key(ApiSecretKey::new("secret").unwrap())
            .build()
            .unwrap();

        assert!(config.old_api_secret_key().is_none());
    }

    #[test]
    fn test_build_allows_deprecated_version_by_default() {
        // By default, deprecated versions should be allowed (with a warning)
        let result = ShopifyConfig::builder()
            .api_key(ApiKey::new("key").unwrap())
            .api_secret_key(ApiSecretKey::new("secret").unwrap())
            .api_version(ApiVersion::V2024_01)
            .build();

        assert!(result.is_ok());
        assert_eq!(result.unwrap().api_version(), &ApiVersion::V2024_01);
    }

    #[test]
    fn test_build_fails_when_reject_deprecated() {
        let result = ShopifyConfig::builder()
            .api_key(ApiKey::new("key").unwrap())
            .api_secret_key(ApiSecretKey::new("secret").unwrap())
            .api_version(ApiVersion::V2024_01)
            .reject_deprecated_versions(true)
            .build();

        assert!(matches!(
            result,
            Err(ConfigError::DeprecatedApiVersion { version, latest })
            if version == "2024-01" && latest == ApiVersion::latest().to_string()
        ));
    }

    #[test]
    fn test_build_succeeds_with_supported_version_when_reject_deprecated() {
        let result = ShopifyConfig::builder()
            .api_key(ApiKey::new("key").unwrap())
            .api_secret_key(ApiSecretKey::new("secret").unwrap())
            .api_version(ApiVersion::V2025_10)
            .reject_deprecated_versions(true)
            .build();

        assert!(result.is_ok());
    }

    #[test]
    fn test_build_succeeds_with_unstable_when_reject_deprecated() {
        let result = ShopifyConfig::builder()
            .api_key(ApiKey::new("key").unwrap())
            .api_secret_key(ApiSecretKey::new("secret").unwrap())
            .api_version(ApiVersion::Unstable)
            .reject_deprecated_versions(true)
            .build();

        assert!(result.is_ok());
    }
}