Class: GetStreamRuby::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/getstream_ruby/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil, api_key: nil, api_secret: nil, **options) ⇒ Client

Returns a new instance of Client.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/getstream_ruby/client.rb', line 24

def initialize(config = nil, api_key: nil, api_secret: nil, **options)
  @configuration = config || GetStreamRuby.configuration

  # Create new configuration with overrides if any parameters provided
  if api_key || api_secret || !options.empty?
    @configuration = Configuration.with_overrides(
      api_key: api_key,
      api_secret: api_secret,
      **options,
    )
  end

  @configuration.validate!
  @connection = build_connection
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



22
23
24
# File 'lib/getstream_ruby/client.rb', line 22

def configuration
  @configuration
end

Instance Method Details

#chatGetStream::Generated::ChatClient

Returns The chat API client.

Returns:



62
63
64
# File 'lib/getstream_ruby/client.rb', line 62

def chat
  @chat ||= GetStream::Generated::ChatClient.new(self)
end

#commonGetStream::Generated::CommonClient

Returns The common API client.

Returns:



47
48
49
# File 'lib/getstream_ruby/client.rb', line 47

def common
  @common ||= GetStream::Generated::CommonClient.new(self)
end

#feed(feed_group_id, feed_id) ⇒ GetStream::Generated::Feed

Create an individual feed instance

Parameters:

  • feed_group_id (String)

    The feed group ID

  • feed_id (String)

    The feed ID

Returns:



75
76
77
# File 'lib/getstream_ruby/client.rb', line 75

def feed(feed_group_id, feed_id)
  GetStream::Generated::Feed.new(self, feed_group_id, feed_id)
end

#feed_resourceObject



40
41
42
# File 'lib/getstream_ruby/client.rb', line 40

def feed_resource
  @feed_resource ||= Resources::Feed.new(self)
end

#feedsGetStream::Generated::FeedsClient

Returns The feeds API client.

Returns:



52
53
54
# File 'lib/getstream_ruby/client.rb', line 52

def feeds
  @feeds ||= GetStream::Generated::FeedsClient.new(self)
end

#make_request(method, path, query_params: nil, body: nil) ⇒ Object



86
87
88
89
90
91
92
93
94
95
# File 'lib/getstream_ruby/client.rb', line 86

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

#moderationGetStream::Generated::ModerationClient

Returns The moderation API client.

Returns:



57
58
59
# File 'lib/getstream_ruby/client.rb', line 57

def moderation
  @moderation ||= GetStream::Generated::ModerationClient.new(self)
end

#post(path, body = {}) ⇒ GetStreamRuby::StreamResponse

Returns The API response.

Parameters:

  • path (String)

    The API path

  • body (Hash) (defaults to: {})

    The request body

Returns:



82
83
84
# File 'lib/getstream_ruby/client.rb', line 82

def post(path, body = {})
  request(:post, path, body)
end

#videoGetStream::Generated::VideoClient

Returns The video API client.

Returns:



67
68
69
# File 'lib/getstream_ruby/client.rb', line 67

def video
  @video ||= GetStream::Generated::VideoClient.new(self)
end