-
-
Save radar/d9ad40ead59e1ec00b35fa3a36af77be to your computer and use it in GitHub Desktop.
How to run this task with delayed_job
This file contains hidden or 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
# fetchs SIB Account information | |
def sib_account_fetch | |
sib = Mailin.new("API_URL","API_KEY") | |
acct = sib.get_account() | |
acct.dig('data') | |
credits = acct.dig('data', 0).to_h | |
SibAccount.find(1).update_attributes(credits) | |
details = acct.dig('data', 2).to_h | |
SibAccount.find(1).update_attributes(details).delay | |
redirect_to(:controller => 'monet', :action => 'refresh') | |
flash[:notice] = "Account Info updated successfully." | |
end |
This file contains hidden or 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
class CreditFetcher | |
def run | |
sib = Mailin.new("API_URL","API_KEY") | |
acct = sib.get_account() | |
acct.dig('data') | |
credits = acct.dig('data', 0).to_h | |
SibAccount.find(1).update_attributes(credits) | |
details = acct.dig('data', 2).to_h | |
SibAccount.find(1).update_attributes(details).delay | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment