stytch 0.1.18 → 0.2.1

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: 10463d08a00797477107bd2ddbc5019ed64387affed2383ed96c977a26477520
4
- data.tar.gz: 7445343227668660e5560bb6078e6c02d1108b5126424b5cecd21eed8cbeba3f
3
+ metadata.gz: e6c9a3df7973de6e5cca7aafee8cbbb439b6966de47f221fa3103971fa5a7191
4
+ data.tar.gz: 423480baba3d5cc878a0ab2dbb203bd9f63f0a27bc68fef2724d21423755846e
5
5
  SHA512:
6
- metadata.gz: 5576d825603203b8a86dcd7496eb7011ce6cf085999340a66b46584814ccfbb07427afe7e5c77f57f55920ea9f693a7ad11c1cc2ae085a3258f52a5204a24a61
7
- data.tar.gz: b12847701543b4a833d10b65625e568e1f4571742de26c0b59c8bb75e295e41718c844e3bd792ad2c5ec9583398bf70586cc8700e4c4eefbd465a14ed24f75a4
6
+ metadata.gz: f6195850d5e3aae1eb17da784ea57fc849eeeb01e2fe7681326010e6253187a0a2038cb947f4de726d45f83d6cdbec91f8a6bd8b9018f34a118a4ed909001b6a
7
+ data.tar.gz: e6270719f8a97deb931efc6a080180d09c5ed7d4f1bb11b79681c96de4f028b4e6e83be2b28f02382e158b69129cdfbf8243acfe401fb5a9084b8e7c94d1a610
data/README.md CHANGED
@@ -41,4 +41,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
41
41
 
42
42
  ## Code of Conduct
43
43
 
44
- Everyone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/stytch/blob/master/CODE_OF_CONDUCT.md).
44
+ Everyone interacting in the Stytch project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/stytchauth/stytch-ruby/blob/main/CODE_OF_CONDUCT.md).
data/lib/stytch/client.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require_relative 'endpoints/user'
2
2
  require_relative 'endpoints/magic'
3
+ require_relative 'endpoints/otp'
3
4
 
4
5
  module Stytch
5
6
  class Client
6
7
  include Stytch::Endpoints::User
7
8
  include Stytch::Endpoints::Magic
9
+ include Stytch::Endpoints::OTP
8
10
 
9
11
  ENVIRONMENTS = %i[live test].freeze
10
12
 
@@ -4,36 +4,36 @@ module Stytch
4
4
  PATH = "/v1/magic_links".freeze
5
5
 
6
6
  def send_magic(
7
- method_id:,
8
- user_id:,
9
- magic_link_url:,
10
- expiration_minutes:,
11
- attributes: {}
7
+ method_id:,
8
+ user_id:,
9
+ magic_link_url:,
10
+ expiration_minutes: nil,
11
+ attributes: {}
12
12
  )
13
13
  request = {
14
- method_id: method_id,
15
- user_id: user_id,
16
- magic_link_url: magic_link_url,
17
- expiration_minutes: expiration_minutes,
14
+ method_id: method_id,
15
+ user_id: user_id,
16
+ magic_link_url: magic_link_url,
18
17
  }
19
18
 
19
+ request[:expiration_minutes] = expiration_minutes if expiration_minutes != nil
20
20
  request[:attributes] = attributes if attributes != {}
21
21
 
22
22
  post("#{PATH}/send", request)
23
23
  end
24
24
 
25
25
  def send_magic_by_email(
26
- email:,
27
- magic_link_url:,
28
- expiration_minutes:,
29
- attributes: {}
26
+ email:,
27
+ magic_link_url:,
28
+ expiration_minutes: nil,
29
+ attributes: {}
30
30
  )
31
31
  request = {
32
- email: email,
33
- magic_link_url: magic_link_url,
34
- expiration_minutes: expiration_minutes,
32
+ email: email,
33
+ magic_link_url: magic_link_url,
35
34
  }
36
35
 
36
+ request[:expiration_minutes] = expiration_minutes if expiration_minutes != nil
37
37
  request[:attributes] = attributes if attributes != {}
38
38
 
39
39
  post("#{PATH}/send_by_email", request)
@@ -67,7 +67,8 @@ module Stytch
67
67
  email:,
68
68
  magic_link_url:,
69
69
  expiration_minutes: nil,
70
- attributes: {}
70
+ attributes: {},
71
+ name: {}
71
72
  )
72
73
 
