Class: GetStreamRuby::Client
- Inherits:
-
Object
- Object
- GetStreamRuby::Client
- Defined in:
- lib/getstream_ruby/client.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
-
#chat ⇒ GetStream::Generated::ChatClient
The chat API client.
-
#common ⇒ GetStream::Generated::CommonClient
The common API client.
-
#feed(feed_group_id, feed_id) ⇒ GetStream::Generated::Feed
Create an individual feed instance.
- #feed_resource ⇒ Object
-
#feeds ⇒ GetStream::Generated::FeedsClient
The feeds API client.
-
#initialize(config = nil, api_key: nil, api_secret: nil, **options) ⇒ Client
constructor
A new instance of Client.
- #make_request(method, path, query_params: nil, body: nil) ⇒ Object
-
#moderation ⇒ GetStream::Generated::ModerationClient
The moderation API client.
-
#parse_sns(notification_body) ⇒ Object
Decode + parse a Stream-delivered SNS notification body.
-
#parse_sqs(message_body) ⇒ Object
Decode + parse a Stream-delivered SQS message body.
-
#post(path, body = {}) ⇒ GetStreamRuby::StreamResponse
The API response.
-
#verify_and_parse_webhook(body, signature) ⇒ Object
Verify and parse a webhook payload in one call, using this client’s API secret (CHA-2961).
-
#verify_signature(body, signature) ⇒ Boolean
Verify a webhook signature using this client’s API secret (CHA-2961).
-
#video ⇒ GetStream::Generated::VideoClient
The video API client.
Constructor Details
#initialize(config = nil, api_key: nil, api_secret: nil, **options) ⇒ Client
Returns a new instance of Client.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/getstream_ruby/client.rb', line 25 def initialize(config = nil, api_key: nil, api_secret: nil, **) @configuration = config || GetStreamRuby.configuration # Create new configuration with overrides if any parameters provided if api_key || api_secret || !.empty? @configuration = Configuration.with_overrides( api_key: api_key, api_secret: api_secret, **, ) end @configuration.validate! @connection = build_connection end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
23 24 25 |
# File 'lib/getstream_ruby/client.rb', line 23 def configuration @configuration end |
Instance Method Details
#chat ⇒ GetStream::Generated::ChatClient
Returns The chat API client.
63 64 65 |
# File 'lib/getstream_ruby/client.rb', line 63 def chat @chat ||= GetStream::Generated::ChatClient.new(self) end |
#common ⇒ GetStream::Generated::CommonClient
Returns The common API client.
48 49 50 |
# File 'lib/getstream_ruby/client.rb', line 48 def common @common ||= GetStream::Generated::CommonClient.new(self) end |
#feed(feed_group_id, feed_id) ⇒ GetStream::Generated::Feed
Create an individual feed instance
76 77 78 |
# File 'lib/getstream_ruby/client.rb', line 76 def feed(feed_group_id, feed_id) GetStream::Generated::Feed.new(self, feed_group_id, feed_id) end |
#feed_resource ⇒ Object
41 42 43 |
# File 'lib/getstream_ruby/client.rb', line 41 def feed_resource @feed_resource ||= Resources::Feed.new(self) end |
#feeds ⇒ GetStream::Generated::FeedsClient
Returns The feeds API client.
53 54 55 |
# File 'lib/getstream_ruby/client.rb', line 53 def feeds @feeds ||= GetStream::Generated::FeedsClient.new(self) end |
#make_request(method, path, query_params: nil, body: nil) ⇒ Object
133 134 135 136 137 138 139 140 141 142 |
# File 'lib/getstream_ruby/client.rb', line 133 def make_request(method, path, query_params: nil, body: nil) # Handle query parameters if query_params && !query_params.empty? query_string = query_params.map { |k, v| "#{k}=#{v}" }.join('&') path = "#{path}?#{query_string}" end # Make the request request(method, path, body) end |
#moderation ⇒ GetStream::Generated::ModerationClient
Returns The moderation API client.
58 59 60 |
# File 'lib/getstream_ruby/client.rb', line 58 def moderation @moderation ||= GetStream::Generated::ModerationClient.new(self) end |
#parse_sns(notification_body) ⇒ Object
Decode + parse a Stream-delivered SNS notification body.
Accepts either the raw SNS HTTP envelope JSON or the pre-extracted Message string. Convenience wrapper around StreamChat::Webhook.parse_sns. No signature is required; SNS deliveries are authenticated via AWS IAM.
122 123 124 |
# File 'lib/getstream_ruby/client.rb', line 122 def parse_sns(notification_body) StreamChat::Webhook.parse_sns(notification_body) end |
#parse_sqs(message_body) ⇒ Object
Decode + parse a Stream-delivered SQS message body.
Convenience wrapper around StreamChat::Webhook.parse_sqs. No signature is required; SQS deliveries are authenticated via AWS IAM.
113 114 115 |
# File 'lib/getstream_ruby/client.rb', line 113 def parse_sqs() StreamChat::Webhook.parse_sqs() end |
#post(path, body = {}) ⇒ GetStreamRuby::StreamResponse
Returns The API response.
129 130 131 |
# File 'lib/getstream_ruby/client.rb', line 129 def post(path, body = {}) request(:post, path, body) end |
#verify_and_parse_webhook(body, signature) ⇒ Object
Verify and parse a webhook payload in one call, using this client’s API secret (CHA-2961).
Handles gzip-compressed bodies transparently. Raises StreamChat::Webhook::InvalidWebhookError on signature mismatch or parse failures; distinguish failure modes via the message substring.
105 106 107 |
# File 'lib/getstream_ruby/client.rb', line 105 def verify_and_parse_webhook(body, signature) StreamChat::Webhook.verify_and_parse_webhook(body, signature, @configuration.api_secret) end |
#verify_signature(body, signature) ⇒ Boolean
Verify a webhook signature using this client’s API secret (CHA-2961).
Convenience wrapper around StreamChat::Webhook.verify_signature that supplies the secret automatically. The module-level method is still available for callers that need to verify with an arbitrary secret.
89 90 91 |
# File 'lib/getstream_ruby/client.rb', line 89 def verify_signature(body, signature) StreamChat::Webhook.verify_signature(body, signature, @configuration.api_secret) end |
#video ⇒ GetStream::Generated::VideoClient
Returns The video API client.
68 69 70 |
# File 'lib/getstream_ruby/client.rb', line 68 def video @video ||= GetStream::Generated::VideoClient.new(self) end |