Class: WhopSDK::Client
Constant Summary
collapse
- DEFAULT_MAX_RETRIES =
Default max number of retries to attempt after a failed retryable request.
2
- DEFAULT_TIMEOUT_IN_SECONDS =
Default per-request timeout.
60.0
- DEFAULT_INITIAL_RETRY_DELAY =
Default initial retry delay in seconds. Overall delay is calculated using exponential backoff + jitter.
0.5
- DEFAULT_MAX_RETRY_DELAY =
Default max retry delay in seconds.
8.0
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary
collapse
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: ENV["WHOP_API_KEY"], app_id: ENV["WHOP_APP_ID"], base_url: ENV["WHOP_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ Client
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
|
# File 'lib/whop_sdk/client.rb', line 141
def initialize(
api_key: ENV["WHOP_API_KEY"],
app_id: ENV["WHOP_APP_ID"],
base_url: ENV["WHOP_BASE_URL"],
max_retries: self.class::DEFAULT_MAX_RETRIES,
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
)
base_url ||= "https://api.whop.com/api/v1"
if app_id.nil?
raise ArgumentError.new("app_id is required, and can be set via environ: \"WHOP_APP_ID\"")
end
if api_key.nil?
raise ArgumentError.new("api_key is required, and can be set via environ: \"WHOP_API_KEY\"")
end
= {
"x-whop-app-id" => (@app_id = app_id.to_s)
}
@api_key = api_key.to_s
super(
base_url: base_url,
timeout: timeout,
max_retries: max_retries,
initial_retry_delay: initial_retry_delay,
max_retry_delay: max_retry_delay,
headers:
)
@apps = WhopSDK::Resources::Apps.new(client: self)
@invoices = WhopSDK::Resources::Invoices.new(client: self)
@course_lesson_interactions = WhopSDK::Resources::CourseLessonInteractions.new(client: self)
@products = WhopSDK::Resources::Products.new(client: self)
@companies = WhopSDK::Resources::Companies.new(client: self)
@webhooks = WhopSDK::Resources::Webhooks.new(client: self)
@plans = WhopSDK::Resources::Plans.new(client: self)
@entries = WhopSDK::Resources::Entries.new(client: self)
@forum_posts = WhopSDK::Resources::ForumPosts.new(client: self)
@transfers = WhopSDK::Resources::Transfers.new(client: self)
@ledger_accounts = WhopSDK::Resources::LedgerAccounts.new(client: self)
@memberships = WhopSDK::Resources::Memberships.new(client: self)
@authorized_users = WhopSDK::Resources::AuthorizedUsers.new(client: self)
@app_builds = WhopSDK::Resources::AppBuilds.new(client: self)
@shipments = WhopSDK::Resources::Shipments.new(client: self)
@checkout_configurations = WhopSDK::Resources::CheckoutConfigurations.new(client: self)
@messages = WhopSDK::Resources::Messages.new(client: self)
@chat_channels = WhopSDK::Resources::ChatChannels.new(client: self)
@users = WhopSDK::Resources::Users.new(client: self)
@payments = WhopSDK::Resources::Payments.new(client: self)
@support_channels = WhopSDK::Resources::SupportChannels.new(client: self)
@experiences = WhopSDK::Resources::Experiences.new(client: self)
@reactions = WhopSDK::Resources::Reactions.new(client: self)
@members = WhopSDK::Resources::Members.new(client: self)
@forums = WhopSDK::Resources::Forums.new(client: self)
@promo_codes = WhopSDK::Resources::PromoCodes.new(client: self)
@courses = WhopSDK::Resources::Courses.new(client: self)
@course_chapters = WhopSDK::Resources::CourseChapters.new(client: self)
@course_lessons = WhopSDK::Resources::CourseLessons.new(client: self)
@reviews = WhopSDK::Resources::Reviews.new(client: self)
end
|
Instance Attribute Details
#api_key ⇒ String
The app API key from an app from the /dashboard/developer page
20
21
22
|
# File 'lib/whop_sdk/client.rb', line 20
def api_key
@api_key
end
|
65
66
67
|
# File 'lib/whop_sdk/client.rb', line 65
def app_builds
@app_builds
end
|
#app_id ⇒ String
23
24
25
|
# File 'lib/whop_sdk/client.rb', line 23
def app_id
@app_id
end
|
26
27
28
|
# File 'lib/whop_sdk/client.rb', line 26
def apps
@apps
end
|
62
63
64
|
# File 'lib/whop_sdk/client.rb', line 62
def authorized_users
@authorized_users
end
|
77
78
79
|
# File 'lib/whop_sdk/client.rb', line 77
def chat_channels
@chat_channels
end
|
71
72
73
|
# File 'lib/whop_sdk/client.rb', line 71
def checkout_configurations
@checkout_configurations
end
|
38
39
40
|
# File 'lib/whop_sdk/client.rb', line 38
def companies
@companies
end
|
107
108
109
|
# File 'lib/whop_sdk/client.rb', line 107
def course_chapters
@course_chapters
end
|
32
33
34
|
# File 'lib/whop_sdk/client.rb', line 32
def course_lesson_interactions
@course_lesson_interactions
end
|
110
111
112
|
# File 'lib/whop_sdk/client.rb', line 110
def course_lessons
@course_lessons
end
|
104
105
106
|
# File 'lib/whop_sdk/client.rb', line 104
def courses
@courses
end
|
47
48
49
|
# File 'lib/whop_sdk/client.rb', line 47
def entries
@entries
end
|
89
90
91
|
# File 'lib/whop_sdk/client.rb', line 89
def experiences
@experiences
end
|
50
51
52
|
# File 'lib/whop_sdk/client.rb', line 50
def forum_posts
@forum_posts
end
|
98
99
100
|
# File 'lib/whop_sdk/client.rb', line 98
def forums
@forums
end
|
29
30
31
|
# File 'lib/whop_sdk/client.rb', line 29
def invoices
@invoices
end
|
56
57
58
|
# File 'lib/whop_sdk/client.rb', line 56
def ledger_accounts
@ledger_accounts
end
|
95
96
97
|
# File 'lib/whop_sdk/client.rb', line 95
def members
@members
end
|
59
60
61
|
# File 'lib/whop_sdk/client.rb', line 59
def memberships
@memberships
end
|
74
75
76
|
# File 'lib/whop_sdk/client.rb', line 74
def messages
@messages
end
|
83
84
85
|
# File 'lib/whop_sdk/client.rb', line 83
def payments
@payments
end
|
44
45
46
|
# File 'lib/whop_sdk/client.rb', line 44
def plans
@plans
end
|
35
36
37
|
# File 'lib/whop_sdk/client.rb', line 35
def products
@products
end
|
101
102
103
|
# File 'lib/whop_sdk/client.rb', line 101
def promo_codes
@promo_codes
end
|
92
93
94
|
# File 'lib/whop_sdk/client.rb', line 92
def reactions
@reactions
end
|
113
114
115
|
# File 'lib/whop_sdk/client.rb', line 113
def reviews
@reviews
end
|
68
69
70
|
# File 'lib/whop_sdk/client.rb', line 68
def shipments
@shipments
end
|
86
87
88
|
# File 'lib/whop_sdk/client.rb', line 86
def support_channels
@support_channels
end
|
53
54
55
|
# File 'lib/whop_sdk/client.rb', line 53
def transfers
@transfers
end
|
80
81
82
|
# File 'lib/whop_sdk/client.rb', line 80
def users
@users
end
|
41
42
43
|
# File 'lib/whop_sdk/client.rb', line 41
def webhooks
@webhooks
end
|
Instance Method Details
#verify_user_token(token_or_headers, **opts) ⇒ UserTokenPayload?
Verifies a Whop user token
226
227
228
229
230
|
# File 'lib/whop_sdk/client.rb', line 226
def verify_user_token(, **opts)
verify_user_token!(, **opts)
rescue StandardError
nil
end
|
#verify_user_token!(token_or_headers, **opts) ⇒ UserTokenPayload
Verifies a Whop user token