chat_sdk-teams 0.1.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 405f17761300fe99e9b9546f42d8d418ab56aaa5e26f62fbf719113bf182f40e
4
- data.tar.gz: 041c7673256c9d330effed6cc09c75dbfaf88641624b738dd7ea86522820a86d
3
+ metadata.gz: e46a42a9e3a6192daf19cc9fa8c42725b19bf07bc506e9166d38183ad6beffeb
4
+ data.tar.gz: b6dc40f4b1ec0921aa504930b8e6fec005006c6ce609696df3e794107c4875b5
5
5
  SHA512:
6
- metadata.gz: a4656f0911cb47d3ac7606f224386e1daa5f51083f69515983236b9fb61163d158425431e14e45ba8cdbc78a8ef89dfed75cc2a195aca09638c02127c7b52d37
7
- data.tar.gz: 64e7090b9f5f052bdde73fcb2acc58b8aec6160b30e26c46ad282e7ce9f03fe8e6d64c62e00d740c111b1ca7628424b81d68804e2a285abca43ada713bc3699f
6
+ metadata.gz: 604766acaf720ace478483a254b2ed43dfe46c80af902ac2cb051dc8aa2e5ef080750b67501ccf16a0c2c2c9a377ac9afc169c15b947698f946067a5ece485ff
7
+ data.tar.gz: b6cdc00bd6176f9db80407d7416242e49df065440adcd004783e70feeee0a4721241331d19d8bb7d10c610c90f5f0dac0f7b5e06dda5e09e46eb370bd7664c98
@@ -37,10 +37,7 @@ module ChatSDK
37
37
  end
38
38
 
39
39
  def parse_events(rack_request)
40
- body = rack_request.body.read
41
- rack_request.body.rewind
42
-
43
- activity = JSON.parse(body)
40
+ activity = read_json_body(rack_request)
44
41
 
45
42
  # Cache the service URL for this conversation
46
43
  if activity["serviceUrl"] && activity.dig("conversation", "id")
@@ -20,11 +20,6 @@ module ChatSDK
20
20
  authorized_request(:post, url, activity)
21
21
  end
22
22
 
23
- def reply_to_activity(service_url:, conversation_id:, activity_id:, activity:)
24
- url = "#{service_url.chomp("/")}/v3/conversations/#{conversation_id}/activities/#{activity_id}"
25
- authorized_request(:put, url, activity)
26
- end
27
-
28
23
  def update_activity(service_url:, conversation_id:, activity_id:, activity:)
29
24
  url = "#{service_url.chomp("/")}/v3/conversations/#{conversation_id}/activities/#{activity_id}"
30
25
  authorized_request(:put, url, activity)
@@ -48,12 +43,7 @@ module ChatSDK
48
43
  def fetch_token
49
44
  return @access_token if @access_token && @token_expires_at && Time.now < @token_expires_at
50
45
 
51
- conn = Faraday.new do |f|
52
- f.request :url_encoded
53
- f.adapter :net_http
54
- end
55
-
56
- response = conn.post(TOKEN_URL, {
46
+ response = token_connection.post(TOKEN_URL, {
57
47
  grant_type: "client_credentials",
58
48
  client_id: @app_id,
59
49
  client_secret: @app_password,
@@ -77,19 +67,27 @@ module ChatSDK
77
67
 
78
68
  private
79
69
 
80
- def authorized_request(method, url, body = nil)
81
- token = fetch_token
70
+ def token_connection
71
+ @token_connection ||= Faraday.new do |f|
72
+ f.request :url_encoded
73
+ f.adapter :net_http
74
+ end
75
+ end
82
76
 
83
- conn = Faraday.new do |f|
84
- f.request :json if body
77
+ def api_connection
78
+ @api_connection ||= Faraday.new do |f|
79
+ f.request :json
85
80
  f.response :json
86
81
  f.adapter :net_http
87
82
  end
83
+ end
84
+
85
+ def authorized_request(method, url, body = nil)
86
+ token = fetch_token
88
87
 
89
- response = conn.public_send(method, url) do |req|
88
+ response = api_connection.public_send(method, url) do |req|
90
89
  req.headers["Authorization"] = "Bearer #{token}"
91
- req.headers["Content-Type"] = "application/json" if body
92
- req.body = JSON.generate(body) if body && !method.to_s.start_with?("get")
90
+ req.body = body if body && !method.to_s.start_with?("get")
93
91
  end
94
92
 
95
93
  unless response.success?
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chat_sdk-teams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
- - Rootly
7
+ - Quentin Rousseau
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
@@ -41,19 +41,19 @@ dependencies:
41
41
  name: jwt
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '2.7'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '2.7'
54
54
  description: Microsoft Teams bot adapter for the ChatSDK framework
55
55
  email:
56
- - eng@rootly.com
56
+ - quentin@rootly.com
57
57
  executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
@@ -64,7 +64,7 @@ files:
64
64
  - lib/chat_sdk/teams/adaptive_card_renderer.rb
65
65
  - lib/chat_sdk/teams/bot_framework_client.rb
66
66
  - lib/chat_sdk/teams/jwt_verifier.rb
67
- homepage: https://github.com/rootlyhq/rootly-chat-sdk
67
+ homepage: https://github.com/rootlyhq/chat-sdk
68
68
  licenses:
69
69
  - MIT
70
70
  metadata: