Module: FoursquareNext::Campaigns

Included in:
Client
Defined in:
lib/foursquare_next/campaigns.rb

Instance Method Summary collapse

Instance Method Details

#add_campaign(options = {}) ⇒ Object

Add a campaign Details on param options can be found at developer.foursquare.com/docs/campaigns/add

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • String (Object)

    :specialId - required (unless the campaignId parameter has been provided). special ID

  • String (Object)

    :groupId - comma-separated list of venue group IDs (either groupId or venueId is required)

  • String (Object)

    :venueId - comma-separated list of venue IDs (either groupId or venueId is required)

  • Integer (Object)

    :endAt - DateTime when the campaign is to be automatically deactivated (seconds since epoch)

  • Integer (Object)

    :startAt - DateTime when the campaign is to be started (seconds since epoch)

  • String (Object)

    :campaignId - ID of an existing campaign to copy.



25
26
27
28
29
30
# File 'lib/foursquare_next/campaigns.rb', line 25

def add_campaign(options = {})
  response = connection.post do |req|
    req.url "campaigns/add", options
  end
  return_error_or_body(response, response.body.response.campaign)
end

#campaign(campaign_id, options = {}) ⇒ Object

Retrieve information about a campaign

param [String] campaign_id The ID of the venue



6
7
8
9
10
11
# File 'lib/foursquare_next/campaigns.rb', line 6

def campaign(campaign_id, options = {})
  response = connection.get do |req|
    req.url "campaigns/#{campaign_id}", options
  end
  return_error_or_body(response, response.body.response.campaign)
end

#end_campaign(campaign_id, options = {}) ⇒ Object

End a campaign Details on param can be found at developer.foursquare.com/docs/campaigns/end



57
58
59
60
61
62
# File 'lib/foursquare_next/campaigns.rb', line 57

def end_campaign(campaign_id, options = {})
  response = connection.post do |req|
    req.url "campaigns/#{campaign_id}/end", options
  end
  return_error_or_body(response, response.body.code)
end

#list_campaigns(options = {}) ⇒ Object

Get a list of campaigns Details on param options can be found at developer.foursquare.com/docs/campaigns/list

stopped,notStarted,ended,all (default=all)

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • String (Object)

    :specialId - if specified, limits response to campaigns involving the given special

  • String (Object)

    :groupId - if specified, limits response to campaigns involving the given group

  • String (Object)

    :status - which campaigns to return: pending,scheduled,active,expired,depleted,



43
44
45
46
47
48
# File 'lib/foursquare_next/campaigns.rb', line 43

def list_campaigns(options = {})
  response = connection.get do |req|
    req.url "campaigns/list", options
  end
  return_error_or_body(response, response.body.response.campaigns.items)
end