This repository has been archived by the owner on Jul 17, 2019. It is now read-only.
-
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.
- Loading branch information
1 parent
1e4c3c8
commit e0f8018
Showing
7 changed files
with
75 additions
and
6 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
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,46 @@ | ||
class BeeminderToken < ActiveRecord::Base | ||
belongs_to :user | ||
|
||
def client | ||
@client ||= create_client | ||
end | ||
|
||
def goal | ||
client.goal goal_name rescue nil | ||
end | ||
|
||
def create_goal | ||
client.create_goal goal_options | ||
end | ||
|
||
private | ||
|
||
def create_client | ||
u = Beeminder::User.new access_token, auth_type: :oauth | ||
class << u | ||
def _connection *a | ||
p *a | ||
super *a | ||
end | ||
end | ||
u | ||
end | ||
|
||
def goal_name | ||
'beemindesk' | ||
end | ||
|
||
def goal_options | ||
{ | ||
slug: goal_name, | ||
title: "Hours on ODesk", | ||
goal_type: :custom, | ||
rate: 0, | ||
goaldate: 1.year.from_now.utc.to_i, | ||
ephem: true, | ||
kyoom: true, | ||
aggday: :last, | ||
steppy: true | ||
} | ||
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 |
---|---|---|
|
@@ -6,4 +6,8 @@ class User < ActiveRecord::Base | |
def hours | ||
odesk.client.hours | ||
end | ||
|
||
def goal | ||
beeminder.goal | ||
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