togglv8 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f08bb5759304ca1a721e28f335d5db0108f5539a
4
- data.tar.gz: ec94cd237fe7db781fec895b50caf7015ef56a8f
3
+ metadata.gz: 9d725d89aea919d3f3eed4468bb6d7cb5809d396
4
+ data.tar.gz: e66e5464bd76daac97a9ed67eb04b0b3373844b4
5
5
  SHA512:
6
- metadata.gz: 76c25d3b0534bc3f6b4c50b95d3151d1ef5a054fd4397836bd66258634312f938d2ae0e6c14f598c245be3aaeee0ed7684216b2442887a0b3335463b054ffd05
7
- data.tar.gz: e7a5d4be646c46db1313ae5ea512f5e2654ebe6ba41f2284cd3053f5750e89dc40335278ef8f07849fa4f89b5c4364ba88f53bc888c956d103c7002280011a95
6
+ metadata.gz: a9704d75caa47000e37c957b10e75599e3837fd55b4d28ff9db9c2442a8ca3e0db5cf57804329e737f78f25852182566fe9b149b0f56775cfc9140e9b8fd7ed3
7
+ data.tar.gz: 84f27430a51dfe0b085b581bd9378b8a8dba85c6ed9867b593d8ddde430048af15563d1146f605706c2e08d944fe4866062cb2c7d459b88f3b317f5e5421a095
data/README.md CHANGED
@@ -51,6 +51,26 @@ See specs for more examples.
51
51
 
52
52
  > For rate limiting we have implemented a Leaky bucket. When a limit has been hit the request will get a HTTP 429 response and it's the task of the client to sleep/wait until bucket is empty. Limits will and can change during time, but a safe window will be 1 request per second. Limiting is applied per api token per IP, meaning two users from the same IP will get their rate allocated separately.
53
53
 
54
+ ## Debugging
55
+
56
+ The `TogglV8::API#debug` method determines if debug output is printed to STDOUT. (The default is `true`.) This code snippet demonstrates the debug output.
57
+
58
+ ```ruby
59
+ require 'togglv8'
60
+
61
+ toggl = TogglV8::API.new
62
+
63
+ toggl.debug(true) # or simply toggl.debug
64
+ user1 = toggl.me
65
+ puts "user: #{user1['fullname']}, debug: true"
66
+
67
+ puts '-'*80
68
+
69
+ toggl.debug(false)
70
+ user2 = toggl.me
71
+ puts "user: #{user2['fullname']}, debug: false"
72
+ ```
73
+
54
74
  ## Documentation
55
75
 
56
76
  Run `rdoc` to generate documentation. Open `doc/index.html` in your browser.
data/lib/togglv8.rb CHANGED
@@ -105,6 +105,7 @@ module TogglV8
105
105
  end
106
106
 
107
107
  def get(resource)
108
+ resource.gsub!('+', '%2B')
108
109
  full_resp = _call_api(debug_output: lambda { "GET #{resource}" },
109
110
  api_call: lambda { self.conn.get(resource) } )
110
111
  return {} if full_resp == {}
@@ -114,6 +115,7 @@ module TogglV8
114
115
  end
115
116
 
116
117
  def post(resource, data='')
118
+ resource.gsub!('+', '%2B')
117
119
  full_resp = _call_api(debug_output: lambda { "POST #{resource} / #{data}" },
118
120
  api_call: lambda { self.conn.post(resource, Oj.dump(data)) } )
119
121
  return {} if full_resp == {}
@@ -122,6 +124,7 @@ module TogglV8
122
124
  end
123
125
 
124
126
  def put(resource, data='')
127
+ resource.gsub!('+', '%2B')
125
128
  full_resp = _call_api(debug_output: lambda { "PUT #{resource} / #{data}" },
126
129
  api_call: lambda { self.conn.put(resource, Oj.dump(data)) } )
127
130
  return {} if full_resp == {}
@@ -130,6 +133,7 @@ module TogglV8
130
133
  end
131
134
 
132
135
  def delete(resource)
136
+ resource.gsub!('+', '%2B')
133
137
  full_resp = _call_api(debug_output: lambda { "DELETE #{resource}" },
134
138
  api_call: lambda { self.conn.delete(resource) } )
135
139
  return {} if full_resp == {}
@@ -38,7 +38,7 @@ module TogglV8
38
38
  if !params.has_key?('wid') and !params.has_key?('pid') and !params.has_key?('tid') then
39
39
  raise ArgumentError, "one of params['wid'], params['pid'], params['tid'] is required"
40
40
  end
41
- post "time_entries/start", {time_entry: params}
41
+ post "time_entries/start", { 'time_entry' => params }
42
42
  end
43
43
 
44
44
  def stop_time_entry(time_entry_id)
@@ -1,4 +1,4 @@
1
1
  module TogglV8
2
2
  # :section:
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.4"
4
4
  end
@@ -17,7 +17,7 @@ describe 'Clients' do
17
17
 
18
18
  context 'new client' do
19
19
  before :all do
20
- @client = @toggl.create_client({ 'name' => 'new client', 'wid' => @workspace_id })
20
+ @client = @toggl.create_client({ 'name' => 'new client +1', 'wid' => @workspace_id })
21
21
  client_ids = @toggl.my_clients.map { |c| c['id'] }
22
22
  expect(client_ids).to eq [ @client['id'] ]
23
23
  end
