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
-
#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, base_url: nil, timeout: nil) ⇒ 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.
-
#post(path, body = {}) ⇒ GetStreamRuby::StreamResponse
The API response.
Constructor Details
#initialize(config = nil, api_key: nil, api_secret: nil, base_url: nil, timeout: nil) ⇒ Client
Returns a new instance of Client.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/getstream_ruby/client.rb', line 21 def initialize(config = nil, api_key: nil, api_secret: nil, base_url: nil, timeout: nil) @configuration = config || GetStreamRuby.configuration # Create new configuration with overrides if any parameters provided if api_key || api_secret || base_url || timeout @configuration = Configuration.with_overrides( api_key: api_key, api_secret: api_secret, base_url: base_url, timeout: timeout, ) end @configuration.validate! @connection = build_connection end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
19 20 21 |
# File 'lib/getstream_ruby/client.rb', line 19 def configuration @configuration end |
Instance Method Details
#common ⇒ GetStream::Generated::CommonClient
Returns The common API client.
45 46 47 |
# File 'lib/getstream_ruby/client.rb', line 45 def common @common ||= GetStream::Generated::CommonClient.new(self) end |
#feed(feed_group_id, feed_id) ⇒ GetStream::Generated::Feed
Create an individual feed instance
63 64 65 |
# File 'lib/getstream_ruby/client.rb', line 63 def feed(feed_group_id, feed_id) GetStream::Generated::Feed.new(self, feed_group_id, feed_id) end |
#feed_resource ⇒ Object
38 39 40 |
# File 'lib/getstream_ruby/client.rb', line 38 def feed_resource @feed_resource ||= Resources::Feed.new(self) end |
#feeds ⇒ GetStream::Generated::FeedsClient
Returns The feeds API client.
50 51 52 |
# File 'lib/getstream_ruby/client.rb', line 50 def feeds @feeds ||= GetStream::Generated::FeedsClient.new(self) end |
#make_request(method, path, query_params: nil, body: nil) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/getstream_ruby/client.rb', line 74 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.
55 56 57 |
# File 'lib/getstream_ruby/client.rb', line 55 def moderation @moderation ||= GetStream::Generated::ModerationClient.new(self) end |
#post(path, body = {}) ⇒ GetStreamRuby::StreamResponse
Returns The API response.
70 71 72 |
# File 'lib/getstream_ruby/client.rb', line 70 def post(path, body = {}) request(:post, path, body) end |