odesk-api 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,57 @@
1
+ # Licensed under the oDesk's API Terms of Use;
2
+ # you may not use this file except in compliance with the Terms.
3
+ #
4
+ # Unless required by applicable law or agreed to in writing, software
5
+ # distributed under the License is distributed on an "AS IS" BASIS,
6
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7
+ # See the License for the specific language governing permissions and
8
+ # limitations under the License.
9
+ #
10
+ # Author:: Maksym Novozhylov (mnovozhilov@odesk.com)
11
+ # Copyright:: Copyright 2014(c) oDesk.com
12
+ # License:: See LICENSE.txt and TOS - http://developers.odesk.com/API-Terms-of-Use
13
+
14
+ module Odesk
15
+ module Api
16
+ module Routers
17
+ module Activities
18
+ # Engagement Activities
19
+ class Engagement
20
+ ENTRY_POINT = 'api'
21
+
22
+ # Init
23
+ #
24
+ # Arguments:
25
+ # client: (Client)
26
+ def initialize(client)
27
+ @client = client
28
+ @client.epoint = ENTRY_POINT
29
+ end
30
+
31
+ # List activities for specific engagement
32
+ #
33
+ # Arguments:
34
+ # company: (String)
35
+ # team: (String)
36
+ # engagement_ref: (String)
37
+ # params: (Hash)
38
+ def get_specific(company, team, engagement_ref, params)
39
+ @client.get '/tasks/v2/tasks/contracts/' + engagement_ref, params
40
+ end
41
+
42
+ # Assign engagements to the list of activities
43
+ #
44
+ # Arguments:
45
+ # company: (String)
46
+ # team: (String)
47
+ # engagement: (String)
48
+ # params: (Hash)
49
+ def assign(company, team, engagement, params)
50
+ @client.put '/otask/v1/tasks/companies/' + company + '/' + team + '/engagements/' + engagement, params
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -42,9 +42,10 @@ module Odesk
42
42
  #
43
43
  # Arguments:
44
44
  # reference: (String)
45
- def get_specific(reference)
45
+ # params: (Hash)
46
+ def get_specific(reference, params)
46
47
  $LOG.i "running " + __method__.to_s
47
- @client.get '/offers/v1/clients/offers/' + reference
48
+ @client.get '/offers/v1/clients/offers/' + reference, params
48
49
  end
49
50
 
50
51
  # Make an Offer
@@ -60,4 +61,4 @@ module Odesk
60
61
  end
61
62
  end
62
63
  end
63
- end
64
+ end
@@ -13,6 +13,6 @@
13
13
 
14
14
  module Odesk # :nodoc:
15
15
  module Api
16
- VERSION = "0.1.1"
16
+ VERSION = "0.1.2"
17
17
  end
18
18
  end
@@ -0,0 +1,21 @@
1
+ $:.unshift 'lib'
2
+ $LOAD_PATH << File.dirname(__FILE__)
3
+
4
+ require 'helper'
5
+ require 'odesk/api/routers/activities/engagement'
6
+ require 'test/unit'
7
+ require 'mocha/test_unit'
8
+
9
+ class ActivitiesEngagementTest < Test::Unit::TestCase
10
+ include TestHelper
11
+
12
+ def test_get_specific
13
+ api = Odesk::Api::Routers::Activities::Engagement.new(get_client_mock)
14
+ assert api.get_specific('company', 'team', '1234', {})
15
+ end
16
+
17
+ def test_assign
18
+ api = Odesk::Api::Routers::Activities::Engagement.new(get_client_mock)
19
+ assert api.assign('company', 'team', '1234', {})
20
+ end
21
+ end
@@ -16,11 +16,11 @@ class HrClientsOffersTest < Test::Unit::TestCase
16
16
 
17
17
  def test_get_specific
18
18
  api = Odesk::Api::Routers::Hr::Clients::Offers.new(get_client_mock)
19
- assert api.get_specific('12')
19
+ assert api.get_specific('12', {})
20
20
  end
21
21
 
22
22
  def test_make_offer
23
23
  api = Odesk::Api::Routers::Hr::Clients::Offers.new(get_client_mock)
24
24
  assert api.make_offer({})
25
25
  end
26
- end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: odesk-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-17 00:00:00.000000000 Z
12
+ date: 2014-08-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -63,8 +63,8 @@ files:
63
63
  - lib/odesk/api/config.rb
64
64
  - lib/odesk/api/logger.rb
65
65
  - lib/odesk/api/routers/activities/company.rb
66
+ - lib/odesk/api/routers/activities/engagement.rb
66
67
  - lib/odesk/api/routers/activities/team.rb
67
- - lib/odesk/api/routers/activities/user.rb
68
68
  - lib/odesk/api/routers/auth.rb
69
69
  - lib/odesk/api/routers/freelancers/profile.rb
70
70
  - lib/odesk/api/routers/freelancers/search.rb
@@ -96,8 +96,8 @@ files:
96
96
  - odesk-api.gemspec
97
97
  - test/helper.rb
98
98
  - test/test_activities_company.rb
99
+ - test/test_activities_engagement.rb
99
100
  - test/test_activities_team.rb
100
- - test/test_activities_user.rb
101
101
  - test/test_auth.rb
102
102
  - test/test_client.rb
103
103
  - test/test_config.rb
@@ -156,8 +156,8 @@ summary: Ruby bindings for oDesk API.
156
156
  test_files:
157
157
  - test/helper.rb
158
158
  - test/test_activities_company.rb
159
+ - test/test_activities_engagement.rb
159
160
  - test/test_activities_team.rb
160
- - test/test_activities_user.rb
161
161
  - test/test_auth.rb
162
162
  - test/test_client.rb
163
163
  - test/test_config.rb
