-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from DSACMS/mg-webhooks
Listen to Argyle Webhooks to check when paystubs are fully sync'd
- Loading branch information
Showing
20 changed files
with
163 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ARGYLE_API_TOKEN= | ||
ARGYLE_SANDBOX= | ||
ARGYLE_WEBHOOK_SECRET= | ||
NGROK_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
/* Entry point for your PostCSS build */ | ||
@forward "uswds-settings.scss"; | ||
@forward "uswds-components.scss"; | ||
|
||
.argyle-loading { | ||
position: relative; | ||
} | ||
|
||
.argyle-loading::after { | ||
background-color: rgba(0, 0, 0, 0.128); | ||
content: ""; | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
top: 0; | ||
left: 0; | ||
z-index: 9999; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
module ApplicationCable | ||
class Connection < ActionCable::Connection::Base | ||
def session | ||
@request.session | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class ArgylePaystubsChannel < ApplicationCable::Channel | ||
def subscribed | ||
cbv_flow = CbvFlow.find(connection.session[:cbv_flow_id]) | ||
stream_for cbv_flow | ||
end | ||
|
||
def unsubscribed | ||
# Any cleanup needed when channel is unsubscribed | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class Webhooks::Argyle::EventsController < ApplicationController | ||
skip_before_action :verify_authenticity_token | ||
|
||
def create | ||
signature = OpenSSL::HMAC.hexdigest('SHA512', ENV['ARGYLE_WEBHOOK_SECRET'], request.raw_post) | ||
|
||
unless request.headers["X-Argyle-Signature"] == signature | ||
return render json: { error: 'Invalid signature' }, status: :unauthorized | ||
end | ||
|
||
if params['event'] == 'paystubs.fully_synced' || params['event'] == 'paystubs.partially_synced' | ||
@cbv_flow = CbvFlow.find_by_argyle_user_id(params['data']['user']) | ||
|
||
if @cbv_flow | ||
@cbv_flow.update(payroll_data_available_from: params['data']['available_from']) | ||
ArgylePaystubsChannel.broadcast_to(@cbv_flow, params) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module Webhooks::Argyle::EventsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddPayrollColumnToCbvFlows < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :cbv_flows, :payroll_data_available_from, :date | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe ArgylePaystubsChannel, type: :channel do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'rails_helper' | ||
|
||
# Specs in this file have access to a helper object that includes | ||
# the Webhooks::Argyle::EventsHelper. For example: | ||
# | ||
# describe Webhooks::Argyle::EventsHelper do | ||
# describe "string concat" do | ||
# it "concats two strings with spaces" do | ||
# expect(helper.concat_strings("this","that")).to eq("this that") | ||
# end | ||
# end | ||
# end | ||
RSpec.describe Webhooks::Argyle::EventsHelper, type: :helper do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "Webhooks::Argyle::Events", type: :request do | ||
describe "GET /index" do | ||
pending "add some examples (or delete) #{__FILE__}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters