podio 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -4
  4. data/README.md +82 -67
  5. data/lib/podio.rb +15 -2
  6. data/lib/podio/client.rb +11 -7
  7. data/lib/podio/middleware/error_response.rb +3 -1
  8. data/lib/podio/middleware/json_response.rb +6 -1
  9. data/lib/podio/middleware/logger.rb +4 -3
  10. data/lib/podio/middleware/oauth2.rb +5 -5
  11. data/lib/podio/models/answer.rb +8 -0
  12. data/lib/podio/models/app_store_category.rb +2 -2
  13. data/lib/podio/models/app_store_share.rb +1 -0
  14. data/lib/podio/models/application.rb +12 -4
  15. data/lib/podio/models/application_field.rb +10 -0
  16. data/lib/podio/models/batch.rb +1 -0
  17. data/lib/podio/models/calendar_event.rb +6 -5
  18. data/lib/podio/models/campaign.rb +88 -0
  19. data/lib/podio/models/category.rb +1 -1
  20. data/lib/podio/models/contract.rb +18 -20
  21. data/lib/podio/models/contract_attribution.rb +24 -0
  22. data/lib/podio/models/contract_period.rb +22 -0
  23. data/lib/podio/models/contract_price.rb +37 -26
  24. data/lib/podio/models/device.rb +22 -0
  25. data/lib/podio/models/email_subscription_setting.rb +8 -0
  26. data/lib/podio/models/embed.rb +5 -2
  27. data/lib/podio/models/experiment.rb +26 -3
  28. data/lib/podio/models/extension.rb +90 -0
  29. data/lib/podio/models/external_file.rb +3 -3
  30. data/lib/podio/models/file_attachment.rb +25 -2
  31. data/lib/podio/models/form.rb +2 -1
  32. data/lib/podio/models/grant.rb +1 -0
  33. data/lib/podio/models/invoice.rb +13 -0
  34. data/lib/podio/models/item.rb +24 -11
  35. data/lib/podio/models/item_field.rb +6 -0
  36. data/lib/podio/models/item_transaction.rb +34 -0
  37. data/lib/podio/models/live.rb +1 -17
  38. data/lib/podio/models/notification.rb +5 -0
  39. data/lib/podio/models/o_auth.rb +9 -2
  40. data/lib/podio/models/o_auth_client.rb +5 -3
  41. data/lib/podio/models/o_auth_scope.rb +11 -0
  42. data/lib/podio/models/organization.rb +26 -8
  43. data/lib/podio/models/organization_member.rb +6 -0
  44. data/lib/podio/models/organization_membership.rb +15 -0
  45. data/lib/podio/models/profile.rb +2 -0
  46. data/lib/podio/models/promotion.rb +6 -8
  47. data/lib/podio/models/promotion_group.rb +51 -0
  48. data/lib/podio/models/promotion_group_member.rb +32 -0
  49. data/lib/podio/models/rating.rb +4 -2
  50. data/lib/podio/models/reference.rb +2 -1
  51. data/lib/podio/models/space.rb +11 -5
  52. data/lib/podio/models/tag.rb +36 -0
  53. data/lib/podio/models/view.rb +5 -0
  54. data/lib/podio/models/vote.rb +8 -0
  55. data/lib/podio/models/voting.rb +9 -0
  56. data/lib/podio/models/voucher.rb +68 -0
  57. data/lib/podio/version.rb +1 -1
  58. data/podio.gemspec +10 -3
  59. data/test/client_test.rb +14 -0
  60. metadata +31 -13
  61. data/lib/podio/models/contract_price_v2.rb +0 -31
  62. data/lib/podio/models/date_election.rb +0 -35
@@ -0,0 +1,22 @@
1
+ # @see https://developers.podio.com/doc/actions
2
+ class Podio::Device < ActivePodio::Base
3
+ property :app, :string
4
+ property :type, :string
5
+ property :token, :string
6
+
7
+ class << self
8
+ def find_all_for_user(user_id)
9
+ list Podio.connection.get("/mobile/user/#{user_id}").body
10
+ end
11
+
12
+ def send_test(user_id, attributes)
13
+ response = Podio.connection.post do |req|
14
+ req.url "/mobile/user/#{user_id}/test"
15
+ req.body = attributes
16
+ end
17
+
18
+ response.body['pushed']
19
+ end
20
+ end
21
+
22
+ end
@@ -11,6 +11,8 @@ class Podio::EmailSubscriptionSetting < ActivePodio::Base
11
11
  property :push_notification, :boolean
