2Performant 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/2Performant.gemspec +4 -4
  2. data/VERSION +1 -1
  3. data/lib/two_performant.rb +257 -154
  4. metadata +13 -4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{2Performant}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["2Performant"]
12
- s.date = %q{2010-05-04}
12
+ s.date = %q{2010-06-17}
13
13
  s.description = %q{Library for the 2Performant API}
14
14
  s.email = %q{andrei@2performant.com}
15
15
  s.extra_rdoc_files = [
@@ -32,7 +32,7 @@ Gem::Specification.new do |s|
32
32
  s.homepage = %q{http://github.com/2performant/2Performant}
33
33
  s.rdoc_options = ["--charset=UTF-8"]
34
34
  s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.3.6}
35
+ s.rubygems_version = %q{1.3.7}
36
36
  s.summary = %q{Library for the 2Performant API}
37
37
  s.test_files = [
38
38
  "test/helper.rb",
@@ -43,7 +43,7 @@ Gem::Specification.new do |s|
43
43
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
44
  s.specification_version = 3
45
45
 
46
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
47
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
48
48
  s.add_development_dependency(%q<shoulda>, [">= 0"])
49
49
  else
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -7,13 +7,13 @@ class TwoPerformant
7
7
  headers 'Content-Type' => 'text/xml'
8
8
 
9
9
  attr_accessor :user, :pass, :host, :version, :auth_type, :oauth, :oauth_request
10
-
11
- def initialize(auth_type, auth_obj, host)
12
- if auth_type == :simple
10
+
11
+ def initialize(auth_type, auth_obj, host)
12
+ if auth_type == :simple
13
13
  self.class.basic_auth auth_obj[:user], auth_obj[:pass]
14
- elsif auth_type == :oauth
14
+ elsif auth_type == :oauth
15
15
  self.oauth = TwoPerformant::OAuth.new(auth_obj, host)
16
- else
16
+ else
17
17
  return false
18
18
  end
19
19
 
@@ -21,81 +21,81 @@ class TwoPerformant
21
21
  self.auth_type = auth_type
22
22
  self.host = host
23
23
  self.class.base_uri host
24
- end
24
+ end
25
25
 
26
26
  # =======
27
- # Users
27
+ # Users
28
28
  # =======
29
29
  def user_show(user_id)
30
30
  self.hook("/users/#{user_id}.xml", "user");
31
31
  end
32
32
 
33
33
 
34
- # Display public information about the logged in user
35
- def user_loggedin
34
+ # Display public information about the logged in user
35
+ def user_loggedin
36
36
  self.hook("/users/loggedin.xml", "user");
37
37
  end
38
38
 
39
39
  # ===========
40
- # Campaigns
40
+ # Campaigns
41
41
  # ===========
42
42
 
43
- # List campaigns. Displays the first 6 entries by default.
44
- def campaigns_list(category_id=nil, page=1, perpage=6)
43
+ # List campaigns. Displays the first 6 entries by default.
44
+ def campaigns_list(category_id=nil, page=1, perpage=6)
45
45
  request = {
46
46
  'category_id' => category_id,
47
47
  'page' => page,
48
48
  'perpage' => perpage
49
49
  }
50
-
50
+
51
51
  self.hook("/campaigns.xml", "campaign", request, 'GET')
52
52
  end
53
53
 
54
- # Search for campaigns
55
- def campaigns_search(search, page = 1, perpage = 6)
54
+ # Search for campaigns
55
+ def campaigns_search(search, page = 1, perpage = 6)
56
56
  request = {
57
57
  'page' => page,
58
58
  'perpage' => perpage,
59
59
  'search' => search
60
60
  }
61
-
61
+
62
62
  self.hook("/campaigns/search.xml", "campaign", request, 'GET')
63
63
  end
64
64
 
65
- # Display public information about a campaign
66
- def campaign_show(campaign_id)
65
+ # Display public information about a campaign
66
+ def campaign_show(campaign_id)
67
67
  self.hook("/campaigns/#{campaign_id}.xml", "campaign")
68
68
  end
69
69
 
70
- # Affiliates: List campaigns which have the logged in user accepted
71
- def campaigns_listforaffiliate
70
+ # Affiliates: List campaigns which have the logged in user accepted
71
+ def campaigns_listforaffiliate
72
72
  self.hook("/campaigns/listforaffiliate.xml", "campaign")
73
73
  end
74
74
 
75
- # Merchants: List all campaigns created by the logged in user
76
- def campaigns_listforowner
75
+ # Merchants: List all campaigns created by the logged in user
76
+ def campaigns_listforowner
77
77
  self.hook("/campaigns/listforowner.xml", "campaign")
78
78
  end
79
79
 
80
- # Merchants: Display complete information about a campaign (only available to owner)
81
- def campaign_showforowner(campaign_id)
80
+ # Merchants: Display complete information about a campaign (only available to owner)
81
+ def campaign_showforowner(campaign_id)
82
82
  self.hook("/campaigns/#{campaign_id}/showforowner.xml", "campaign")
83
83
  end
84
-
85
- # Merchants: Update a campaign
86
- def campaign_update(campaign_id, campaign)
84
+
85
+ # Merchants: Update a campaign
86
+ def campaign_update(campaign_id, campaign)
87
87
  request = {
88
88
  'campaign' => campaign
89
89
  }
90
90
  self.hook("/campaigns/#{campaign_id}.xml", "campaign", request, 'PUT')
91
91
  end
92
-
92
+
93
93
  # Create a Deep Link. This method was created so it wouldn't make a request for every Quick Link.
94
- # You may need to get some data before using it.
95
- def campaign_quicklink(campaign_id, aff_code, redirect)
94
+ # You may need to get some data before using it.
95
+ def campaign_quicklink(campaign_id, aff_code, redirect)
96
96
  url = "#{self.host}/events/click?ad_type=quicklink&aff_code=#{aff_code}&unique=#{campaign_id}&redirect_to=#{redirect}"
97
97
 
98
- if (self.auth_type == :oauth)
98
+ if (self.auth_type == :oauth)
99
99
  url << "&app=#{self.oauth}"
100
100
  end
101
101
 
@@ -103,11 +103,35 @@ class TwoPerformant
103
103
  end
104
104
 
105
105
  # ============
106
- # Affiliates
106
+ # Sales
107
+ # ============
108
+
109
+ def sale_create(campaign_id, sale)
110
+ request = {
111
+ 'sale' => sale
112
+ }
113
+
114
+ self.hook("/campaigns/#{campaign_id}/sales.xml", "sale", request, "POST")
115
+ end
116
+
117
+ # ============
118
+ # Leads
119
+ # ============
120
+
121
+ def lead_create(campaign_id, sale)
122
+ request = {
123
+ 'lead' => lead
124
+ }
125
+
126
+ self.hook("/campaigns/#{campaign_id}/leads.xml", "lead", request, "POST")
127
+ end
128
+
129
+ # ============
130
+ # Affiliates
107
131
  # ============
108
132
 
109
- # Search for affiliates
110
- def affiliates_search(search, page=1, perpage=6)
133
+ # Search for affiliates
134
+ def affiliates_search(search, page=1, perpage=6)
111
135
  request = {
112
136
  'page' => page,
113
137
  'perpage' => perpage,
@@ -117,20 +141,20 @@ class TwoPerformant
117
141
  self.hook("/affiliates/search", "user", request, 'GET')
118
142
  end
119
143
 
120
- # Merchants: List affiliates approved in campaigns
121
- def affiliates_listformerchant(campaign_id=nil)
122
- request = {
144
+ # Merchants: List affiliates approved in campaigns
145
+ def affiliates_listformerchant(campaign_id=nil)
146
+ request = {
123
147
  'campaign_id' => campaign_id
124
148
  }
125
149
  self.hook("/affiliates/listformerchant", "user", request, 'GET')
126
150
  end
127
-
151
+
128
152
  # =============
129
- # Commissions
153
+ # Commissions
130
154
  # =============
131
-
155
+
132
156
  # Search for commissions. Month: 01 to 12; Year: 20xx. Status: accepted, pending or rejected. nil if empty search.
133
- def commissions_search(options, campaign_id=nil, month=nil, year=nil, page=1, perpage=6)
157
+ def commissions_search(options, campaign_id=nil, month=nil, year=nil, page=1, perpage=6)
134
158
  request = {
135
159
  'campaign_id' => campaign_id,
136
160
  'month' => month,
@@ -144,8 +168,8 @@ class TwoPerformant
144
168
  self.hook("/commissions/search.xml", "commission", request, 'GET')
145
169
  end
146
170
 
147
- # Merchants: List commissions on campaigns. Month: 01 to 12; Year: 20xx.
148
- def commissions_listformerchant(campaign_id, month, year)
171
+ # Merchants: List commissions on campaigns. Month: 01 to 12; Year: 20xx.
172
+ def commissions_listformerchant(campaign_id, month, year)
149
173
  request = {
150
174
  'campaign_id' => campaign_id,
151
175
  'month' => month,
@@ -155,8 +179,8 @@ class TwoPerformant
155
179
  self.hook("/commissions/listformerchant.xml", "campaign", request, 'GET')
156
180
  end
157
181
 
158
- # Affiliates: List commissions on campaigns. Month: 01 to 12; Year: 20xx.
159
- def commissions_listforaffiliate(campaign_id, month, year)
182
+ # Affiliates: List commissions on campaigns. Month: 01 to 12; Year: 20xx.
183
+ def commissions_listforaffiliate(campaign_id, month, year)
160
184
  request = {
161
185
  'campaign_id' => campaign_id,
162
186
  'month' => month,
@@ -166,13 +190,13 @@ class TwoPerformant
166
190
  self.hook("/commissions/listforaffiliate.xml", "commission", request, 'GET')
167
191
  end
168
192
 
169
- # Merchant Campaign Owner or Affiliate Commission Owner: Show information about a commission
170
- def commission_show(commission_id)
193
+ # Merchant Campaign Owner or Affiliate Commission Owner: Show information about a commission
194
+ def commission_show(commission_id)
171
195
  self.hook("/commissions/#{commission_id}.xml", "commission")
172
196
  end
173
197
 
174
- # Merchant: Update a commission
175
- def commission_update(commission_id, commission)
198
+ # Merchant: Update a commission
199
+ def commission_update(commission_id, commission)
176
200
  request = {
177
201
  'commission' => commission
178
202
  }
@@ -180,11 +204,11 @@ class TwoPerformant
180
204
  end
181
205
 
182
206
  # =======
183
- # Sites
207
+ # Sites
184
208
  # =======
185
209
 
186
- # List sites. Displays the first 6 entries by default.
187
- def sites_list(category_id=nil, page=1, perpage=6)
210
+ # List sites. Displays the first 6 entries by default.
211
+ def sites_list(category_id=nil, page=1, perpage=6)
188
212
  request = {
189
213
  'category_id' => category_id,
190
214
  'page' => page,
@@ -194,13 +218,13 @@ class TwoPerformant
194
218
  self.hook("/sites.xml", "site", request)
195
219
  end
196
220
 
197
- # Display information about a site
198
- def site_show(site_id)
221
+ # Display information about a site
222
+ def site_show(site_id)
199
223
  self.hook("/sites/#{site_id}.xml", "site")
200
224
  end
201
225
 
202
- # Search for sites
203
- def sites_search(search, page=1, perpage=6)
226
+ # Search for sites
227
+ def sites_search(search, page=1, perpage=6)
204
228
  request = {
205
229
  'page' => page,
206
230
  'perpage' => perpage,
@@ -210,13 +234,13 @@ class TwoPerformant
210
234
  self.hook("/sites/search.xml", "site", request, 'GET')
211
235
  end
212
236
 
213
- # Affiliates: List all sites created by the logged in user
214
- def sites_listforowner
237
+ # Affiliates: List all sites created by the logged in user
238
+ def sites_listforowner
215
239
  self.hook("/sites/listforowner.xml", "site")
216
240
  end
217
241
 
218
- # Affiliates: Update a site
219
- def site_update(site_id, site)
242
+ # Affiliates: Update a site
243
+ def site_update(site_id, site)
220
244
  request = {
221
245
  'site' => site
222
246
  }
@@ -224,17 +248,17 @@ class TwoPerformant
224
248
  end
225
249
 
226
250
 
227
- # Affiliates: Destroy a site
228
- def site_destroy(site_id)
251
+ # Affiliates: Destroy a site
252
+ def site_destroy(site_id)
229
253
  self.hook("/sites/#{site_id}.xml", "site", request, 'DELETE')
230
254
  end
231
255
 
232
256
  # ============
233
- # Text Links
257
+ # Text Links
234
258
  # ============
235
259
 
236
- # List text links from a campaign. Displays the first 6 entries by default.
237
- def txtlinks_list(campaign_id, page=1, perpage=6)
260
+ # List text links from a campaign. Displays the first 6 entries by default.
261
+ def txtlinks_list(campaign_id, page=1, perpage=6)
238
262
  request = {
239
263
  'page' => page,
240
264
  'perpage' => perpage
@@ -243,13 +267,13 @@ class TwoPerformant
243
267
  self.hook("/campaigns/#{campaign_id}/txtlinks.xml", "txtlink", request, 'GET')
244
268
  end
245
269
 
246
- # Display information about a text link
247
- def txtlink_show(campaign_id, txtlink_id)
270
+ # Display information about a text link
271
+ def txtlink_show(campaign_id, txtlink_id)
248
272
  self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.xml", "txtlink")
249
273
  end
250
274
 
251
- # Search for text links in a campaign
252
- def txtlinks_search(campaign_id, search, page=1, perpage=6, sort='date')
275
+ # Search for text links in a campaign
276
+ def txtlinks_search(campaign_id, search, page=1, perpage=6, sort='date')
253
277
  request = {
254
278
  'page' => page,
255
279
  'perpage' => perpage,
@@ -260,16 +284,16 @@ class TwoPerformant
260
284
  self.hook("/campaigns/#{campaign_id}/txtlinks/search.xml", "txtlink", request, 'GET')
261
285
  end
262
286
 
263
- #
264
- # Merchants: Create Text Link.
287
+ #
288
+ # Merchants: Create Text Link.
265
289
  #
266
290
  # Txtlink must be a hash of:
267
291
  # { "title" => "title",
268
292
  # "url" => "url",
269
293
  # "help" => "help"
270
294
  # }, where "help" is optional
271
-
272
- def txtlink_create(campaign_id, txtlink)
295
+
296
+ def txtlink_create(campaign_id, txtlink)
273
297
  request = {
274
298
  'txtlink' => txtlink
275
299
  }
@@ -277,25 +301,25 @@ class TwoPerformant
277
301
  self.hook("/campaigns/#{campaign_id}/txtlinks.xml", "txtlink", request, 'POST')
278
302
  end
279
303
 
280
- # Merchants: Update a text link
281
- def txtlink_update(campaign_id, txtlink_id, txtlink)
304
+ # Merchants: Update a text link
305
+ def txtlink_update(campaign_id, txtlink_id, txtlink)
282
306
  request = {
283
307
  'txtlink' => txtlink
284
308
  }
285
309
  self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.xml", "txtlink", request, 'PUT')
286
310
  end
287
311
 
288
- # Merchants: Destroy a text link
289
- def txtlink_destroy(campaign_id, txtlink_id)
312
+ # Merchants: Destroy a text link
313
+ def txtlink_destroy(campaign_id, txtlink_id)
290
314
  self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.xml", "txtlink", nil, 'DELETE')
291
315
  end
292
316
 
293
317
  # ============
294
- # Text Ads
318
+ # Text Ads
295
319
  # ============
296
320
 
297
- # List text ads from a campaign. Displays the first 6 entries by default.
298
- def txtads_list(campaign_id, page=1, perpage=6)
321
+ # List text ads from a campaign. Displays the first 6 entries by default.
322
+ def txtads_list(campaign_id, page=1, perpage=6)
299
323
  request = {
300
324
  'page' => page,
301
325
  'perpage' => perpage
@@ -304,13 +328,13 @@ class TwoPerformant
304
328
  self.hook("/campaigns/#{campaign_id}/txtads.xml", "txtad", request, 'GET')
305
329
  end
306
330
 
307
- # Display information about a text ad
308
- def txtad_show(campaign_id, txtad_id)
331
+ # Display information about a text ad
332
+ def txtad_show(campaign_id, txtad_id)
309
333
  self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.xml", "txtad")
310
334
  end
311
335
 
312
- # Search for text ads in a campaign
313
- def txtads_search(campaign_id, search, page=1, perpage=6, sort='date')
336
+ # Search for text ads in a campaign
337
+ def txtads_search(campaign_id, search, page=1, perpage=6, sort='date')
314
338
  request = {
315
339
  'page' => page,
316
340
  'perpage' => perpage,
@@ -321,25 +345,25 @@ class TwoPerformant
321
345
  self.hook("/campaigns/#{campaign_id}/txtads/search.xml", "txtad", request, 'GET')
322
346
  end
323
347
 
324
- #
325
- # Merchants: Create Text Ad.
348
+ #
349
+ # Merchants: Create Text Ad.
326
350
  # Txtad must be a hash of:
327
351
  # { "title" => "title",
328
352
  # "content" => "content",
329
353
  # "url" => "url",
330
354
  # "help" => "help"
331
355
  # }, where "help" is optional
332
- def txtad_create(campaign_id, txtad)
356
+ def txtad_create(campaign_id, txtad)
333
357
  request = {
334
358
  'txtad' => txtad
335
359
  }
336
-
360
+
337
361
  self.hook("/campaigns/#{campaign_id}/txtads.xml", "txtad", request, 'POST')
338
362
  end
339
363
 
340
364
 
341
- # Merchants: Update a text ad
342
- def txtad_update(campaign_id, txtad_id, txtad)
365
+ # Merchants: Update a text ad
366
+ def txtad_update(campaign_id, txtad_id, txtad)
343
367
  request = {
344
368
  'txtad' => txtad
345
369
  }
@@ -347,18 +371,18 @@ class TwoPerformant
347
371
  self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.xml", "txtad", request, 'PUT')
348
372
  end
349
373
 
350
- # Merchants: Destroy a text ad
351
- def txtad_destroy(campaign_id, txtad_id)
374
+ # Merchants: Destroy a text ad
375
+ def txtad_destroy(campaign_id, txtad_id)
352
376
  self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.xml", "txtad", nil, 'DELETE')
353
377
  end
354
378
 
355
379
  # =========
356
- # Banners
380
+ # Banners
357
381
  # =========
358
382
 
359
- # List banners from a campaign. Displays the first 6 entries by default.
360
- def banners_list(campaign_id, page=1, perpage=6)
361
- request = {
383
+ # List banners from a campaign. Displays the first 6 entries by default.
384
+ def banners_list(campaign_id, page=1, perpage=6)
385
+ request = {
362
386
  'page' => page,
363
387
  'perpage' => perpage
364
388
  }
@@ -366,13 +390,13 @@ class TwoPerformant
366
390
  self.hook("/campaigns/#{campaign_id}/banners.xml", "banner", request, 'GET')
367
391
  end
368
392
 
369
- # Display information about a banner
370
- def banner_show(campaign_id, banner_id)
393
+ # Display information about a banner
394
+ def banner_show(campaign_id, banner_id)
371
395
  self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.xml", "banner")
372
396
  end
373
397
 
374
- # Search for banners in a campaign
375
- def banners_search(campaign_id, search, page=1, perpage=6, sort='date')
398
+ # Search for banners in a campaign
399
+ def banners_search(campaign_id, search, page=1, perpage=6, sort='date')
376
400
  request = {
377
401
  'page' => page,
378
402
  'perpage' => perpage,
@@ -383,8 +407,18 @@ class TwoPerformant
383
407
  self.hook("/campaigns/#{campaign_id}/banners/search.xml", "banner", request, 'GET')
384
408
  end
385
409
 
386
- # Merchants: Update a banner
387
- def banner_update(campaign_id, banner_id, banner)
410
+ # Merchants: Create a banner
411
+ def banner_create(campaign_id, banner, banner_picture)
412
+ request = {
413
+ 'banner' => banner,
414
+ 'banner_picture' => banner_picture
415
+ }
416
+
417
+ self.hook("/campaigns/#{campaign_id}/banners.xml", "banner", request, 'POST')
418
+ end
419
+
420
+ # Merchants: Update a banner
421
+ def banner_update(campaign_id, banner_id, banner)
388
422
  request = {
389
423
  'banner' => banner
390
424
  }
@@ -392,31 +426,31 @@ class TwoPerformant
392
426
  self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.xml", "banner", request, 'PUT')
393
427
  end
394
428
 
395
- # Merchants: Destroy a banner
396
- def banner_destroy(campaign_id, banner_id)
429
+ # Merchants: Destroy a banner
430
+ def banner_destroy(campaign_id, banner_id)
397
431
  self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.xml", "banner", nil, 'DELETE')
398
432
  end
399
433
 
400
434
  # ===============
401
- # Widget Stores
435
+ # Product Stores
402
436
  # ===============
403
437
 
404
- # List Widget Stores from a Campaign
405
- def product_stores_list(campaign_id)
406
- request = {
438
+ # List Product Stores from a Campaign
439
+ def product_stores_list(campaign_id)
440
+ request = {
407
441
  'campaign_id' => campaign_id
408
442
  }
409
443
 
410
444
  self.hook("/product_stores.xml", "product-store", request)
411
445
  end
412
446
 
413
- # Show a WidgetStore
414
- def product_store_show(product_store_id)
447
+ # Show a Product Store
448
+ def product_store_show(product_store_id)
415
449
  self.hook("/product_stores/#{product_store_id}.xml", "product-store")
416
450
  end
417
451
 
418
- # Show Products from a WidgetStore
419
- def product_store_showitems(product_store_id, category=nil, page=1, perpage=6, uniq_products=nil)
452
+ # Show Products from a Product Store
453
+ def product_store_showitems(product_store_id, category=nil, page=1, perpage=6, uniq_products=nil)
420
454
  request = {
421
455
  'category' => category,
422
456
  'page' => page,
@@ -428,8 +462,8 @@ class TwoPerformant
428
462
  self.hook("/product_stores/#{product_store_id}/showitems.xml", "product-store-data", request)
429
463
  end
430
464
 
431
- # Show a Product from a WidgetStore
432
- def product_store_showitem(product_store_id, product_id)
465
+ # Show a Product from a Product Store
466
+ def product_store_showitem(product_store_id, product_id)
433
467
  request = {
434
468
  'product_id' => product_id
435
469
  }
@@ -438,8 +472,8 @@ class TwoPerformant
438
472
  end
439
473
 
440
474
 
441
- # Search for Products in a WidgetStore
442
- def product_store_products_search(campaign_id, search, product_store_id='all', category=nil, page=1, perpage=6, sort='date', uniq_products=false)
475
+ # Search for Products in a Product Store
476
+ def product_store_products_search(campaign_id, search, product_store_id='all', category=nil, page=1, perpage=6, sort='date', uniq_products=false)
443
477
  request = {
444
478
  'page' => page,
445
479
  'perpage' => perpage,
@@ -456,8 +490,8 @@ class TwoPerformant
456
490
  self.hook("/product_stores/#{product_store_id}/searchpr.xml", "product-store-data", request, 'GET')
457
491
  end
458
492
 
459
- # Merchants: Update a WidgetStore
460
- def product_store_update(product_store_id, product_store)
493
+ # Merchants: Update a Product Store
494
+ def product_store_update(product_store_id, product_store)
461
495
  request = {
462
496
  'product_store' => product_store
463
497
  }
@@ -465,26 +499,26 @@ class TwoPerformant
465
499
  self.hook("/product_stores/#{product_store_id}.xml", "product-store", request, 'PUT')
466
500
  end
467
501
 
468
- # Merchants: Destroy a WidgetStore
469
- def product_store_destroy(product_store_id)
502
+ # Merchants: Destroy a Product Store
503
+ def product_store_destroy(product_store_id)
470
504
  self.hook("/product_stores/#{product_store_id}.xml", "product-store", nil, 'DELETE')
471
505
  end
472
506
 
473
- #
474
- # Merchants: Create a WidgetStoreProduct.
475
- # WidgetStoreProduct must be a hash of:
507
+ #
508
+ # Merchants: Create a Product Store Product.
509
+ # Product Store Product must be a hash of:
476
510
  # { "title" => "title",
477
511
  # "description" => "desc",
478
512
  # "caption" => "caption",
479
- # "price" => "price(integer in RON)",
513
+ # "price" => "price(integer in RON)",
480
514
  # "promoted" => "promoted (0 or 1)",
481
515
  # "category" => "category",
482
- # "subcategory" => "subcategory",
483
- # "url" => "url",
516
+ # "subcategory" => "subcategory",
517
+ # "url" => "url",
484
518
  # "image_url" => "url to image location",
485
519
  # "prid" => "product id"
486
520
  # }
487
- def product_store_createitem(product_store_id, product)
521
+ def product_store_createitem(product_store_id, product)
488
522
  request = {
489
523
  'product' => product
490
524
  }
@@ -492,8 +526,8 @@ class TwoPerformant
492
526
  self.hook("/product_stores/#{product_store_id}/createitem.xml", "product-store-data", request, 'POST')
493
527
  end
494
528
 
495
- # Merchants: Update a product
496
- def product_store_updateitem(product_store_id, product_id, product)
529
+ # Merchants: Update a product
530
+ def product_store_updateitem(product_store_id, product_id, product)
497
531
  request = {
498
532
  'product' => product,
499
533
  'product_id' => product_id
@@ -502,8 +536,8 @@ class TwoPerformant
502
536
  self.hook("/product_stores/#{product_store_id}/updateitem.xml", "product-store-data", request, 'PUT')
503
537
  end
504
538
 
505
- # Merchants: Destroy a product
506
- def product_store_destroyitem(product_store_id, product_id)
539
+ # Merchants: Destroy a product
540
+ def product_store_destroyitem(product_store_id, product_id)
507
541
  request = {
508
542
  'pr_id' => product_id
509
543
  }
@@ -512,26 +546,38 @@ class TwoPerformant
512
546
  end
513
547
 
514
548
  # =====================
515
- # Affiliate Ad Groups
549
+ # Affiliate Ad Groups
516
550
  # =====================
517
-
518
- # Affiliates: List Ad Groups
519
- def ad_groups_list
551
+
552
+ # Affiliates: List Ad Groups
553
+ def ad_groups_list
520
554
  self.hook("/ad_groups.xml", "ad_group", nil, "GET")
521
555
  end
522
556
 
523
- # Affiliates: Display information about an Ad Group
524
- def ad_group_show(ad_group_id)
557
+ # Affiliates: Display information about an Ad Group
558
+ def ad_group_show(ad_group_id)
525
559
  self.hook("/ad_groups/#{ad_group_id}.xml", "ad_group", nil, "GET")
526
560
  end
527
561
 
528
- # Affiliates: Destroy an Ad Group
529
- def ad_group_destroy(ad_group_id)
562
+ # Affiliates: Add item to an Ad Group / Crate new Ad Group
563
+ def ad_group_createitem(group_id, tool_type, tool_id, new_group = nil)
564
+ request = {
565
+ 'group_id' => group_id,
566
+ 'new_group' => new_group,
567
+ 'tool_type' => tool_type,
568
+ 'tool_id' => tool_id
569
+ }
570
+
571
+ self.hook("/ad_groups/createitem.xml", "ad_group", request, 'POST')
572
+ end
573
+
574
+ # Affiliates: Destroy an Ad Group
575
+ def ad_group_destroy(ad_group_id)
530
576
  self.hook("/ad_groups/#{ad_group_id}.xml", "ad_group", nil, "DELETE")
531
577
  end
532
578
 
533
- # Affiliates: Delete an Tool from a Group. tooltype is one of 'txtlink', 'txtad' or 'banner'.
534
- def ad_group_destroyitem(ad_group_id, tool_type, tool_id)
579
+ # Affiliates: Delete an Tool from a Group. tooltype is one of 'txtlink', 'txtad' or 'banner'.
580
+ def ad_group_destroyitem(ad_group_id, tool_type, tool_id)
535
581
  request = {
536
582
  'tool_type' => tool_type,
537
583
  'tool_id' => tool_id
@@ -540,12 +586,45 @@ class TwoPerformant
540
586
  self.hook("/ad_groups/#{ad_group_id}/destroyitem.xml", "ad_group", request, "DELETE")
541
587
  end
542
588
 
589
+ #=================
590
+ # Affiliate Feeds
591
+ #=================
592
+
593
+ # Affiliates: List Feeds
594
+ def feeds_list()
595
+ self.hook("/feeds.xml", "feed", nil, "GET")
596
+ end
597
+
598
+ # Affiliates: Create a Feed
599
+ def feed_create(feed)
600
+ request = {
601
+ 'feed' => feed
602
+ }
603
+
604
+ self.hook("/feeds.xml", "feed", request, 'POST')
605
+ end
606
+
607
+ # Affiliates: Update a Feed
608
+ def feed_update(feed_id, feed)
609
+ request = {
610
+ 'feed' => feed
611
+ }
612
+
613
+ self.hook("/feeds/#{feed_id}.xml", "feed", request, 'PUT')
614
+ end
615
+
616
+
617
+ # Affiliates: Destroy a Feed
618
+ def feed_destroy(feed_id)
619
+ self.hook("/feeds/#{feed_id}.xml", "feed", nil, "DELETE")
620
+ end
621
+
543
622
  # ==========
544
- # Messages
623
+ # Messages
545
624
  # ==========
546
625
 
547
- # List received messages. Displays the first 6 entries by default.
548
- def received_messages_list(page=1, perpage=6)
626
+ # List received messages. Displays the first 6 entries by default.
627
+ def received_messages_list(page=1, perpage=6)
549
628
  request = {
550
629
  'page' => page,
551
630
  'perpage' => perpage
@@ -554,8 +633,8 @@ class TwoPerformant
554
633
  self.hook("/messages.xml", "message", nil, "GET")
555
634
  end
556
635
 
557
- # List sent messages. Displays the first 6 entries by default.
558
- def sent_messages_list(page=1, perpage=6)
636
+ # List sent messages. Displays the first 6 entries by default.
637
+ def sent_messages_list(page=1, perpage=6)
559
638
  request = {
560
639
  'page' => page,
561
640
  'perpage' => perpage
@@ -564,20 +643,44 @@ class TwoPerformant
564
643
  self.hook("/messages/sent.xml", "message", nil, "GET")
565
644
  end
566
645
 
567
- # Display information about a message
568
- def message_show(message_id)
646
+ # Display information about a message
647
+ def message_show(message_id)
569
648
  self.hook("/messages/#{message_id}.xml", "message")
570
649
  end
571
650
 
572
- # Destroy a message
573
- def message_destroy(message_id)
651
+ # Destroy a message
652
+ def message_destroy(message_id)
574
653
  self.hook("/messages/#{message_id}.xml", "message", nil, 'DELETE')
575
654
  end
576
655
 
577
656
 
578
- def hook(path, expected, send = nil, method = 'GET') #:nodoc:
657
+ #=======
658
+ # Hooks
659
+ #=======
660
+
661
+ # List Hooks
662
+ def hooks_list(oauth_token_key = 'current')
663
+ hook("/oauth_clients/{$oauth_token_key}/hooks.xml", "hook", nil, 'GET');
664
+ end
665
+
666
+
667
+ # Create a Hook
668
+ def hook_create(hook, oauth_token_key = 'current')
669
+ request = {
670
+ 'hook' => hook
671
+ }
672
+
673
+ hook("/oauth_clients/#{oauth_token_key}/hooks.xml", "hook", request, 'POST');
674
+ end
675
+
676
+ # Destroy a Hook
677
+ def hook_destroy(hook_id, oauth_token_key = 'current')
678
+ hook("/oauth_clients/#{oauth_token_key}/hooks/#{hook_id}.xml", "hook", nil, 'DELETE');
679
+ end
680
+
681
+ def hook(path, expected, send = nil, method = 'GET') #:nodoc:
579
682
  params = normalize_params(send, method)
580
-
683
+
581
684
  if self.oauth
582
685
  result = self.oauth.send(method.downcase, "/#{version}#{path}", send, params)
583
686
  else
@@ -586,11 +689,11 @@ class TwoPerformant
586
689
 
587
690
  # scrap the container
588
691
  if result.respond_to? :values
589
- result.values.first
692
+ result.values.first
590
693
  else
591
694
  result
592
695
  end
593
- end
696
+ end
594
697
 
595
698
  def normalize_params(params, method)
596
699
  hash_to_xml(:request => params).to_s
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 2Performant
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 25
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 2
9
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - 2Performant
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-04 00:00:00 +03:00
18
+ date: 2010-06-17 00:00:00 +03:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: httparty
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -33,9 +36,11 @@ dependencies:
33
36
  name: shoulda
34
37
  prerelease: false
35
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
36
40
  requirements:
37
41
  - - ">="
38
42
  - !ruby/object:Gem::Version
43
+ hash: 3
39
44
  segments:
40
45
  - 0
41
46
  version: "0"
@@ -72,23 +77,27 @@ rdoc_options:
72
77
  require_paths:
73
78
  - lib
74
79
  required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
75
81
  requirements:
76
82
  - - ">="
77
83
  - !ruby/object:Gem::Version
84
+ hash: 3
78
85
  segments:
79
86
  - 0
80
87
  version: "0"
81
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
82
90
  requirements:
83
91
  - - ">="
84
92
  - !ruby/object:Gem::Version
93
+ hash: 3
85
94
  segments:
86
95
  - 0
87
96
  version: "0"
88
97
  requirements: []
89
98
 
90
99
  rubyforge_project:
91
- rubygems_version: 1.3.6
100
+ rubygems_version: 1.3.7
92
101
  signing_key:
93
102
  specification_version: 3
94
103
  summary: Library for the 2Performant API