lockstep_rails 0.3.58 → 0.3.59

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: 10e5396a66ad03f74ab26110a5e28735de9ded83067164fde5c51dd5eedeac7a
4
- data.tar.gz: 2c6c8f5d092e8496185b6ac7f8f06574eb345a4f39818732009089f19c884995
3
+ metadata.gz: 37c92eb628b79e4032b9b3e60e73bb7013d09166c069fcdedc2a00afd8a89f0e
4
+ data.tar.gz: c698ba9b0b12932a7241ef7e232abbe2ba1b158384bbe6b697bc597c9b1eb53d
5
5
  SHA512:
6
- metadata.gz: 336c65121dccd797672347a3334e72198f36bc1b042b17fae4c52d8f4764270ae0e5d66d6f4a8004753721bd3728e939d6d1ddf07a6b65121f5489562bcb74fc
7
- data.tar.gz: 72669f5a0dbaeba077cdea70084c284e5f852fd22e1e31e48c12bf691a7fb180916f28cf9f15a1410f419bfa6bee33ae13af8a7930029923544e7a46e163fcff
6
+ metadata.gz: ef3dbdfdfc56c7afff66a008c2d3f7b6e915b1654cab5732b1efab68b3a3772efde67ae6520d81f3279507e4a098baeae173ea515e3f001f560a5f99d9a608a8
7
+ data.tar.gz: 7384e6ce1a3a99bf36f25bdf9e90f5d751747847dce356c1ec82df2837a45fbe38d6ba18b1bad2752e02eac37b878c5bd33ad5951bb5c53ccd13c4385cb92381
@@ -7,4 +7,32 @@ class Lockstep::User < Lockstep::ApiRecord
7
7
  belongs_to :account, class_name: "Lockstep::Account", loader: ->(user) { Lockstep::Account.first }
8
8
 
9
9
  alias_attribute :last_logged_in, :b2_c_last_logged_in
10
+
11
+ def self.invite(email_addresses)
12
+ emails = email_addresses.map { |email| { email: email } }
13
+ resp = resource.post('/invite', body: emails, params: {})
14
+ parsed_response = JSON.parse(resp.body)
15
+ case resp.code.to_s
16
+ when '401'
17
+ raise Lockstep::Exceptions::UnauthorizedError, parsed_response['title']
18
+ when '400'
19
+ raise Lockstep::Exceptions::BadRequestError, parsed_response['title']
20
+ when '404'
21
+ raise Lockstep::Exceptions::RecordNotFound, parsed_response['title']
22
+ when '200'
23
+ snake_case_parsed_response = parsed_response.map { |response| response.transform_keys { |key| key.underscore } }
24
+ result = snake_case_parsed_response&.map do |user|
25
+ if user['success']
26
+ invited_user_in_snake_case = user['invited_user'].transform_keys { |key| key.underscore }
27
+ Lockstep::User.new(invited_user_in_snake_case)
28
+ else
29
+ invited_user = Lockstep::User.new(email: user['email'])
30
+ invited_user.errors.add "email", "#{user['error_message']}"
31
+ invited_user
32
+ end
33
+ end
34
+ else
35
+ raise Lockstep::Exceptions::BadRequestError, parsed_response
36
+ end
37
+ end
10
38
  end
@@ -1,3 +1,3 @@
1
1
  module LockstepRails
2
- VERSION = '0.3.58'
2
+ VERSION = '0.3.59'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockstep_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.58
4
+ version: 0.3.59
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vivek AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-30 00:00:00.000000000 Z
11
+ date: 2023-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails