podio 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/Rakefile +0 -16
  2. data/lib/podio.rb +6 -3
  3. data/lib/podio/active_podio/base.rb +53 -21
  4. data/lib/podio/active_podio/updatable.rb +9 -14
  5. data/lib/podio/client.rb +46 -17
  6. data/lib/podio/error.rb +9 -0
  7. data/lib/podio/middleware/error_response.rb +5 -1
  8. data/lib/podio/middleware/json_request.rb +27 -5
  9. data/lib/podio/models/account_provider.rb +16 -0
  10. data/lib/podio/models/app_store_category.rb +25 -0
  11. data/lib/podio/models/app_store_share.rb +90 -11
  12. data/lib/podio/models/application.rb +52 -12
  13. data/lib/podio/models/application_field.rb +4 -4
  14. data/lib/podio/models/batch.rb +31 -0
  15. data/lib/podio/models/calendar_event.rb +64 -10
  16. data/lib/podio/models/category.rb +11 -9
  17. data/lib/podio/models/contact.rb +3 -1
  18. data/lib/podio/models/contract.rb +3 -0
  19. data/lib/podio/models/email_subscription_setting.rb +26 -3
  20. data/lib/podio/models/file_attachment.rb +3 -2
  21. data/lib/podio/models/form.rb +2 -2
  22. data/lib/podio/models/importer.rb +18 -9
  23. data/lib/podio/models/item.rb +87 -22
  24. data/lib/podio/models/item_field.rb +8 -3
  25. data/lib/podio/models/linked_account.rb +11 -3
  26. data/lib/podio/models/linked_account_data.rb +6 -0
  27. data/lib/podio/models/news.rb +1 -0
  28. data/lib/podio/models/organization.rb +4 -0
  29. data/lib/podio/models/organization_member.rb +17 -4
  30. data/lib/podio/models/organization_profile.rb +5 -1
  31. data/lib/podio/models/profile.rb +19 -10
  32. data/lib/podio/models/reference.rb +33 -0
  33. data/lib/podio/models/search.rb +4 -7
  34. data/lib/podio/models/space.rb +21 -12
  35. data/lib/podio/models/space_invitation.rb +7 -7
  36. data/lib/podio/models/space_member.rb +28 -3
  37. data/lib/podio/models/task.rb +38 -14
  38. data/lib/podio/models/user.rb +27 -5
  39. data/lib/podio/models/user_status.rb +5 -0
  40. data/lib/podio/models/view.rb +51 -0
  41. data/lib/podio/models/widget.rb +1 -1
  42. data/lib/podio/version.rb +1 -1
  43. data/test/client_test.rb +13 -3
  44. data/test/fixtures/fixtures.yaml +7 -7
  45. data/test/test_helper.rb +1 -24
  46. metadata +16 -23
  47. data/lib/podio/middleware/response_recorder.rb +0 -14
  48. data/lib/podio/models/meeting.rb +0 -151
  49. data/lib/podio/models/meeting_participiant.rb +0 -11
  50. data/test/fixtures/client/18a224aaf83ac57a7b8159cecdbb1263.rack +0 -1
  51. data/test/fixtures/client/a87c69a0624af0413a670094c6615651.rack +0 -1
  52. data/test/fixtures/client/ac493997db62308972c208afa76f8479.rack +0 -1
  53. data/test/fixtures/client/d7fbf422c77af768552423633d0389e8.rack +0 -1
  54. data/test/fixtures/client/e2d68afe39f5531195273ea259b63916.rack +0 -1
@@ -4,36 +4,38 @@ class Podio::Category < ActivePodio::Base
4
4
  property :name, :string
5
5
 
6
6
  alias_method :id, :category_id
7
-
7
+
8
8
  class << self
9
9
  def create(attributes)
10
10
  response = Podio.connection.post do |req|
11
11
  req.url "/app_store/category/"
12
12
  req.body = attributes
13
13
  end
14
-
14
+
15
15
  response.status
16
16
  end
17
-
17
+
18
18
  def update(id, attributes)
19
19
  response = Podio.connection.put do |req|
20
20
  req.url "/app_store/category/#{id}"
