Skip to content

Commit

Permalink
add events
Browse files Browse the repository at this point in the history
  • Loading branch information
Yann Guillon committed Aug 11, 2022
1 parent 84de425 commit fcd3293
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,31 @@
wallets_response.body.to_json
end

get '/wallets/:id/events' do
conn = Faraday.new(
url: ENV['VUE_APP_VENLY_LOGIN_URL'],
headers: {'Content-Type' => 'application/x-www-form-urlencoded'}
)

response = conn.post('/auth/realms/Arkane/protocol/openid-connect/token') do |req|
req.body = URI.encode_www_form({
grant_type: 'client_credentials',
client_id: ENV['VUE_APP_VENLY_CLIENT_ID'],
client_secret: ENV['VUE_APP_SECRET_ID']
})
end
token = JSON.parse(response.body)['access_token']
pp token
content_type :json
conn = Faraday.new(
url: ENV['VUE_APP_VENLY_API_URL'],
headers: {'Content-Type' => 'application/json', 'Authorization' => "Bearer #{token}" }
)
wallets_response = conn.get("/api/wallets/#{params['id']}/events")
content_type :json
wallets_response.body.to_json
end

options "*" do
response.headers["Allow"] = "GET, PUT, POST, DELETE, OPTIONS"
response.headers["Access-Control-Allow-Headers"] = "Authorization, Content-Type, Accept, X-User-Email, X-Auth-Token"
Expand Down

0 comments on commit fcd3293

Please sign in to comment.