12
12
  property :push_notification_sound, :boolean
13
13
  property :push_notification_browser, :boolean
14
+ property :user, :boolean
15
+ property :bulletin, :boolean
14
16
 
15
17
  def self.find_for_current_user
16
18
  self.get_groups
@@ -27,6 +29,12 @@ class Podio::EmailSubscriptionSetting < ActivePodio::Base
27
29
  req.url("/email/group/", {})
28
30
  }.body
29
31
  end
32
+
33
+ def find_for_user(user_id, client_type)
34
+ member Podio.connection.get { |req|
35
+ req.url("/user/#{user_id}/setting/#{client_type}/", {})
36
+ }.body
37
+ end
30
38
 
31
39
  # @see https://developers.podio.com/doc/email/update-groups-333981
32
40
  def update_groups(options)
@@ -18,10 +18,11 @@ class Podio::Embed < ActivePodio::Base
18
18
  class << self
19
19
 
20
20
  # @see https://developers.podio.com/doc/embeds/add-an-embed-726483
21
- def create(url)
21
+ # mode: immediate or delayed
22
+ def create(url, mode = 'immediate')
22
23
  response = Podio.connection.post do |req|
23
24
  req.url '/embed/'
24
- req.body = {:url => url }
25
+ req.body = {:url => url, :mode => mode }
25
26
  end
26
27
  member response.body
27
28
  end
@@ -32,3 +33,5 @@ class Podio::Embed < ActivePodio::Base
32
33
 
33
34
  end
34
35
  end
36
+
37
+
@@ -1,4 +1,12 @@
1
1
  class Podio::Experiment < ActivePodio::Base
2
+ class Podio::Variation < ActivePodio::Base
3
+ property :name, :string
4
+ property :weight, :integer
5
+ property :active, :boolean
6
+ end
7
+
8
+ property :name, :string
9
+ has_many :variations, :class => 'Variation'
2
10
 
3
11
  class << self
4
12
 
@@ -31,7 +39,11 @@ class Podio::Experiment < ActivePodio::Base
31
39
  end
32
40
 
33
41
  def find_all
34
- Podio.connection.get('/experiment/').body
42
+ list Podio.connection.get('/experiment/').body
43
+ end
44
+
45
+ def find(experiment)
46
+ member Podio.connection.get("/experiment/#{experiment}").body
35
47
  end
36
48
 
37
49
  def create_variation(experiment, variation)
@@ -46,6 +58,17 @@ class Podio::Experiment < ActivePodio::Base
46
58
  Podio.connection.post("/experiment/#{experiment}/variation/#{variation}/deactivate")
47
59
  end
48
60
 
61
+ def delete_variation(experiment, variation)
62
+ Podio.connection.delete("/experiment/#{experiment}/variation/#{variation}")
63
+ end
64
+
65
+ def update_variation_weight(experiment, variation, weight)
66
+ Podio.connection.post do |req|
67
+ req.url "/experiment/#{experiment}/variation/#{variation}/weight"
68
+ req.body = { "weight" => weight }
69
+ end
70
+ end
71
+
49
72
  def assign_variation(experiment, variation, attributes)
50
73
  Podio.connection.post do |req|
51
74
  req.url "/experiment/#{experiment}/variation/#{variation}/assign"
@@ -56,9 +79,9 @@ class Podio::Experiment < ActivePodio::Base
56
79
  def combined(supported_variations_map, identifier=nil, attributes={})
57
80
  connection = Podio.client.oauth_token ? Podio.client.connection : Podio.client.trusted_connection
58
81
 
59
- body = {
82
+ body = attributes.merge({
60
83
  "experiments" => supported_variations_map
61
- }
84
+ })
62
85
 
63
86
  body["identifier"] = identifier if identifier.present?
64
87
 