21
21
  req.body = attributes
22
22
  end
23
-
23
+
24
24
  response.status
25
25
  end
26
-
26
+
27
27
  def delete(id)
28
28
  Podio.connection.delete("/app_store/category/#{id}").status
29
29
  end
30
-
30
+
31
31
  def find(id)
32
32
  member Podio.connection.get("/app_store/category/#{id}").body
33
33
  end
34
-
35
- def find_all
36
- collection Podio.connection.get("/app_store/category/").body
34
+
35
+ def find_all(options = {})
36
+ collection Podio.connection.get { |req|
37
+ req.url("/app_store/category/", options)
38
+ }.body
37
39
  end
38
40
 
39
41
  private
@@ -1,14 +1,16 @@
1
1
  class Podio::Contact < Podio::Profile
2
2
  include ActivePodio::Updatable
3
-
3
+
4
4
  property :user_id, :integer
5
5
  property :organization, :string
6
6
  property :role, :string # Only available when getting contacts for a space
7
7
  property :removable, :boolean # Only available when getting contacts for a space
8
8
  property :type, :string # user, space, connection - blank probably means it's a real user / Podio member
9
+ property :space_id, :integer
9
10
  property :link, :string
10
11
  property :last_seen_on, :datetime
11
12
  property :rights, :array
13
+ property :external_id, :string
12
14
 
13
15
  alias_method :id, :user_id
14
16
 
@@ -8,6 +8,7 @@ class Podio::Contract < ActivePodio::Base
8
8
  property :started_on, :datetime
9
9
  property :ended_on, :datetime
10
10
  property :item_prices, :hash
11
+ property :item_limits, :hash
11
12
  property :payment_id, :string
12
13
  property :payment_status, :string
13
14
  property :accounting_id, :string
@@ -21,6 +22,8 @@ class Podio::Contract < ActivePodio::Base
21
22
  property :invoicing_mode, :string
22
23
  property :ended_reason, :string
23
24
  property :ended_comment, :string
25
+ property :billing_mail, :string
26
+ property :model, :string
24
27
 
25
28
  has_one :org, :class => 'Organization'
26
29
  has_one :user, :class => 'User'
@@ -10,15 +10,16 @@ class Podio::EmailSubscriptionSetting < ActivePodio::Base
10
10
  property :subscription, :boolean
11
11
  property :push_notification, :boolean
12
12
  property :push_notification_sound, :boolean
13
+ property :push_notification_browser, :boolean
13
14
 
14
15
  def self.find_for_current_user
15
16
  self.get_groups
16
17
  end
17
-
18
+
18
19
  def update
19
20
  self.class.update_groups(self.attributes)
20
21
  end
21
-
22
+
22
23
  class << self
23
24
  def get_groups()
