setsuzoku 0.11.5 → 0.11.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 576427e8c71dfaf7306d5c7de069440bc47f4d8d9de185f3eb230a8304ea8162
4
- data.tar.gz: 24fc28270185bca4db25ac804b783e28ec2e6c505c17e545e35625cc2695ca8e
3
+ metadata.gz: 3e0e78fe9c055eb1696a1df750b36fad06363646e465a3cbe4e86da69cd75215
4
+ data.tar.gz: 5f3c4c99f1587492b7c552205a4bfc99ff1b29631346f50206216a397686e90a
5
5
  SHA512:
6
- metadata.gz: 66c24bc8e924754a8b47fff0180ebd8ea73c7f42d1ddfe9694c3600850870514b6357a87f86c6b820b657e5393a081ab68d635534a2555dcc10419243540c2d7
7
- data.tar.gz: f55aae400065ab41b8f5d98e66154f80ca044c8de60cd552b3e29fd3d8d9895d09a930bf9a3e7253d2d5ce835062a75ec89f26cde7275419bda7f0a389dc11f9
6
+ metadata.gz: b0d1a53b0552e7cbf2941933a80cce484f1c5c4d606fd806d230692045acb6bb6bd11b42c3427ec603353d4380af690764cfc3f1fe0f5511082fdd0bd0dcb150
7
+ data.tar.gz: 3c1f8a24908d294f221bb7bdb8c0d731693b1e43b10e42b4b6457f66dcff3fb7f15d171cead30f8bfbf6ad8098283059c1a476a807261a8868ca9134a7308145
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- setsuzoku (0.11.5)
4
+ setsuzoku (0.11.6)
5
5
  activesupport (~> 5.0)
6
6
  faraday (~> 0.11)
7
7
  httparty (~> 0.16.4)
@@ -57,7 +57,7 @@ GEM
57
57
  safe_yaml (1.0.5)
58
58
  sorbet (0.5.5675)
59
59
  sorbet-static (= 0.5.5675)
60
- sorbet-runtime (0.5.5862)
60
+ sorbet-runtime (0.5.5878)
61
61
  sorbet-static (0.5.5675-universal-darwin-14)
62
62
  thread_safe (0.3.6)
63
63
  tzinfo (1.2.7)
@@ -114,34 +114,23 @@ module Setsuzoku
114
114
 
115
115
  resp = self.api_strategy.call_external_api(request: request, strategy: :auth)
116
116
 
117
+ attrs = {}
117
118
  if resp.data && resp.data[:access_token]
118
- self.credential.status = 'active' if self.credential.respond_to?(:"status=")
119
- self.credential.token = resp.data[:access_token]
120
- self.credential.refresh_token = resp.data[:refresh_token] if resp.data.key?(:refresh_token)
121
- self.credential.expires_on = if resp.data[:expires_in]
122
- resp.data[:expires_in].to_i.seconds.from_now
123
- # elsif resp.data[:issued_at] && self.class.token_valid_for
124
- # Time.at(resp.data[:issued_at].to_i / 1000) + self.class.token_valid_for
125
- end
126
-
127
- self.plugin.set_credential_fields!(resp) if self.plugin.respond_to?(:set_credential_fields!)
128
-
129
- #TODO: figure out a better way to do this when we add other integrations...
130
- #
131
- # if self.is_a?(FacebookIntegration)
132
- # resp = self.exchange_for_long_lived_token
133
- # if resp && resp.data['access_token']
134
- # self.token = resp.data['access_token']
135
- # self.refresh_token = resp.data['access_token']
136
- # self.expires_on = 59.days.from_now
137
- # end
138
- # end
119
+ attrs[:status] = 'active' if self.credential.respond_to?(:"status=")
120
+ attrs[:access_token] = resp.data[:access_token]
121
+ attrs[:refresh_token] = resp.data[:refresh_token] if resp.data.key?(:refresh_token)
122
+ attrs[:expires_on] = resp.data[:expires_in].to_i.seconds.from_now if resp.data[:expires_in]
123
+
124
+ plugin_attrs = self.plugin.credential_fields_to_update(resp) if self.plugin.respond_to?(:credential_fields_to_update)
125
+ attrs.merge!(plugin_attrs)
139
126
  else
140
- self.credential.status = 'error' if self.credential.respond_to?(:"status=")
127
+ attrs[:status] = 'error' if self.credential.respond_to?(:"status=")
141
128
  end
142
129
 
143
- if self.credential.respond_to?(:"save")
144
- self.credential.save && resp.success
130
+ # Only save Setsuzoku known fields, and any additional attributes the plugin specifies
131
+ # in credential_fields_to_update.
132
+ if self.credential.respond_to?(:"update_attributes")
133
+ self.credential.update_attributes(attrs) && resp.success
145
134
  else
146
135
  resp.success
147
136
  end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Setsuzoku
5
- VERSION = '0.11.5'
5
+ VERSION = '0.11.6'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: setsuzoku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.5
4
+ version: 0.11.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Stadtler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-24 00:00:00.000000000 Z
11
+ date: 2020-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler