podio 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,8 @@
1
+ class Podio::Answer < ActivePodio::Base
2
+
3
+ property :answer_id, :integer
4
+ property :text, :string
5
+
6
+ alias_method :id, :answer_id
7
+
8
+ end
@@ -14,8 +14,8 @@ class Podio::AppStoreCategory < ActivePodio::Base
14
14
  end
15
15
 
16
16
  # @see https://developers.podio.com/doc/app-market/get-categories-37009
17
- def find_all
18
- categories = Podio.connection.get("/app_store/category/").body
17
+ def find_all(options = {})
18
+ categories = Podio.connection.get("/app_store/category/", options).body
19
19
 
20
20
  categories.each do | key, value |
21
21
  categories[key] = list value
@@ -3,6 +3,7 @@ class Podio::AppStoreShare < ActivePodio::Base
3
3
  property :share_id, :integer
4
4
  property :type, :string
5
5
  property :status, :string
6
+ property :visible, :boolean
6
7
  property :link, :string
7
8
  property :name, :string
8
9
  property :description, :string
@@ -3,17 +3,21 @@ class Podio::Application < ActivePodio::Base
3
3
  property :app_id, :integer
4
4
  property :original, :integer
5
5
  property :original_revision, :integer
6
+ property :current_revision, :integer
6
7
  property :status, :string
7
8
  property :icon, :string
8
9
  property :icon_id, :integer
10
+ property :default_view_id, :integer
9
11
  property :pinned, :boolean
10
12
  property :space_id, :integer
11
13
  property :owner_id, :integer
12
14
  property :owner, :hash
13
15
  property :config, :hash
14
16
  property :fields, :array
17
+ property :votings, :array
15
18
  property :subscribed, :boolean
16
19
  property :integration, :hash
20
+ property :layouts, :hash
17
21
  property :rights, :array
18
22
  property :link, :string
19
23
  property :url_add, :string
@@ -47,13 +51,17 @@ class Podio::Application < ActivePodio::Base
47
51
  end
48
52
 
49
53
  # @see https://developers.podio.com/doc/applications/get-app-on-space-by-url-label-477105
50
- def find_by_url_label(space_id, url_label)
51
- member Podio.connection.get("/app/space/#{space_id}/#{url_label}").body
54
+ def find_by_url_label(space_id, url_label, options={})
55
+ member Podio.connection.get { |req|
56
+ req.url("/app/space/#{space_id}/#{url_label}", options)
57
+ }.body
52
58
  end
53
59
 
54
60
  # @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
61
+ def find_by_org_space_and_app_labels(org_label, space_label, app_label, options={})
62
+ member Podio.connection.get { |req|
63
+ req.url("/app/org/#{org_label}/space/#{space_label}/#{app_label}", options)
64
+ }.body
57
65
  end
58
66
 
59
67
  def find_all(options={})
@@ -17,5 +17,15 @@ class Podio::ApplicationField < ActivePodio::Base
17
17
  member Podio.connection.get("/app/#{app_id}/field/#{field_id}").body
18
18
  end
19
19
 
20
+ # @see https://developers.podio.com/doc/applications/update-an-app-field-22356
21
+ def update(app_id, field_id, attributes)
22
+ Podio.connection.put("/app/#{app_id}/field/#{field_id}", attributes).body['revision']
23
+ end
24
+
25
+ # @see https://developers.podio.com/doc/applications/add-new-app-field-22354
26
+ def create(app_id, attributes)
27
+ Podio.connection.post("/app/#{app_id}/field/", attributes).body['field_id']
28
+ end
29
+
20
30
  end
21
31
  end
@@ -14,6 +14,7 @@ class Podio::Batch < ActivePodio::Base
14
14
  has_one :file, :class => 'FileAttachment'
15
15
  has_one :app, :class => 'Application'
16
16
  has_one :space, :class => 'Space'
17
+ has_one :ref, :class => 'Reference'
17
18
 
18
19
  alias_method :id, :batch_id
19
20
 
@@ -18,7 +18,8 @@ class Podio::CalendarEvent < ActivePodio::Base
18
18
  property :link, :string