24
25
  member Podio.connection.get { |req|
@@ -36,7 +37,29 @@ class Podio::EmailSubscriptionSetting < ActivePodio::Base
36
37
  def unsubscribe(username)
37
38
  Podio.connection.post("/email/unsubscribe/#{username}").status
38
39
  end
39
-
40
+
41
+ def get_global_email_as_vcard(name)
42
+ Podio.connection.get("/email/contact/#{name}/vcard").body
43
+ end
44
+
45
+ def get_ref_email_as_vcard(name, ref_type, ref_id)
46
+ Podio.connection.get("/email/contact/#{name}/#{ref_type}/#{ref_id}/vcard").body
47
+ end
48
+
49
+ def export_global_contact_to_linked_acc(name, linked_acc_id)
50
+ Podio.connection.post { |req|
51
+ req.url "/email/contact/#{name}/export"
52
+ req.body = { :linked_account_id => linked_acc_id }
53
+ }.body
54
+ end
55
+
56
+ def export_ref_contact_to_linked_acc(name, ref_type, ref_id, linked_acc_id)
57
+ Podio.connection.post { |req|
58
+ req.url "/email/contact/#{name}/#{ref_type}/#{ref_id}/export"
59
+ req.body = { :linked_account_id => linked_acc_id }
60
+ }.body
61
+ end
62
+
40
63
  end
41
64
 
42
65
  end
@@ -33,9 +33,10 @@ class Podio::FileAttachment < ActivePodio::Base
33
33
  class << self
34
34
  # Accepts an open file stream along with a file name and uploads the file to Podio
35
35
  def upload(file_stream, file_name)
36
- response = Podio.client.raw_connection.post do |req|
36
+ response = Podio.client.connection.post do |req|
37
37
  req.options[:timeout] = 1200
38
38
  req.url "/file/v2/"
39
+ req.headers['Content-Type'] = 'multipart/form-data'
39
40
  req.body = {:source => Faraday::UploadIO.new(file_stream, nil, nil), :filename => file_name}
40
41
  end
41
42
 
@@ -72,7 +73,7 @@ class Podio::FileAttachment < ActivePodio::Base
72
73
  end
73
74
 
74
75
  def find_raw(id)
75
- Podio.client.raw_connection.get("/file/#{id}/raw").body
76
+ Podio.client.connection.get("/file/#{id}/raw").body
76
77
  end
77
78
 
78
79
  def find_for_app(app_id, options={})
@@ -12,9 +12,9 @@ class Podio::Form < ActivePodio::Base
12
12
  property :field_ids, :array
13
13
 
14
14
  alias_method :id, :form_id
15
- delegate_to_hash :settings, :captcha, :text, :theme, :setter => true
15
+ delegate_to_hash :settings, :captcha, :text, :theme, :css, :setter => true
16
16
  delegate_to_hash :text, :submit, :success, :heading, :description, :setter => true
17
-
17
+
18
18
  class << self
19
19
  def create(app_id, attributes)
20
20
  response = Podio.connection.post do |req|
@@ -1,14 +1,10 @@
1
1
  class Podio::Importer < ActivePodio::Base
2
-
2
+
3
3
  class << self
4
- def process_file(file_id, app_id, mappings, tags_column_id)
4
+ def process_file(file_id, options = {})
5
5
  response = Podio.connection.post do |req|
6
6
  req.url "/importer/#{file_id}/process"
7
- req.body = {
8
- :app_id => app_id,
9
- :mappings => mappings,
10
- :tags_column_id => tags_column_id
11
- }
7
+ req.body = options
12
8
  end
13
9
 
14
10
  response.body
@@ -17,6 +13,19 @@ class Podio::Importer < ActivePodio::Base
17
13
  def get_columns(file_id)
18
14
  list Podio.connection.get("/importer/#{file_id}/column/").body
19
15
  end
20
-
16
+
17
+ def get_info(file_id)
18
+ Podio.connection.get("/importer/#{file_id}/info").body
19
+ end
20
+
21
+ def preview(file_id, row, options)
22
+ response = Podio.connection.post do |req|
23
+ req.url "/importer/#{file_id}/preview/#{row}"
24
+ req.body = options
25
+ end
26
+
27
+ response.body
28
+ end
29
+
21
30
  end
22
- end
31
+ end
@@ -11,7 +11,7 @@ class Podio::Item < ActivePodio::Base
11
11
 
12
12
  has_one :initial_revision, :class => 'ItemRevision'
13
13
  has_one :current_revision, :class => 'ItemRevision'
14
-
14
+
15
15
  # Also included in the full Get item
16
16
  property :ratings, :hash
17
17
  property :conversations, :array
@@ -23,28 +23,39 @@ class Podio::Item < ActivePodio::Base
23
23
  property :user_ratings, :hash
24
24
  property :link, :string
25
25
  property :invite, :hash
26
+ property :participants, :hash
27
+ property :linked_account_id, :integer
28
+ property :ref, :hash # linked items
29
+ property :priority, :float
30
+
31
+ # Get items
32
+ property :comment_count, :integer
33
+ property :task_count, :integer
26
34
 
27
35
  has_many :revisions, :class => 'ItemRevision'
28
36
  has_many :files, :class => 'FileAttachment'
29
37
  has_many :comments, :class => 'Comment'
30
38
  has_many :shares, :class => 'AppStoreShare'
39
+ has_one :reminder, :class => 'Reminder'
40
+ has_one :recurrence, :class => 'Recurrence'
41
+ has_one :linked_account_data, :class => 'LinkedAccountData'
31
42
 
32
43
  # For inserting/updating
33
44
  property :file_ids, :array
34
-
45
+
35
46
  alias_method :id, :item_id
36
47
  delegate_to_hash :app, :app_id, :app_name, :item_name
37
48
 
38
49
  def create
39
- self.item_id = Item.create(self.app_id, prepare_item_values(self))
50
+ self.item_id = self.class.create(self.app_id, prepare_item_values(self))
40
51
  end
41
52
 
42
53
  def destroy
43
- Item.delete(self.id)
54
+ self.class.delete(self.id)
44
55
  end
45
56
 
46
57
  def update
47
- Item.update(self.id, prepare_item_values(self))
58
+ self.class.update(self.id, prepare_item_values(self))
48
59
  end
49
60
 
50
61
  handle_api_errors_for :create, :update
@@ -57,7 +68,7 @@ class Podio::Item < ActivePodio::Base
57
68
 
58
69
  {:fields => fields, :file_ids => file_ids, :tags => tags }
59
70
  end
60
-
71
+
61
72
  class << self
62
73
  def find(id)
63
74
  member Podio.connection.get("/item/#{id}").body
@@ -71,6 +82,14 @@ class Podio::Item < ActivePodio::Base
71
82
  Podio.connection.get("/item/#{id}/basic").body
72
83
  end
73
84
 
85
+ def find_basic_by_field(item_id, field_id)
86
+ member Podio.connection.get("/item/#{item_id}/reference/#{field_id}/preview").body
87
+ end
88
+
89
+ def find_basic_hash_by_field(item_id, field_id)
90
+ Podio.connection.get("/item/#{item_id}/reference/#{field_id}/preview").body
91
+ end
92
+
74
93
  def find_all_by_external_id(app_id, external_id)
75
94
  collection Podio.connection.get("/item/app/#{app_id}/v2/?external_id=#{external_id}").body
76
95
  end
@@ -95,14 +114,6 @@ class Podio::Item < ActivePodio::Base
95
114
  req.body = attributes
96
115
  }.body