@@ -0,0 +1,90 @@
1
+ class Podio::Extension < ActivePodio::Base
2
+ property :extension_id, :integer
3
+ property :name, :string
4
+ property :installation_url, :string
5
+ property :status, :string
6
+ property :created_on, :datetime
7
+ property :ratings, :hash
8
+ property :description, :string
9
+ property :url_label, :string
10
+
11
+ # Publisher
12
+ property :publisher_name, :string
13
+ property :publisher_url, :string
14
+ property :publisher_mail, :string
15
+
16
+ # Price
17
+ property :price_model, :string
18
+ property :price_from, :integer
19
+ property :price_to, :integer
20
+ property :price_desc, :string
21
+
22
+ # Writing
23
+ property :main_screenshot_id, :integer
24
+ property :logo_id, :integer
25
+ # Reading
26
+ has_one :main_screenshot, :class => 'FileAttachment'
27
+ has_one :logo, :class => 'FileAttachment'
28
+
29
+ has_one :user, :class => 'User'
30
+ has_many :other_screenshots, :class => 'FileAttachment'
31
+
32
+
33
+ class << self
34
+ def create(attributes, options={})
35
+ response = Podio.connection.post do |req|
36
+ req.url("/extension/", options)
37
+ req.body = attributes
38
+ end
39
+
40
+ response.body
41
+ end
42
+
43
+ def find_all(options = {})
44
+ list Podio.connection.get { |req|
45
+ req.url("/extension/", options)
46
+ }.body
47
+ end
48
+
49
+ def find_all_by_status(status, options = {})
50
+ list Podio.connection.get { |req|
51
+ req.url("/extension/status/#{status}", options)
52
+ }.body
53
+ end
54
+
55
+ def find_overview(options = {})
56
+ response = Podio.connection.get { |req|
57
+ req.url("/extension/overview", options)
58
+ }.body
59
+
60
+ response['popular'] = list(response['popular'])
61
+ response['staffpicks'] = list(response['staffpicks'])
62
+ response['recent'] = list(response['recent'])
63
+
64
+ response
65
+ end
66
+
67
+ def find_all_for_current_user(options = {})
68
+ list Podio.connection.get { |req|
69
+ req.url("/extension/user/", options)
70
+ }.body
71
+ end
72
+
73
+ def find(id)
74
+ member Podio.connection.get("/extension/#{id}").body
75
+ end
76
+
77
+ def update(id, attributes, options={})
78
+ response = Podio.connection.put do |req|
79
+ req.url("/extension/#{id}", options)
80
+ req.body = attributes
81
+ end
82
+ response.status
83
+ end
84
+
85
+ def delete(id)
86
+ Podio.connection.delete("/extension/#{id}").body
87
+ end
88
+
89
+ end
90
+ end
@@ -18,10 +18,10 @@ class Podio::ExternalFile < ActivePodio::Base
18
18
  }.body
19
19
  end
20
20
 
21
-
22
- def create_from_external_file_id(linked_account_id, external_file_id, preserve_permissions=false)
21
+ # DEPRECATED please use FileAttachment.create_from_external_id
22
+ def create_from_external_file_id(linked_account_id, external_file_id, preserve_permissions=false, options={})
23
23
  response = Podio.client.connection.post do |req|
