Class: Teams::Api::TeamClient
- Inherits:
-
Object
- Object
- Teams::Api::TeamClient
- Defined in:
- lib/teams/api/team_client.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#service_url ⇒ Object
readonly
Returns the value of attribute service_url.
Instance Method Summary collapse
- #get_by_id(team_id, service_url: nil) ⇒ Object
-
#get_conversations(team_id, service_url: nil) ⇒ Object
Returns the team's channels; the service wraps them in a "conversations" envelope, which all the SDKs unwrap.
-
#initialize(service_url:, http:, logger: nil) ⇒ TeamClient
constructor
A new instance of TeamClient.
Constructor Details
#initialize(service_url:, http:, logger: nil) ⇒ TeamClient
Returns a new instance of TeamClient.
10 11 12 13 14 |
# File 'lib/teams/api/team_client.rb', line 10 def initialize(service_url:, http:, logger: nil) @service_url = service_url.sub(%r{/+\z}, "") @http = http @logger = logger end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
8 9 10 |
# File 'lib/teams/api/team_client.rb', line 8 def http @http end |
#service_url ⇒ Object (readonly)
Returns the value of attribute service_url.
8 9 10 |
# File 'lib/teams/api/team_client.rb', line 8 def service_url @service_url end |
Instance Method Details
#get_by_id(team_id, service_url: nil) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/teams/api/team_client.rb', line 16 def get_by_id(team_id, service_url: nil) path = "/v3/teams/#{escape(team_id)}" url = absolute(path, service_url:) @logger&.debug("Teams API GET #{url}") TeamDetails.new(http.get(url)) end |
#get_conversations(team_id, service_url: nil) ⇒ Object
Returns the team's channels; the service wraps them in a "conversations" envelope, which all the SDKs unwrap.
25 26 27 28 29 30 31 32 |
# File 'lib/teams/api/team_client.rb', line 25 def get_conversations(team_id, service_url: nil) path = "/v3/teams/#{escape(team_id)}/conversations" url = absolute(path, service_url:) @logger&.debug("Teams API GET #{url}") response = http.get(url) conversations = response.is_a?(Hash) ? Array(response["conversations"]) : [] conversations.map { |channel| ChannelInfo.new(channel) } end |