Skip to content

Commit

Permalink
Move promotion_group_member to its own model
Browse files Browse the repository at this point in the history
  • Loading branch information
albertfdp committed Apr 29, 2015
1 parent e47ca35 commit 935f482
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/podio.rb
Expand Up @@ -137,6 +137,7 @@ def initialize(params = {})
autoload :Profile, 'podio/models/profile'
autoload :Promotion, 'podio/models/promotion'
autoload :PromotionGroup, 'podio/models/promotion_group'
autoload :PromotionGroupMember, 'podio/models/promotion_group_member'
autoload :Question, 'podio/models/question'
autoload :QuestionAnswer, 'podio/models/question_answer'
autoload :QuestionOption, 'podio/models/question_option'
Expand Down
1 change: 0 additions & 1 deletion lib/podio/models/promotion_group.rb
Expand Up @@ -4,7 +4,6 @@ class Podio::PromotionGroup < ActivePodio::Base
property :name, :string
property :description, :string
property :status, :string
property :member_ids, :array

alias_method :id, :promotion_group_id

Expand Down
32 changes: 32 additions & 0 deletions lib/podio/models/promotion_group_member.rb
@@ -0,0 +1,32 @@
class Podio::PromotionGroupMember < ActivePodio::Base

property :promotion_group_id, :integer
property :member_id, :integer

alias_method :id, :promotion_group_id

class << self

def create(attributes)
member Podio.connection.post { |req|
req.url("/promotion_group/#{attributes[:promotion_group_id]}/add")
req.body = attributes
}.body
end

def find_all(promotion_group_id, options = {})
Podio.connection.get { |req|
req.url("/promotion_group/#{promotion_group_id}/members", options)
}.body
end

def add_members(promotion_group_id, attributes)
Podio.connection.post { |req|
req.url "/promotion_group/#{promotion_group_id}/members/add"
req.body = attributes
}.status
end

end

end

0 comments on commit 935f482

Please sign in to comment.