podio 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +0 -16
- data/lib/podio.rb +6 -3
- data/lib/podio/active_podio/base.rb +53 -21
- data/lib/podio/active_podio/updatable.rb +9 -14
- data/lib/podio/client.rb +46 -17
- data/lib/podio/error.rb +9 -0
- data/lib/podio/middleware/error_response.rb +5 -1
- data/lib/podio/middleware/json_request.rb +27 -5
- data/lib/podio/models/account_provider.rb +16 -0
- data/lib/podio/models/app_store_category.rb +25 -0
- data/lib/podio/models/app_store_share.rb +90 -11
- data/lib/podio/models/application.rb +52 -12
- data/lib/podio/models/application_field.rb +4 -4
- data/lib/podio/models/batch.rb +31 -0
- data/lib/podio/models/calendar_event.rb +64 -10
- data/lib/podio/models/category.rb +11 -9
- data/lib/podio/models/contact.rb +3 -1
- data/lib/podio/models/contract.rb +3 -0
- data/lib/podio/models/email_subscription_setting.rb +26 -3
- data/lib/podio/models/file_attachment.rb +3 -2
- data/lib/podio/models/form.rb +2 -2
- data/lib/podio/models/importer.rb +18 -9
- data/lib/podio/models/item.rb +87 -22
- data/lib/podio/models/item_field.rb +8 -3
- data/lib/podio/models/linked_account.rb +11 -3
- data/lib/podio/models/linked_account_data.rb +6 -0
- data/lib/podio/models/news.rb +1 -0
- data/lib/podio/models/organization.rb +4 -0
- data/lib/podio/models/organization_member.rb +17 -4
- data/lib/podio/models/organization_profile.rb +5 -1
- data/lib/podio/models/profile.rb +19 -10
- data/lib/podio/models/reference.rb +33 -0
- data/lib/podio/models/search.rb +4 -7
- data/lib/podio/models/space.rb +21 -12
- data/lib/podio/models/space_invitation.rb +7 -7
- data/lib/podio/models/space_member.rb +28 -3
- data/lib/podio/models/task.rb +38 -14
- data/lib/podio/models/user.rb +27 -5
- data/lib/podio/models/user_status.rb +5 -0
- data/lib/podio/models/view.rb +51 -0
- data/lib/podio/models/widget.rb +1 -1
- data/lib/podio/version.rb +1 -1
- data/test/client_test.rb +13 -3
- data/test/fixtures/fixtures.yaml +7 -7
- data/test/test_helper.rb +1 -24
- metadata +16 -23
- data/lib/podio/middleware/response_recorder.rb +0 -14
- data/lib/podio/models/meeting.rb +0 -151
- data/lib/podio/models/meeting_participiant.rb +0 -11
- data/test/fixtures/client/18a224aaf83ac57a7b8159cecdbb1263.rack +0 -1
- data/test/fixtures/client/a87c69a0624af0413a670094c6615651.rack +0 -1
- data/test/fixtures/client/ac493997db62308972c208afa76f8479.rack +0 -1
- data/test/fixtures/client/d7fbf422c77af768552423633d0389e8.rack +0 -1
- data/test/fixtures/client/e2d68afe39f5531195273ea259b63916.rack +0 -1
data/lib/podio/models/user.rb
CHANGED
@@ -8,11 +8,12 @@ class Podio::User < ActivePodio::Base
|
|
8
8
|
property :old_password, :string
|
9
9
|
property :new_password, :string
|
10
10
|
property :flags, :array
|
11
|
+
property :betas, :array
|
11
12
|
property :created_on, :datetime
|
12
13
|
property :name, :string
|
13
14
|
property :link, :string
|
14
15
|
property :avatar, :integer
|
15
|
-
property :profile_id, :integer
|
16
|
+
property :profile_id, :integer
|
16
17
|
property :type, :string
|
17
18
|
|
18
19
|
has_many :mails, :class => 'UserMail'
|
@@ -25,14 +26,14 @@ class Podio::User < ActivePodio::Base
|
|
25
26
|
property :marketo_cookie, :string
|
26
27
|
|
27
28
|
alias_method :id, :user_id
|
28
|
-
|
29
|
+
|
29
30
|
class << self
|
30
31
|
def current
|
31
32
|
member Podio.connection.get("/user/").body
|
32
33
|
end
|
33
34
|
|
34
35
|
def create(attributes)
|
35
|
-
response = Podio.
|
36
|
+
response = Podio.client.trusted_connection.post do |req|
|
36
37
|
req.url '/user/'
|
37
38
|
req.body = attributes
|
38
39
|
end
|
@@ -73,11 +74,28 @@ class Podio::User < ActivePodio::Base
|
|
73
74
|
def get_property(name)
|
74
75
|
Podio.connection.get("/user/property/#{name}").body['value']
|
75
76
|
end
|
76
|
-
|
77
|
+
|
77
78
|
def set_property(name, value)
|
78
79
|
Podio.connection.put("/user/property/#{name}", {:value => value}).status
|
79
80
|
end
|
80
81
|
|
82
|
+
def get_property_hash(name)
|
83
|
+
Podio.connection.get("/user/property/#{name}").body
|
84
|
+
end
|
85
|
+
|
86
|
+
def set_property_hash(name, hash)
|
87
|
+
Podio.connection.put("/user/property/#{name}", hash).status
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_properties(attributes)
|
91
|
+
response = Podio.connection.put do |req|
|
92
|
+
req.url '/user/property/'
|
93
|
+
req.body = attributes
|
94
|
+
end
|
95
|
+
|
96
|
+
response.body
|
97
|
+
end
|
98
|
+
|
81
99
|
def remove_property(name)
|
82
100
|
Podio.connection.delete("/user/property/#{name}", {}).status
|
83
101
|
end
|
@@ -115,6 +133,10 @@ class Podio::User < ActivePodio::Base
|
|
115
133
|
|
116
134
|
def delete
|
117
135
|
Podio.connection.delete("/user/").status
|
118
|
-
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def internal_source
|
139
|
+
Podio.connection.get("/user/source").body
|
140
|
+
end
|
119
141
|
end
|
120
142
|
end
|
@@ -15,6 +15,11 @@ class Podio::UserStatus < ActivePodio::Base
|
|
15
15
|
def current
|
16
16
|
member Podio.connection.get("/user/status").body
|
17
17
|
end
|
18
|
+
|
19
|
+
def find_first_ux
|
20
|
+
Podio.connection.get("/user/status/1ux").body
|
21
|
+
end
|
22
|
+
|
18
23
|
def find_for_space(space_id)
|
19
24
|
Podio.connection.get("/user/status/1ux/space/#{space_id}").body
|
20
25
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class Podio::View < ActivePodio::Base
|
2
|
+
property :view_id, :integer
|
3
|
+
property :name, :string
|
4
|
+
property :created_on, :datetime
|
5
|
+
property :items, :integer
|
6
|
+
property :sort_by, :string
|
7
|
+
property :sort_desc, :string
|
8
|
+
property :filters, :hash
|
9
|
+
property :layout, :string
|
10
|
+
property :fields, :hash
|
11
|
+
|
12
|
+
alias_method :id, :view_id
|
13
|
+
|
14
|
+
has_one :created_by, :class => 'User'
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def find_last(app_id)
|
18
|
+
member Podio.connection.get("/view/app/#{app_id}/last").body
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_all(app_id)
|
22
|
+
list Podio.connection.get { |req|
|
23
|
+
req.url("/view/app/#{app_id}/")
|
24
|
+
}.body
|
25
|
+
end
|
26
|
+
|
27
|
+
def find(id)
|
28
|
+
member Podio.connection.get("/view/#{id}").body
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(view_id)
|
32
|
+
Podio.connection.delete("/view/#{view_id}").status
|
33
|
+
end
|
34
|
+
|
35
|
+
def create(app_id, attributes)
|
36
|
+
response = Podio.connection.post do |req|
|
37
|
+
req.url "/view/app/#{app_id}/"
|
38
|
+
req.body = attributes
|
39
|
+
end
|
40
|
+
|
41
|
+
response.body['view_id']
|
42
|
+
end
|
43
|
+
|
44
|
+
def update_last(app_id, attributes)
|
45
|
+
Podio.connection.put do |req|
|
46
|
+
req.url "/view/app/#{app_id}/last"
|
47
|
+
req.body = attributes
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/podio/models/widget.rb
CHANGED
data/lib/podio/version.rb
CHANGED
data/test/client_test.rb
CHANGED
@@ -27,10 +27,12 @@ class ClientTest < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
test 'should get an access token' do
|
30
|
+
Podio.client.stubs.post('/oauth/token') {[200, {}, {"access_token" => "a3345189a07b478284356c8b0b3c54d5", "expires_in" => 28799, "refresh_token" => "cdca6acfeb374598ba2790c9e5283b21"}]}
|
31
|
+
|
30
32
|
client = Podio.client
|
31
33
|
client.oauth_token = nil
|
32
34
|
assert_nil client.oauth_token
|
33
|
-
|
35
|
+
|
34
36
|
user = fixtures[:users][:professor]
|
35
37
|
client.authenticate_with_credentials(user[:mail], user[:password])
|
36
38
|
|
@@ -39,10 +41,14 @@ class ClientTest < Test::Unit::TestCase
|
|
39
41
|
end
|
40
42
|
|
41
43
|
test 'should be able to refresh access token' do
|
44
|
+
Podio.client.stubs.post('/oauth/token') {[200, {}, {"access_token" => "a3345189a07b478284356c8b0b3c54d5", "expires_in" => 28799, "refresh_token" => "cdca6acfeb374598ba2790c9e5283b21"}]}
|
45
|
+
|
42
46
|
login_as(:fry)
|
43
47
|
client = Podio.client
|
44
48
|
old_token = client.oauth_token.dup
|
45
49
|
|
50
|
+
Podio.client.stubs.post('/oauth/token') {[200, {}, {"access_token" => "efb7614007ae426481de69310ec14953", "expires_in" => 28799, "refresh_token" => "cdca6acfeb374598ba2790c9e5283b21"}]}
|
51
|
+
|
46
52
|
client.refresh_access_token
|
47
53
|
|
48
54
|
assert_not_equal old_token.access_token, client.oauth_token.access_token
|
@@ -50,12 +56,13 @@ class ClientTest < Test::Unit::TestCase
|
|
50
56
|
end
|
51
57
|
|
52
58
|
test 'should automatically refresh an expired token' do
|
53
|
-
|
54
|
-
# Podio.client.oauth_token = Podio::OAuthToken.new('access_token' => '30da4594eef93528c11df7fb5deb989cd629ea7060a1ce1ced628d19398214c942bcfe0334cf953ef70a80ea1afdfd80183d5c75d19c1f5526ca4c6f6f3471ef', 'refresh_token' => '82e7a11ae187f28a25261599aa6229cd89f8faee48cba18a75d70efae88ba665ced11d43143b7f5bebb31a4103662b851dd2db1879a3947b843259479fccfad3', 'expires_in' => -10)
|
59
|
+
Podio.client.stubs.post('/oauth/token') {[200, {}, {"access_token" => "a3345189a07b478284356c8b0b3c54d5", "expires_in" => 28799, "refresh_token" => "cdca6acfeb374598ba2790c9e5283b21"}]}
|
55
60
|
|
56
61
|
login_as(:professor)
|
57
62
|
Podio.client.reset
|
58
63
|
|
64
|
+
Podio.client.stubs.get('/org/') {[200, {}, [{"status" => "active"}]]}
|
65
|
+
|
59
66
|
assert_nothing_raised do
|
60
67
|
response = Podio.connection.get("/org/")
|
61
68
|
assert_equal 200, response.status
|
@@ -80,6 +87,9 @@ class ClientTest < Test::Unit::TestCase
|
|
80
87
|
|
81
88
|
test 'should be able to make arbitrary requests' do
|
82
89
|
login_as(:professor)
|
90
|
+
|
91
|
+
Podio.client.stubs.get('/org/') {[200, {}, [{"status" => "active"}]]}
|
92
|
+
|
83
93
|
response = Podio.connection.get("/org/")
|
84
94
|
assert_equal 200, response.status
|
85
95
|
assert response.body.is_a?(Array)
|
data/test/fixtures/fixtures.yaml
CHANGED
@@ -6,29 +6,29 @@
|
|
6
6
|
:user_id: 3
|
7
7
|
:professor:
|
8
8
|
:mail: professor@planetexpress.com
|
9
|
-
:password:
|
9
|
+
:password: professor_$ecur3Pwd
|
10
10
|
:user_id: 4
|
11
11
|
:fry:
|
12
12
|
:mail: fry@planetexpress.com
|
13
|
-
:password:
|
13
|
+
:password: fry_$ecur3Pwd
|
14
14
|
:user_id: 5
|
15
15
|
:leela:
|
16
16
|
:mail: leela@planetexpress.com
|
17
|
-
:password:
|
17
|
+
:password: leela_$ecur3Pwd
|
18
18
|
:user_id: 6
|
19
19
|
:bender:
|
20
20
|
:mail: bender@planetexpress.com
|
21
|
-
:password:
|
21
|
+
:password: killallhumans_$ecur3Pwd
|
22
22
|
:user_id: 7
|
23
23
|
:amy:
|
24
24
|
:mail: amy@planetexpress.com
|
25
|
-
:password:
|
25
|
+
:password: amy_$ecur3Pwd
|
26
26
|
:user_id: 8
|
27
27
|
:zoidberg:
|
28
28
|
:mail: zoidberg@planetexpress.com
|
29
|
-
:password:
|
29
|
+
:password: zoidberg_$ecur3Pwd
|
30
30
|
:user_id: 9
|
31
31
|
:hermes:
|
32
32
|
:mail: hermes@planetexpress.com
|
33
|
-
:password:
|
33
|
+
:password: hermes_$ecur3Pwd
|
34
34
|
:user_id: 10
|
data/test/test_helper.rb
CHANGED
@@ -2,14 +2,10 @@ require 'test/unit'
|
|
2
2
|
|
3
3
|
require 'podio'
|
4
4
|
|
5
|
-
ENABLE_STUBS = ENV['ENABLE_STUBS'] == 'true'
|
6
|
-
ENABLE_RECORD = ENV['ENABLE_RECORD'] == 'true'
|
7
|
-
|
8
5
|
class Test::Unit::TestCase
|
9
6
|
|
10
7
|
def setup
|
11
8
|
set_podio_client
|
12
|
-
stub_responses if ENABLE_STUBS
|
13
9
|
end
|
14
10
|
|
15
11
|
# test "verify something" do
|
@@ -33,8 +29,7 @@ class Test::Unit::TestCase
|
|
33
29
|
:api_url => 'http://api-sandbox.podio.dev',
|
34
30
|
:api_key => 'sandbox@podio.com',
|
35
31
|
:api_secret => 'sandbox_secret',
|
36
|
-
:enable_stubs =>
|
37
|
-
:record_mode => ENABLE_RECORD,
|
32
|
+
:enable_stubs => true,
|
38
33
|
:test_mode => true
|
39
34
|
)
|
40
35
|
end
|
@@ -47,24 +42,6 @@ class Test::Unit::TestCase
|
|
47
42
|
Podio.client.reset
|
48
43
|
end
|
49
44
|
|
50
|
-
def stub_responses
|
51
|
-
folder_name = self.class.name.underscore.gsub('_test', '')
|
52
|
-
current_folder = File.join(File.dirname(__FILE__), 'fixtures', folder_name)
|
53
|
-
|
54
|
-
if File.exists?(current_folder)
|
55
|
-
Dir.foreach(current_folder) do |filename|
|
56
|
-
next unless filename.include?('.rack')
|
57
|
-
|
58
|
-
rack_response = eval(File.read(File.join(current_folder, filename)))
|
59
|
-
|
60
|
-
url = rack_response.shift
|
61
|
-
method = rack_response.shift
|
62
|
-
|
63
|
-
Podio.client.stubs.send(method, url) { rack_response }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
45
|
def fixtures
|
69
46
|
@fixtures ||= YAML.load_file(File.join(File.dirname(__FILE__), 'fixtures', 'fixtures.yaml'))
|
70
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: podio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: faraday
|
17
|
-
requirement: &
|
17
|
+
requirement: &2152006820 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.7.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2152006820
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activesupport
|
28
|
-
requirement: &
|
28
|
+
requirement: &2152005480 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2152005480
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: activemodel
|
39
|
-
requirement: &
|
39
|
+
requirement: &2152004840 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '3.0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2152004840
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: multi_json
|
50
|
-
requirement: &
|
50
|
+
requirement: &2152004340 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2152004340
|
59
59
|
description: ! 'The official Ruby wrapper for the Podio API used and maintained by
|
60
60
|
the Podio team
|
61
61
|
|
@@ -83,14 +83,16 @@ files:
|
|
83
83
|
- lib/podio/middleware/json_response.rb
|
84
84
|
- lib/podio/middleware/logger.rb
|
85
85
|
- lib/podio/middleware/oauth2.rb
|
86
|
-
- lib/podio/
|
86
|
+
- lib/podio/models/account_provider.rb
|
87
87
|
- lib/podio/models/action.rb
|
88
88
|
- lib/podio/models/activation_status.rb
|
89
89
|
- lib/podio/models/activity.rb
|
90
|
+
- lib/podio/models/app_store_category.rb
|
90
91
|
- lib/podio/models/app_store_share.rb
|
91
92
|
- lib/podio/models/application.rb
|
92
93
|
- lib/podio/models/application_email.rb
|
93
94
|
- lib/podio/models/application_field.rb
|
95
|
+
- lib/podio/models/batch.rb
|
94
96
|
- lib/podio/models/bulletin.rb
|
95
97
|
- lib/podio/models/by_line.rb
|
96
98
|
- lib/podio/models/calendar_event.rb
|
@@ -119,8 +121,7 @@ files:
|
|
119
121
|
- lib/podio/models/item_field.rb
|
120
122
|
- lib/podio/models/item_revision.rb
|
121
123
|
- lib/podio/models/linked_account.rb
|
122
|
-
- lib/podio/models/
|
123
|
-
- lib/podio/models/meeting_participiant.rb
|
124
|
+
- lib/podio/models/linked_account_data.rb
|
124
125
|
- lib/podio/models/news.rb
|
125
126
|
- lib/podio/models/notification.rb
|
126
127
|
- lib/podio/models/notification_group.rb
|
@@ -136,6 +137,7 @@ files:
|
|
136
137
|
- lib/podio/models/question_option.rb
|
137
138
|
- lib/podio/models/rating.rb
|
138
139
|
- lib/podio/models/recurrence.rb
|
140
|
+
- lib/podio/models/reference.rb
|
139
141
|
- lib/podio/models/referral.rb
|
140
142
|
- lib/podio/models/reminder.rb
|
141
143
|
- lib/podio/models/search.rb
|
@@ -155,17 +157,13 @@ files:
|
|
155
157
|
- lib/podio/models/user_mail.rb
|
156
158
|
- lib/podio/models/user_status.rb
|
157
159
|
- lib/podio/models/via.rb
|
160
|
+
- lib/podio/models/view.rb
|
158
161
|
- lib/podio/models/widget.rb
|
159
162
|
- lib/podio/response_wrapper.rb
|
160
163
|
- lib/podio/version.rb
|
161
164
|
- podio.gemspec
|
162
165
|
- test/active_podio_test.rb
|
163
166
|
- test/client_test.rb
|
164
|
-
- test/fixtures/client/18a224aaf83ac57a7b8159cecdbb1263.rack
|
165
|
-
- test/fixtures/client/a87c69a0624af0413a670094c6615651.rack
|
166
|
-
- test/fixtures/client/ac493997db62308972c208afa76f8479.rack
|
167
|
-
- test/fixtures/client/d7fbf422c77af768552423633d0389e8.rack
|
168
|
-
- test/fixtures/client/e2d68afe39f5531195273ea259b63916.rack
|
169
167
|
- test/fixtures/fixtures.yaml
|
170
168
|
- test/models_sanity_test.rb
|
171
169
|
- test/test_helper.rb
|
@@ -196,11 +194,6 @@ summary: Ruby wrapper for the Podio API
|
|
196
194
|
test_files:
|
197
195
|
- test/active_podio_test.rb
|
198
196
|
- test/client_test.rb
|
199
|
-
- test/fixtures/client/18a224aaf83ac57a7b8159cecdbb1263.rack
|
200
|
-
- test/fixtures/client/a87c69a0624af0413a670094c6615651.rack
|
201
|
-
- test/fixtures/client/ac493997db62308972c208afa76f8479.rack
|
202
|
-
- test/fixtures/client/d7fbf422c77af768552423633d0389e8.rack
|
203
|
-
- test/fixtures/client/e2d68afe39f5531195273ea259b63916.rack
|
204
197
|
- test/fixtures/fixtures.yaml
|
205
198
|
- test/models_sanity_test.rb
|
206
199
|
- test/test_helper.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'digest/md5'
|
2
|
-
|
3
|
-
module Podio
|
4
|
-
module Middleware
|
5
|
-
class ResponseRecorder < Faraday::Response::Middleware
|
6
|
-
def on_complete(env)
|
7
|
-
response = "['#{Faraday::Utils.normalize_path(env[:url])}', :#{env[:method]}, #{env[:status]}, #{env[:response_headers]}, '#{env[:body]}']"
|
8
|
-
|
9
|
-
filename = Digest::MD5.hexdigest(env[:url].request_uri)
|
10
|
-
::File.open("#{filename}.rack", 'w') { |f| f.write(response) }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/lib/podio/models/meeting.rb
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
class Podio::Meeting < ActivePodio::Base
|
2
|
-
include ActivePodio::Updatable, HasReference
|
3
|
-
|
4
|
-
property :meeting_id, :integer
|
5
|
-
property :rights, :array
|
6
|
-
property :title, :string
|
7
|
-
property :start_date, :date
|
8
|
-
property :starts_on, :datetime, :convert_incoming_local_datetime_to_utc => true
|
9
|
-
property :ends_on, :datetime, :convert_incoming_local_datetime_to_utc => true
|
10
|
-
property :participant_ids, :array
|
11
|
-
property :plugin, :string
|
12
|
-
property :plugin_data, :hash
|
13
|
-
property :location, :string
|
14
|
-
property :agenda, :string
|
15
|
-
property :notes, :string
|
16
|
-
property :subscribed, :bool
|
17
|
-
property :liked, :integer
|
18
|
-
property :external_id, :string
|
19
|
-
property :external_url, :string
|
20
|
-
property :external_phone, :string
|
21
|
-
property :external_password, :string
|
22
|
-
property :external_recording_url, :string
|
23
|
-
property :created_on, :datetime
|
24
|
-
property :deleted_on, :datetime
|
25
|
-
property :link, :string
|
26
|
-
property :ref, :hash
|
27
|
-
property :space_id, :integer
|
28
|
-
|
29
|
-
# For creation only
|
30
|
-
property :ref_id, :integer
|
31
|
-
property :ref_type, :string
|
32
|
-
property :file_ids, :array
|
33
|
-
|
34
|
-
has_one :created_by, :class => 'User'
|
35
|
-
has_one :created_via, :class => 'Via'
|
36
|
-
has_many :participants, :class => 'MeetingParticipant'
|
37
|
-
has_many :files, :class => 'FileAttachment'
|
38
|
-
has_many :comments, :class => 'Comment'
|
39
|
-
has_one :reminder, :class => 'Reminder'
|
40
|
-
has_one :recurrence, :class => 'Recurrence'
|
41
|
-
|
42
|
-
alias_method :id, :meeting_id
|
43
|
-
|
44
|
-
def create
|
45
|
-
compacted_attributes = remove_nil_values(self.attributes)
|
46
|
-
created_model = if(self.ref_type.present? && self.ref_id.present?)
|
47
|
-
self.class.create_with_ref(self.ref_type, self.ref_id, compacted_attributes)
|
48
|
-
else
|
49
|
-
self.class.create(compacted_attributes)
|
50
|
-
end
|
51
|
-
|
52
|
-
self.attributes = created_model.attributes
|
53
|
-
end
|
54
|
-
|
55
|
-
def update
|
56
|
-
# compacted_attributes = remove_nil_values(self.attributes)
|
57
|
-
# updated_model = self.class.update(self.id, compacted_attributes)
|
58
|
-
# self.attributes = updated_model.attributes
|
59
|
-
updated_model = self.class.update(self.id, self.attributes)
|
60
|
-
self.attributes = updated_model.attributes
|
61
|
-
end
|
62
|
-
|
63
|
-
def destroy
|
64
|
-
self.class.delete(self.id)
|
65
|
-
end
|
66
|
-
|
67
|
-
handle_api_errors_for :create, :destroy # Call must be made after the methods to handle have been defined
|
68
|
-
|
69
|
-
class << self
|
70
|
-
def create(attributes)
|
71
|
-
response = Podio.connection.post do |req|
|
72
|
-
req.url "/meeting/"
|
73
|
-
req.body = attributes
|
74
|
-
end
|
75
|
-
|
76
|
-
member response.body
|
77
|
-
end
|
78
|
-
|
79
|
-
def create_with_ref(ref_type, ref_id, attributes)
|
80
|
-
response = Podio.connection.post do |req|
|
81
|
-
req.url "/meeting/#{ref_type}/#{ref_id}/"
|
82
|
-
req.body = attributes
|
83
|
-
end
|
84
|
-
|
85
|
-
member response.body
|
86
|
-
end
|
87
|
-
|
88
|
-
def update(id, attributes)
|
89
|
-
response = Podio.connection.put do |req|
|
90
|
-
req.url "/meeting/#{id}"
|
91
|
-
req.body = attributes
|
92
|
-
end
|
93
|
-
|
94
|
-
member response.body
|
95
|
-
end
|
96
|
-
|
97
|
-
def delete(id)
|
98
|
-
Podio.connection.delete("/meeting/#{id}").status
|
99
|
-
end
|
100
|
-
|
101
|
-
def find(id)
|
102
|
-
member Podio.connection.get("/meeting/#{id}").body
|
103
|
-
end
|
104
|
-
|
105
|
-
def find_for_reference(ref_type, ref_id, options={})
|
106
|
-
list Podio.connection.get { |req|
|
107
|
-
req.url("/meeting/#{ref_type}/#{ref_id}/", options)
|
108
|
-
}.body
|
109
|
-
end
|
110
|
-
|
111
|
-
def find_all(options={})
|
112
|
-
list Podio.connection.get { |req|
|
113
|
-
req.url('/meeting/', options)
|
114
|
-
}.body
|
115
|
-
end
|
116
|
-
|
117
|
-
def find_summary
|
118
|
-
response = Podio.connection.get("/meeting/summary").body
|
119
|
-
response['past']['tasks'] = list(response['past']['meetings'])
|
120
|
-
response['today']['tasks'] = list(response['today']['meetings'])
|
121
|
-
response['future']['tasks'] = list(response['future']['meetings'])
|
122
|
-
response
|
123
|
-
end
|
124
|
-
|
125
|
-
def find_summary_for_reference(ref_type, ref_id)
|
126
|
-
response = Podio.connection.get("/meeting/#{ref_type}/#{ref_id}/summary").body
|
127
|
-
response['past']['tasks'] = list(response['past']['meetings'])
|
128
|
-
response['today']['tasks'] = list(response['today']['meetings'])
|
129
|
-
response['future']['tasks'] = list(response['future']['meetings'])
|
130
|
-
response
|
131
|
-
end
|
132
|
-
|
133
|
-
def find_personal_summary
|
134
|
-
response = Podio.connection.get("/meeting/personal/summary").body
|
135
|
-
response['past']['tasks'] = list(response['past']['meetings'])
|
136
|
-
response['today']['tasks'] = list(response['today']['meetings'])
|
137
|
-
response['future']['tasks'] = list(response['future']['meetings'])
|
138
|
-
response
|
139
|
-
end
|
140
|
-
|
141
|
-
def set_participation_status(id, status)
|
142
|
-
response = Podio.connection.post do |req|
|
143
|
-
req.url "/meeting/#{id}/status"
|
144
|
-
req.body = { :status => status }
|
145
|
-
end
|
146
|
-
|
147
|
-
response.status
|
148
|
-
end
|
149
|
-
|
150
|
-
end
|
151
|
-
end
|