podio 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/lib/podio.rb +3 -0
- data/lib/podio/active_podio/base.rb +9 -1
- data/lib/podio/client.rb +7 -2
- data/lib/podio/models/application.rb +18 -0
- data/lib/podio/models/application_field.rb +1 -1
- data/lib/podio/models/comment.rb +1 -0
- data/lib/podio/models/conversation.rb +5 -2
- data/lib/podio/models/conversation_message.rb +2 -0
- data/lib/podio/models/file_attachment.rb +13 -23
- data/lib/podio/models/form.rb +6 -0
- data/lib/podio/models/importer.rb +3 -2
- data/lib/podio/models/item.rb +2 -0
- data/lib/podio/models/question.rb +32 -0
- data/lib/podio/models/question_answer.rb +5 -0
- data/lib/podio/models/question_option.rb +6 -0
- data/lib/podio/models/space.rb +22 -0
- data/lib/podio/models/space_invite.rb +24 -1
- data/lib/podio/models/status.rb +2 -0
- data/lib/podio/version.rb +1 -1
- data/podio.gemspec +5 -5
- data/test/active_podio_test.rb +14 -4
- data/test/client_test.rb +19 -3
- metadata +7 -4
data/.gitignore
CHANGED
data/lib/podio.rb
CHANGED
@@ -100,6 +100,9 @@ module Podio
|
|
100
100
|
autoload :OrganizationMember, 'podio/models/organization_member'
|
101
101
|
autoload :OrganizationProfile, 'podio/models/organization_profile'
|
102
102
|
autoload :Profile, 'podio/models/profile'
|
103
|
+
autoload :Question, 'podio/models/question'
|
104
|
+
autoload :QuestionAnswer, 'podio/models/question_answer'
|
105
|
+
autoload :QuestionOption, 'podio/models/question_option'
|
103
106
|
autoload :Rating, 'podio/models/rating'
|
104
107
|
autoload :Search, 'podio/models/search'
|
105
108
|
autoload :Space, 'podio/models/space'
|
@@ -159,11 +159,19 @@ module ActivePodio
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def delegate_to_hash(hash_name, *attribute_names)
|
162
|
+
options = attribute_names.extract_options! || { :prefix => false, :setter => false }
|
163
|
+
options.assert_valid_keys(:prefix, :setter)
|
162
164
|
attribute_names.each do |attribute_name|
|
163
165
|
hash_index = attribute_name.to_s.gsub(/[\?!]/, '')
|
164
|
-
|
166
|
+
method_name = "#{options[:prefix] ? "#{hash_name}_" : ''}#{attribute_name}"
|
167
|
+
self.send(:define_method, method_name) do
|
165
168
|
self.send(hash_name)[hash_index]
|
166
169
|
end
|
170
|
+
if options[:setter]
|
171
|
+
self.send(:define_method, "#{method_name}=") do |value|
|
172
|
+
self.send(hash_name)[hash_index] = value
|
173
|
+
end
|
174
|
+
end
|
167
175
|
end
|
168
176
|
end
|
169
177
|
|
data/lib/podio/client.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Podio
|
2
2
|
class Client
|
3
|
-
attr_reader :api_url, :api_key, :api_secret, :connection, :raw_connection
|
4
|
-
attr_accessor :
|
3
|
+
attr_reader :api_url, :api_key, :api_secret, :oauth_token, :connection, :raw_connection
|
4
|
+
attr_accessor :stubs, :current_http_client
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
@api_url = options[:api_url] || 'https://api.podio.com'
|
@@ -72,6 +72,11 @@ module Podio
|
|
72
72
|
@oauth_token
|
73
73
|
end
|
74
74
|
|
75
|
+
def oauth_token=(new_oauth_token)
|
76
|
+
@oauth_token = new_oauth_token.is_a?(Hash) ? OAuthToken.new(new_oauth_token) : new_oauth_token
|
77
|
+
configure_oauth
|
78
|
+
end
|
79
|
+
|
75
80
|
def refresh_access_token
|
76
81
|
response = @oauth_connection.post do |req|
|
77
82
|
req.url '/oauth/token', :grant_type => 'refresh_token', :refresh_token => oauth_token.refresh_token, :client_id => api_key, :client_secret => api_secret
|
@@ -36,6 +36,12 @@ class Podio::Application < ActivePodio::Base
|
|
36
36
|
}.body
|
37
37
|
end
|
38
38
|
|
39
|
+
def get_calculations(app_id)
|
40
|
+
list Podio.connection.get { |req|
|
41
|
+
req.url("/app/#{app_id}/calculation/", {})
|
42
|
+
}.body
|
43
|
+
end
|
44
|
+
|
39
45
|
def update_order(space_id, app_ids = [])
|
40
46
|
response = Podio.connection.put do |req|
|
41
47
|
req.url "/app/space/#{space_id}/order"
|
@@ -52,6 +58,18 @@ class Podio::Application < ActivePodio::Base
|
|
52
58
|
end
|
53
59
|
response.body['app_id']
|
54
60
|
end
|
61
|
+
|
62
|
+
def update(app_id, attributes)
|
63
|
+
response = Podio.connection.put do |req|
|
64
|
+
req.url "/app/#{app_id}"
|
65
|
+
req.body = attributes
|
66
|
+
end
|
67
|
+
response.status
|
68
|
+
end
|
69
|
+
|
70
|
+
def delete_field(app_id, field_id)
|
71
|
+
Podio.connection.delete("/app/#{app_id}/field/#{field_id}").status
|
72
|
+
end
|
55
73
|
|
56
74
|
def deactivate(id)
|
57
75
|
Podio.connection.post("/app/#{id}/deactivate").body
|
@@ -6,7 +6,7 @@ class Podio::ApplicationField < ActivePodio::Base
|
|
6
6
|
|
7
7
|
alias_method :id, :field_id
|
8
8
|
delegate_to_hash :config, :label, :description, :delta, :settings, :required?, :visible?
|
9
|
-
delegate_to_hash :settings, :allowed_values, :referenceable_types, :allowed_currencies, :valid_types
|
9
|
+
delegate_to_hash :settings, :allowed_values, :referenceable_types, :allowed_currencies, :valid_types, :options, :multiple
|
10
10
|
|
11
11
|
class << self
|
12
12
|
def find(app_id, field_id)
|
data/lib/podio/models/comment.rb
CHANGED
@@ -15,6 +15,7 @@ class Podio::Comment < ActivePodio::Base
|
|
15
15
|
has_one :created_by, :class => 'ByLine'
|
16
16
|
has_one :created_via, :class => 'Via'
|
17
17
|
has_many :files, :class => 'FileAttachment'
|
18
|
+
has_many :questions, :class => 'Question'
|
18
19
|
|
19
20
|
alias_method :id, :comment_id
|
20
21
|
attr_accessor :commentable_type, :commentable_id
|
@@ -11,10 +11,13 @@ class Podio::Conversation < ActivePodio::Base
|
|
11
11
|
|
12
12
|
# When outputting conversation(s)
|
13
13
|
property :created_on, :datetime
|
14
|
+
has_one :embed, :class => 'Embed'
|
15
|
+
has_one :embed_file, :class => 'FileAttachment'
|
14
16
|
has_one :created_by, :class => 'ByLine'
|
15
17
|
has_many :files, :class => 'FileAttachment'
|
16
18
|
has_many :messages, :class => 'ConversationMessage'
|
17
19
|
has_many :participants_full, :class => 'ConversationParticipant'
|
20
|
+
|
18
21
|
|
19
22
|
alias_method :id, :conversation_id
|
20
23
|
alias_method :name, :subject # So tasks can refer to ref.name on all types of references
|
@@ -52,10 +55,10 @@ class Podio::Conversation < ActivePodio::Base
|
|
52
55
|
response.body
|
53
56
|
end
|
54
57
|
|
55
|
-
def create_reply(conversation_id, text, file_ids =
|
58
|
+
def create_reply(conversation_id, text, file_ids=[], embed_id=nil, embed_file_id=nil)
|
56
59
|
response = Podio.connection.post do |req|
|
57
60
|
req.url "/conversation/#{conversation_id}/reply"
|
58
|
-
req.body = {
|
61
|
+
req.body = {:text => text, :file_ids => file_ids, :embed_id => embed_id, :embed_file_id => embed_file_id}
|
59
62
|
end
|
60
63
|
response.body['message_id']
|
61
64
|
end
|
@@ -5,6 +5,8 @@ class Podio::ConversationMessage < ActivePodio::Base
|
|
5
5
|
property :text, :string
|
6
6
|
property :created_on, :datetime
|
7
7
|
|
8
|
+
has_one :embed, :class => 'Embed'
|
9
|
+
has_one :embed_file, :class => 'FileAttachment'
|
8
10
|
has_one :created_by, :class => 'ByLine'
|
9
11
|
has_many :files, :class => 'FileAttachment'
|
10
12
|
|
@@ -18,37 +18,23 @@ class Podio::FileAttachment < ActivePodio::Base
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class << self
|
21
|
-
|
22
|
-
|
23
|
-
# Returns an instantiated FileAttachment model with id, link, name and mimetype set
|
24
|
-
# If you use Ruby on Rails 3 or higher you can also pass the file in params directly to +upload_from_rails_param+
|
25
|
-
def upload(file_stream, content_type, file_name)
|
21
|
+
# Accepts an open file stream along with a file name and uploads the file to Podio
|
22
|
+
def upload(file_stream, file_name)
|
26
23
|
response = Podio.client.raw_connection.post do |req|
|
24
|
+
req.options[:timeout] = 1200
|
27
25
|
req.url "/file/v2/"
|
28
|
-
req.body = {:source => Faraday::UploadIO.new(file_stream,
|
26
|
+
req.body = {:source => Faraday::UploadIO.new(file_stream, nil, nil), :filename => file_name}
|
29
27
|
end
|
30
|
-
|
31
|
-
|
32
|
-
member
|
33
|
-
end
|
34
|
-
|
35
|
-
# Accepts a ActionDispatch::Http::UploadedFile or similar and uploads the file to Podio
|
36
|
-
# Optionally attaches the file to the given ref type and ref id
|
37
|
-
# Returns an instantiated FileAttachment model with id, link, name and mimetype set
|
38
|
-
def upload_from_rails_param(uploaded_file, ref_type = nil, ref_id = nil)
|
39
|
-
p uploaded_file
|
40
|
-
file_attachment = self.upload(uploaded_file.tempfile, uploaded_file.content_type, uploaded_file.original_filename)
|
41
|
-
if ref_type.present? && ref_id.present?
|
42
|
-
self.attach(file_attachment.id, ref_type, ref_id)
|
43
|
-
end
|
44
|
-
file_attachment
|
28
|
+
|
29
|
+
# Using raw_connection means response is not automatically decoded to json
|
30
|
+
member MultiJson.decode(response.body)
|
45
31
|
end
|
46
|
-
|
32
|
+
|
47
33
|
# Attach a file to an existing reference
|
48
34
|
def attach(id, ref_type, ref_id)
|
49
35
|
Podio.connection.post do |req|
|
50
36
|
req.url "/file/#{id}/attach"
|
51
|
-
req.body = {
|
37
|
+
req.body = {:ref_type => ref_type, :ref_id => ref_id}
|
52
38
|
end
|
53
39
|
end
|
54
40
|
|
@@ -64,6 +50,10 @@ class Podio::FileAttachment < ActivePodio::Base
|
|
64
50
|
member Podio.connection.get("/file/#{id}").body
|
65
51
|
end
|
66
52
|
|
53
|
+
def find_raw(id)
|
54
|
+
Podio.client.raw_connection.get("/file/#{id}/raw").body
|
55
|
+
end
|
56
|
+
|
67
57
|
def find_for_app(app_id, options={})
|
68
58
|
collection Podio.connection.get { |req|
|
69
59
|
req.url("/file/app/#{app_id}/", options)
|
data/lib/podio/models/form.rb
CHANGED
@@ -18,6 +18,12 @@ class Podio::Form < ActivePodio::Base
|
|
18
18
|
response.body['form_id']
|
19
19
|
end
|
20
20
|
|
21
|
+
def find_all_for_app(app_id)
|
22
|
+
list Podio.connection.get { |req|
|
23
|
+
req.url("/form/app/#{app_id}/")
|
24
|
+
}.body
|
25
|
+
end
|
26
|
+
|
21
27
|
def find(form_id)
|
22
28
|
member Podio.connection.get("/form/#{form_id}").body
|
23
29
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
class Podio::Importer < ActivePodio::Base
|
2
2
|
|
3
3
|
class << self
|
4
|
-
def process_file(file_id, app_id, mappings)
|
4
|
+
def process_file(file_id, app_id, mappings, tags_column_id)
|
5
5
|
response = Podio.connection.post do |req|
|
6
6
|
req.url "/importer/#{file_id}/process"
|
7
7
|
req.body = {
|
8
8
|
:app_id => app_id,
|
9
|
-
:mappings => mappings
|
9
|
+
:mappings => mappings,
|
10
|
+
:tags_column_id => tags_column_id
|
10
11
|
}
|
11
12
|
end
|
12
13
|
|
data/lib/podio/models/item.rb
CHANGED
@@ -16,9 +16,11 @@ class Podio::Item < ActivePodio::Base
|
|
16
16
|
property :conversations, :array
|
17
17
|
property :tasks, :array
|
18
18
|
property :references, :array
|
19
|
+
property :refs, :array
|
19
20
|
property :tags, :array
|
20
21
|
property :subscribed, :boolean
|
21
22
|
property :user_ratings, :hash
|
23
|
+
property :link, :string
|
22
24
|
|
23
25
|
has_many :revisions, :class => 'ItemRevision'
|
24
26
|
has_many :files, :class => 'FileAttachment'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Podio::Question < ActivePodio::Base
|
2
|
+
|
3
|
+
property :question_id, :integer
|
4
|
+
property :text, :string
|
5
|
+
property :ref, :hash
|
6
|
+
|
7
|
+
has_many :answers, :class => 'QuestionAnswer'
|
8
|
+
has_many :options, :class => 'QuestionOption'
|
9
|
+
|
10
|
+
alias_method :id, :question_id
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def create(ref_type, ref_id, text, options)
|
15
|
+
response = Podio.connection.post do |req|
|
16
|
+
req.url "/question/#{ref_type}/#{ref_id}/"
|
17
|
+
req.body = {:text => text, :options => options }
|
18
|
+
end
|
19
|
+
member response.body
|
20
|
+
end
|
21
|
+
|
22
|
+
def answer(question_id, ref_type, ref_id, question_option_id)
|
23
|
+
response = Podio.connection.post do |req|
|
24
|
+
req.url "/question/#{question_id}/#{ref_type}/#{ref_id}/"
|
25
|
+
req.body = {:question_option_id => question_option_id }
|
26
|
+
end
|
27
|
+
|
28
|
+
response.status
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/podio/models/space.rb
CHANGED
@@ -8,6 +8,8 @@ class Podio::Space < ActivePodio::Base
|
|
8
8
|
property :members, :integer
|
9
9
|
property :role, :string
|
10
10
|
property :rights, :array
|
11
|
+
property :post_on_new_app, :bool
|
12
|
+
property :post_on_new_member, :bool
|
11
13
|
|
12
14
|
has_one :created_by, :class => 'ByLine'
|
13
15
|
|
@@ -19,6 +21,10 @@ class Podio::Space < ActivePodio::Base
|
|
19
21
|
self.space_id = response['space_id']
|
20
22
|
end
|
21
23
|
|
24
|
+
def update
|
25
|
+
self.class.update(self.space_id, :name => self.name, :post_on_new_app => self.post_on_new_app, :post_on_new_member => self.post_on_new_member, :url_label => self.url_label)
|
26
|
+
end
|
27
|
+
|
22
28
|
class << self
|
23
29
|
def create(attributes)
|
24
30
|
response = Podio.connection.post do |req|
|
@@ -29,6 +35,14 @@ class Podio::Space < ActivePodio::Base
|
|
29
35
|
response.body
|
30
36
|
end
|
31
37
|
|
38
|
+
def update(space_id, attributes)
|
39
|
+
Podio.connection.put("/space/#{space_id}", attributes).status
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete(id)
|
43
|
+
Podio.connection.delete("/space/#{id}").status
|
44
|
+
end
|
45
|
+
|
32
46
|
def find(id)
|
33
47
|
member Podio.connection.get("/space/#{id}").body
|
34
48
|
end
|
@@ -40,6 +54,14 @@ class Podio::Space < ActivePodio::Base
|
|
40
54
|
def find_all_for_org(org_id)
|
41
55
|
list Podio.connection.get("/org/#{org_id}/space/").body
|
42
56
|
end
|
57
|
+
|
58
|
+
def validate_url_label(org_id, url_label)
|
59
|
+
Podio.connection.post { |req|
|
60
|
+
req.url "/space/org/#{org_id}/url/validate"
|
61
|
+
req.body = {:url_label => url_label}
|
62
|
+
}.body
|
63
|
+
end
|
64
|
+
|
43
65
|
end
|
44
66
|
end
|
45
67
|
|
@@ -15,11 +15,15 @@ class Podio::SpaceInvite < ActivePodio::Base
|
|
15
15
|
self.class.create(self.space_id, self.role, self.attributes.except(:contacts))
|
16
16
|
end
|
17
17
|
|
18
|
+
def save_member
|
19
|
+
self.class.create_member(self.space_id, self.role, self.attributes.except(:contacts))
|
20
|
+
end
|
21
|
+
|
18
22
|
def accept(invite_code)
|
19
23
|
self.class.accept(invite_code)
|
20
24
|
end
|
21
25
|
|
22
|
-
handle_api_errors_for :save, :accept # Call must be made after the methods to handle have been defined
|
26
|
+
handle_api_errors_for :save, :save_member, :accept # Call must be made after the methods to handle have been defined
|
23
27
|
|
24
28
|
class << self
|
25
29
|
def create(space_id, role, attributes={})
|
@@ -31,6 +35,15 @@ class Podio::SpaceInvite < ActivePodio::Base
|
|
31
35
|
response.body
|
32
36
|
end
|
33
37
|
|
38
|
+
def create_member(space_id, role, attributes={})
|
39
|
+
response = Podio.connection.post do |req|
|
40
|
+
req.url "/space/#{space_id}/member/"
|
41
|
+
req.body = attributes.merge(:role => role)
|
42
|
+
end
|
43
|
+
|
44
|
+
response.body
|
45
|
+
end
|
46
|
+
|
34
47
|
def accept(invite_code)
|
35
48
|
response = Podio.connection.post do |req|
|
36
49
|
req.url '/space/invite/accept'
|
@@ -49,9 +62,19 @@ class Podio::SpaceInvite < ActivePodio::Base
|
|
49
62
|
response.body
|
50
63
|
end
|
51
64
|
|
65
|
+
def decline_member(invite_code)
|
66
|
+
Podio.connection.delete("/space/membership?invite_code=#{invite_code}").status
|
67
|
+
|
68
|
+
response.body
|
69
|
+
end
|
70
|
+
|
52
71
|
def find(invite_code)
|
53
72
|
member Podio.connection.get("/space/invite/status?invite_code=#{ERB::Util.url_encode(invite_code)}").body
|
54
73
|
end
|
74
|
+
|
75
|
+
def find_member(invite_code)
|
76
|
+
member Podio.connection.get("/space/membership?invite_code=#{ERB::Util.url_encode(invite_code)}").body
|
77
|
+
end
|
55
78
|
|
56
79
|
end
|
57
80
|
end
|
data/lib/podio/models/status.rb
CHANGED
@@ -10,6 +10,8 @@ class Podio::Status < ActivePodio::Base
|
|
10
10
|
|
11
11
|
has_one :created_by, :class => 'Contact'
|
12
12
|
has_one :created_via, :class => 'Via'
|
13
|
+
has_one :embed, :class => 'Embed'
|
14
|
+
has_one :embed_file, :class => 'FileAttachment'
|
13
15
|
has_many :comments, :class => 'Comment'
|
14
16
|
has_many :conversations, :class => 'Conversation'
|
15
17
|
has_many :tasks, :class => 'Task'
|
data/lib/podio/version.rb
CHANGED
data/podio.gemspec
CHANGED
@@ -15,11 +15,11 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.require_paths = ['lib']
|
17
17
|
|
18
|
-
s.
|
19
|
-
s.
|
20
|
-
s.
|
21
|
-
s.
|
22
|
-
s.
|
18
|
+
s.add_dependency('faraday', '~> 0.7.0')
|
19
|
+
s.add_dependency('activesupport', '~> 3.0.0')
|
20
|
+
s.add_dependency('activemodel', '~> 3.0.0')
|
21
|
+
s.add_dependency('i18n', '~> 0.5.0')
|
22
|
+
s.add_dependency('multi_json', '~> 0.0.5')
|
23
23
|
|
24
24
|
s.description = <<desc
|
25
25
|
The official Ruby wrapper for the Podio API used and maintained by the Podio team
|
data/test/active_podio_test.rb
CHANGED
@@ -10,6 +10,7 @@ class ActivePodioTest < Test::Unit::TestCase
|
|
10
10
|
property :test_id, :integer
|
11
11
|
property :string, :string
|
12
12
|
property :hash_property, :hash
|
13
|
+
property :other_hash_property, :hash
|
13
14
|
property :datetime, :datetime
|
14
15
|
property :date, :date
|
15
16
|
property :integer, :integer
|
@@ -24,6 +25,8 @@ class ActivePodioTest < Test::Unit::TestCase
|
|
24
25
|
alias_method :id, :test_id
|
25
26
|
|
26
27
|
delegate_to_hash :hash_property, :key1, :key2, :really?
|
28
|
+
delegate_to_hash :other_hash_property, :key3, :prefix => true, :setter => true
|
29
|
+
|
27
30
|
|
28
31
|
def save(exception_class = nil)
|
29
32
|
if exception_class
|
@@ -156,11 +159,18 @@ class ActivePodioTest < Test::Unit::TestCase
|
|
156
159
|
assert_equal 'other association 2', @test.different_associations[1].string
|
157
160
|
end
|
158
161
|
|
159
|
-
test 'should expose methods defined by delegate to hash' do
|
162
|
+
test 'should expose getter methods defined by delegate to hash' do
|
160
163
|
@test = TestModel.new(:hash_property => {'key1' => 'value1', 'key2' => 'value2', 'really' => true})
|
161
164
|
assert_equal 'value1', @test.key1
|
162
165
|
assert @test.really?
|
163
166
|
end
|
167
|
+
|
168
|
+
test 'should expose prefixed getter and setter methods defined by delegate to hash' do
|
169
|
+
@test = TestModel.new(:other_hash_property => {'key3' => 'value3'})
|
170
|
+
assert_equal 'value3', @test.other_hash_property_key3
|
171
|
+
@test.other_hash_property_key3 = 'new'
|
172
|
+
assert_equal 'new', @test.other_hash_property_key3
|
173
|
+
end
|
164
174
|
|
165
175
|
test 'should handle non failing api requests' do
|
166
176
|
@test = TestModel.new
|
@@ -229,12 +239,12 @@ class ActivePodioTest < Test::Unit::TestCase
|
|
229
239
|
|
230
240
|
test 'should initialize nil attributes when constructed without given attributes' do
|
231
241
|
@test = TestModel.new
|
232
|
-
assert_equal({:string=>nil, :test_id=>nil, :hash_property=>nil, :datetime=>nil, :date=>nil, :integer=>nil, :boolean=>nil, :array=>nil}, @test.attributes)
|
242
|
+
assert_equal({:string=>nil, :test_id=>nil, :hash_property=>nil, :other_hash_property=>nil, :datetime=>nil, :date=>nil, :integer=>nil, :boolean=>nil, :array=>nil}, @test.attributes)
|
233
243
|
end
|
234
244
|
|
235
245
|
test 'should accept unknown properties when constructed' do
|
236
246
|
@test = TestModel.new(:unknown => 'attribute')
|
237
|
-
assert_equal({:string=>nil, :test_id=>nil, :hash_property=>nil, :datetime=>nil, :date=>nil, :integer=>nil, :boolean=>nil, :array=>nil, :unknown => 'attribute'}, @test.attributes)
|
247
|
+
assert_equal({:string=>nil, :test_id=>nil, :hash_property=>nil, :other_hash_property=>nil, :datetime=>nil, :date=>nil, :integer=>nil, :boolean=>nil, :array=>nil, :unknown => 'attribute'}, @test.attributes)
|
238
248
|
end
|
239
249
|
|
240
250
|
test 'should use id for ==' do
|
@@ -250,7 +260,7 @@ class ActivePodioTest < Test::Unit::TestCase
|
|
250
260
|
|
251
261
|
test 'should return attributes for as_json' do
|
252
262
|
@test = TestModel.new(:test_id => 42)
|
253
|
-
assert_equal({:string=>nil, :test_id=>42, :hash_property=>nil, :datetime=>nil, :date=>nil, :integer=>nil, :boolean=>nil, :array=>nil}, @test.as_json)
|
263
|
+
assert_equal({:string=>nil, :test_id=>42, :hash_property=>nil, :other_hash_property=>nil, :datetime=>nil, :date=>nil, :integer=>nil, :boolean=>nil, :array=>nil}, @test.as_json)
|
254
264
|
end
|
255
265
|
|
256
266
|
end
|
data/test/client_test.rb
CHANGED
@@ -52,16 +52,32 @@ class ClientTest < Test::Unit::TestCase
|
|
52
52
|
test 'should automatically refresh an expired token' do
|
53
53
|
# this token is already expired in the test database
|
54
54
|
# Podio.client.oauth_token = Podio::OAuthToken.new('access_token' => '30da4594eef93528c11df7fb5deb989cd629ea7060a1ce1ced628d19398214c942bcfe0334cf953ef70a80ea1afdfd80183d5c75d19c1f5526ca4c6f6f3471ef', 'refresh_token' => '82e7a11ae187f28a25261599aa6229cd89f8faee48cba18a75d70efae88ba665ced11d43143b7f5bebb31a4103662b851dd2db1879a3947b843259479fccfad3', 'expires_in' => -10)
|
55
|
-
|
55
|
+
|
56
56
|
login_as(:professor)
|
57
57
|
Podio.client.reset
|
58
|
-
|
58
|
+
|
59
59
|
assert_nothing_raised do
|
60
60
|
response = Podio.connection.get("/org/")
|
61
61
|
assert_equal 200, response.status
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
|
+
test 'setting the oauth_token should reconfigure the connection' do
|
66
|
+
podio = Podio::Client.new
|
67
|
+
assert_nil podio.connection.headers['authorization']
|
68
|
+
|
69
|
+
podio.oauth_token = Podio::OAuthToken.new('access_token' => 'access', 'refresh_token' => 'refresh')
|
70
|
+
assert_equal 'OAuth2 access', podio.connection.headers['authorization']
|
71
|
+
end
|
72
|
+
|
73
|
+
test 'setting the oauth_token as a hash should reconfigure the connection' do
|
74
|
+
podio = Podio::Client.new
|
75
|
+
assert_nil podio.connection.headers['authorization']
|
76
|
+
|
77
|
+
podio.oauth_token = {'access_token' => 'access', 'refresh_token' => 'refresh'}
|
78
|
+
assert_equal 'OAuth2 access', podio.connection.headers['authorization']
|
79
|
+
end
|
80
|
+
|
65
81
|
test 'should be able to make arbitrary requests' do
|
66
82
|
login_as(:professor)
|
67
83
|
response = Podio.connection.get("/org/")
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: podio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Florian Munz
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-
|
14
|
+
date: 2011-07-18 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -52,9 +52,9 @@ dependencies:
|
|
52
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
|
-
- -
|
55
|
+
- - ~>
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.
|
57
|
+
version: 0.5.0
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id004
|
60
60
|
- !ruby/object:Gem::Dependency
|
@@ -131,6 +131,9 @@ files:
|
|
131
131
|
- lib/podio/models/organization_member.rb
|
132
132
|
- lib/podio/models/organization_profile.rb
|
133
133
|
- lib/podio/models/profile.rb
|
134
|
+
- lib/podio/models/question.rb
|
135
|
+
- lib/podio/models/question_answer.rb
|
136
|
+
- lib/podio/models/question_option.rb
|
134
137
|
- lib/podio/models/rating.rb
|
135
138
|
- lib/podio/models/search.rb
|
136
139
|
- lib/podio/models/space.rb
|