stytch 0.1.7 → 0.1.13
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 +4 -4
- data/lib/stytch/client.rb +1 -3
- data/lib/stytch/endpoints/magic.rb +74 -5
- data/lib/stytch/endpoints/user.rb +14 -3
- data/lib/stytch/middleware.rb +1 -1
- data/lib/stytch/version.rb +1 -1
- metadata +2 -3
- data/lib/stytch/endpoints/email.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8aa51bb45fcf007fecdcd610723bbabd7329fa67359a22c11d5f1bc34784a56
|
4
|
+
data.tar.gz: b00fed4171c89d4faae5fc149621bb2f432d353f77bcbafeb652c8ccf007ef0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0ad0f15846df9f982c377f51242d99c5de2fbccaa84c675cb3d4484755fd69b5108e30db93d08fb2a4d9f0aea2490ed3108289c75c92cd1c89637287996693f
|
7
|
+
data.tar.gz: 59174086cbbe257b1dd99f0aa26d9893a12905511ab7816e691c5957a0dd92724b757f6a2e193f5a1d3076b478cb664baf298f152f1fbfe262a42f137a6c48c2
|
data/lib/stytch/client.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require_relative 'endpoints/user'
|
2
|
-
require_relative 'endpoints/email'
|
3
2
|
require_relative 'endpoints/magic'
|
4
3
|
|
5
4
|
module Stytch
|
6
5
|
class Client
|
7
6
|
include Stytch::Endpoints::User
|
8
|
-
include Stytch::Endpoints::Email
|
9
7
|
include Stytch::Endpoints::Magic
|
10
8
|
|
11
9
|
ENVIRONMENTS = %i[live test].freeze
|
@@ -72,4 +70,4 @@ module Stytch
|
|
72
70
|
).body
|
73
71
|
end
|
74
72
|
end
|
75
|
-
end
|
73
|
+
end
|
@@ -8,7 +8,6 @@ module Stytch
|
|
8
8
|
user_id:,
|
9
9
|
magic_link_url:,
|
10
10
|
expiration_minutes:,
|
11
|
-
template_id: nil,
|
12
11
|
attributes: {}
|
13
12
|
)
|
14
13
|
request = {
|
@@ -18,7 +17,6 @@ module Stytch
|
|
18
17
|
expiration_minutes: expiration_minutes,
|
19
18
|
}
|
20
19
|
|
21
|
-
request[:template_id] = template_id if template_id != nil
|
22
20
|
request[:attributes] = attributes if attributes != {}
|
23
21
|
|
24
22
|
post("#{PATH}/send", request)
|
@@ -28,7 +26,6 @@ module Stytch
|
|
28
26
|
email:,
|
29
27
|
magic_link_url:,
|
30
28
|
expiration_minutes:,
|
31
|
-
template_id: nil,
|
32
29
|
attributes: {}
|
33
30
|
)
|
34
31
|
request = {
|
@@ -37,12 +34,84 @@ module Stytch
|
|
37
34
|
expiration_minutes: expiration_minutes,
|
38
35
|
}
|
39
36
|
|
40
|
-
request[:template_id] = template_id if template_id != nil
|
41
37
|
request[:attributes] = attributes if attributes != {}
|
42
38
|
|
43
39
|
post("#{PATH}/send_by_email", request)
|
44
40
|
end
|
45
41
|
|
42
|
+
def login_or_create_user(
|
43
|
+
email:,
|
44
|
+
login_magic_link_url:,
|
45
|
+
signup_magic_link_url:,
|
46
|
+
login_expiration_minutes: nil,
|
47
|
+
signup_expiration_minutes: nil,
|
48
|
+
attributes: {}
|
49
|
+
)
|
50
|
+
|
51
|
+
request = {
|
52
|
+
email: email,
|
53
|
+
login_magic_link_url: login_magic_link_url,
|
54
|
+
signup_magic_link_url: signup_magic_link_url,
|
55
|
+
}
|
56
|
+
|
57
|
+
request[:login_expiration_minutes] = login_expiration_minutes if login_expiration_minutes != nil
|
58
|
+
request[:signup_expiration_minutes] = signup_expiration_minutes if signup_expiration_minutes != nil
|
59
|
+
request[:attributes] = attributes if attributes != {}
|
60
|
+
|
61
|
+
post("#{PATH}/login_or_create", request)
|
62
|
+
end
|
63
|
+
|
64
|
+
def login_or_invite_by_email(
|
65
|
+
email:,
|
66
|
+
login_magic_link_url:,
|
67
|
+
invite_magic_link_url:,
|
68
|
+
login_expiration_minutes: nil,
|
69
|
+
invite_expiration_minutes: nil,
|
70
|
+
attributes: {}
|
71
|
+
)
|
72
|
+
|
73
|
+
request = {
|
74
|
+
email: email,
|
75
|
+
login_magic_link_url: login_magic_link_url,
|
76
|
+
invite_magic_link_url: invite_magic_link_url,
|
77
|
+
}
|
78
|
+
|
79
|
+
request[:login_expiration_minutes] = login_expiration_minutes if login_expiration_minutes != nil
|
80
|
+
request[:invite_expiration_minutes] = invite_expiration_minutes if invite_expiration_minutes != nil
|
81
|
+
request[:attributes] = attributes if attributes != {}
|
82
|
+
|
83
|
+
post("#{PATH}/login_or_invite", request)
|
84
|
+
end
|
85
|
+
|
86
|
+
def invite_by_email(
|
87
|
+
email:,
|
88
|
+
magic_link_url:,
|
89
|
+
expiration_minutes: nil,
|
90
|
+
attributes: {}
|
91
|
+
)
|
92
|
+
|
93
|
+
request = {
|
94
|
+
email: email,
|
95
|
+
magic_link_url: magic_link_url,
|
96
|
+
}
|
97
|
+
|
98
|
+
request[:expiration_minutes] = expiration_minutes if expiration_minutes != nil
|
99
|
+
request[:attributes] = attributes if attributes != {}
|
100
|
+
|
101
|
+
post("#{PATH}/invite_by_email", request)
|
102
|
+
end
|
103
|
+
|
104
|
+
def revoke_invite_by_email(
|
105
|
+
email:
|
106
|
+
)
|
107
|
+
|
108
|
+
request = {
|
109
|
+
email: email,
|
110
|
+
}
|
111
|
+
|
112
|
+
post("#{PATH}/revoke_invite", request)
|
113
|
+
end
|
114
|
+
|
46
115
|
def authenticate_magic(
|
47
116
|
token:,
|
48
117
|
attributes: {},
|
@@ -57,4 +126,4 @@ module Stytch
|
|
57
126
|
end
|
58
127
|
end
|
59
128
|
end
|
60
|
-
end
|
129
|
+
end
|
@@ -7,6 +7,10 @@ module Stytch
|
|
7
7
|
get("#{PATH}/#{user_id}")
|
8
8
|
end
|
9
9
|
|
10
|
+
def get_invited_users()
|
11
|
+
get("#{PATH}/invites")
|
12
|
+
end
|
13
|
+
|
10
14
|
def create_user(
|
11
15
|
email:,
|
12
16
|
name: {},
|
@@ -24,15 +28,15 @@ module Stytch
|
|
24
28
|
|
25
29
|
def update_user(
|
26
30
|
user_id:,
|
27
|
-
name:
|
31
|
+
name: {},
|
28
32
|
emails: [],
|
29
33
|
attributes: {}
|
30
34
|
)
|
31
35
|
request = {
|
32
|
-
name: name,
|
33
36
|
emails: format_emails(emails),
|
34
37
|
}
|
35
38
|
|
39
|
+
request[:name] = name if name != {}
|
36
40
|
request[:attributes] = attributes if attributes != {}
|
37
41
|
|
38
42
|
put("#{PATH}/#{user_id}", request)
|
@@ -42,6 +46,13 @@ module Stytch
|
|
42
46
|
delete("#{PATH}/#{user_id}")
|
43
47
|
end
|
44
48
|
|
49
|
+
def delete_user_email(
|
50
|
+
user_id:,
|
51
|
+
email:
|
52
|
+
)
|
53
|
+
delete("#{PATH}/#{user_id}/emails/#{email}")
|
54
|
+
end
|
55
|
+
|
45
56
|
private
|
46
57
|
|
47
58
|
def format_emails(emails)
|
@@ -51,4 +62,4 @@ module Stytch
|
|
51
62
|
end
|
52
63
|
end
|
53
64
|
end
|
54
|
-
end
|
65
|
+
end
|
data/lib/stytch/middleware.rb
CHANGED
data/lib/stytch/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stytch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alex-stytch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -57,7 +57,6 @@ files:
|
|
57
57
|
- bin/setup
|
58
58
|
- lib/stytch.rb
|
59
59
|
- lib/stytch/client.rb
|
60
|
-
- lib/stytch/endpoints/email.rb
|
61
60
|
- lib/stytch/endpoints/magic.rb
|
62
61
|
- lib/stytch/endpoints/user.rb
|
63
62
|
- lib/stytch/middleware.rb
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Stytch
|
2
|
-
module Endpoints
|
3
|
-
module Email
|
4
|
-
PATH = "/v1/emails".freeze
|
5
|
-
|
6
|
-
def send_email_verification(
|
7
|
-
user_id:,
|
8
|
-
email_id:,
|
9
|
-
magic_link_url:,
|
10
|
-
expiration_minutes:
|
11
|
-
)
|
12
|
-
request = {
|
13
|
-
user_id: user_id,
|
14
|
-
magic_link_url: magic_link_url,
|
15
|
-
expiration_minutes: expiration_minutes
|
16
|
-
}
|
17
|
-
|
18
|
-
post("#{PATH}/#{email_id}/send_verification", request)
|
19
|
-
end
|
20
|
-
|
21
|
-
def verify_email(token:)
|
22
|
-
post("#{PATH}/#{token}/verify", {})
|
23
|
-
end
|
24
|
-
|
25
|
-
def delete_email(user_id:, email_id:)
|
26
|
-
delete("#{PATH}/#{email_id}/users/#{user_id}")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|