2Performant 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/2Performant.gemspec +19 -26
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/two_performant.rb +78 -94
- data/lib/two_performant/oauth.rb +20 -10
- metadata +63 -79
- data/.gitignore +0 -22
data/2Performant.gemspec
CHANGED
@@ -1,46 +1,39 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "
|
7
|
+
s.name = "2Performant"
|
8
|
+
s.version = ""
|
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 =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2012-09-20"
|
13
|
+
s.description = "Library for the 2Performant API"
|
14
|
+
s.email = "radu@2performant.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
"lib/two_performant/oauth.rb",
|
29
|
-
"test/helper.rb",
|
30
|
-
"test/test_2performant.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/2performant/2Performant}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.7}
|
36
|
-
s.summary = %q{Library for the 2Performant API}
|
37
|
-
s.test_files = [
|
21
|
+
"2Performant.gemspec",
|
22
|
+
"LICENSE",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"lib/two_performant.rb",
|
27
|
+
"lib/two_performant/oauth.rb",
|
38
28
|
"test/helper.rb",
|
39
|
-
|
29
|
+
"test/test_2performant.rb"
|
40
30
|
]
|
31
|
+
s.homepage = "http://github.com/2performant/2Performant"
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = "1.8.24"
|
34
|
+
s.summary = "Library for the 2Performant API"
|
41
35
|
|
42
36
|
if s.respond_to? :specification_version then
|
43
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
44
37
|
s.specification_version = 3
|
45
38
|
|
46
39
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ The API allows you to integrate any 2Performant network in your application.
|
|
4
4
|
|
5
5
|
Its goal is to make sure developers can implement anything that can be done via the web interface using API functions.
|
6
6
|
|
7
|
-
The API is RESTful
|
7
|
+
The API is RESTful JSON over HTTP using all four verbs (GET/POST/PUT/DELETE).
|
8
8
|
|
9
9
|
The current implementation is a straight port of the PHP library, so the documentation applies, for the most part, to both libraries.
|
10
10
|
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ begin
|
|
7
7
|
gem.name = "2Performant"
|
8
8
|
gem.summary = %Q{Library for the 2Performant API}
|
9
9
|
gem.description = %Q{Library for the 2Performant API}
|
10
|
-
gem.email = "
|
10
|
+
gem.email = "radu@2performant.com"
|
11
11
|
gem.homepage = "http://github.com/2performant/2Performant"
|
12
12
|
gem.authors = ["2Performant"]
|
13
13
|
gem.add_dependency "httparty"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/two_performant.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'json'
|
2
3
|
require 'two_performant/oauth'
|
3
4
|
|
4
5
|
class TwoPerformant
|
5
6
|
include HTTParty
|
6
|
-
format :
|
7
|
-
headers 'Content-Type' => 'text/
|
7
|
+
format :json
|
8
|
+
headers 'Content-Type' => 'text/json'
|
8
9
|
|
9
10
|
attr_accessor :user, :pass, :host, :version, :auth_type, :oauth, :oauth_request
|
10
11
|
|
@@ -27,13 +28,13 @@ class TwoPerformant
|
|
27
28
|
# Users
|
28
29
|
# =======
|
29
30
|
def user_show(user_id)
|
30
|
-
self.hook("/users/#{user_id}.
|
31
|
+
self.hook("/users/#{user_id}.json", "user");
|
31
32
|
end
|
32
33
|
|
33
34
|
|
34
35
|
# Display public information about the logged in user
|
35
36
|
def user_loggedin
|
36
|
-
self.hook("/users/loggedin.
|
37
|
+
self.hook("/users/loggedin.json", "user");
|
37
38
|
end
|
38
39
|
|
39
40
|
# ===========
|
@@ -48,7 +49,7 @@ class TwoPerformant
|
|
48
49
|
'perpage' => perpage
|
49
50
|
}
|
50
51
|
|
51
|
-
self.hook("/campaigns.
|
52
|
+
self.hook("/campaigns.json", "campaign", request, 'GET')
|
52
53
|
end
|
53
54
|
|
54
55
|
# Search for campaigns
|
@@ -59,27 +60,27 @@ class TwoPerformant
|
|
59
60
|
'search' => search
|
60
61
|
}
|
61
62
|
|
62
|
-
self.hook("/campaigns/search.
|
63
|
+
self.hook("/campaigns/search.json", "campaign", request, 'GET')
|
63
64
|
end
|
64
65
|
|
65
66
|
# Display public information about a campaign
|
66
67
|
def campaign_show(campaign_id)
|
67
|
-
self.hook("/campaigns/#{campaign_id}.
|
68
|
+
self.hook("/campaigns/#{campaign_id}.json", "campaign")
|
68
69
|
end
|
69
70
|
|
70
71
|
# Affiliates: List campaigns which have the logged in user accepted
|
71
72
|
def campaigns_listforaffiliate
|
72
|
-
self.hook("/campaigns/listforaffiliate.
|
73
|
+
self.hook("/campaigns/listforaffiliate.json", "campaign")
|
73
74
|
end
|
74
75
|
|
75
76
|
# Merchants: List all campaigns created by the logged in user
|
76
77
|
def campaigns_listforowner
|
77
|
-
self.hook("/campaigns/listforowner.
|
78
|
+
self.hook("/campaigns/listforowner.json", "campaign")
|
78
79
|
end
|
79
80
|
|
80
81
|
# Merchants: Display complete information about a campaign (only available to owner)
|
81
82
|
def campaign_showforowner(campaign_id)
|
82
|
-
self.hook("/campaigns/#{campaign_id}/showforowner.
|
83
|
+
self.hook("/campaigns/#{campaign_id}/showforowner.json", "campaign")
|
83
84
|
end
|
84
85
|
|
85
86
|
# Merchants: Update a campaign
|
@@ -87,7 +88,7 @@ class TwoPerformant
|
|
87
88
|
request = {
|
88
89
|
'campaign' => campaign
|
89
90
|
}
|
90
|
-
self.hook("/campaigns/#{campaign_id}.
|
91
|
+
self.hook("/campaigns/#{campaign_id}.json", "campaign", request, 'PUT')
|
91
92
|
end
|
92
93
|
|
93
94
|
# Create a Deep Link. This method was created so it wouldn't make a request for every Quick Link.
|
@@ -111,7 +112,7 @@ class TwoPerformant
|
|
111
112
|
'sale' => sale
|
112
113
|
}
|
113
114
|
|
114
|
-
self.hook("/campaigns/#{campaign_id}/sales.
|
115
|
+
self.hook("/campaigns/#{campaign_id}/sales.json", "sale", request, "POST")
|
115
116
|
end
|
116
117
|
|
117
118
|
# ============
|
@@ -123,7 +124,7 @@ class TwoPerformant
|
|
123
124
|
'lead' => lead
|
124
125
|
}
|
125
126
|
|
126
|
-
self.hook("/campaigns/#{campaign_id}/leads.
|
127
|
+
self.hook("/campaigns/#{campaign_id}/leads.json", "lead", request, "POST")
|
127
128
|
end
|
128
129
|
|
129
130
|
# ============
|
@@ -138,7 +139,7 @@ class TwoPerformant
|
|
138
139
|
'search' => search
|
139
140
|
}
|
140
141
|
|
141
|
-
self.hook("/affiliates/search.
|
142
|
+
self.hook("/affiliates/search.json", "user", request, 'GET')
|
142
143
|
end
|
143
144
|
|
144
145
|
# Merchants: List affiliates approved in campaigns
|
@@ -146,7 +147,7 @@ class TwoPerformant
|
|
146
147
|
request = {
|
147
148
|
'campaign_id' => campaign_id
|
148
149
|
}
|
149
|
-
self.hook("/affiliates/listformerchant.
|
150
|
+
self.hook("/affiliates/listformerchant.json", "user", request, 'GET')
|
150
151
|
end
|
151
152
|
|
152
153
|
# =============
|
@@ -165,7 +166,7 @@ class TwoPerformant
|
|
165
166
|
|
166
167
|
request.merge(options)
|
167
168
|
|
168
|
-
self.hook("/commissions/search.
|
169
|
+
self.hook("/commissions/search.json", "commission", request, 'GET')
|
169
170
|
end
|
170
171
|
|
171
172
|
# Merchants: List commissions on campaigns. Month: 01 to 12; Year: 20xx.
|
@@ -176,7 +177,7 @@ class TwoPerformant
|
|
176
177
|
'year' => year
|
177
178
|
}
|
178
179
|
|
179
|
-
self.hook("/commissions/listformerchant.
|
180
|
+
self.hook("/commissions/listformerchant.json", "campaign", request, 'GET')
|
180
181
|
end
|
181
182
|
|
182
183
|
# Affiliates: List commissions on campaigns. Month: 01 to 12; Year: 20xx.
|
@@ -187,12 +188,12 @@ class TwoPerformant
|
|
187
188
|
'year' => year
|
188
189
|
}
|
189
190
|
|
190
|
-
self.hook("/commissions/listforaffiliate.
|
191
|
+
self.hook("/commissions/listforaffiliate.json", "commission", request, 'GET')
|
191
192
|
end
|
192
193
|
|
193
194
|
# Merchant Campaign Owner or Affiliate Commission Owner: Show information about a commission
|
194
195
|
def commission_show(commission_id)
|
195
|
-
self.hook("/commissions/#{commission_id}.
|
196
|
+
self.hook("/commissions/#{commission_id}.json", "commission")
|
196
197
|
end
|
197
198
|
|
198
199
|
# Merchant: Update a commission
|
@@ -200,7 +201,7 @@ class TwoPerformant
|
|
200
201
|
request = {
|
201
202
|
'commission' => commission
|
202
203
|
}
|
203
|
-
self.hook("/commissions/#{commission_id}.
|
204
|
+
self.hook("/commissions/#{commission_id}.json", "commission", request, 'PUT')
|
204
205
|
end
|
205
206
|
|
206
207
|
# =======
|
@@ -215,12 +216,12 @@ class TwoPerformant
|
|
215
216
|
'perpage' => perpage
|
216
217
|
}
|
217
218
|
|
218
|
-
self.hook("/sites.
|
219
|
+
self.hook("/sites.json", "site", request)
|
219
220
|
end
|
220
221
|
|
221
222
|
# Display information about a site
|
222
223
|
def site_show(site_id)
|
223
|
-
self.hook("/sites/#{site_id}.
|
224
|
+
self.hook("/sites/#{site_id}.json", "site")
|
224
225
|
end
|
225
226
|
|
226
227
|
# Search for sites
|
@@ -231,12 +232,12 @@ class TwoPerformant
|
|
231
232
|
'search' => search
|
232
233
|
}
|
233
234
|
|
234
|
-
self.hook("/sites/search.
|
235
|
+
self.hook("/sites/search.json", "site", request, 'GET')
|
235
236
|
end
|
236
237
|
|
237
238
|
# Affiliates: List all sites created by the logged in user
|
238
239
|
def sites_listforowner
|
239
|
-
self.hook("/sites/listforowner.
|
240
|
+
self.hook("/sites/listforowner.json", "site")
|
240
241
|
end
|
241
242
|
|
242
243
|
# Affiliates: Update a site
|
@@ -244,13 +245,13 @@ class TwoPerformant
|
|
244
245
|
request = {
|
245
246
|
'site' => site
|
246
247
|
}
|
247
|
-
self.hook("/sites/#{site_id}.
|
248
|
+
self.hook("/sites/#{site_id}.json", "site", request, 'PUT')
|
248
249
|
end
|
249
250
|
|
250
251
|
|
251
252
|
# Affiliates: Destroy a site
|
252
253
|
def site_destroy(site_id)
|
253
|
-
self.hook("/sites/#{site_id}.
|
254
|
+
self.hook("/sites/#{site_id}.json", "site", request, 'DELETE')
|
254
255
|
end
|
255
256
|
|
256
257
|
# ============
|
@@ -264,12 +265,12 @@ class TwoPerformant
|
|
264
265
|
'perpage' => perpage
|
265
266
|
}
|
266
267
|
|
267
|
-
self.hook("/campaigns/#{campaign_id}/txtlinks.
|
268
|
+
self.hook("/campaigns/#{campaign_id}/txtlinks.json", "txtlink", request, 'GET')
|
268
269
|
end
|
269
270
|
|
270
271
|
# Display information about a text link
|
271
272
|
def txtlink_show(campaign_id, txtlink_id)
|
272
|
-
self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.
|
273
|
+
self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.json", "txtlink")
|
273
274
|
end
|
274
275
|
|
275
276
|
# Search for text links in a campaign
|
@@ -281,7 +282,7 @@ class TwoPerformant
|
|
281
282
|
'sort' => sort,
|
282
283
|
}
|
283
284
|
|
284
|
-
self.hook("/campaigns/#{campaign_id}/txtlinks/search.
|
285
|
+
self.hook("/campaigns/#{campaign_id}/txtlinks/search.json", "txtlink", request, 'GET')
|
285
286
|
end
|
286
287
|
|
287
288
|
#
|
@@ -298,7 +299,7 @@ class TwoPerformant
|
|
298
299
|
'txtlink' => txtlink
|
299
300
|
}
|
300
301
|
|
301
|
-
self.hook("/campaigns/#{campaign_id}/txtlinks.
|
302
|
+
self.hook("/campaigns/#{campaign_id}/txtlinks.json", "txtlink", request, 'POST')
|
302
303
|
end
|
303
304
|
|
304
305
|
# Merchants: Update a text link
|
@@ -306,12 +307,12 @@ class TwoPerformant
|
|
306
307
|
request = {
|
307
308
|
'txtlink' => txtlink
|
308
309
|
}
|
309
|
-
self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.
|
310
|
+
self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.json", "txtlink", request, 'PUT')
|
310
311
|
end
|
311
312
|
|
312
313
|
# Merchants: Destroy a text link
|
313
314
|
def txtlink_destroy(campaign_id, txtlink_id)
|
314
|
-
self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.
|
315
|
+
self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.json", "txtlink", nil, 'DELETE')
|
315
316
|
end
|
316
317
|
|
317
318
|
# ============
|
@@ -325,12 +326,12 @@ class TwoPerformant
|
|
325
326
|
'perpage' => perpage
|
326
327
|
}
|
327
328
|
|
328
|
-
self.hook("/campaigns/#{campaign_id}/txtads.
|
329
|
+
self.hook("/campaigns/#{campaign_id}/txtads.json", "txtad", request, 'GET')
|
329
330
|
end
|
330
331
|
|
331
332
|
# Display information about a text ad
|
332
333
|
def txtad_show(campaign_id, txtad_id)
|
333
|
-
self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.
|
334
|
+
self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.json", "txtad")
|
334
335
|
end
|
335
336
|
|
336
337
|
# Search for text ads in a campaign
|
@@ -342,7 +343,7 @@ class TwoPerformant
|
|
342
343
|
'sort' => sort
|
343
344
|
}
|
344
345
|
|
345
|
-
self.hook("/campaigns/#{campaign_id}/txtads/search.
|
346
|
+
self.hook("/campaigns/#{campaign_id}/txtads/search.json", "txtad", request, 'GET')
|
346
347
|
end
|
347
348
|
|
348
349
|
#
|
@@ -358,7 +359,7 @@ class TwoPerformant
|
|
358
359
|
'txtad' => txtad
|
359
360
|
}
|
360
361
|
|
361
|
-
self.hook("/campaigns/#{campaign_id}/txtads.
|
362
|
+
self.hook("/campaigns/#{campaign_id}/txtads.json", "txtad", request, 'POST')
|
362
363
|
end
|
363
364
|
|
364
365
|
|
@@ -368,12 +369,12 @@ class TwoPerformant
|
|
368
369
|
'txtad' => txtad
|
369
370
|
}
|
370
371
|
|
371
|
-
self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.
|
372
|
+
self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.json", "txtad", request, 'PUT')
|
372
373
|
end
|
373
374
|
|
374
375
|
# Merchants: Destroy a text ad
|
375
376
|
def txtad_destroy(campaign_id, txtad_id)
|
376
|
-
self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.
|
377
|
+
self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.json", "txtad", nil, 'DELETE')
|
377
378
|
end
|
378
379
|
|
379
380
|
# =========
|
@@ -387,12 +388,12 @@ class TwoPerformant
|
|
387
388
|
'perpage' => perpage
|
388
389
|
}
|
389
390
|
|
390
|
-
self.hook("/campaigns/#{campaign_id}/banners.
|
391
|
+
self.hook("/campaigns/#{campaign_id}/banners.json", "banner", request, 'GET')
|
391
392
|
end
|
392
393
|
|
393
394
|
# Display information about a banner
|
394
395
|
def banner_show(campaign_id, banner_id)
|
395
|
-
self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.
|
396
|
+
self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.json", "banner")
|
396
397
|
end
|
397
398
|
|
398
399
|
# Search for banners in a campaign
|
@@ -404,7 +405,7 @@ class TwoPerformant
|
|
404
405
|
'sort' => sort
|
405
406
|
}
|
406
407
|
|
407
|
-
self.hook("/campaigns/#{campaign_id}/banners/search.
|
408
|
+
self.hook("/campaigns/#{campaign_id}/banners/search.json", "banner", request, 'GET')
|
408
409
|
end
|
409
410
|
|
410
411
|
# Merchants: Create a banner
|
@@ -414,7 +415,7 @@ class TwoPerformant
|
|
414
415
|
'banner_picture' => banner_picture
|
415
416
|
}
|
416
417
|
|
417
|
-
self.hook("/campaigns/#{campaign_id}/banners.
|
418
|
+
self.hook("/campaigns/#{campaign_id}/banners.json", "banner", request, 'POST')
|
418
419
|
end
|
419
420
|
|
420
421
|
# Merchants: Update a banner
|
@@ -423,12 +424,12 @@ class TwoPerformant
|
|
423
424
|
'banner' => banner
|
424
425
|
}
|
425
426
|
|
426
|
-
self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.
|
427
|
+
self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.json", "banner", request, 'PUT')
|
427
428
|
end
|
428
429
|
|
429
430
|
# Merchants: Destroy a banner
|
430
431
|
def banner_destroy(campaign_id, banner_id)
|
431
|
-
self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.
|
432
|
+
self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.json", "banner", nil, 'DELETE')
|
432
433
|
end
|
433
434
|
|
434
435
|
# ===============
|
@@ -441,12 +442,12 @@ class TwoPerformant
|
|
441
442
|
'campaign_id' => campaign_id
|
442
443
|
}
|
443
444
|
|
444
|
-
self.hook("/product_stores.
|
445
|
+
self.hook("/product_stores.json", "product-store", request)
|
445
446
|
end
|
446
447
|
|
447
448
|
# Show a Product Store
|
448
449
|
def product_store_show(product_store_id)
|
449
|
-
self.hook("/product_stores/#{product_store_id}.
|
450
|
+
self.hook("/product_stores/#{product_store_id}.json", "product-store")
|
450
451
|
end
|
451
452
|
|
452
453
|
# Show Products from a Product Store
|
@@ -459,7 +460,7 @@ class TwoPerformant
|
|
459
460
|
|
460
461
|
request['uniq_products'] = uniq_products if (uniq_products)
|
461
462
|
|
462
|
-
self.hook("/product_stores/#{product_store_id}/showitems.
|
463
|
+
self.hook("/product_stores/#{product_store_id}/showitems.json", "product-store-data", request)
|
463
464
|
end
|
464
465
|
|
465
466
|
# Show a Product from a Product Store
|
@@ -468,7 +469,7 @@ class TwoPerformant
|
|
468
469
|
'product_id' => product_id
|
469
470
|
}
|
470
471
|
|
471
|
-
self.hook("/product_stores/#{product_store_id}/showitem.
|
472
|
+
self.hook("/product_stores/#{product_store_id}/showitem.json", "product-store-data", request)
|
472
473
|
end
|
473
474
|
|
474
475
|
|
@@ -487,7 +488,7 @@ class TwoPerformant
|
|
487
488
|
|
488
489
|
product_store_id = 'all' if !product_store_id
|
489
490
|
|
490
|
-
self.hook("/product_stores/#{product_store_id}/searchpr.
|
491
|
+
self.hook("/product_stores/#{product_store_id}/searchpr.json", "product-store-data", request, 'GET')
|
491
492
|
end
|
492
493
|
|
493
494
|
# Merchants: Update a Product Store
|
@@ -496,12 +497,12 @@ class TwoPerformant
|
|
496
497
|
'product_store' => product_store
|
497
498
|
}
|
498
499
|
|
499
|
-
self.hook("/product_stores/#{product_store_id}.
|
500
|
+
self.hook("/product_stores/#{product_store_id}.json", "product-store", request, 'PUT')
|
500
501
|
end
|
501
502
|
|
502
503
|
# Merchants: Destroy a Product Store
|
503
504
|
def product_store_destroy(product_store_id)
|
504
|
-
self.hook("/product_stores/#{product_store_id}.
|
505
|
+
self.hook("/product_stores/#{product_store_id}.json", "product-store", nil, 'DELETE')
|
505
506
|
end
|
506
507
|
|
507
508
|
#
|
@@ -523,7 +524,7 @@ class TwoPerformant
|
|
523
524
|
'product' => product
|
524
525
|
}
|
525
526
|
|
526
|
-
self.hook("/product_stores/#{product_store_id}/createitem.
|
527
|
+
self.hook("/product_stores/#{product_store_id}/createitem.json", "product-store-data", request, 'POST')
|
527
528
|
end
|
528
529
|
|
529
530
|
# Merchants: Update a product
|
@@ -533,7 +534,7 @@ class TwoPerformant
|
|
533
534
|
'product_id' => product_id
|
534
535
|
}
|
535
536
|
|
536
|
-
self.hook("/product_stores/#{product_store_id}/updateitem.
|
537
|
+
self.hook("/product_stores/#{product_store_id}/updateitem.json", "product-store-data", request, 'PUT')
|
537
538
|
end
|
538
539
|
|
539
540
|
# Merchants: Destroy a product
|
@@ -542,7 +543,7 @@ class TwoPerformant
|
|
542
543
|
'pr_id' => product_id
|
543
544
|
}
|
544
545
|
|
545
|
-
self.hook("/product_stores/#{product_store_id}/destroyitem.
|
546
|
+
self.hook("/product_stores/#{product_store_id}/destroyitem.json", "product-store-data", request, 'DELETE')
|
546
547
|
end
|
547
548
|
|
548
549
|
# =====================
|
@@ -551,12 +552,12 @@ class TwoPerformant
|
|
551
552
|
|
552
553
|
# Affiliates: List Ad Groups
|
553
554
|
def ad_groups_list
|
554
|
-
self.hook("/ad_groups.
|
555
|
+
self.hook("/ad_groups.json", "ad_group", nil, "GET")
|
555
556
|
end
|
556
557
|
|
557
558
|
# Affiliates: Display information about an Ad Group
|
558
559
|
def ad_group_show(ad_group_id)
|
559
|
-
self.hook("/ad_groups/#{ad_group_id}.
|
560
|
+
self.hook("/ad_groups/#{ad_group_id}.json", "ad_group", nil, "GET")
|
560
561
|
end
|
561
562
|
|
562
563
|
# Affiliates: Add item to an Ad Group / Crate new Ad Group
|
@@ -568,12 +569,12 @@ class TwoPerformant
|
|
568
569
|
'tool_id' => tool_id
|
569
570
|
}
|
570
571
|
|
571
|
-
self.hook("/ad_groups/createitem.
|
572
|
+
self.hook("/ad_groups/createitem.json", "ad_group", request, 'POST')
|
572
573
|
end
|
573
574
|
|
574
575
|
# Affiliates: Destroy an Ad Group
|
575
576
|
def ad_group_destroy(ad_group_id)
|
576
|
-
self.hook("/ad_groups/#{ad_group_id}.
|
577
|
+
self.hook("/ad_groups/#{ad_group_id}.json", "ad_group", nil, "DELETE")
|
577
578
|
end
|
578
579
|
|
579
580
|
# Affiliates: Delete an Tool from a Group. tooltype is one of 'txtlink', 'txtad' or 'banner'.
|
@@ -583,7 +584,7 @@ class TwoPerformant
|
|
583
584
|
'tool_id' => tool_id
|
584
585
|
}
|
585
586
|
|
586
|
-
self.hook("/ad_groups/#{ad_group_id}/destroyitem.
|
587
|
+
self.hook("/ad_groups/#{ad_group_id}/destroyitem.json", "ad_group", request, "DELETE")
|
587
588
|
end
|
588
589
|
|
589
590
|
#=================
|
@@ -592,7 +593,7 @@ class TwoPerformant
|
|
592
593
|
|
593
594
|
# Affiliates: List Feeds
|
594
595
|
def feeds_list()
|
595
|
-
self.hook("/feeds.
|
596
|
+
self.hook("/feeds.json", "feed", nil, "GET")
|
596
597
|
end
|
597
598
|
|
598
599
|
# Affiliates: Create a Feed
|
@@ -601,7 +602,7 @@ class TwoPerformant
|
|
601
602
|
'feed' => feed
|
602
603
|
}
|
603
604
|
|
604
|
-
self.hook("/feeds.
|
605
|
+
self.hook("/feeds.json", "feed", request, 'POST')
|
605
606
|
end
|
606
607
|
|
607
608
|
# Affiliates: Update a Feed
|
@@ -610,13 +611,13 @@ class TwoPerformant
|
|
610
611
|
'feed' => feed
|
611
612
|
}
|
612
613
|
|
613
|
-
self.hook("/feeds/#{feed_id}.
|
614
|
+
self.hook("/feeds/#{feed_id}.json", "feed", request, 'PUT')
|
614
615
|
end
|
615
616
|
|
616
617
|
|
617
618
|
# Affiliates: Destroy a Feed
|
618
619
|
def feed_destroy(feed_id)
|
619
|
-
self.hook("/feeds/#{feed_id}.
|
620
|
+
self.hook("/feeds/#{feed_id}.json", "feed", nil, "DELETE")
|
620
621
|
end
|
621
622
|
|
622
623
|
# ==========
|
@@ -630,7 +631,7 @@ class TwoPerformant
|
|
630
631
|
'perpage' => perpage
|
631
632
|
}
|
632
633
|
|
633
|
-
self.hook("/messages.
|
634
|
+
self.hook("/messages.json", "message", nil, "GET")
|
634
635
|
end
|
635
636
|
|
636
637
|
# List sent messages. Displays the first 6 entries by default.
|
@@ -640,17 +641,17 @@ class TwoPerformant
|
|
640
641
|
'perpage' => perpage
|
641
642
|
}
|
642
643
|
|
643
|
-
self.hook("/messages/sent.
|
644
|
+
self.hook("/messages/sent.json", "message", nil, "GET")
|
644
645
|
end
|
645
646
|
|
646
647
|
# Display information about a message
|
647
648
|
def message_show(message_id)
|
648
|
-
self.hook("/messages/#{message_id}.
|
649
|
+
self.hook("/messages/#{message_id}.json", "message")
|
649
650
|
end
|
650
651
|
|
651
652
|
# Destroy a message
|
652
653
|
def message_destroy(message_id)
|
653
|
-
self.hook("/messages/#{message_id}.
|
654
|
+
self.hook("/messages/#{message_id}.json", "message", nil, 'DELETE')
|
654
655
|
end
|
655
656
|
|
656
657
|
|
@@ -660,31 +661,31 @@ class TwoPerformant
|
|
660
661
|
|
661
662
|
# List Hooks
|
662
663
|
def hooks_list(oauth_token_key = 'current')
|
663
|
-
hook("/oauth_clients/#{oauth_token_key}/hooks.
|
664
|
+
self.hook("/oauth_clients/#{oauth_token_key}/hooks.json", "client_application_hook", nil, 'GET')
|
664
665
|
end
|
665
666
|
|
666
667
|
|
667
668
|
# Create a Hook
|
668
|
-
def hook_create(
|
669
|
+
def hook_create(name, opts, oauth_token_key = 'current')
|
669
670
|
request = {
|
670
|
-
'
|
671
|
+
'name' => name,
|
672
|
+
'opts' => opts,
|
671
673
|
}
|
672
674
|
|
673
|
-
hook("/oauth_clients/#{oauth_token_key}/hooks.
|
675
|
+
self.hook("/oauth_clients/#{oauth_token_key}/hooks.json", "client_application_hook", request, 'POST')
|
674
676
|
end
|
675
677
|
|
676
678
|
# Destroy a Hook
|
677
679
|
def hook_destroy(hook_id, oauth_token_key = 'current')
|
678
|
-
hook("/oauth_clients/#{oauth_token_key}/hooks/#{hook_id}.
|
680
|
+
self.hook("/oauth_clients/#{oauth_token_key}/hooks/#{hook_id}.json", "client_application_hook", nil, 'DELETE')
|
679
681
|
end
|
680
682
|
|
681
|
-
def hook(path, expected, send = nil, method = 'GET') #:nodoc:
|
682
|
-
params = normalize_params(send, method)
|
683
|
-
|
683
|
+
def hook(path, expected, send = nil, method = 'GET') #:nodoc:
|
684
684
|
if self.oauth
|
685
|
-
result = self.oauth.send(method.downcase, "/#{version}#{path}", send
|
685
|
+
result = self.oauth.send(method.downcase, "/#{version}#{path}", send)
|
686
686
|
else
|
687
|
-
result = self.class.send(method.downcase, "/#{version}#{path}", :body =>
|
687
|
+
result = self.class.send(method.downcase, "/#{version}#{path}", :body => send)
|
688
|
+
result = result.parsed_response
|
688
689
|
end
|
689
690
|
|
690
691
|
# scrap the container
|
@@ -695,21 +696,4 @@ class TwoPerformant
|
|
695
696
|
end
|
696
697
|
end
|
697
698
|
|
698
|
-
def normalize_params(params, method)
|
699
|
-
hash_to_xml(:request => params).to_s
|
700
|
-
end
|
701
|
-
|
702
|
-
def hash_to_xml(var, document = nil)
|
703
|
-
document = REXML::Document.new if document.nil?
|
704
|
-
|
705
|
-
if var.respond_to? :keys
|
706
|
-
var.keys.each do |key|
|
707
|
-
hash_to_xml(var[key], document.add_element(key.to_s))
|
708
|
-
end
|
709
|
-
else
|
710
|
-
document.add_text(var.to_s)
|
711
|
-
end
|
712
|
-
|
713
|
-
document
|
714
|
-
end
|
715
699
|
end
|
data/lib/two_performant/oauth.rb
CHANGED
@@ -1,4 +1,14 @@
|
|
1
1
|
require 'oauth'
|
2
|
+
require "addressable/uri"
|
3
|
+
|
4
|
+
class Hash
|
5
|
+
def to_params
|
6
|
+
uri = Addressable::URI.new
|
7
|
+
uri.query_values = self
|
8
|
+
uri.query
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
2
12
|
|
3
13
|
class TwoPerformant
|
4
14
|
class OAuth
|
@@ -7,28 +17,28 @@ class TwoPerformant
|
|
7
17
|
def initialize(options, host)
|
8
18
|
consumer = ::OAuth::Consumer.new(options[:consumer_token], options[:consumer_secret], {:site => host})
|
9
19
|
@access_token = ::OAuth::AccessToken.new(consumer, options[:access_token], options[:access_secret])
|
10
|
-
@headers = { 'Accept' => 'application/
|
20
|
+
@headers = { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded' }
|
11
21
|
end
|
12
22
|
|
13
|
-
def get(path, params_hash
|
23
|
+
def get(path, params_hash)
|
14
24
|
params_hash ||= {}
|
15
25
|
response = access_token.get("#{path}?#{params_hash.to_params}")
|
16
|
-
|
26
|
+
JSON.parse(response.body)
|
17
27
|
end
|
18
28
|
|
19
|
-
def post(path, params_hash
|
20
|
-
response = access_token.post(path,
|
21
|
-
|
29
|
+
def post(path, params_hash)
|
30
|
+
response = access_token.post(path, params_hash.to_json, @headers)
|
31
|
+
JSON.parse(response.body)
|
22
32
|
end
|
23
33
|
|
24
|
-
def put(path, params_hash
|
25
|
-
response = access_token.put(path,
|
26
|
-
|
34
|
+
def put(path, params_hash)
|
35
|
+
response = access_token.put(path, params_hash.to_json, @headers)
|
36
|
+
JSON.parse(response.body)
|
27
37
|
end
|
28
38
|
|
29
39
|
def delete(path, params)
|
30
40
|
response = access_token.delete("#{path}?#{params.to_params}")
|
31
|
-
|
41
|
+
JSON.parse(response.body)
|
32
42
|
end
|
33
43
|
end
|
34
44
|
end
|
metadata
CHANGED
@@ -1,77 +1,73 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: 2Performant
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 8
|
10
|
-
version: 0.0.8
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- 2Performant
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-09-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: httparty
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: oauth
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
25
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: oauth
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
47
38
|
type: :runtime
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: shoulda
|
51
39
|
prerelease: false
|
52
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
41
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: shoulda
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
61
54
|
type: :development
|
62
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
63
62
|
description: Library for the 2Performant API
|
64
|
-
email:
|
63
|
+
email: radu@2performant.com
|
65
64
|
executables: []
|
66
|
-
|
67
65
|
extensions: []
|
68
|
-
|
69
|
-
extra_rdoc_files:
|
66
|
+
extra_rdoc_files:
|
70
67
|
- LICENSE
|
71
68
|
- README.md
|
72
|
-
files:
|
69
|
+
files:
|
73
70
|
- .document
|
74
|
-
- .gitignore
|
75
71
|
- 2Performant.gemspec
|
76
72
|
- LICENSE
|
77
73
|
- README.md
|
@@ -81,40 +77,28 @@ files:
|
|
81
77
|
- lib/two_performant/oauth.rb
|
82
78
|
- test/helper.rb
|
83
79
|
- test/test_2performant.rb
|
84
|
-
has_rdoc: true
|
85
80
|
homepage: http://github.com/2performant/2Performant
|
86
81
|
licenses: []
|
87
|
-
|
88
82
|
post_install_message:
|
89
|
-
rdoc_options:
|
90
|
-
|
91
|
-
require_paths:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
92
85
|
- lib
|
93
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
87
|
none: false
|
95
|
-
requirements:
|
96
|
-
- -
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
|
99
|
-
|
100
|
-
- 0
|
101
|
-
version: "0"
|
102
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
93
|
none: false
|
104
|
-
requirements:
|
105
|
-
- -
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
108
|
-
segments:
|
109
|
-
- 0
|
110
|
-
version: "0"
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
111
98
|
requirements: []
|
112
|
-
|
113
99
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.
|
100
|
+
rubygems_version: 1.8.24
|
115
101
|
signing_key:
|
116
102
|
specification_version: 3
|
117
103
|
summary: Library for the 2Performant API
|
118
|
-
test_files:
|
119
|
-
- test/helper.rb
|
120
|
-
- test/test_2performant.rb
|
104
|
+
test_files: []
|