Module: Stytch::RequestHelper

Instance Method Summary collapse

Instance Method Details

#delete_request(path, headers) ⇒ Object



28
29
30
31
32
33
# File 'lib/stytch/request_helper.rb', line 28

def delete_request(path, headers)
  @connection.delete(
    path,
    headers
  ).body
end

#get_request(path, headers) ⇒ Object



5
6
7
8
9
10
# File 'lib/stytch/request_helper.rb', line 5

def get_request(path, headers)
  @connection.get(
    path,
    headers
  ).body
end

#post_request(path, payload, headers) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/stytch/request_helper.rb', line 12

def post_request(path, payload, headers)
  @connection.post(
    path,
    payload,
    headers
  ).body
end

#put_request(path, payload, headers) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/stytch/request_helper.rb', line 20

def put_request(path, payload, headers)
  @connection.put(
    path,
    payload,
    headers
  ).body
end

#request_with_query_params(path, params) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/stytch/request_helper.rb', line 35

def request_with_query_params(path, params)
  request = path
  params.compact.each_with_index do |p, i|
    request += if i.zero?
                 "?#{p[0]}=#{p[1]}"
               else
                 "&#{p[0]}=#{p[1]}"
               end
  end
  request
end