podio 0.8.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +9 -2
- data/README.md +1 -4
- data/examples/oauth_web_flow/Gemfile +4 -0
- data/examples/{sinatra.rb → oauth_web_flow/sinatra.rb} +7 -6
- data/lib/podio.rb +18 -3
- data/lib/podio/active_podio/base.rb +107 -62
- data/lib/podio/client.rb +30 -5
- data/lib/podio/error.rb +22 -10
- data/lib/podio/middleware/error_response.rb +23 -16
- data/lib/podio/middleware/json_response.rb +1 -1
- data/lib/podio/middleware/logger.rb +3 -0
- data/lib/podio/middleware/oauth2.rb +3 -0
- data/lib/podio/models/account_provider.rb +1 -0
- data/lib/podio/models/action.rb +19 -2
- data/lib/podio/models/activation_status.rb +8 -2
- data/lib/podio/models/app_store_category.rb +4 -1
- data/lib/podio/models/app_store_share.rb +29 -16
- data/lib/podio/models/application.rb +57 -2
- data/lib/podio/models/application_email.rb +5 -2
- data/lib/podio/models/application_field.rb +5 -2
- data/lib/podio/models/batch.rb +8 -0
- data/lib/podio/models/by_line.rb +2 -1
- data/lib/podio/models/calendar_event.rb +63 -3
- data/lib/podio/models/calendar_mute.rb +6 -1
- data/lib/podio/models/category.rb +1 -0
- data/lib/podio/models/comment.rb +29 -8
- data/lib/podio/models/condition.rb +8 -0
- data/lib/podio/models/condition_set.rb +40 -0
- data/lib/podio/models/contact.rb +13 -2
- data/lib/podio/models/contract.rb +85 -1
- data/lib/podio/models/contract_event.rb +17 -0
- data/lib/podio/models/contract_price.rb +3 -7
- data/lib/podio/models/contract_price_v2.rb +31 -0
- data/lib/podio/models/contract_user.rb +4 -0
- data/lib/podio/models/conversation.rb +114 -13
- data/lib/podio/models/conversation_event.rb +51 -0
- data/lib/podio/models/conversation_message.rb +2 -1
- data/lib/podio/models/conversation_participant.rb +3 -2
- data/lib/podio/models/date_election.rb +35 -0
- data/lib/podio/models/email_contact.rb +46 -0
- data/lib/podio/models/email_subscription_setting.rb +4 -23
- data/lib/podio/models/embed.rb +4 -4
- data/lib/podio/models/experiment.rb +71 -0
- data/lib/podio/models/external_file.rb +7 -2
- data/lib/podio/models/file_attachment.rb +23 -0
- data/lib/podio/models/form.rb +7 -0
- data/lib/podio/models/friend.rb +12 -0
- data/lib/podio/models/grant.rb +73 -0
- data/lib/podio/models/hook.rb +13 -6
- data/lib/podio/models/importer.rb +3 -0
- data/lib/podio/models/integration.rb +17 -6
- data/lib/podio/models/invoice.rb +30 -0
- data/lib/podio/models/item.rb +81 -14
- data/lib/podio/models/item_diff.rb +9 -5
- data/lib/podio/models/item_field.rb +11 -2
- data/lib/podio/models/item_revision.rb +5 -2
- data/lib/podio/models/linked_account.rb +1 -0
- data/lib/podio/models/live.rb +61 -0
- data/lib/podio/models/net_promoter_score.rb +28 -0
- data/lib/podio/models/notification.rb +9 -4
- data/lib/podio/models/notification_group.rb +5 -2
- data/lib/podio/models/o_auth.rb +4 -2
- data/lib/podio/models/o_auth_client.rb +1 -2
- data/lib/podio/models/organization.rb +22 -10
- data/lib/podio/models/organization_contact.rb +2 -1
- data/lib/podio/models/organization_member.rb +17 -3
- data/lib/podio/models/organization_profile.rb +8 -2
- data/lib/podio/models/pin.rb +27 -0
- data/lib/podio/models/profile.rb +19 -50
- data/lib/podio/models/promotion.rb +91 -0
- data/lib/podio/models/rating.rb +23 -5
- data/lib/podio/models/recurrence.rb +6 -3
- data/lib/podio/models/reference.rb +17 -1
- data/lib/podio/models/reminder.rb +8 -3
- data/lib/podio/models/search.rb +7 -1
- data/lib/podio/models/space.rb +41 -2
- data/lib/podio/models/space_contact.rb +1 -2
- data/lib/podio/models/space_invitation.rb +4 -5
- data/lib/podio/models/space_member.rb +37 -4
- data/lib/podio/models/status.rb +20 -8
- data/lib/podio/models/stream_activity_group.rb +40 -0
- data/lib/podio/models/stream_mute.rb +7 -8
- data/lib/podio/models/stream_object.rb +19 -11
- data/lib/podio/models/subscription.rb +7 -1
- data/lib/podio/models/tag.rb +6 -1
- data/lib/podio/models/tag_search.rb +2 -1
- data/lib/podio/models/task.rb +74 -18
- data/lib/podio/models/task_label.rb +10 -2
- data/lib/podio/models/user.rb +50 -6
- data/lib/podio/models/user_mail.rb +4 -0
- data/lib/podio/models/user_status.rb +7 -0
- data/lib/podio/models/view.rb +27 -7
- data/lib/podio/models/widget.rb +25 -3
- data/lib/podio/version.rb +1 -1
- data/podio.gemspec +13 -10
- data/script/config.example.rb +6 -0
- data/script/referenceGenerator.rb +87 -0
- data/test/active_podio_test.rb +44 -34
- data/test/client_test.rb +13 -2
- metadata +89 -36
- data/lib/podio/middleware/date_conversion.rb +0 -37
- data/lib/podio/models/bulletin.rb +0 -60
- data/lib/podio/models/connection.rb +0 -53
- data/lib/podio/models/news.rb +0 -85
data/lib/podio/client.rb
CHANGED
@@ -104,7 +104,7 @@ module Podio
|
|
104
104
|
|
105
105
|
# Sign in with an OpenID, only available for Podio
|
106
106
|
def authenticate_with_openid(identifier, type)
|
107
|
-
response = @
|
107
|
+
response = @trusted_connection.post do |req|
|
108
108
|
req.url '/oauth/token_by_openid'
|
109
109
|
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
110
110
|
req.body = {:grant_type => type, :client_id => api_key, :client_secret => api_secret, :identifier => identifier}
|
@@ -115,12 +115,31 @@ module Podio
|
|
115
115
|
@oauth_token
|
116
116
|
end
|
117
117
|
|
118
|
+
# Sign in with an activation code, only available for Podio
|
119
|
+
def authenticate_with_activation_code(activation_code)
|
120
|
+
response = @oauth_connection.post do |req|
|
121
|
+
req.url '/oauth/token'
|
122
|
+
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
123
|
+
req.body = {:grant_type => 'activation_code', :client_id => api_key, :client_secret => api_secret, :activation_code => activation_code}
|
124
|
+
end
|
125
|
+
|
126
|
+
@oauth_token = OAuthToken.new(response.body)
|
127
|
+
configure_oauth
|
128
|
+
@oauth_token
|
129
|
+
end
|
130
|
+
|
118
131
|
# reconfigure the client with a different access token
|
119
132
|
def oauth_token=(new_oauth_token)
|
120
133
|
@oauth_token = new_oauth_token.is_a?(Hash) ? OAuthToken.new(new_oauth_token) : new_oauth_token
|
121
134
|
configure_oauth
|
122
135
|
end
|
123
136
|
|
137
|
+
def locale=(new_locale)
|
138
|
+
@connection.headers['Accept-Language'] = new_locale
|
139
|
+
@oauth_connection.headers['Accept-Language'] = new_locale
|
140
|
+
@trusted_connection.headers['Accept-Language'] = new_locale
|
141
|
+
end
|
142
|
+
|
124
143
|
def refresh_access_token
|
125
144
|
response = @oauth_connection.post do |req|
|
126
145
|
req.url '/oauth/token'
|
@@ -135,9 +154,16 @@ module Podio
|
|
135
154
|
|
136
155
|
def configured_headers
|
137
156
|
headers = @headers.dup
|
138
|
-
headers['User-Agent']
|
139
|
-
headers['
|
140
|
-
|
157
|
+
headers['User-Agent'] = "Podio Ruby Library (#{Podio::VERSION})"
|
158
|
+
headers['X-Podio-Dry-Run'] = @test_mode.to_s if @test_mode
|
159
|
+
|
160
|
+
if oauth_token
|
161
|
+
# if we have a token, set up Oauth2
|
162
|
+
headers['authorization'] = "OAuth2 #{oauth_token.access_token}"
|
163
|
+
elsif api_key && api_secret
|
164
|
+
# if we have an auth_client, set up public authentication (only works with trusted auth clients)
|
165
|
+
headers['authorization'] = Faraday::Request::BasicAuthentication.header(api_key, api_secret)
|
166
|
+
end
|
141
167
|
|
142
168
|
headers
|
143
169
|
end
|
@@ -161,7 +187,6 @@ module Podio
|
|
161
187
|
builder.adapter(*default_adapter)
|
162
188
|
|
163
189
|
# first response middleware defined get's executed last
|
164
|
-
# builder.use Middleware::DateConversion
|
165
190
|
builder.use Middleware::ErrorResponse
|
166
191
|
builder.use Middleware::JsonResponse
|
167
192
|
end
|
data/lib/podio/error.rb
CHANGED
@@ -1,12 +1,31 @@
|
|
1
1
|
module Podio
|
2
2
|
class PodioError < StandardError
|
3
|
-
attr_reader :response_body, :response_status, :url
|
3
|
+
attr_reader :response_body, :response_status, :url, :code, :sub_code, :message, :parameters
|
4
|
+
attr_accessor :propagate
|
4
5
|
|
5
6
|
def initialize(response_body, response_status, url)
|
6
7
|
@response_body, @response_status, @url = response_body, response_status, url
|
7
8
|
|
9
|
+
if response_body.is_a?(Hash)
|
10
|
+
@code = response_body["error"]
|
11
|
+
@sub_code = response_body["error_detail"]
|
12
|
+
@message = response_body["error_description"]
|
13
|
+
@propagate = response_body["error_propagate"]
|
14
|
+
@parameters = response_body["error_parameters"]
|
15
|
+
else
|
16
|
+
@message = response_body.to_s
|
17
|
+
end
|
18
|
+
|
8
19
|
super(response_body.inspect)
|
9
20
|
end
|
21
|
+
|
22
|
+
def resolved_message(default_message=nil)
|
23
|
+
if @propagate
|
24
|
+
@message
|
25
|
+
else
|
26
|
+
default_message || "An unexpected error occurred"
|
27
|
+
end
|
28
|
+
end
|
10
29
|
end
|
11
30
|
|
12
31
|
class TokenExpired < PodioError; end
|
@@ -19,13 +38,6 @@ module Podio
|
|
19
38
|
class GoneError < PodioError; end
|
20
39
|
class RateLimitError < PodioError; end
|
21
40
|
class UnavailableError < PodioError; end
|
22
|
-
|
23
|
-
class RequestableAuthorizationError < AuthorizationError
|
24
|
-
attr_reader :request_access_info
|
25
|
-
|
26
|
-
def initialize(response_body, response_status, url)
|
27
|
-
@request_access_info = response_body['error_parameters']
|
28
|
-
super
|
29
|
-
end
|
30
|
-
end
|
41
|
+
class PaymentRequiredError < AuthorizationError; end
|
42
|
+
class RequestableAuthorizationError < AuthorizationError; end
|
31
43
|
end
|
@@ -4,42 +4,49 @@ module Podio
|
|
4
4
|
module Middleware
|
5
5
|
class ErrorResponse < Faraday::Response::Middleware
|
6
6
|
def on_complete(env)
|
7
|
-
case env[:status]
|
7
|
+
error_class = case env[:status]
|
8
8
|
when 200, 204
|
9
9
|
# pass
|
10
10
|
when 400
|
11
|
-
|
12
|
-
|
11
|
+
case env[:body]['error']
|
12
|
+
when 'invalid_grant'
|
13
|
+
InvalidGrantError
|
13
14
|
else
|
14
|
-
|
15
|
+
BadRequestError
|
15
16
|
end
|
16
17
|
when 401
|
17
18
|
if env[:body]['error_description'] =~ /expired_token/
|
18
|
-
|
19
|
+
TokenExpired
|
19
20
|
else
|
20
|
-
|
21
|
+
AuthorizationError
|
21
22
|
end
|
23
|
+
when 402
|
24
|
+
PaymentRequiredError
|
22
25
|
when 403
|
23
26
|
if env[:body]['error'] == 'requestable_forbidden'
|
24
|
-
|
27
|
+
RequestableAuthorizationError
|
25
28
|
else
|
26
|
-
|
29
|
+
AuthorizationError
|
27
30
|
end
|
28
31
|
when 404
|
29
|
-
|
32
|
+
NotFoundError
|
30
33
|
when 409
|
31
|
-
|
34
|
+
ConflictError
|
32
35
|
when 410
|
33
|
-
|
36
|
+
GoneError
|
34
37
|
when 420
|
35
|
-
|
38
|
+
RateLimitError
|
36
39
|
when 500
|
37
|
-
|
40
|
+
ServerError
|
38
41
|
when 502, 503
|
39
|
-
|
42
|
+
UnavailableError
|
40
43
|
else
|
41
|
-
# anything else is something unexpected, so
|
42
|
-
|
44
|
+
# anything else is something unexpected, so it
|
45
|
+
ServerError
|
46
|
+
end
|
47
|
+
|
48
|
+
if error_class
|
49
|
+
raise error_class.new(env[:body], env[:status], env[:url])
|
43
50
|
end
|
44
51
|
end
|
45
52
|
end
|
@@ -15,6 +15,9 @@ module Podio
|
|
15
15
|
# new access token needs to be put into the header
|
16
16
|
orig_env[:request_headers].merge!(podio_client.configured_headers)
|
17
17
|
|
18
|
+
# rewind the body if this was a file upload
|
19
|
+
orig_env[:body].rewind if orig_env[:body].respond_to?(:rewind)
|
20
|
+
|
18
21
|
# redo the request with the new access token
|
19
22
|
@app.call(orig_env)
|
20
23
|
end
|
data/lib/podio/models/action.rb
CHANGED
@@ -1,15 +1,32 @@
|
|
1
|
+
# @see https://developers.podio.com/doc/actions
|
1
2
|
class Podio::Action < ActivePodio::Base
|
2
3
|
property :action_id, :integer
|
3
4
|
property :type, :string
|
4
5
|
property :data, :hash
|
5
6
|
property :text, :string
|
7
|
+
property :push, :hash
|
8
|
+
property :presence, :hash
|
9
|
+
property :pinned, :boolean
|
10
|
+
property :created_on, :datetime
|
11
|
+
property :subscribed, :boolean
|
12
|
+
property :is_liked, :boolean
|
13
|
+
property :like_count, :integer
|
14
|
+
property :subscribed_count, :integer
|
15
|
+
property :push, :hash
|
16
|
+
property :presence, :hash
|
17
|
+
property :rights, :array
|
18
|
+
|
19
|
+
has_one :created_by, :class => 'ByLine'
|
20
|
+
has_one :created_via, :class => 'Via'
|
21
|
+
has_many :comments, :class => 'Comment'
|
6
22
|
|
7
23
|
alias_method :id, :action_id
|
8
|
-
|
24
|
+
|
9
25
|
class << self
|
26
|
+
# @see https://developers.podio.com/doc/actions/get-action-1701120
|
10
27
|
def find(id)
|
11
28
|
member Podio.connection.get("/action/#{id}").body
|
12
29
|
end
|
13
30
|
end
|
14
|
-
|
31
|
+
|
15
32
|
end
|
@@ -1,9 +1,15 @@
|
|
1
1
|
class Podio::ActivationStatus < ActivePodio::Base
|
2
|
+
property :user_id, :integer
|
3
|
+
property :status, :string
|
4
|
+
property :mail, :string
|
5
|
+
property :name, :string
|
6
|
+
property :has_valid_password, :boolean
|
2
7
|
property :space_count, :integer
|
3
|
-
|
8
|
+
property :internal_source, :hash
|
9
|
+
|
4
10
|
class << self
|
5
11
|
def find(activation_code)
|
6
|
-
member Podio.
|
12
|
+
member Podio.client.trusted_connection.get("/user/status/activation?activation_code=#{activation_code}").body
|
7
13
|
end
|
8
14
|
end
|
9
15
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# @see https://developers.podio.com/doc/app-store
|
1
2
|
class Podio::AppStoreCategory < ActivePodio::Base
|
2
3
|
property :category_id, :integer
|
3
4
|
property :name, :string
|
@@ -7,10 +8,12 @@ class Podio::AppStoreCategory < ActivePodio::Base
|
|
7
8
|
|
8
9
|
class << self
|
9
10
|
|
11
|
+
# @see https://developers.podio.com/doc/app-market/get-shares-by-category-22498
|
10
12
|
def find(category_id)
|
11
|
-
member Podio.connection.get("/app_store/category/#{category_id}").body
|
13
|
+
member Podio.connection.get("/app_store/category/#{category_id}/v2").body
|
12
14
|
end
|
13
15
|
|
16
|
+
# @see https://developers.podio.com/doc/app-market/get-categories-37009
|
14
17
|
def find_all
|
15
18
|
categories = Podio.connection.get("/app_store/category/").body
|
16
19
|
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# @see https://developers.podio.com/doc/app-store
|
1
2
|
class Podio::AppStoreShare < ActivePodio::Base
|
2
3
|
property :share_id, :integer
|
3
4
|
property :type, :string
|
4
5
|
property :status, :string
|
6
|
+
property :link, :string
|
5
7
|
property :name, :string
|
6
8
|
property :description, :string
|
7
9
|
property :abstract, :string
|
@@ -30,25 +32,28 @@ class Podio::AppStoreShare < ActivePodio::Base
|
|
30
32
|
|
31
33
|
alias_method :id, :share_id
|
32
34
|
|
35
|
+
# @see https://developers.podio.com/doc/app-market/share-app-22504
|
33
36
|
def create
|
34
37
|
self.share_id = self.class.create(self.attributes)
|
35
38
|
end
|
36
39
|
|
40
|
+
# @see https://developers.podio.com/doc/app-market/unshare-app-37917
|
37
41
|
def destroy
|
38
42
|
self.class.destroy(self.share_id)
|
39
43
|
end
|
40
44
|
|
45
|
+
# @see https://developers.podio.com/doc/app-market/install-share-22499
|
41
46
|
def install(space_id, dependencies, social = true)
|
42
47
|
self.class.install(self.share_id, space_id, dependencies, social)
|
43
48
|
end
|
44
49
|
|
45
|
-
handle_api_errors_for :create, :install # Call must be made after the methods to handle have been defined
|
46
|
-
|
47
50
|
def api_friendly_ref_type
|
48
51
|
'share'
|
49
52
|
end
|
50
53
|
|
51
54
|
class << self
|
55
|
+
|
56
|
+
# @see https://developers.podio.com/doc/app-market/share-app-22504
|
52
57
|
def create(attributes)
|
53
58
|
response = Podio.connection.post do |req|
|
54
59
|
req.url "/app_store/"
|
@@ -58,6 +63,7 @@ class Podio::AppStoreShare < ActivePodio::Base
|
|
58
63
|
response.body['share_id']
|
59
64
|
end
|
60
65
|
|
66
|
+
# @see https://developers.podio.com/doc/app-market/update-share-38639
|
61
67
|
def update(id, attributes)
|
62
68
|
response = Podio.connection.put do |req|
|
63
69
|
req.url "/app_store/#{id}"
|
@@ -65,12 +71,14 @@ class Podio::AppStoreShare < ActivePodio::Base
|
|
65
71
|
end
|
66
72
|
end
|
67
73
|
|
74
|
+
# @see https://developers.podio.com/doc/app-market/unshare-app-37917
|
68
75
|
def destroy(id)
|
69
76
|
response = Podio.connection.delete do |req|
|
70
77
|
req.url "/app_store/#{id}"
|
71
78
|
end
|
72
79
|
end
|
73
80
|
|
81
|
+
# @see https://developers.podio.com/doc/app-market/install-share-22499
|
74
82
|
def install(share_id, space_id, dependencies, social = true)
|
75
83
|
response = Podio.connection.post do |req|
|
76
84
|
req.url "/app_store/#{share_id}/install/v2"
|
@@ -80,28 +88,32 @@ class Podio::AppStoreShare < ActivePodio::Base
|
|
80
88
|
response.body
|
81
89
|
end
|
82
90
|
|
83
|
-
def find(id)
|
84
|
-
member Podio.connection.get
|
91
|
+
def find(id, options = {})
|
92
|
+
member Podio.connection.get { |req|
|
93
|
+
req.url "/app_store/#{id}/v2", options
|
94
|
+
}.body
|
85
95
|
end
|
86
96
|
|
87
|
-
|
97
|
+
# @see https://developers.podio.com/doc/app-market/get-own-shares-38645
|
98
|
+
def find_all_own(share_type, options = {})
|
88
99
|
shares_collection Podio.connection.get { |req|
|
89
|
-
req.url "/app_store/own/", options
|
100
|
+
req.url "/app_store/#{share_type}/own/", options
|
90
101
|
}.body
|
91
102
|
end
|
92
103
|
|
93
|
-
def find_all_private_for_org(org_id, options = {})
|
104
|
+
def find_all_private_for_org(share_type, org_id, options = {})
|
94
105
|
shares_collection Podio.connection.get { |req|
|
95
|
-
req.url "/app_store/org/#{org_id}/", options
|
106
|
+
req.url "/app_store/#{share_type}/org/#{org_id}/", options
|
96
107
|
}.body
|
97
108
|
end
|
98
109
|
|
99
|
-
def find_all_public_for_org(org_url, options = {})
|
110
|
+
def find_all_public_for_org(share_type, org_url, options = {})
|
100
111
|
shares_collection Podio.connection.get { |req|
|
101
|
-
req.url "/app_store/org/#{org_url}/", options
|
112
|
+
req.url "/app_store/#{share_type}/org/#{org_url}/", options
|
102
113
|
}.body
|
103
114
|
end
|
104
115
|
|
116
|
+
# @see https://developers.podio.com/doc/app-market/get-recommended-shares-5340177
|
105
117
|
def find_all_recommended_for_area(area, options = {})
|
106
118
|
list Podio.connection.get { |req|
|
107
119
|
req.url("/app_store/recommended/#{area}/", options)
|
@@ -117,25 +129,26 @@ class Podio::AppStoreShare < ActivePodio::Base
|
|
117
129
|
response.status
|
118
130
|
end
|
119
131
|
|
132
|
+
# @see https://developers.podio.com/doc/app-market/get-share-by-reference-45002
|
120
133
|
def find_all_by_reference(ref_type, ref_id)
|
121
134
|
list Podio.connection.get("/app_store/#{ref_type}/#{ref_id}/").body
|
122
135
|
end
|
123
136
|
|
124
|
-
def find_top(options = {})
|
137
|
+
def find_top(share_type, options = {})
|
125
138
|
shares_collection Podio.connection.get { |req|
|
126
|
-
req.url("/app_store/top/", options)
|
139
|
+
req.url("/app_store/#{share_type}/top/", options)
|
127
140
|
}.body
|
128
141
|
end
|
129
142
|
|
130
|
-
def find_all_by_category(category_id, options = {})
|
143
|
+
def find_all_by_category(share_type, category_id, options = {})
|
131
144
|
shares_collection Podio.connection.get { |req|
|
132
|
-
req.url("/app_store/category/#{category_id}/", options)
|
145
|
+
req.url("/app_store/#{share_type}/category/#{category_id}/", options)
|
133
146
|
}.body
|
134
147
|
end
|
135
148
|
|
136
|
-
def find_all_by_search(options = {})
|
149
|
+
def find_all_by_search(share_type, options = {})
|
137
150
|
shares_collection Podio.connection.get { |req|
|
138
|
-
req.url("/app_store/search/", options)
|
151
|
+
req.url("/app_store/#{share_type}/search/", options)
|
139
152
|
}.body
|
140
153
|
end
|
141
154
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# @see https://developers.podio.com/doc/applications
|
1
2
|
class Podio::Application < ActivePodio::Base
|
2
3
|
property :app_id, :integer
|
3
4
|
property :original, :integer
|
@@ -5,6 +6,7 @@ class Podio::Application < ActivePodio::Base
|
|
5
6
|
property :status, :string
|
6
7
|
property :icon, :string
|
7
8
|
property :icon_id, :integer
|
9
|
+
property :pinned, :boolean
|
8
10
|
property :space_id, :integer
|
9
11
|
property :owner_id, :integer
|
10
12
|
property :owner, :hash
|
@@ -26,7 +28,7 @@ class Podio::Application < ActivePodio::Base
|
|
26
28
|
has_one :integration, :class => 'Integration'
|
27
29
|
|
28
30
|
alias_method :id, :app_id
|
29
|
-
delegate_to_hash :config, :allow_edit?, :allow_attachments?, :allow_comments?, :description, :visible?, :usage, :default_view
|
31
|
+
delegate_to_hash :config, :allow_edit?, :allow_attachments?, :allow_comments?, :description, :visible?, :usage, :default_view, :show_app_item_id?
|
30
32
|
|
31
33
|
def name
|
32
34
|
self[:name] || self.config['name']
|
@@ -37,51 +39,65 @@ class Podio::Application < ActivePodio::Base
|
|
37
39
|
end
|
38
40
|
|
39
41
|
class << self
|
42
|
+
# @see https://developers.podio.com/doc/applications/get-app-22349
|
40
43
|
def find(app_id, options = {})
|
41
44
|
member Podio.connection.get { |req|
|
42
45
|
req.url("/app/#{app_id}", options)
|
43
46
|
}.body
|
44
47
|
end
|
45
48
|
|
49
|
+
# @see https://developers.podio.com/doc/applications/get-app-on-space-by-url-label-477105
|
46
50
|
def find_by_url_label(space_id, url_label)
|
47
51
|
member Podio.connection.get("/app/space/#{space_id}/#{url_label}").body
|
48
52
|
end
|
49
53
|
|
54
|
+
# @see https://developers.podio.com/doc/applications/get-app-by-org-label-space-label-and-app-label-91708386
|
55
|
+
def find_by_org_space_and_app_labels(org_label, space_label, app_label)
|
56
|
+
member Podio.connection.get("/app/org/#{org_label}/space/#{space_label}/#{app_label}").body
|
57
|
+
end
|
58
|
+
|
50
59
|
def find_all(options={})
|
51
60
|
list Podio.connection.get { |req|
|
52
61
|
req.url("/app/", options)
|
53
62
|
}.body
|
54
63
|
end
|
55
64
|
|
65
|
+
# @see https://developers.podio.com/doc/applications/get-all-user-apps-5902728
|
56
66
|
def find_all_for_current_user(options={})
|
57
67
|
list Podio.connection.get { |req|
|
58
68
|
req.url("/app/v2/", options)
|
59
69
|
}.body
|
60
70
|
end
|
61
71
|
|
72
|
+
# @see https://developers.podio.com/doc/applications/get-top-apps-22476
|
62
73
|
def find_top(options={})
|
63
74
|
list Podio.connection.get { |req|
|
64
75
|
req.url("/app/top/", options)
|
65
76
|
}.body
|
66
77
|
end
|
78
|
+
|
79
|
+
## @see https://developers.podio.com/doc/applications/get-top-apps-for-organization-1671395
|
67
80
|
def find_top_for_org(org_id, options={})
|
68
81
|
list Podio.connection.get { |req|
|
69
82
|
req.url("/app/org/#{org_id}/top/", options)
|
70
83
|
}.body
|
71
84
|
end
|
72
85
|
|
86
|
+
# @see https://developers.podio.com/doc/applications/get-apps-by-space-22478
|
73
87
|
def find_all_for_space(space_id, options = {})
|
74
88
|
list Podio.connection.get { |req|
|
75
89
|
req.url("/app/space/#{space_id}/", options)
|
76
90
|
}.body
|
77
91
|
end
|
78
92
|
|
93
|
+
# @see https://developers.podio.com/doc/applications/get-calculations-for-app-773005
|
79
94
|
def get_calculations(app_id)
|
80
95
|
list Podio.connection.get { |req|
|
81
96
|
req.url("/app/#{app_id}/calculation/", {})
|
82
97
|
}.body
|
83
98
|
end
|
84
99
|
|
100
|
+
# @see https://developers.podio.com/doc/applications/update-app-order-22463
|
85
101
|
def update_order(space_id, app_ids = [])
|
86
102
|
response = Podio.connection.put do |req|
|
87
103
|
req.url "/app/space/#{space_id}/order"
|
@@ -91,6 +107,7 @@ class Podio::Application < ActivePodio::Base
|
|
91
107
|
response.body
|
92
108
|
end
|
93
109
|
|
110
|
+
# @see https://developers.podio.com/doc/applications/add-new-app-22351
|
94
111
|
def create(attributes)
|
95
112
|
response = Podio.connection.post do |req|
|
96
113
|
req.url "/app/"
|
@@ -99,6 +116,7 @@ class Podio::Application < ActivePodio::Base
|
|
99
116
|
response.body['app_id']
|
100
117
|
end
|
101
118
|
|
119
|
+
# @see https://developers.podio.com/doc/applications/update-app-22352
|
102
120
|
def update(app_id, attributes)
|
103
121
|
response = Podio.connection.put do |req|
|
104
122
|
req.url "/app/#{app_id}"
|
@@ -107,6 +125,25 @@ class Podio::Application < ActivePodio::Base
|
|
107
125
|
response.status
|
108
126
|
end
|
109
127
|
|
128
|
+
# @see https://developers.podio.com/doc/applications/update-app-description-33569973
|
129
|
+
def update_description(app_id, description)
|
130
|
+
response = Podio.connection.put do |req|
|
131
|
+
req.url "/app/#{app_id}/description"
|
132
|
+
req.body = {:description => description}
|
133
|
+
end
|
134
|
+
response.status
|
135
|
+
end
|
136
|
+
|
137
|
+
# @see https://developers.podio.com/doc/applications/update-app-usage-33570086
|
138
|
+
def update_usage(app_id, usage)
|
139
|
+
response = Podio.connection.put do |req|
|
140
|
+
req.url "/app/#{app_id}/usage"
|
141
|
+
req.body = {:usage => usage}
|
142
|
+
end
|
143
|
+
response.status
|
144
|
+
end
|
145
|
+
|
146
|
+
# @see https://developers.podio.com/doc/applications/install-app-22506
|
110
147
|
def install(app_id, attributes)
|
111
148
|
response = Podio.connection.post do |req|
|
112
149
|
req.url "/app/#{app_id}/install"
|
@@ -115,18 +152,22 @@ class Podio::Application < ActivePodio::Base
|
|
115
152
|
response.body['app_id']
|
116
153
|
end
|
117
154
|
|
155
|
+
# @see https://developers.podio.com/doc/applications/delete-app-field-22355
|
118
156
|
def delete_field(app_id, field_id)
|
119
157
|
Podio.connection.delete("/app/#{app_id}/field/#{field_id}").status
|
120
158
|
end
|
121
159
|
|
160
|
+
# @see https://developers.podio.com/doc/applications/deactivate-app-43821
|
122
161
|
def deactivate(id)
|
123
162
|
Podio.connection.post("/app/#{id}/deactivate").body
|
124
163
|
end
|
125
164
|
|
165
|
+
# @see https://developers.podio.com/doc/applications/activate-app-43822
|
126
166
|
def activate(id)
|
127
167
|
Podio.connection.post("/app/#{id}/activate").body
|
128
168
|
end
|
129
169
|
|
170
|
+
# @see https://developers.podio.com/doc/applications/delete-app-43693
|
130
171
|
def delete(id)
|
131
172
|
Podio.connection.delete("/app/#{id}").body
|
132
173
|
end
|
@@ -135,21 +176,35 @@ class Podio::Application < ActivePodio::Base
|
|
135
176
|
Podio.connection.post("/mobile/install_app/#{id}").body
|
136
177
|
end
|
137
178
|
|
179
|
+
# @see https://developers.podio.com/doc/applications/get-features-43648
|
138
180
|
def features(options)
|
139
181
|
Podio.connection.get { |req|
|
140
182
|
req.url("/app/features/", options)
|
141
183
|
}.body
|
142
184
|
end
|
143
185
|
|
186
|
+
# @see https://developers.podio.com/doc/applications/get-app-dependencies-39159
|
144
187
|
def dependencies(id)
|
145
188
|
Podio.connection.get("/app/#{id}/dependencies/").body
|
146
189
|
end
|
147
190
|
|
191
|
+
# @see https://developers.podio.com/doc/applications/get-space-app-dependencies-45779
|
148
192
|
def space_dependencies(space_id)
|
149
|
-
result = Podio.connection.get("/
|
193
|
+
result = Podio.connection.get("/space/#{space_id}/dependencies/").body
|
150
194
|
result['apps'] = result['apps'].collect { |app| Application.new(app) }
|
151
195
|
result
|
152
196
|
end
|
153
197
|
|
198
|
+
def regenerate_apptoken(app_id)
|
199
|
+
Podio.connection.post("/app/#{app_id}/token/regenerate").body
|
200
|
+
end
|
201
|
+
|
202
|
+
# @see https://developers.podio.com/doc/applications/get-icon-suggestions-82045764
|
203
|
+
def search_icons(query)
|
204
|
+
Podio.connection.get { |req|
|
205
|
+
req.url("/app/icon/search", {:query => query})
|
206
|
+
}.body
|
207
|
+
end
|
208
|
+
|
154
209
|
end
|
155
210
|
end
|