-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack0.rb
More file actions
72 lines (68 loc) · 1.81 KB
/
Copy pathstack0.rb
File metadata and controls
72 lines (68 loc) · 1.81 KB
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
# frozen_string_literal: true
require_relative "stack0/version"
require_relative "stack0/errors"
require_relative "stack0/configuration"
require_relative "stack0/http_client"
require_relative "stack0/polling"
require_relative "stack0/client"
# Stack0 Ruby SDK
#
# @example Quick start
# require "stack0"
#
# client = Stack0::Client.new(api_key: ENV["STACK0_API_KEY"])
#
# # Send an email
# client.mail.send(
# from: "[email protected]",
# to: "[email protected]",
# subject: "Hello from Stack0",
# html: "<h1>Welcome!</h1>"
# )
#
# # Upload to CDN
# asset = client.cdn.upload_from_url(url: "https://example.com/image.png")
# puts asset["url"]
#
# # Capture a screenshot
# screenshot = client.screenshots.capture_and_wait(url: "https://example.com")
# puts screenshot["imageUrl"]
#
# # Extract content from a webpage
# extraction = client.extraction.extract_and_wait(url: "https://example.com/article")
# puts extraction["markdown"]
#
module Stack0
class << self
# Configure the SDK globally
#
# @yield [config] Configuration block
# @yieldparam config [Configuration] The configuration instance
#
# @example
# Stack0.configure do |config|
# config.api_key = "stack0_..."
# config.timeout = 60
# end
def configure
yield(configuration)
end
# Get the global configuration
#
# @return [Configuration] The global configuration instance
def configuration
@configuration ||= Configuration.new
end
# Create a new client with the global configuration
#
# @return [Client] A new client instance
def client
Client.new(
api_key: configuration.api_key,
base_url: configuration.base_url,
cdn_url: configuration.cdn_url,
timeout: configuration.timeout
)
end
end
end