Skip to content

Commit ba12657

Browse files
committed
Minor updates
1 parent 0cdca84 commit ba12657

6 files changed

Lines changed: 17 additions & 16 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ client.start_webhook_listener
162162

163163
## 📚 API Endpoints
164164

165-
All endpoints automatically use the `/v1` prefix when connecting to `https://api.licensechain.app`.
165+
Use the canonical API base URL `https://api.licensechain.app/v1`. The SDK also accepts the root host and normalizes requests to the same API version.
166166

167167
### Base URL
168168
- **Production**: `https://api.licensechain.app/v1`
@@ -183,7 +183,7 @@ All endpoints automatically use the `/v1` prefix when connecting to `https://api
183183
| `POST` | `/v1/webhooks` | Create webhook |
184184
| `GET` | `/v1/analytics` | Get analytics |
185185

186-
**Note**: The SDK automatically prepends `/v1` to all endpoints, so you only need to specify the path (e.g., `/auth/login` instead of `/v1/auth/login`).
186+
**Note**: The SDK accepts either the root host or the canonical `/v1` base and normalizes endpoint requests automatically.
187187

188188
## 📚 API Reference
189189

@@ -196,7 +196,7 @@ client = LicenseChain::Client.new(
196196
api_key: 'your-api-key',
197197
app_name: 'your-app-name',
198198
version: '1.0.0',
199-
base_url: 'https://api.licensechain.app' # Optional
199+
base_url: 'https://api.licensechain.app/v1' # Optional
200200
)
201201
```
202202

@@ -302,7 +302,7 @@ export LICENSECHAIN_APP_NAME=your-app-name
302302
export LICENSECHAIN_APP_VERSION=1.0.0
303303

304304
# Optional
305-
export LICENSECHAIN_BASE_URL=https://api.licensechain.app
305+
export LICENSECHAIN_BASE_URL=https://api.licensechain.app/v1
306306
export LICENSECHAIN_DEBUG=true
307307
```
308308

@@ -313,7 +313,7 @@ client = LicenseChain::Client.new(
313313
api_key: 'your-api-key',
314314
app_name: 'your-app-name',
315315
version: '1.0.0',
316-
base_url: 'https://api.licensechain.app',
316+
base_url: 'https://api.licensechain.app/v1',
317317
timeout: 30, # Request timeout in seconds
318318
retries: 3, # Number of retry attempts
319319
debug: false, # Enable debug logging

examples/basic_usage.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Configure the SDK
66
LicenseChainRubySdk.configure do |config|
77
config.api_key = 'your-api-key-here'
8-
config.base_url = 'https://api.licensechain.app'
8+
config.base_url = 'https://api.licensechain.app/v1'
99
config.timeout = 30
1010
config.retries = 3
1111
end

lib/licensechain/api_client.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,17 @@ def make_request(method, endpoint, data = nil, params = {})
4949
end
5050

5151
def build_uri(endpoint, params = {})
52-
# Ensure endpoint starts with /v1 prefix
52+
base_url = @config.base_url.sub(%r{/\z}, '')
53+
base_has_v1 = base_url.end_with?('/v1')
5354
normalized_endpoint = if endpoint.start_with?('/v1/')
54-
endpoint
55+
base_has_v1 ? endpoint.sub(%r{\A/v1}, '') : endpoint
5556
elsif endpoint.start_with?('/')
56-
"/v1#{endpoint}"
57+
base_has_v1 ? endpoint : "/v1#{endpoint}"
5758
else
58-
"/v1/#{endpoint}"
59+
base_has_v1 ? "/#{endpoint}" : "/v1/#{endpoint}"
5960
end
60-
61-
uri = URI.join(@config.base_url, normalized_endpoint)
61+
62+
uri = URI.parse("#{base_url}#{normalized_endpoint}")
6263
uri.query = URI.encode_www_form(params) unless params.empty?
6364
uri
6465
end

lib/licensechain/configuration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Configuration
44

55
def initialize
66
@api_key = ENV['LICENSECHAIN_API_KEY']
7-
@base_url = ENV['LICENSECHAIN_BASE_URL'] || 'https://api.licensechain.app'
7+
@base_url = ENV['LICENSECHAIN_BASE_URL'] || 'https://api.licensechain.app/v1'
88
@timeout = 30
99
@retries = 3
1010
@logger = Logger.new(STDOUT)
@@ -16,7 +16,7 @@ def valid?
1616

1717
def reset!
1818
@api_key = nil
19-
@base_url = 'https://api.licensechain.app'
19+
@base_url = 'https://api.licensechain.app/v1'
2020
@timeout = 30
2121
@retries = 3
2222
@logger = Logger.new(STDOUT)

lib/licensechain/enhanced_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module LicenseChain
1313
class EnhancedClient < Client
1414
attr_reader :session_id, :user_data, :initialized
1515

16-
def initialize(app_name:, owner_id:, app_secret:, base_url: 'https://api.licensechain.app', timeout: 30, retries: 3)
16+
def initialize(app_name:, owner_id:, app_secret:, base_url: 'https://api.licensechain.app/v1', timeout: 30, retries: 3)
1717
super
1818
@session_id = nil
1919
@user_data = nil

test/licensechain_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
before do
1111
LicenseChain.configure do |config|
1212
config.api_key = api_key
13-
config.base_url = "https://api.licensechain.app"
13+
config.base_url = "https://api.licensechain.app/v1"
1414
end
1515
end
1616

0 commit comments

Comments
 (0)