24
- req.url "/file/linked_account/#{linked_account_id}/"
24
+ req.url("/file/linked_account/#{linked_account_id}/", options)
25
25
  req.body = {
26
26
  :external_file_id => external_file_id,
27
27
  :preserve_permissions => preserve_permissions
@@ -1,6 +1,7 @@
1
1
  # @see https://developers.podio.com/doc/files
2
2
  class Podio::FileAttachment < ActivePodio::Base
3
3
  property :file_id, :integer
4
+ property :external_file_id, :string
4
5
  property :link, :string
5
6
  property :link_target, :string
6
7
  property :perma_link, :string
@@ -37,8 +38,11 @@ class Podio::FileAttachment < ActivePodio::Base
37
38
  'file'
38
39
  end
39
40
 
40
- def raw_data
41
- Podio.connection.get(self.link).body
41
+ # Returns the raw bytes of a file
42
+ # for images pass the size used by podio in its urls e.g. https://files.podio.com/:file/medium
43
+ def raw_data(size=nil)
44
+ link = size ? "#{self.link}/#{size}" : self.link
45
+ Podio.connection.get(link).body
42
46
  end
43
47
 
44
48
  class << self
@@ -64,6 +68,18 @@ class Podio::FileAttachment < ActivePodio::Base
64
68
  member response.body
65
69
  end
66
70
 
71
+ def create_from_external_file_id(linked_account_id, external_file_id, preserve_permissions=false, options={})
72
+ response = Podio.client.connection.post do |req|
73
+ req.url("/file/linked_account/#{linked_account_id}/", options)
74
+ req.body = {
75
+ :external_file_id => external_file_id,
76
+ :preserve_permissions => preserve_permissions
77
+ }
78
+ end
79
+
80
+ member response.body
81
+ end
82
+
67
83
  # Attach a file to an existing reference
68
84
  # @see https://developers.podio.com/doc/files/attach-file-22518
69
85
  def attach(id, ref_type, ref_id)
@@ -93,6 +109,13 @@ class Podio::FileAttachment < ActivePodio::Base
93
109
  Podio.client.connection.get("/file/#{id}/raw").body
94
110
  end
95
111
 
112
+ # @see https://developers.podio.com/doc/files/get-files-4497983
113
+ def find_all(options={})
114
+ list Podio.connection.get { |req|
115
+ req.url("/file/", options)
116
+ }.body
117
+ end
118
+
96
119
  # @see https://developers.podio.com/doc/files/get-files-on-app-22472
97
120
  def find_for_app(app_id, options={})
98
121
  list Podio.connection.get { |req|
@@ -8,12 +8,13 @@ class Podio::Form < ActivePodio::Base
8
8
  property :fields, :array
9
9
  property :attachments, :boolean
10
10
  property :status, :string
11
+ property :item_capacity, :boolean
11
12
 
12
13
  # Deprecated
13
14
  property :field_ids, :array
14
15
 
15
16
  alias_method :id, :form_id
16
- delegate_to_hash :settings, :captcha, :text, :theme, :css, :setter => true
17
+ delegate_to_hash :settings, :captcha, :text, :theme, :css, :success_page, :setter => true
17
18
  delegate_to_hash :text, :submit, :success, :heading, :description, :setter => true
18
19
 
19
20
  class << self
@@ -6,6 +6,7 @@ class Podio::Grant < ActivePodio::Base
6
6
  property :action, :string
7
7
  property :message, :string
8
8
  property :ref, :hash
9
+ property :rights, :array
9
10
  property :created_on, :datetime
10
11
 
11
12
  has_one :created_by, :class => 'ByLine'
@@ -22,6 +22,19 @@ class Podio::Invoice < ActivePodio::Base
22
22
  def find_by_contract(contract_id)
23
23
  list Podio.connection.get("/invoice/contract/#{contract_id}/").body
24
24
  end
25
+
26
+ def invoice_contract(contract_id, attributes)
27
+ response = Podio.connection.post do |req|
28
+ req.url "/invoice/contract/#{contract_id}/invoice"
29
+ req.body = attributes
30
+ end
31
+
32
+ if response.status == 200
33
+ member response.body
34
+ else
35
+ nil
36
+ end
37
+ end
25
38
 
26
39
  def pay(invoice_id)
27
40
  Podio.connection.post("/invoice/#{invoice_id}/pay").status
@@ -16,7 +16,6 @@ class Podio::Item < ActivePodio::Base
16
16
 
17
17
  has_one :created_by, :class => 'ByLine'
18
18
  has_one :created_via, :class => 'Via'
19
- has_one :date_election, :class => 'DateElection'
20
19
 
21
20
  # Also included in the full Get item
22
21
  property :ratings, :hash
@@ -25,6 +24,7 @@ class Podio::Item < ActivePodio::Base
25
24
  property :references, :array
26
25
  property :refs, :array
27
26
  property :tags, :array
27
+ property :votes, :hash
28
28
  property :subscribed, :boolean
29
29
  property :pinned, :boolean
30
30
  property :user_ratings, :hash
@@ -49,10 +49,12 @@ class Podio::Item < ActivePodio::Base
49
49
  has_many :files, :class => 'FileAttachment'
50
50
  has_many :comments, :class => 'Comment'
51
51
  has_many :shares, :class => 'AppStoreShare'
52
+ has_one :current_revision, :class => 'ItemRevision'
52
53
  has_one :reminder, :class => 'Reminder'
53
54
  has_one :recurrence, :class => 'Recurrence'
54
55
  has_one :linked_account_data, :class => 'LinkedAccountData'
55
56
  has_one :application, :class => 'Application', :property => :app
57
+ has_one :grant, :class => 'Grant'
56
58
 
57
59
  # For inserting/updating
58
60
  property :file_ids, :array
@@ -88,8 +90,10 @@ class Podio::Item < ActivePodio::Base
88
90
 
89
91
  class << self
90
92
  # @see https://developers.podio.com/doc/items/get-item-22360
91
- def find(id)
92
- member Podio.connection.get("/item/#{id}").body
93
+ def find(id, options = {})
94
+ member Podio.connection.get { |req|
95
+ req.url("/item/#{id}", options)
96
+ }.body
93
97
  end
94
98
 
95
99
  def find_by_app_item_id(app_id, app_item_id)
@@ -127,18 +131,18 @@ class Podio::Item < ActivePodio::Base
127
131
  end
128
132
 
129
133
  # @see https://developers.podio.com/doc/items/filter-items-by-view-4540284
130
- def find_by_filter_id(app_id, filter_id, attributes)
134
+ def find_by_filter_id(app_id, filter_id, attributes, options={})
131
135
  collection Podio.connection.post { |req|
132
- req.url "/item/app/#{app_id}/filter/#{filter_id}/"
136
+ req.url("/item/app/#{app_id}/filter/#{filter_id}/", options)
133
137
  req.body = attributes
134
138
  }.body
135
139
  end
136
140
 
137
141
  # @see https://developers.podio.com/doc/items/filter-items-4496747
138
- def find_by_filter_values(app_id, filter_values, attributes={})
142
+ def find_by_filter_values(app_id, filter_values, attributes={}, options={})
139
143
  attributes[:filters] = filter_values
140
144
  collection Podio.connection.post { |req|
141
- req.url "/item/app/#{app_id}/filter/"
145
+ req.url("/item/app/#{app_id}/filter/", options)
142
146
  req.body = attributes
143
147
  }.body
144
148
  end
@@ -182,6 +186,11 @@ class Podio::Item < ActivePodio::Base
182
186
  }.body
183
187
  end
184
188
 
189
+ # @see https://developers.podio.com/doc/items/get-item-count-34819997
190
+ def item_count(app_id)
191
+ Podio.connection.get("/item/app/#{app_id}/count/").body
192
+ end
193
+
185
194
  # @see https://developers.podio.com/doc/items/get-items-as-xlsx-63233
186
195
  def xlsx(app_id, options={})
187
196
  response = Podio.connection.get { |req|
@@ -235,8 +244,12 @@ class Podio::Item < ActivePodio::Base
235
244
  end
236
245
 
237
246
  # @see https://developers.podio.com/doc/items/delete-item-22364
238
- def delete(id)
239
- Podio.connection.delete("/item/#{id}").body
247
+ def delete(id, options={})
248
+ response = Podio.connection.delete do |req|
249
+ req.url("/item/#{id}", options)
250
+ end
251
+
252
+ response.body
240
253
  end
241
254
 
242
255
  # @see https://developers.podio.com/doc/items/delete-item-reference-7302326
@@ -266,9 +279,9 @@ class Podio::Item < ActivePodio::Base
266
279
  Podio.connection.post("/item/app/#{app_id}/cleanup_field_values").body
267
280
  end
268
281
 
269
- def rearrange(id, attributes)
282
+ def rearrange(id, attributes, options = {})
270
283
  response = Podio.connection.post do |req|
271
- req.url "/item/#{id}/rearrange"
284
+ req.url("/item/#{id}/rearrange", options)
272
285
  req.body = attributes
273
286
  end
274
287
 
@@ -10,6 +10,12 @@ class Podio::ItemField < ActivePodio::Base
10
10
  alias_method :id, :field_id
11
11
 
12
12
  class << self
13
+
14
+ # @see https://developers.podio.com/doc/items/get-item-field-values-22368
15
+ def find_values(item_id, field_id)
16
+ Podio.connection.get("/item/#{item_id}/value/#{field_id}").body
17
+ end
18
+
13
19
  # @see https://developers.podio.com/doc/items/update-item-field-values-22367
14
20
  def update(item_id, field_id, values, options = {})
15
21
  response = Podio.connection.put do |req|
@@ -0,0 +1,34 @@
1
+ class Podio::ItemTransaction < ActivePodio::Base
2
+ property :item_transaction_id, :integer
3
+ property :state, :string
4
+ property :reason, :string
5
+ property :amount, :integer
6
+
7
+ property :text, :string
8
+
9
+ property :created_on, :datetime
10
+
11
+ property :ratings, :hash
12
+ property :created_on, :datetime
13
+ property :rights, :array
14
+ property :is_liked, :boolean
15
+ property :like_count, :integer
16
+
17
+ has_one :created_by, :class => 'ByLine'
18
+ has_one :created_via, :class => 'Via'
19
+
20
+ has_many :comments, :class => 'Comment'
21
+ has_many :tasks, :class => 'Task'
22
+
23
+ alias_method :id, :item_transaction_id
24
+
25
+ class << self
26
+
27
+ def find(id)
28
+ member Podio.connection.get { |req|
29
+ req.url("/item_accounting/transaction/#{id}")
30
+ }.body
31
+ end
32
+
33
+ end
34
+ end