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
//! # Open Payments Client Utilities
//!
//! This module provides utility functions for URL manipulation and resource server
//! URL extraction that are commonly used throughout the Open Payments client.
//!
//! ## Functions
//!
//! - [`get_resource_server_url`] - Extract resource server URL from wallet address
//! - [`join_url_paths`] - Safely join URL paths with proper handling
//!
use crateOpClientError;
use crateResult;
use Url;
/// Extracts the resource server URL from a wallet address URL.
///
/// This function takes a wallet address URL
/// and extracts the base resource server URL by removing the wallet address portion.
///
/// ## Arguments
///
/// * `wallet_address_url` - The complete wallet address URL path
///
/// ## Returns
///
/// Returns the resource server base URL as a string, or an error if the URL cannot be parsed.
///
/// ## Errors
///
/// Returns an `OpClientError` with:
/// - `description`: Human-readable error message
/// - `status`: HTTP status text (for HTTP errors)
/// - `code`: HTTP status code (for HTTP errors)
/// - `validation_errors`: List of validation errors (if applicable)
/// - `details`: Additional error details (if applicable)
/// Safely joins a base URL with a path component.
///
/// This function ensures proper URL path joining by handling trailing slashes
/// and ensuring the resulting URL is valid. It's useful for constructing
/// API endpoint URLs from base URLs and relative paths.
///
/// ## Arguments
///
/// * `base_url` - The base URL to join with the path
/// * `path` - The path component to append to the base URL
///
/// ## Returns
///
/// Returns the joined URL as a string, or an error if URL parsing fails.
///
/// ## Errors
///
/// Returns an `OpClientError` with:
/// - `description`: Human-readable error message
/// - `status`: HTTP status text (for HTTP errors)
/// - `code`: HTTP status code (for HTTP errors)
/// - `validation_errors`: List of validation errors (if applicable)
/// - `details`: Additional error details (if applicable)