73
74
  request = {
@@ -77,6 +78,7 @@ module Stytch
77
78
 
78
79
  request[:expiration_minutes] = expiration_minutes if expiration_minutes != nil
79
80
  request[:attributes] = attributes if attributes != {}
81
+ request[:name] = name if name != {}
80
82
 
81
83
  post("#{PATH}/invite_by_email", request)
82
84
  end
@@ -93,9 +95,9 @@ module Stytch
93
95
  end
94
96
 
95
97
  def authenticate_magic(
96
- token:,
97
- attributes: {},
98
- options: {}
98
+ token:,
99
+ attributes: {},
100
+ options: {}
99
101
  )
100
102
  request = {}
101
103
 
@@ -0,0 +1,56 @@
1
+ module Stytch
2
+ module Endpoints
3
+ module OTP
4
+ PATH = "/v1/otp".freeze
5
+
6
+ def send_otp_by_sms(
7
+ phone_number:,
8
+ expiration_minutes: nil,
9
+ attributes: {}
10
+ )
11
+ request = {
12
+ phone_number: phone_number,
13
+ expiration_minutes: expiration_minutes,
14
+ }
15
+
16
+ request[:attributes] = attributes if attributes != {}
17
+
18
+ post("#{PATH}/send_by_sms", request)
19
+ end
20
+
21
+ def login_or_create_user_by_sms(
22
+ phone_number:,
23
+ expiration_minutes: nil,
24
+ attributes: {},
25
+ create_user_as_pending: false
26
+ )
27
+ request = {
28
+ phone_number: phone_number,
29
+ expiration_minutes: expiration_minutes,
30
+ create_user_as_pending: create_user_as_pending
31
+ }
32
+
33
+ request[:attributes] = attributes if attributes != {}
34
+
35
+ post("#{PATH}/login_or_create", request)
36
+ end
37
+
38
+ def authenticate_otp(
39
+ method_id:,
40
+ code:,
41
+ attributes: {},
42
+ options: {}
43
+ )
44
+ request = {
45
+ method_id: method_id,
46
+ code: code,
47
+ }
48
+
49
+ request[:attributes] = attributes if attributes != {}
50
+ request[:options] = options if options != {}
51
+
52
+ post("#{PATH}/authenticate", request)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -8,8 +8,8 @@ module Stytch
8
8
  end
9
9
 
10
10
  def get_pending_users(
11
- limit: nil,
12
- starting_after_id: nil
11
+ limit: nil,
12
+ starting_after_id: nil
13
13
  )
14
14
  query_params = {
15
15
  limit: limit,
@@ -22,12 +22,14 @@ module Stytch
22
22
  end
23
23
 
24
24
  def create_user(
25
- email:,
26
- name: {},
27
- attributes: {}
25
+ email: nil,
26
+ phone_number: nil,
27
+ name: {},
28
+ attributes: {}
28
29
  )
29
30
  request = {
30
31
  email: email,
32
+ phone_number: phone_number
31
33
  }
32
34
 
33
35
  request[:name] = name if name != {}
@@ -40,10 +42,12 @@ module Stytch
40
42
  user_id:,
41
43
  name: {},
42
44
  emails: [],
45
+ phone_numbers: [],
43
46
  attributes: {}
44
47
  )
45
48
  request = {
46
- emails: format_emails(emails),
49
+ emails: format_emails(emails),
50
+ phone_numbers: format_phone_numbers(phone_numbers),
47
51
  }
48
52
 
49
53
  request[:name] = name if name != {}
@@ -57,10 +61,15 @@ module Stytch
57
61
  end
58
62
 
59
63
  def delete_user_email(
60
- user_id:,
61
- email:
64
+ email_id:
65
+ )
66
+ delete("#{PATH}/emails/#{email_id}")
67
+ end
68
+
69
+ def delete_user_phone_number(
70
+ phone_id:
62
71
  )
63
- delete("#{PATH}/#{user_id}/emails/#{email}")
72
+ delete("#{PATH}/phone_numbers/#{phone_id}")
64
73
  end
65
74
 
66
75
  private
@@ -70,6 +79,12 @@ module Stytch
70
79
  emails.each { |email| e << { email: email} }
71
80
  e
72
81
  end
82
+
83
+ def format_phone_numbers(phone_numbers)
84
+ p = []
85
+ phone_numbers.each { |phone_number| p << { phone_number: phone_number} }
86
+ p
87
+ end
73
88
  end
74
89
  end
75
90
  end
@@ -1,3 +1,3 @@
1
1
  module Stytch
2
- VERSION = "0.1.18"
2
+ VERSION = "0.2.1"
3
3
  end
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.18
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - alex-stytch
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-09 00:00:00.000000000 Z
11
+ date: 2021-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -50,7 +50,7 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '2.0'
53
- description:
53
+ description:
54
54
  email:
55
55
  - alex@stytch.com
56
56
  executables: []
@@ -70,6 +70,7 @@ files:
70
70
  - lib/stytch.rb
71
71
  - lib/stytch/client.rb
72
72
  - lib/stytch/endpoints/magic.rb
73
+ - lib/stytch/endpoints/otp.rb
73
74
  - lib/stytch/endpoints/user.rb
74
75
  - lib/stytch/middleware.rb
75
76
  - lib/stytch/version.rb
@@ -80,7 +81,7 @@ licenses:
80
81
  metadata:
81
82
  homepage_uri: https://stytch.com
82
83
  source_code_uri: https://github.com/stytchauth/stytch-ruby
83
- post_install_message:
84
+ post_install_message:
84
85
  rdoc_options: []
85
86
  require_paths:
86
87
  - lib
@@ -95,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0'
97
98
  requirements: []
98
- rubygems_version: 3.0.3
99
- signing_key:
99
+ rubygems_version: 3.1.4
100
+ signing_key:
100
101
  specification_version: 4
101
102
  summary: Stytch Ruby Gem
102
103
  test_files: []