crowdmob 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/campaigns.rb +39 -18
  2. metadata +3 -3
@@ -20,32 +20,49 @@ module CrowdMob::Campaigns
20
20
  @organization_secret_key = '9cbfbe10e13f2a30cb6509ef0e09445b'
21
21
  @organization_permalink = 'crowdmob'
22
22
 
23
- def self.create(app_store_url, active, params)
24
- url = CrowdMob.base_url + '/organizations/' + @organization_permalink + '/sponsored_action_campaigns.json'
23
+ def self.create(params, active)
24
+ url = CrowdMob.base_url + '/api/organizations/' + @organization_permalink + '/sponsored_action_campaigns.json'
25
25
  uri = URI.parse(url)
26
26
  now, secret_hash = self.compute_secret_hash
27
- params = {
28
- 'app_store_url' => app_store_url,
27
+
28
+ form = {
29
+ 'ios_url' => params[:ios_url],
30
+ 'android_url' => params[:android_url],
29
31
  'datetime' => now,
30
32
  'secret_hash' => secret_hash,
31
33
  'active' => active,
32
- 'sponsored_action_campaign[bid_in_cents]' => params[:bid_in_cents],
33
- 'sponsored_action_campaign[max_total_spend_in_cents]' => params[:max_total_spend_in_cents],
34
- 'sponsored_action_campaign[max_spend_per_day_in_cents]' => params[:max_spend_per_day_in_cents],
35
- 'sponsored_action_campaign[starts_at]' => params[:starts_at],
36
- 'sponsored_action_campaign[ends_at]' => params[:ends_at],
37
- 'sponsored_action_campaign[kind]' => 'install',
34
+ 'campaign[max_total_spend_in_dollars]' => params[:max_total_spend_in_dollars],
35
+ 'campaign[max_spend_per_day_in_dollars]' => params[:max_spend_per_day_in_dollars],
36
+ 'campaign[starts_at]' => params[:starts_at],
37
+ 'campaign[ends_at]' => params[:ends_at],
38
38
  }
39
- response, data = Net::HTTP.post_form(uri, params)
39
+ form['campaign[android]'] = '1' if params[:android_bid]
40
+ form['campaign[android_bid]'] = params[:android_bid] if params[:android_bid]
41
+ form['campaign[ipad]'] = '1' if params[:ipad_bid]
42
+ form['campaign[ipad_bid]'] = params[:ipad_bid] if params[:ipad_bid]
43
+ form['campaign[iphone]'] = '1' if params[:iphone_bid]
44
+ form['campaign[iphone_bid]'] = params[:iphone_bid] if params[:iphone_bid]
45
+ form['campaign[ipod]'] = '1' if params[:ipod_bid]
46
+ form['campaign[ipod_bid]'] = params[:ipod_bid] if params[:ipod_bid]
47
+
48
+ response, data = Net::HTTP.post_form(uri, form)
40
49
  json = JSON.parse(response.body)
41
50
  json
42
51
  end
43
52
 
53
+ def self.query(campaign_id)
54
+ url = CrowdMob.base_url + '/api/organizations/' + @organization_permalink + '/sponsored_action_campaigns/' + campaign_id.to_s + '.json'
55
+ now, secret_hash = self.compute_secret_hash
56
+ url += '?datetime=' + now + '&secret_hash=' + secret_hash
57
+ uri = URI.parse(url)
58
+ response = self.issue_http_request(uri, 'Get')
59
+ end
60
+
44
61
  def self.edit(campaign_id, active, params)
45
- url = CrowdMob.base_url + '/organizations/' + @organization_permalink + '/sponsored_action_campaigns/' + campaign_id.to_s + '.json'
62
+ url = CrowdMob.base_url + '/api/organizations/' + @organization_permalink + '/sponsored_action_campaigns/' + campaign_id.to_s + '.json'
46
63
  now, secret_hash = self.compute_secret_hash
47
64
  url += '?datetime=' + now + '&secret_hash=' + secret_hash + '&active=' + active.to_s
48
- params.each { |key, value| url += '&sponsored_action_campaign[' + key.to_s + ']=' + value.to_s }
65
+ params.each { |key, value| url += '&campaign[' + key.to_s + ']=' + value.to_s }
49
66
  uri = URI.parse(url)
50
67
  response = self.issue_http_request(uri, 'Put')
51
68
  json = JSON.parse(response.body)
@@ -53,7 +70,7 @@ module CrowdMob::Campaigns
53
70
  end
54
71
 
55
72
  def self.delete(campaign_id)
56
- url = CrowdMob.base_url + '/organizations/' + @organization_permalink + '/sponsored_action_campaigns/' + campaign_id.to_s + '.json'
73
+ url = CrowdMob.base_url + '/api/organizations/' + @organization_permalink + '/sponsored_action_campaigns/' + campaign_id.to_s + '.json'
57
74
  now, secret_hash = self.compute_secret_hash
58
75
  url += '?datetime=' + now + '&secret_hash=' + secret_hash
59
76
  uri = URI.parse(url)
@@ -90,13 +107,17 @@ if __FILE__ == $0
90
107
  now = DateTime.now
91
108
  one_week_from_now = now + 7
92
109
  params = {
93
- bid_in_cents: 1,
94
- max_total_spend_in_cents: 100,
95
- max_spend_per_day_in_cents: 10,
110
+ ios_url: 'https://itunes.apple.com/us/app/angry-birds-free/id409807569?mt=8',
111
+ max_total_spend_in_dollars: 100.00,
112
+ max_spend_per_day_in_dollars: 10.00,
96
113
  starts_at: now,
97
114
  ends_at: one_week_from_now,
115
+ # android_bid: 2.00,
116
+ # ipad_bid: 2.50,
117
+ iphone_bid: 3.00,
118
+ ipod_bid: 2.00,
98
119
  }
99
- campaign = CrowdMob::Campaigns.create('https://itunes.apple.com/us/app/angry-birds-free/id409807569?mt=8', true, params)
120
+ campaign = CrowdMob::Campaigns.create(params, true)
100
121
 
101
122
  # Edit the campaign:
102
123
  params = { bid_in_cents: 2 }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowdmob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
12
+ date: 2012-12-13 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Server to server integration with CrowdMob
15
15
  email: developers@crowdmob.com
@@ -21,7 +21,7 @@ files:
21
21
  - lib/campaigns.rb
22
22
  - lib/crowdmob.rb
23
23
  - lib/installs.rb
24
- homepage: http://rubygems.org/gems/bing_images
24
+ homepage: http://rubygems.org/gems/crowdmob
25
25
  licenses: []
26
26
  post_install_message:
27
27
  rdoc_options: []