@@ -60,7 +60,7 @@ describe 'Clients' do
60
60
 
61
61
  it 'creates a client' do
62
62
  expect(@client).to_not be nil
63
- expect(@client['name']).to eq 'new client'
63
+ expect(@client['name']).to eq 'new client +1'
64
64
  expect(@client['notes']).to eq nil
65
65
  expect(@client['wid']).to eq @workspace_id
66
66
  end
@@ -12,7 +12,7 @@ describe 'Dashboard' do
12
12
 
13
13
  context 'gets dashboard time entries' do
14
14
  before :all do
15
- @new_time_entry = @toggl.start_time_entry({ 'wid' => @workspace_id, 'description' => 'new time entry' })
15
+ @new_time_entry = @toggl.start_time_entry({ 'wid' => @workspace_id, 'description' => 'new time entry +1' })
16
16
  end
17
17
 
18
18
  after :all do
@@ -25,7 +25,7 @@ describe 'Dashboard' do
25
25
  expect(dashboard['activity']).to_not be nil
26
26
  expect(dashboard['activity'].first['user_id']).to eq @toggl.me['id']
27
27
  expect(dashboard['activity'].first['project_id']).to be nil
28
- expect(dashboard['activity'].first['description']).to eq 'new time entry'
28
+ expect(dashboard['activity'].first['description']).to eq 'new time entry +1'
29
29
  end
30
30
  end
31
31
  end
@@ -12,7 +12,7 @@ describe 'Projects' do
12
12
 
13
13
  context 'new project' do
14
14
  before :all do
15
- @project = @toggl.create_project({ 'name' => 'new project', 'wid' => @workspace_id })
15
+ @project = @toggl.create_project({ 'name' => 'new project +1', 'wid' => @workspace_id })
16
16
  project_ids = @toggl.my_projects.map { |p| p['id'] }
17
17
  expect(project_ids).to eq [ @project['id'] ]
18
18
  end
@@ -25,7 +25,7 @@ describe 'Projects' do
25
25
 
26
26
  it 'creates a project' do
27
27
  expect(@project).to_not be nil
28
- expect(@project['name']).to eq 'new project'
28
+ expect(@project['name']).to eq 'new project +1'
29
29
  expect(@project['billable']).to eq false
30
30
  expect(@project['is_private']).to eq true
31
31
  expect(@project['active']).to eq true
@@ -7,7 +7,7 @@ describe 'Tags' do
7
7
 
8
8
  context 'new tag' do
9
9
  before :all do
10
- @tag = @toggl.create_tag({ 'name' => 'new tag', 'wid' => @workspace_id })
10
+ @tag = @toggl.create_tag({ 'name' => 'new tag +1', 'wid' => @workspace_id })
11
11
  tag_ids = @toggl.my_tags.map { |t| t['id'] }
12
12
  expect(tag_ids).to eq [ @tag['id'] ]
13
13
  end
@@ -20,7 +20,7 @@ describe 'Tags' do
20
20
 
21
21
  it 'creates a tag' do
22
22
  expect(@tag).to_not be nil
23
- expect(@tag['name']).to eq 'new tag'
23
+ expect(@tag['name']).to eq 'new tag +1'
24
24
  expect(@tag['notes']).to eq nil
25
25
  expect(@tag['wid']).to eq @workspace_id
26
26
  end
@@ -12,7 +12,7 @@ describe 'Tasks', :pro_account do
12
12
 
13
13
  context 'new task' do
14
14
  before :all do
15
- @task = @toggl.create_task({ 'name' => 'new task', 'pid' => @project['id'] })
15
+ @task = @toggl.create_task({ 'name' => 'new task +1', 'pid' => @project['id'] })
16
16
  @task_ids = @toggl.get_project_tasks(@project['id']).map { |t| t['id'] }
17
17
  expect(@task_ids).to eq [ @task['id'] ]
18
18
  end
@@ -25,7 +25,7 @@ describe 'Tasks', :pro_account do
25
25
 
26
26
  it 'creates a task' do
27
27
  expect(@task).to_not be nil
28
- expect(@task['name']).to eq 'new task'
28
+ expect(@task['name']).to eq 'new task +1'
29
29
  expect(@task['pid']).to eq @project['id']
30
30
  expect(@task['wid']).to eq @workspace_id
31
31
  expect(@task['active']).to eq true
@@ -70,10 +70,10 @@ describe 'Users' do
70
70
  it 'creates a new user' do
71
71
  now = Time.now.to_i
72
72
  user_info = {
73
- 'email' => "test-#{now}@mailinator.com",
73
+ 'email' => "test-#{now}+1@mailinator.com",
74
74
  'timezone' => 'Etc/UTC'
75
75
  }
76
- user_password = { 'password' => "password-#{now}" }
76
+ user_password = { 'password' => "password-#{now}+1" }
77
77
 
78
78
  new_user = @toggl.create_user(user_info.merge(user_password))
79
79
  expect(new_user).to include(user_info)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: togglv8
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Kane
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  requirements:
224
224
  - A Toggl account (https://toggl.com/)
225
225
  rubyforge_project:
226
- rubygems_version: 2.4.5.1
226
+ rubygems_version: 2.5.1
227
227
  signing_key:
228
228
  specification_version: 4
229
229
  summary: Toggl v8 API wrapper (See https://github.com/toggl/toggl_api_docs)