cloudflare-ruby 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/cloudflare/errors.rb +15 -2
- data/lib/cloudflare/realtime_kit/README.md +2 -0
- data/lib/cloudflare/realtime_kit/app.rb +20 -0
- data/lib/cloudflare/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c7b6b2639357377a873b7f3210578d60f8166999dae878c8f0f7936ead3a4e2e
|
|
4
|
+
data.tar.gz: 50e29bc2641f8d92eca7b3f72866245c0be6d91515bb3096993575bda1346e9e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eec80fb84dbd9ee66181bb557751ce430fb8921ca6111eba8866a05f5bfe33b2fc061e5b1a00ffeff426d3574e75fe18fbef1de5a075e560b66a00d88fd6c12a
|
|
7
|
+
data.tar.gz: f7004207e8e592e0da8afc823ceda1f0dbd81ecafac5da44f4d7d592b9a8629283b2520a60e22a9080d8c1f0e418668f9311b4eb7ec43540f6120c95324b25ab
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
- **`App.current`** — convenience that returns the App matching
|
|
6
|
+
`Cloudflare::RealtimeKit.app_id` (or nil if no match). Useful for
|
|
7
|
+
verifying the configured app_id resolves to a real app and for
|
|
8
|
+
inspecting its name / created_at. Implemented over `App.all` +
|
|
9
|
+
client-side filter; upstream doesn't expose `GET /apps/{id}`.
|
|
10
|
+
|
|
3
11
|
## 0.3.0
|
|
4
12
|
|
|
5
13
|
- **Per-product API tokens.** Set `Cloudflare::RealtimeKit.api_token` to
|
data/lib/cloudflare/errors.rb
CHANGED
|
@@ -3,10 +3,23 @@ module Cloudflare
|
|
|
3
3
|
attr_reader :status, :body
|
|
4
4
|
|
|
5
5
|
def initialize(message = nil, status: nil, body: nil)
|
|
6
|
-
super(message)
|
|
6
|
+
super(message_with_body(message, body))
|
|
7
7
|
@status = status
|
|
8
|
-
@body
|
|
8
|
+
@body = body
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
def message_with_body(message, body)
|
|
13
|
+
return message if body.nil? || body == ""
|
|
14
|
+
"#{message} | body=#{format_body(body)}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def format_body(body)
|
|
18
|
+
case body
|
|
19
|
+
when Hash, Array then body.to_json
|
|
20
|
+
else body.to_s
|
|
21
|
+
end
|
|
22
|
+
end
|
|
10
23
|
end
|
|
11
24
|
|
|
12
25
|
class AuthenticationError < Error; end
|
|
@@ -31,6 +31,8 @@ Top-level tenants. Meetings, sessions, recordings, presets, webhooks, livestream
|
|
|
31
31
|
```ruby
|
|
32
32
|
RK::App.create(name: "Production") # POST /apps
|
|
33
33
|
RK::App.all # GET /apps
|
|
34
|
+
RK::App.current # GET /apps + filter by Cloudflare::RealtimeKit.app_id
|
|
35
|
+
# — verify your configured app_id resolves to a real app
|
|
34
36
|
```
|
|
35
37
|
|
|
36
38
|
## Meetings
|
|
@@ -18,6 +18,9 @@ module Cloudflare
|
|
|
18
18
|
# app.created_at # => Time
|
|
19
19
|
#
|
|
20
20
|
# Cloudflare::RealtimeKit::App.all
|
|
21
|
+
#
|
|
22
|
+
# # Inspect the app the rest of the SDK is configured to use:
|
|
23
|
+
# Cloudflare::RealtimeKit::App.current
|
|
21
24
|
class App < Resource
|
|
22
25
|
collection_path "/accounts/{account_id}/realtime/kit/apps"
|
|
23
26
|
|
|
@@ -45,6 +48,23 @@ module Cloudflare
|
|
|
45
48
|
Array(unwrap_envelope(response)).map { new(_1, scope: scope) }
|
|
46
49
|
end
|
|
47
50
|
|
|
51
|
+
# Returns the App whose id matches +Cloudflare::RealtimeKit.app_id+,
|
|
52
|
+
# or nil if no such app exists in the account. Convenience for
|
|
53
|
+
# verifying that the configured app_id is valid and inspecting the
|
|
54
|
+
# app's name / created_at.
|
|
55
|
+
#
|
|
56
|
+
# Implemented over GET /apps + client-side filter because upstream
|
|
57
|
+
# doesn't expose GET /apps/{id} — see the Resource class docs above
|
|
58
|
+
# for the apps surface.
|
|
59
|
+
#
|
|
60
|
+
# Cloudflare::RealtimeKit::App.current
|
|
61
|
+
# # => #<App id="...", name="tokimonki-exchange-development">
|
|
62
|
+
def current(account_id: nil)
|
|
63
|
+
target = RealtimeKit.app_id
|
|
64
|
+
raise ArgumentError, "Cloudflare::RealtimeKit.app_id not configured" if target.nil?
|
|
65
|
+
all(account_id: account_id).find { |app| app.id == target }
|
|
66
|
+
end
|
|
67
|
+
|
|
48
68
|
private
|
|
49
69
|
def unwrap_create_payload(response)
|
|
50
70
|
payload = unwrap_envelope(response)
|
data/lib/cloudflare/version.rb
CHANGED