97
116
  end
98
-
99
- def find_next(current_item_id, time = nil)
100
- find_next_or_previous(:next, current_item_id, time)
101
- end
102
-
103
- def find_previous(current_item_id, time = nil)
104
- find_next_or_previous(:previous, current_item_id, time)
105
- end
106
117
 
107
118
  def find_app_values(app_id)
108
119
  response = Podio.connection.get { |req|
@@ -110,13 +121,28 @@ class Podio::Item < ActivePodio::Base
110
121
  }
111
122
  response.body
112
123
  end
113
-
124
+
125
+ def find_references_by_field(item_id, field_id, options = {})
126
+ list Podio.connection.get { |req|
127
+ req.url("/item/#{item_id}/reference/field/#{field_id}", options)
128
+ }.body
129
+ end
130
+
131
+ def calculate(app_id, config)
132
+ response = Podio.connection.post do |req|
133
+ req.url "/item/app/#{app_id}/calculate"
134
+ req.body = config
135
+ end
136
+
137
+ response.body
138
+ end
139
+
114
140
  def find_field_top(field_id, options={:limit => 8})
115
141
  list Podio.connection.get { |req|
116
142
  req.url("/item/field/#{field_id}/top/", options)
117
143
  }.body
118
144
  end
119
-
145
+
120
146
  def xlsx(app_id, options={})
