chat_sdk-teams 0.1.0 → 0.2.1

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: 2db2df04670d799de482613122b8871972ebdc7bdb112b1f8322fe6a36a53594
4
+ data.tar.gz: a59fa28420b6177925d91cd483cbb958b66bddde5c9482a1aa2665a6ef9d2d87
5
5
  SHA512:
6
- metadata.gz: a4656f0911cb47d3ac7606f224386e1daa5f51083f69515983236b9fb61163d158425431e14e45ba8cdbc78a8ef89dfed75cc2a195aca09638c02127c7b52d37
7
- data.tar.gz: 64e7090b9f5f052bdde73fcb2acc58b8aec6160b30e26c46ad282e7ce9f03fe8e6d64c62e00d740c111b1ca7628424b81d68804e2a285abca43ada713bc3699f
6
+ metadata.gz: bb1c4c0d3b64d8d5ba2d91261b4834116d1d88c415f46513c0788ca747498abdd6a4b4f87b81b1a2cf60b3735cb0b04ddf4f7f1ab8a2eb86ecf4474f702ddc74
7
+ data.tar.gz: eaa19054b2b4a9367ecd34a8154421d856585ce9ef1d07c291d2413a91b562f49d1ecb209370ab3ad69b55d291651aa5b68f83cabeef61888f77e5264ade56d4
@@ -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,7 +1,7 @@
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.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rootly