Class: Foursquare::Merchant::Campaign

Inherits:
Model
  • Object
show all
Defined in:
lib/foursquare/campaign.rb

Constant Summary

Constants included from Requests

Requests::API, Requests::OAUTH

Instance Attribute Summary

Attributes inherited from Model

#consumer

Instance Method Summary collapse

Methods included from Requests

#get, #post

Constructor Details

#initialize(hash, consumer) ⇒ Campaign

Returns a new instance of Campaign.



14
15
16
17
18
19
20
# File 'lib/foursquare/campaign.rb', line 14

def initialize(hash, consumer)
  super
  self.venue_ids       = self.venue_ids['items'].map { |item| item['id'] } if self.venue_ids
  self.venue_group_ids = self.venue_group_ids['items'].map { |item| item['id'] } if self.venue_group_ids
  self.venue_groups    = self.venue_groups['items'].map { |item| item['id'] } if self.venue_groups
  self.special         = Special.new(self.special, consumer) if self.special
end

Instance Method Details

#deleteObject



43
44
45
# File 'lib/foursquare/campaign.rb', line 43

def delete
  self.post("/campaigns/#{id}/delete", {})
end

#end(end_time = nil) ⇒ Object



37
38
39
40
41
# File 'lib/foursquare/campaign.rb', line 37

def end(end_time=nil)
  params = {}
  params[:end_at] = end_time if end_time
  self.post("/campaigns/#{id}/start", params)
end

#start(start_time = nil) ⇒ Object



31
32
33
34
35
# File 'lib/foursquare/campaign.rb', line 31

def start(start_time=nil)
  params = {}
  params[:start_at] = start_time if start_time
  self.post("/campaigns/#{id}/start", params)
end

#timeseries(start_time = nil, end_time = nil) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/foursquare/campaign.rb', line 22

def timeseries(start_time=nil, end_time=nil)
  params = {}
  params[:start_at] = start_time if start_time
  params[:end_at]   = end_time if end_time

  response = self.get("/campaigns/#{id}/timeseries", params)['timeseries']
  response.map { |ts| TimeSeries.new(ts) }
end