@@ -1,125 +0,0 @@
1
- # Licensed under the oDesk's API Terms of Use;
2
- # you may not use this file except in compliance with the Terms.
3
- #
4
- # Unless required by applicable law or agreed to in writing, software
5
- # distributed under the License is distributed on an "AS IS" BASIS,
6
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7
- # See the License for the specific language governing permissions and
8
- # limitations under the License.
9
- #
10
- # Author:: Maksym Novozhylov (mnovozhilov@odesk.com)
11
- # Copyright:: Copyright 2014(c) oDesk.com
12
- # License:: See LICENSE.txt and TOS - http://developers.odesk.com/API-Terms-of-Use
13
-
14
- module Odesk
15
- module Api
16
- module Routers
17
- module Activities
18
- # User Activities
19
- class User
20
- ENTRY_POINT = 'api'
21
-
22
- # Init
23
- #
24
- # Arguments:
25
- # client: (Client)
26
- def initialize(client)
27
- @client = client
28
- @client.epoint = ENTRY_POINT
29
- end
30
-
31
- # List all oTask/Activity records within a Company
32
- #
33
- # Arguments:
34
- # company: (String)
35
- # team: (String)
36
- # user: (String)
37
- def get_list(company, team, user)
38
- get_by_type company, team, user, nil, false
39
- end
40
-
41
- # List all oTask/Activity records within a Company with additional info
42
- #
43
- # Arguments:
44
- # company: (String)
45
- # team: (String)
46
- # user: (String)
47
- def get_full_list(company, team, user)
48
- get_by_type company, team, user, nil, true
49
- end
50
-
51
- # List all oTask/Activity records within a Company by specified code(s)
52
- #
53
- # Arguments:
54
- # company: (String)
55
- # team: (String)
56
- # user: (String)
57
- # code: (String)
58
- def get_specific_list(company, team, user, code)
59
- get_by_type company, team, user, code, false
60
- end
61
-
62
- # Create an oTask/Activity record within a company
63
- #
64
- # Arguments:
65
- # company: (String)
66
- # team: (String)
67
- # user: (String)
68
- # params: (Hash)
69
- def add_activity(company, team, user, params)
70
- @client.post '/otask/v1/tasks/companies/' + company + '/' + team + '/' + user + '/tasks', params
71
- end
72
-
73
- # Update specific oTask/Activity record within a company
74
- #
75
- # Arguments:
76
- # company: (String)
77
- # team: (String)
78
- # user: (String)
79
- # code: (String)
80
- # params: (Hash)
81
- def update_activities(company, team, user, code, params)
82
- @client.put '/otask/v1/tasks/companies/' + company + '/' + team + '/' + user + '/tasks/' + code, params
83
- end
84
-
85
- # Delete specific oTask/Activity record within a company
86
- #
87
- # Arguments:
88
- # company: (String)
89
- # team: (String)
90
- # user: (String)
91
- # code: (String)
92
- def delete_activities(company, team, user, code)
93
- @client.delete '/otask/v1/tasks/companies/' + company + '/' + team + '/' + user + '/tasks/' + code
94
- end
95
-
96
- # Delete all oTask/Activity records within a company
97
- #
98
- # Arguments:
99
- # company: (String)
100
- # team: (String)
101
- # user: (String)
102
- def delete_all_activities(company, team, user)
103
- @client.delete '/otask/v1/tasks/companies/' + company + '/' + team + '/' + user + '/tasks/all_tasks'
104
- end
105
-
106
- private
107
-
108
- # Get by type
109
- def get_by_type(company, team, user, code = nil, is_full = false)
110
- $LOG.i "running " + __method__.to_s
111
- url = '';
112
- if (is_full)
113
- url = '/full_list';
114
- elsif code != nil
115
- url = '/' + code;
116
- end
117
-
118
- @client.get '/otask/v1/tasks/companies/' + company + '/' + team + '/' + user + '/tasks' + url
119
- end
120
-
121
- end
122
- end
123
- end
124
- end
125
- end
@@ -1,46 +0,0 @@
1
- $:.unshift 'lib'
2
- $LOAD_PATH << File.dirname(__FILE__)
3
-
4
- require 'helper'
5
- require 'odesk/api/routers/activities/user'
6
- require 'test/unit'
7
- require 'mocha/test_unit'
8
-
9
- class ActivitiesUserTest < Test::Unit::TestCase
10
- include TestHelper
11
-
12
- def test_get_list
13
- api = Odesk::Api::Routers::Activities::User.new(get_client_mock)
14
- assert api.get_list('company', 'team', 'user')
15
- end
16
-
17
- def test_get_full_list
18
- api = Odesk::Api::Routers::Activities::User.new(get_client_mock)
19
- assert api.get_full_list('company', 'team', 'user')
20
- end
21
-
22
- def test_get_specific_list
23
- api = Odesk::Api::Routers::Activities::User.new(get_client_mock)
24
- assert api.get_specific_list('company', 'team', 'user', 'code')
25
- end
26
-
27
- def test_add_activity
28
- api = Odesk::Api::Routers::Activities::User.new(get_client_mock)
29
- assert api.add_activity('company', 'team', 'user', {})
30
- end
31
-
32
- def test_update_activities
33
- api = Odesk::Api::Routers::Activities::User.new(get_client_mock)
34
- assert api.update_activities('company', 'team', 'user', 'code', {})
35
- end
36
-
37
- def test_delete_activities
38
- api = Odesk::Api::Routers::Activities::User.new(get_client_mock)
39
- assert api.delete_activities('company', 'team', 'user', 'code')
40
- end
41
-
42
- def test_delete_all_activities
43
- api = Odesk::Api::Routers::Activities::User.new(get_client_mock)
44
- assert api.delete_all_activities('company', 'team', 'user')
45
- end
46
- end