19
19
  property :app, :hash
20
20
  property :source, :string
21
-
21
+ property :color, :string
22
+
22
23
  alias_method :id, :uid
23
24
 
24
25
  class << self
@@ -50,7 +51,7 @@ class Podio::CalendarEvent < ActivePodio::Base
50
51
  }.body
51
52
  end
52
53
 
53
- # @see
54
+ # @see
54
55
  def move_event(uid, attributes={})
55
56
  response = Podio.connection.post do |req|
56
57
  req.url "/calendar/event/#{uid}/move"
@@ -59,7 +60,7 @@ class Podio::CalendarEvent < ActivePodio::Base
59
60
  member response.body
60
61
  end
61
62
 
62
- # @see
63
+ # @see
63
64
  def move_event_external(linked_account_id, uid, attributes={})
64
65
  response = Podio.connection.post do |req|
65
66
  req.url "/calendar/linked_account/#{linked_account_id}/event/#{CGI.escape(uid)}/move"
@@ -68,7 +69,7 @@ class Podio::CalendarEvent < ActivePodio::Base
68
69
  member response.body
69
70
  end
70
71
 
71
- # @see
72
+ # @see
72
73
  def update_event_duration(uid, attributes={})
73
74
  response = Podio.connection.put do |req|
74
75
  req.url "/calendar/event/#{uid}/duration"
@@ -77,7 +78,7 @@ class Podio::CalendarEvent < ActivePodio::Base
77
78
  member response.body
78
79
  end
79
80
 
80
- # @see
81
+ # @see
81
82
  def update_event_duration_external(linked_account_id, uid, attributes={})
82
83
  response = Podio.connection.put do |req|
83
84
  req.url "/calendar/linked_account/#{linked_account_id}/event/#{CGI.escape(uid)}/duration"
@@ -0,0 +1,88 @@
1
+ class Podio::Campaign < ActivePodio::Base
2
+ include ActivePodio::Updatable
3
+
4
+ property :campaign_id, :integer
5
+ property :name, :string
6
+ property :description, :string
7
+ property :status, :string
8
+ property :tier, :string
9
+ property :rebate_type, :string
10
+ property :rebate_config, :hash
11
+ property :duration_type, :string
12
+ property :duration_config, :hash
13
+ property :usages, :integer
14
+
15
+ alias_method :id, :campaign_id
16
+
17
+ def create
18
+ result = self.class.create(self.attributes)
19
+ self.update_attributes(result.attributes)
20
+ end
21
+
22
+ def update
23
+ result = self.class.update(self.campaign_id, self.attributes)
24
+ self.update_attributes(result.attributes)
25
+ end
26
+
27
+ def activate
28
+ self.class.activate(self.campaign_id)
29
+ end
30
+
31
+ def deactivate
32
+ self.class.deactivate(self.campaign_id)
33
+ end
34
+
35
+ def delete
36
+ self.class.delete(self.campaign_id)
37
+ end
38
+
39
+ def active?
40
+ self.status == 'active'
41
+ end
42
+
43
+ def inactive?
44
+ self.status == 'inactive'
45
+ end
46
+
47
+ class << self
48
+ def create(attributes)
49
+ member Podio.connection.post { |req|
50
+ req.url "/campaign/"
51
+ req.body = attributes
52
+ }.body
53
+ end
54
+
55
+ def update(id, attributes)
56
+ member Podio.connection.put { |req|
57
+ req.url "/campaign/#{id}"
58
+ req.body = attributes
59
+ }.body
60
+ end
61
+
62
+ def delete(id)
63
+ Podio.connection.delete("/campaign/#{id}").status
64
+ end
65
+
66
+ def activate(id)
67
+ Podio.connection.post("/campaign/#{id}/activate").status
68
+ end
69
+
70
+ def deactivate(id)
71
+ Podio.connection.post("/campaign/#{id}/deactivate").status
72
+ end
73
+
74
+ def find(id)
75
+ member Podio.connection.get("/campaign/#{id}").body
76
+ end
77
+
78
+ def find_all(options = {})
79
+ list Podio.connection.get { |req|
80
+ req.url("/campaign/", options)
81
+ }.body
82
+ end
83
+
84
+ def find_usage(id)
85
+ Podio.connection.get("/campaign/#{id}/usage").body
86
+ end
87
+ end
88
+ end
@@ -30,7 +30,7 @@ class Podio::Category < ActivePodio::Base
30
30
  end
