ruby_desk 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ruby_desk/connector.rb +3 -1
- data/lib/ruby_desk/time_report.rb +18 -11
- data/lib/ruby_desk.rb +1 -0
- data/test/test_ruby_desk.rb +4 -3
- metadata +18 -9
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/lib/ruby_desk/connector.rb
CHANGED
@@ -100,6 +100,7 @@ module RubyDesk
|
|
100
100
|
case resp.code
|
101
101
|
when "200" then return data
|
102
102
|
when "401" then raise RubyDesk::UnauthorizedError, data
|
103
|
+
when "404" then raise RubyDesk::PageNotFound, data
|
103
104
|
when "500" then raise RubyDesk::ServerError, data
|
104
105
|
end
|
105
106
|
|
@@ -109,6 +110,7 @@ module RubyDesk
|
|
109
110
|
def prepare_and_invoke_api_call(path, options = {})
|
110
111
|
api_call = prepare_api_call(path, options)
|
111
112
|
data = invoke_api_call(api_call)
|
113
|
+
|
112
114
|
parsed_data = case options[:format]
|
113
115
|
when 'json' then JSON.parse(data)
|
114
116
|
when 'xml' then REXML::Document.new(data)
|
@@ -129,7 +131,7 @@ module RubyDesk
|
|
129
131
|
# return the URL that logs user out of odesk applications
|
130
132
|
def logout_url
|
131
133
|
logout_call = prepare_api_call("", :base_url=>ODESK_AUTH_URL,
|
132
|
-
:secure=>false)
|
134
|
+
:secure=>false, :auth=>false)
|
133
135
|
return logout_call[:url]
|
134
136
|
end
|
135
137
|
|
@@ -29,27 +29,34 @@ class RubyDesk::TimeReport
|
|
29
29
|
# * provider_id
|
30
30
|
# * worked_on
|
31
31
|
# * assignment_team_id
|
32
|
-
# * provider_id
|
33
32
|
# * task
|
34
33
|
# :order
|
35
34
|
def self.find(connector, options={})
|
36
35
|
options = DEFAULT_OPTIONS.merge(options)
|
36
|
+
options[:conditions].each_pair do |k, v|
|
37
|
+
if Array === v && v.size == 1
|
38
|
+
options[:conditions][k] = v.first
|
39
|
+
elsif Array === v && v.empty?
|
40
|
+
options[:conditions].delete(k)
|
41
|
+
end
|
42
|
+
end
|
37
43
|
call_url = "timereports/v1"
|
38
44
|
# Adjust a URL that has as much information as we can
|
39
45
|
if String === options[:conditions][:company_id]
|
40
46
|
# Limit to one company in url (better looking)
|
41
47
|
call_url << "/companies/#{options[:conditions].delete :company_id}"
|
42
|
-
|
43
|
-
|
44
|
-
# Limit to one agency in url (better looking)
|
45
|
-
call_url << "/agencies/#{options[:conditions].delete :agency_id}"
|
46
|
-
elsif String === options[:conditions][:team_id]
|
47
|
-
# Limit to one team in url (better looking)
|
48
|
-
call_url << "/teams/#{options[:conditions].delete :team_id}"
|
49
|
-
end
|
50
|
-
elsif String === options[:conditions][:provider_id]
|
48
|
+
end
|
49
|
+
if String === options[:conditions][:provider_id]
|
51
50
|
call_url << "/providers/#{options[:conditions].delete :provider_id}"
|
52
51
|
end
|
52
|
+
if String === options[:conditions][:agency_id]
|
53
|
+
# Limit to one agency in url (better looking)
|
54
|
+
call_url << "/agencies/#{options[:conditions].delete :agency_id}"
|
55
|
+
end
|
56
|
+
if String === options[:conditions][:team_id]
|
57
|
+
# Limit to one team in url (better looking)
|
58
|
+
call_url << "/teams/#{options[:conditions].delete :team_id}"
|
59
|
+
end
|
53
60
|
|
54
61
|
call_url << "/hours" if options[:hours]
|
55
62
|
|
@@ -104,7 +111,7 @@ class RubyDesk::TimeReport
|
|
104
111
|
|
105
112
|
def self.value_to_str(value)
|
106
113
|
case value
|
107
|
-
when String then value
|
114
|
+
when String then "'#{value}'"
|
108
115
|
when Date, Time then "'"+value.strftime("%Y-%m-%d")+"'"
|
109
116
|
when Numeric then value.to_s
|
110
117
|
end
|
data/lib/ruby_desk.rb
CHANGED
data/test/test_ruby_desk.rb
CHANGED
@@ -105,9 +105,9 @@ class TestRubyDesk < Test::Unit::TestCase
|
|
105
105
|
"SELECT worked_on WHERE (worked_on='2009-10-10')"],
|
106
106
|
[{:select=>"worked_on, provider_id", :conditions=>{:provider_id=>[1,2,3]}},
|
107
107
|
"SELECT worked_on, provider_id WHERE (provider_id=1 OR provider_id=2 OR provider_id=3)"],
|
108
|
-
[{:select=>"worked_on", :conditions=>{:provider_id=>
|
109
|
-
["SELECT worked_on WHERE (agency_id=3) AND (provider_id=
|
110
|
-
"SELECT worked_on WHERE (provider_id=
|
108
|
+
[{:select=>"worked_on", :conditions=>{:provider_id=>'aseldawy', :agency_id=>3}},
|
109
|
+
["SELECT worked_on WHERE (agency_id=3) AND (provider_id='aseldawy')",
|
110
|
+
"SELECT worked_on WHERE (provider_id='aseldawy') AND (agency_id=3)"]],
|
111
111
|
[{:select=>"worked_on", :conditions=>{:provider_id=>1..3}},
|
112
112
|
"SELECT worked_on WHERE (provider_id>=1 AND provider_id<=3)"],
|
113
113
|
[{:select=>"worked_on", :conditions=>{:provider_id=>1...3}},
|
@@ -116,6 +116,7 @@ class TestRubyDesk < Test::Unit::TestCase
|
|
116
116
|
"SELECT worked_on,hours"],
|
117
117
|
]
|
118
118
|
test_data.each do |options, query|
|
119
|
+
# I use include? because some queries have more than possible form
|
119
120
|
assert query.include?(RubyDesk::TimeReport.build_query(options))
|
120
121
|
end
|
121
122
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_desk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 7
|
8
|
+
- 0
|
9
|
+
version: 0.7.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Ahmed ElDawy
|
@@ -9,19 +14,21 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-03-03 00:00:00 +02:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: json
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
25
32
|
description: A gem that works as an interface for oDesk APIs that can be used for both desktop and web applications
|
26
33
|
email: ahmed.eldawy@badrit.com
|
27
34
|
executables: []
|
@@ -67,18 +74,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
74
|
requirements:
|
68
75
|
- - ">="
|
69
76
|
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
70
79
|
version: "0"
|
71
|
-
version:
|
72
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
81
|
requirements:
|
74
82
|
- - ">="
|
75
83
|
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
76
86
|
version: "0"
|
77
|
-
version:
|
78
87
|
requirements: []
|
79
88
|
|
80
89
|
rubyforge_project:
|
81
|
-
rubygems_version: 1.3.
|
90
|
+
rubygems_version: 1.3.6
|
82
91
|
signing_key:
|
83
92
|
specification_version: 3
|
84
93
|
summary: Wrapper for oDesk APIs in Ruby
|