Module: Revolut::HTTP

Included in:
Client
Defined in:
lib/revolut/http.rb

Instance Method Summary collapse

Instance Method Details

#delete(path, headers: {}, **query) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/revolut/http.rb', line 31

def delete(path, headers: {}, **query)
  full_uri = uri(path:, query:)

  conn.delete(full_uri) do |req|
    req.headers = all_headers(headers)
  end
end

#get(path, headers: {}, **query) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/revolut/http.rb', line 5

def get(path, headers: {}, **query)
  full_uri = uri(path:, query:)

  conn.get(full_uri) do |req|
    req.headers = all_headers(headers)
  end
end

#get_access_token(authorization_code:) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/revolut/http.rb', line 39

def get_access_token(authorization_code:)
  full_uri = uri(path: "auth/token")

  conn(content_type: :url_encoded, authed: false).post(full_uri) do |req|
    req.headers = global_headers
    req.body = URI.encode_www_form({
      grant_type: "authorization_code",
      code: authorization_code,
      client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
      client_assertion:
    })
  end
end

#patch(path, data: {}, headers: {}, **query) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/revolut/http.rb', line 22

def patch(path, data: {}, headers: {}, **query)
  full_uri = uri(path:, query:)

  conn.patch(full_uri) do |req|
    req.body = data.to_json if data.any?
    req.headers = all_headers(headers)
  end
end

#post(path, data: {}, headers: {}, **query) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/revolut/http.rb', line 13

def post(path, data: {}, headers: {}, **query)
  full_uri = uri(path:, query:)

  conn.post(full_uri) do |req|
    req.body = data.to_json if data.any?
    req.headers = all_headers(headers)
  end
end

#refresh_access_token(refresh_token:) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/revolut/http.rb', line 53

def refresh_access_token(refresh_token:)
  full_uri = uri(path: "auth/token")

  conn(content_type: :url_encoded, authed: false).post(full_uri) do |req|
    req.headers = global_headers
    req.body = URI.encode_www_form({
      grant_type: "refresh_token",
      refresh_token:,
      client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
      client_assertion:
    })
  end
end