31
31
 
32
32
  def find(id)
33
- member Podio.connection.get("/app_store/category/#{id}").body
33
+ member Podio.connection.get("/app_store/category/#{id}/v2").body
34
34
  end
35
35
 
36
36
  def find_all(options = {})
@@ -7,6 +7,7 @@ class Podio::Contract < ActivePodio::Base
7
7
  property :blocked, :boolean
8
8
  property :created_on, :datetime
9
9
  property :started_on, :datetime
10
+ property :reconciled_until, :datetime
10
11
  property :created_via, :string
11
12
  property :ended_on, :datetime
12
13
  property :item_prices, :hash
@@ -35,18 +36,18 @@ class Podio::Contract < ActivePodio::Base
35
36
  property :mrr, :decimal
36
37
  property :days_overdue, :integer
37
38
  property :overdue_status, :string
39
+ property :tier, :string
38
40
 
39
41
  has_one :org, :class => 'Organization'
40
42
  has_one :user, :class => 'User'
41
43
  has_one :sold_by, :class => 'User'
42
44
  has_one :price, :class => 'ContractPrice'
43
- has_one :price_v2, :class => 'ContractPriceV2'
44
45
  has_many :premium_spaces, :class => 'Space'
45
46
 
46
47
  alias_method :id, :contract_id
47
48
 
48
- def price_v2=(attributes)
49
- self[:price_v2] = attributes
49
+ def price=(attributes)
50
+ self[:price] = attributes
50
51
  end
51
52
 
52
53
  def premium_space_ids=(values)
@@ -63,12 +64,6 @@ class Podio::Contract < ActivePodio::Base
63
64
  self["price"] = pricing
64
65
  end
65
66
 
66
- def calculate_price_v2
67
- pricing = self.class.calculate_price_v2(self.contract_id, self.attributes.slice(:full, :premium_emp_network, :premium_space_ids))
68
- self.clear_price_v2
69
- self["price_v2"] = pricing
70
- end
71
-
72
67
  def create_payment(query_string)
73
68
  self.class.create_payment(self.contract_id, query_string)
74
69
  end
@@ -102,10 +97,14 @@ class Podio::Contract < ActivePodio::Base
102
97
  def unblock
103
98
  self.class.unblock(self.contract_id)
104
99
  end
100
+
101
+ def tier_prices
102
+ self.class.get_tier_prices(self.contract_id)
103
+ end
105
104
 
106
105
  class << self
107
- def find(contract_id)
108
- member Podio.connection.get("/contract/#{contract_id}").body
106
+ def find(contract_id, options={})
107
+ member Podio.connection.get("/contract/#{contract_id}", options).body
109
108
  end
110
109
 
111
110
  def find_all_mine
@@ -167,16 +166,7 @@ class Podio::Contract < ActivePodio::Base
167
166
  req.url "/contract/#{contract_id}/price"
168
167
  req.body = attributes
169
168
  end
170
-
171
- response.body
172
- end
173
169
 
174
- def calculate_price_v2(contract_id, attributes)
175
- response = Podio.connection.post do |req|
176
- req.url "/contract/#{contract_id}/price/v2"
177
- req.body = attributes
178
- end
179
-
180
170
  response.body
181
171
  end
182
172
 
@@ -212,5 +202,13 @@ class Podio::Contract < ActivePodio::Base
212
202
  response = Podio.connection.post("/contract/#{contract_id}/unblock")
213
203
  response.status
214
204
  end
205
+
206
+ def get_tier_prices(contract_id)
207
+ Podio.connection.get("/contract/#{contract_id}/price/tier").body
208
+ end
209
+
210
+ def get_list_prices
211
+ Podio.connection.get('/contract/price/').body
212
+ end
215
213
  end
216
214
  end
