-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup sidekiq and add new job to get dwolla_id from dwolla api
- Loading branch information
1 parent
15b49d0
commit 8e9ae59
Showing
11 changed files
with
87 additions
and
15 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
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,12 +1,4 @@ | ||
require './routes' | ||
|
||
ActiveRecord::Base.establish_connection( | ||
adapter: 'postgresql', | ||
host: 'localhost', | ||
database: 'ecommerce_development', | ||
username: 'ecomerce_user', | ||
password: 'postgres', | ||
pool: 5 | ||
) | ||
require './config/database.rb' | ||
|
||
run Sinatra::Application |
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 @@ | ||
require 'active_record' | ||
|
||
ActiveRecord::Base.establish_connection( | ||
adapter: 'postgresql', | ||
host: 'localhost', | ||
database: 'ecommerce_development', | ||
username: 'ecomerce_user', | ||
password: 'postgres', | ||
pool: 5 | ||
) |
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 @@ | ||
# schedule.yml | ||
set_costumer_id_job: | ||
cron: "*/15 * * * *" | ||
class: "SetCostumerIdJob" |
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,12 @@ | ||
require 'sidekiq' | ||
require 'sidekiq-cron' | ||
require 'yaml' | ||
require 'active_record' | ||
require_relative '../../jobs/set_costumer_id_job' | ||
require_relative '../database' | ||
|
||
schedule_file = './schedule.yml' | ||
|
||
if File.exist?(schedule_file) | ||
Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_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,20 @@ | ||
require 'sidekiq' | ||
require 'sidekiq-cron' | ||
require 'json' | ||
require_relative '../modal/dwolla' | ||
require_relative '../modal/user' | ||
|
||
class SetCostumerIdJob | ||
include Sidekiq::Worker | ||
|
||
def perform | ||
dwolla = Dwolla.new() | ||
dwolla.init() | ||
costumers = dwolla.get_costomers() | ||
|
||
costumers["_embedded"]["customers"].each do |customer| | ||
user = ::User.find_by(email: customer["email"] ) | ||
user.update(dwolla_id: customer["id"] ) if user.present? | ||
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
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 @@ | ||
|
||
class dwolla_reponse | ||
|
||
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