Class: Podio::Promotion

Inherits:
ActivePodio::Base show all
Defined in:
lib/podio/models/promotion.rb

Instance Attribute Summary

Attributes inherited from ActivePodio::Base

#attributes

Class Method Summary collapse

Methods inherited from ActivePodio::Base

#==, #[], #[]=, #api_friendly_ref_type, #as_json, collection, delegate_to_hash, has_many, has_one, #hash, #initialize, #initialize_attributes, klass_from_string, list, member, #new_record?, output_attribute_as_json, #parent_model, #persisted?, property, #to_param

Constructor Details

This class inherits a constructor from ActivePodio::Base

Class Method Details

.assign(promotion_id, user_id) ⇒ Object



60
61
62
# File 'lib/podio/models/promotion.rb', line 60

def assign(promotion_id, user_id)
  Podio.connection.post("/promotion/#{promotion_id}/assign/#{user_id}")
end

.click(promotion_id, body = nil) ⇒ Object



81
82
83
84
85
86
# File 'lib/podio/models/promotion.rb', line 81

def click(promotion_id, body = nil)
  Podio.connection.post { |req|
    req.url "/promotion/#{promotion_id}/click"
    req.body = body
  }
end

.create(attributes) ⇒ Object



30
31
32
33
34
35
# File 'lib/podio/models/promotion.rb', line 30

def create(attributes)
  member Podio.connection.post { |req|
    req.url("/promotion/")
    req.body = attributes
  }.body
end

.delete(promotion_id) ⇒ Object



52
53
54
# File 'lib/podio/models/promotion.rb', line 52

def delete(promotion_id)
  Podio.connection.delete("/promotion/#{promotion_id}")
end

.disable(promotion_id) ⇒ Object



48
49
50
# File 'lib/podio/models/promotion.rb', line 48

def disable(promotion_id)
  member Podio.connection.post("/promotion/#{promotion_id}/disable").body
end

.enable(promotion_id) ⇒ Object



44
45
46
# File 'lib/podio/models/promotion.rb', line 44

def enable(promotion_id)
  member Podio.connection.post("/promotion/#{promotion_id}/enable").body
end

.end(promotion_id, body = nil) ⇒ Object



74
75
76
77
78
79
# File 'lib/podio/models/promotion.rb', line 74

def end(promotion_id, body = nil)
  Podio.connection.post { |req|
    req.url "/promotion/#{promotion_id}/end"
    req.body = body
  }
end

.find(promotion_id) ⇒ Object



26
27
28
# File 'lib/podio/models/promotion.rb', line 26

def find(promotion_id)
  member Podio.connection.get("/promotion/#{promotion_id}").body
end

.find_all(options = {}) ⇒ Object



20
21
22
23
24
# File 'lib/podio/models/promotion.rb', line 20

def find_all(options={})
  list Podio.connection.get { |req|
    req.url("/promotion/", options)
  }.body
end

.find_for_context(context_name, options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/podio/models/promotion.rb', line 64

def find_for_context(context_name, options = {})
  result = Podio.connection.get("/promotion/#{context_name}", options)

  if result.body.present?
    member(result.body)
  else
    nil
  end
end

.stats(promotion_id) ⇒ Object



56
57
58
# File 'lib/podio/models/promotion.rb', line 56

def stats(promotion_id)
  Podio.connection.get("/promotion/#{promotion_id}/stats").body
end

.update(promotion_id, attributes) ⇒ Object



37
38
39
40
41
42
# File 'lib/podio/models/promotion.rb', line 37

def update(promotion_id, attributes)
  member Podio.connection.put { |req|
    req.url("/promotion/#{promotion_id}")
    req.body = attributes
  }.body
end