@@ -0,0 +1,24 @@
1
+ class Podio::ContractAttribution < ActivePodio::Base
2
+
3
+ property :contract_id, :integer
4
+ property :name, :string
5
+ property :partner_id, :string
6
+
7
+ alias_method :id, :contract_id
8
+
9
+ class << self
10
+
11
+ def find(contract_id, options={})
12
+ member Podio.connection.get("contract/attribution/#{contract_id}", options).body
13
+ end
14
+
15
+ def update(contract_id, partner_id)
16
+ member Podio.connection.put { |req|
17
+ req.url("/contract/attribution/#{contract_id}")
18
+ req.body = {:partner_id => partner_id}
19
+ }.body
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,22 @@
1
+ class Podio::ContractPeriod < ActivePodio::Base
2
+ property :start, :datetime
3
+ property :end, :datetime
4
+ property :prices, :hash
5
+ property :quantities, :hash
6
+ property :total_mrr, :decimal
7
+ property :mrr, :hash
8
+ property :rebate, :hash
9
+ property :saved_mrr, :float
10
+ property :list_prices, :hash
11
+ property :invoice_interval, :integer
12
+ property :tier, :string
13
+
14
+ has_many :users, :class => 'ContractUser'
15
+
16
+ class << self
17
+ def find_all_for_contract(contract_id, start_date, end_date)
18
+ list Podio.connection.get("/contract/#{contract_id}/history", {:start => start_date, :end => end_date}).body
19
+ end
20
+ end
21
+
22
+ end
@@ -1,42 +1,53 @@
1
1
  class Podio::ContractPrice < ActivePodio::Base
2
- property :total, :float
3
2
 
4
- has_many :users, :class => 'ContractUser'
5
-
6
- def premium_employees
7
- users.select { |u| u['items']['employee'].present? }
3
+ has_one :employee, :class => 'ContractPriceItem'
4
+ has_one :external, :class => 'ContractPriceItem'
5
+ has_one :item, :class => 'ContractPriceItem'
6
+
7
+ def mrr_saved
8
+ self.employee.mrr_saved + self.external.mrr_saved
8
9
  end
9
-
10
- def emp_network_employees
11
- users.select { |u| u['items']['emp_network'].present? }
10
+
11
+ def mrr_list
12
+ self.employee.mrr_list + self.external.mrr_list
12
13
  end
13
14
 
14
- def premium_employees?
15
- items['employee'].present?
15
+ def mrr
16
+ self.employee.mrr + self.external.mrr
16
17
  end
17
18
 
18
- def total_for_premium_employees
19
- items['employee']['sub_total']
19
+ def total
20
+ self.employee.sub_total + self.external.sub_total
20
21
  end
21
22
 
22
- def emp_network?
23
- items['emp_network'].present?
24
- end
25
-
26
- def items
27
- if @items.nil?
28
- @items = {}
29
- self[:items].each do |key, attributes|
30
- @items[key] = Podio::ContractPriceItem.new(attributes)
23
+ class << self
24
+ def calculate(contract_id, attributes)
25
+ response = Podio.connection.post do |req|
26
+ req.url "/contract/#{contract_id}/price"
27
+ req.body = attributes
31
28
  end
29
+
30
+ member response.body
32
31
  end
33
- @items
34
- end
35
32
 
33
+ end
36
34
  end
37
35
 
38
36
  class Podio::ContractPriceItem < ActivePodio::Base
39
- property :sub_total, :float
40
- property :quantity, :integer
41
- property :already_paid, :integer
37
+ property :list_price, :float #The list price per user
38
+ property :price, :float # Price per user
39
+ property :price_rebate, :float # The rebate on the price
40
+ property :quantity, :integer # Number of users
41
+ property :mrr_saved, :float #The MRR saved
42
+ property :mrr_list, :float #The MRR based on the list price
43
+ property :mrr, :float #The MRR on the rebated price
44
+
45
+ def sub_total
46
+ if self.quantity
47
+ (self.quantity*self.price).to_f
48
+ else
49
+ 0.to_f
50
+ end
51
+ end
52
+
42
53
  end