Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Then add the following line to your crontab (schedule may vary, of course):

== How to use

First, go to your Redmine profile and set your Toggl API key. You can get one at https://www.toggl.com/app/profile.
First, go to your Redmine profile and set your Toggl API key. You can get one at https://track.toggl.com/profile.
If you want to use only some of your Toggl workspaces, you can set them up in Redmine as a comma separated string. To fetch entries from all workspaces, just leave workspace setting empty.

After that any entry in Toggl marked with a hash and a number goes to the corresponding task in your projects. For example, an entry "Going out with Sarah #1324" of 2.5 hours will add 2.5h to the issue #1324 with the "Going out with Sarah" comment.
Expand Down
5 changes: 3 additions & 2 deletions app/models/toggl_api_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def get_toggl_entries
protected

def get_latest_toggl_entries_api_response(target)
uri = URI.parse "https://www.toggl.com/api/v8/#{target}"
# https://github.com/toggl/toggl_api_docs/blob/master/toggl_api.md
uri = URI.parse "https://api.track.toggl.com/api/v8/#{target}"
uri.query = URI.encode_www_form({ :user_agent => 'Redmine Toggl Client' })

http = Net::HTTP.new(uri.host, uri.port)
Expand All @@ -48,7 +49,7 @@ def get_latest_toggl_entries_api_response(target)
req.basic_auth @toggl_api_key, 'api_token'

res = http.request(req)

if res.code.eql? "200"
JSON.parse(res.body)
else
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/001_create_toggl_time_entries.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateTogglTimeEntries < ActiveRecord::Migration
class CreateTogglTimeEntries < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
def change
create_table :toggl_time_entries do |t|
end
Expand Down
6 changes: 3 additions & 3 deletions db/migrate/002_create_api_key_field.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateApiKeyField < ActiveRecord::Migration
class CreateApiKeyField < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]

def up
custom_field = CustomField.new_subclass_instance('UserCustomField', {
Expand All @@ -15,9 +15,9 @@ def up
})
custom_field.save!
end

def down
CustomField.find_by_name('Toggl API Key').destroy
end

end
end
3 changes: 1 addition & 2 deletions db/migrate/003_set_api_key_not_visible.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class SetApiKeyNotVisible < ActiveRecord::Migration
class SetApiKeyNotVisible < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]

def up
custom_field = CustomField.find_by_name('Toggl API Key')
Expand All @@ -13,4 +13,3 @@ def down
end

end

2 changes: 1 addition & 1 deletion db/migrate/004_create_workspace_field.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateWorkspaceField < ActiveRecord::Migration
class CreateWorkspaceField < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]

def up
custom_field = CustomField.new_subclass_instance('UserCustomField', {
Expand Down