121
147
  response = Podio.connection.get { |req|
122
148
  req.url("/item/app/#{app_id}/xlsx/", options)
@@ -124,6 +150,13 @@ class Podio::Item < ActivePodio::Base
124
150
  response.body
125
151
  end
126
152
 
153
+ def export(app_id, exporter, options={})
154
+ response = Podio.connection.post { |req|
155
+ req.url "/item/app/#{app_id}/export/#{exporter}"
156
+ req.body = options
157
+ }.body
158
+ end
159
+
127
160
  def search_field(field_id, options={})
128
161
  list Podio.connection.get { |req|
129
162
  req.url("/item/field/#{field_id}/find", options)
@@ -138,7 +171,7 @@ class Podio::Item < ActivePodio::Base
138
171
 
139
172
  response.body['item_id']
140
173
  end
141
-
174
+
142
175
  def update(id, attributes)
143
176
  response = Podio.connection.put do |req|
144
177
  req.url "/item/#{id}"
@@ -146,21 +179,53 @@ class Podio::Item < ActivePodio::Base
146
179
  end
147
180
  response.status
148
181
  end
149
-
182
+
150
183
  def delete(id)
151
184
  Podio.connection.delete("/item/#{id}").body
152
185
  end
153
-
186
+
187
+ def delete_ref(id)
188
+ Podio.connection.delete("/item/#{id}/ref").body
189
+ end
190
+
191
+ def set_participation(id, status)
192
+ response = Podio.connection.put do |req|
193
+ req.url "/item/#{id}/participation"
194
+ req.body = { :status => status }
195
+ end
196
+ response.status
197
+ end
198
+
199
+ def cleanup_field_values(app_id)
200
+ Podio.connection.post("/item/app/#{app_id}/cleanup_field_values").body
201
+ end
202
+
203
+ def rearrange(id, attributes)
204
+ response = Podio.connection.post do |req|
205
+ req.url "/item/#{id}/rearrange"
206
+ req.body = attributes
207
+ end
208
+
209
+ member response.body
210
+ end
211
+
212
+ def find_meeting_url(id)
213
+ response = Podio.connection.get { |req|
214
+ req.url("/item/#{id}/meeting/url")
215
+ }
216
+ response.body
217
+ end
218
+
154
219
  protected
155
-
220
+
156
221
  def time_options(time)
157
222
  time.present? ? { 'time' => (time.is_a?(String) ? time : time.to_s(:db)) } : {}
158
223
  end
159
-
224
+
160
225
  def find_next_or_previous(operation, current_item_id, time)
161
226
  member Podio.connection.get { |req|
162
227
  req.url("/item/#{current_item_id}/#{operation}", time_options(time))
163
228
  }.body
164
229
  end
165
230
  end
166
- end
231
+ end
@@ -4,9 +4,10 @@ class Podio::ItemField < ActivePodio::Base
4
4
  property :external_id, :string
5
5
  property :label, :string
6
6
  property :values, :array
7
+ property :config, :hash
7
8
 
8
9
  alias_method :id, :field_id
9
-
10
+
10
11
  class << self
11
12
  def update(item_id, field_id, values)
12
13
  response = Podio.connection.put do |req|
@@ -14,6 +15,10 @@ class Podio::ItemField < ActivePodio::Base
14
15
  req.body = values
15
16
  end
16
17
  response.body
17
- end
18
+ end
19
+
20
+ def ical_entry(item_id, field_id)
21
+ Podio.connection.get("/calendar/item/#{item_id}/field/#{field_id}/ics/").body
22
+ end
18
23
  end
19
- end
24
+ end
@@ -2,14 +2,15 @@ class Podio::LinkedAccount < ActivePodio::Base
2
2
  property :linked_account_id, :integer
3
3
  property :label, :string
4
4
  property :provider, :string
5
+ property :provider_humanized_name, :string
6
+ property :capability_names, :hash
7
+ property :options, :hash
5
8
 
6
9
  alias_method :id, :linked_account_id
7
10
 
8
11
  class << self
9
12
 
10
- def find_all(provider, capability = nil)
11
- options = { :provider => provider }
12
- options[:capability] = capability if capability.present?
13
+ def find_all(options = {})
13
14
  list Podio.connection.get { |req|
14
15
  req.url("/linked_account/", options)
15
16
  }.body
@@ -28,5 +29,12 @@ class Podio::LinkedAccount < ActivePodio::Base
28
29
  Podio.connection.delete("/linked_account/#{id}").status
29
30
  end
30
31
 
32
+ def update_options(id, attributes)
33
+ Podio.connection.put do |req|
34
+ req.url "/linked_account/#{id}/options"
35
+ req.body = attributes
36
+ end
37
+ end
38
+
31
39
  end
32
40
  end