Class: TwoPerformant

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/two_performant.rb,
lib/two_performant/oauth.rb

Defined Under Namespace

Classes: OAuth

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth_type, auth_obj, host) ⇒ TwoPerformant

Returns a new instance of TwoPerformant.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/two_performant.rb', line 11

def initialize(auth_type, auth_obj, host)
  if auth_type == :simple
    self.class.basic_auth auth_obj[:user], auth_obj[:pass]
  elsif auth_type == :oauth
    self.oauth = TwoPerformant::OAuth.new(auth_obj, host)
  else
    return false
  end

  self.version = "v1.0"
  self.auth_type = auth_type
  self.host = host
  self.class.base_uri host
end

Instance Attribute Details

#auth_typeObject

Returns the value of attribute auth_type.



9
10
11
# File 'lib/two_performant.rb', line 9

def auth_type
  @auth_type
end

#hostObject

Returns the value of attribute host.



9
10
11
# File 'lib/two_performant.rb', line 9

def host
  @host
end

#oauthObject

Returns the value of attribute oauth.



9
10
11
# File 'lib/two_performant.rb', line 9

def oauth
  @oauth
end

#oauth_requestObject

Returns the value of attribute oauth_request.



9
10
11
# File 'lib/two_performant.rb', line 9

def oauth_request
  @oauth_request
end

#passObject

Returns the value of attribute pass.



9
10
11
# File 'lib/two_performant.rb', line 9

def pass
  @pass
end

#userObject

Returns the value of attribute user.



9
10
11
# File 'lib/two_performant.rb', line 9

def user
  @user
end

#versionObject

Returns the value of attribute version.



9
10
11
# File 'lib/two_performant.rb', line 9

def version
  @version
end

Instance Method Details

#ad_group_createitem(group_id, tool_type, tool_id, new_group = nil) ⇒ Object

Affiliates: Add item to an Ad Group / Crate new Ad Group



563
564
565
566
567
568
569
570
571
572
# File 'lib/two_performant.rb', line 563

def ad_group_createitem(group_id, tool_type, tool_id, new_group = nil)
  request = {
    'group_id' => group_id,
    'new_group' => new_group,
    'tool_type' => tool_type,
    'tool_id' => tool_id
  }

  self.hook("/ad_groups/createitem.xml", "ad_group", request, 'POST')
end

#ad_group_destroy(ad_group_id) ⇒ Object

Affiliates: Destroy an Ad Group



575
576
577
# File 'lib/two_performant.rb', line 575

def ad_group_destroy(ad_group_id)
  self.hook("/ad_groups/#{ad_group_id}.xml", "ad_group", nil, "DELETE")
end

#ad_group_destroyitem(ad_group_id, tool_type, tool_id) ⇒ Object

Affiliates: Delete an Tool from a Group. tooltype is one of ‘txtlink’, ‘txtad’ or ‘banner’.



580
581
582
583
584
585
586
587
# File 'lib/two_performant.rb', line 580

def ad_group_destroyitem(ad_group_id, tool_type, tool_id)
  request = {
    'tool_type' => tool_type,
    'tool_id'   => tool_id
  }

  self.hook("/ad_groups/#{ad_group_id}/destroyitem.xml", "ad_group", request, "DELETE")
end

#ad_group_show(ad_group_id) ⇒ Object

Affiliates: Display information about an Ad Group



558
559
560
# File 'lib/two_performant.rb', line 558

def ad_group_show(ad_group_id)
  self.hook("/ad_groups/#{ad_group_id}.xml", "ad_group", nil, "GET")
end

#ad_groups_listObject

Affiliates: List Ad Groups



553
554
555
# File 'lib/two_performant.rb', line 553

def ad_groups_list
  self.hook("/ad_groups.xml", "ad_group", nil, "GET")
end

#affiliates_listformerchant(campaign_id = nil) ⇒ Object

Merchants: List affiliates approved in campaigns



145
146
147
148
149
150
# File 'lib/two_performant.rb', line 145

def affiliates_listformerchant(campaign_id=nil)
  request = {
    'campaign_id' => campaign_id
  }
  self.hook("/affiliates/listformerchant", "user", request, 'GET')
end

#affiliates_search(search, page = 1, perpage = 6) ⇒ Object

Search for affiliates



134
135
136
137
138
139
140
141
142
# File 'lib/two_performant.rb', line 134

def affiliates_search(search, page=1, perpage=6)
  request = {
    'page'    => page,
    'perpage' => perpage,
    'search'  => search
  }

  self.hook("/affiliates/search", "user", request, 'GET')
end

Merchants: Create a banner



411
412
413
414
415
416
417
418
# File 'lib/two_performant.rb', line 411

def banner_create(campaign_id, banner, banner_picture)
  request = {
    'banner' => banner,
    'banner_picture' => banner_picture
  }

  self.hook("/campaigns/#{campaign_id}/banners.xml", "banner", request, 'POST')
end

Merchants: Destroy a banner



430
431
432
# File 'lib/two_performant.rb', line 430

def banner_destroy(campaign_id, banner_id)
  self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.xml", "banner", nil, 'DELETE')
end

Display information about a banner



394
395
396
# File 'lib/two_performant.rb', line 394

def banner_show(campaign_id, banner_id)
  self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.xml", "banner")
end

Merchants: Update a banner



421
422
423
424
425
426
427
# File 'lib/two_performant.rb', line 421

def banner_update(campaign_id, banner_id, banner)
  request = {
    'banner' => banner
  }

  self.hook("/campaigns/#{campaign_id}/banners/#{banner_id}.xml", "banner", request, 'PUT')
end

#banners_list(campaign_id, page = 1, perpage = 6) ⇒ Object

List banners from a campaign. Displays the first 6 entries by default.



384
385
386
387
388
389
390
391
# File 'lib/two_performant.rb', line 384

def banners_list(campaign_id, page=1, perpage=6)
  request = {
    'page'    => page,
    'perpage' => perpage
  }

  self.hook("/campaigns/#{campaign_id}/banners.xml", "banner", request, 'GET')
end

#banners_search(campaign_id, search, page = 1, perpage = 6, sort = 'date') ⇒ Object

Search for banners in a campaign



399
400
401
402
403
404
405
406
407
408
# File 'lib/two_performant.rb', line 399

def banners_search(campaign_id, search, page=1, perpage=6, sort='date')
  request = {
    'page'    => page,
    'perpage' => perpage,
    'search'  => search,
    'sort'    => sort
  }

  self.hook("/campaigns/#{campaign_id}/banners/search.xml", "banner", request, 'GET')
end

Create a Deep Link. This method was created so it wouldn’t make a request for every Quick Link.

You may need to get some data before using it.


95
96
97
98
99
100
101
102
103
# File 'lib/two_performant.rb', line 95

def campaign_quicklink(campaign_id, aff_code, redirect)
  url = "#{self.host}/events/click?ad_type=quicklink&aff_code=#{aff_code}&unique=#{campaign_id}&redirect_to=#{redirect}"

  if (self.auth_type == :oauth)
    url << "&app=#{self.oauth}"
  end

  url
end

#campaign_show(campaign_id) ⇒ Object

Display public information about a campaign



66
67
68
# File 'lib/two_performant.rb', line 66

def campaign_show(campaign_id)
  self.hook("/campaigns/#{campaign_id}.xml", "campaign")
end

#campaign_showforowner(campaign_id) ⇒ Object

Merchants: Display complete information about a campaign (only available to owner)



81
82
83
# File 'lib/two_performant.rb', line 81

def campaign_showforowner(campaign_id)
  self.hook("/campaigns/#{campaign_id}/showforowner.xml", "campaign")
end

#campaign_update(campaign_id, campaign) ⇒ Object

Merchants: Update a campaign



86
87
88
89
90
91
# File 'lib/two_performant.rb', line 86

def campaign_update(campaign_id, campaign)
  request = {
    'campaign' => campaign
  }
  self.hook("/campaigns/#{campaign_id}.xml", "campaign", request, 'PUT')
end

#campaigns_list(category_id = nil, page = 1, perpage = 6) ⇒ Object

List campaigns. Displays the first 6 entries by default.



44
45
46
47
48
49
50
51
52
# File 'lib/two_performant.rb', line 44

def campaigns_list(category_id=nil, page=1, perpage=6)
  request = {
    'category_id'  => category_id,
    'page'         => page,
    'perpage'      => perpage
  }

  self.hook("/campaigns.xml", "campaign", request, 'GET')
end

#campaigns_listforaffiliateObject

Affiliates: List campaigns which have the logged in user accepted



71
72
73
# File 'lib/two_performant.rb', line 71

def campaigns_listforaffiliate
  self.hook("/campaigns/listforaffiliate.xml", "campaign")
end

#campaigns_listforownerObject

Merchants: List all campaigns created by the logged in user



76
77
78
# File 'lib/two_performant.rb', line 76

def campaigns_listforowner
  self.hook("/campaigns/listforowner.xml", "campaign")
end

#campaigns_search(search, page = 1, perpage = 6) ⇒ Object

Search for campaigns



55
56
57
58
59
60
61
62
63
# File 'lib/two_performant.rb', line 55

def campaigns_search(search, page = 1, perpage = 6)
  request = {
    'page'    => page,
    'perpage' => perpage,
    'search'  => search
  }

  self.hook("/campaigns/search.xml", "campaign", request, 'GET')
end

#commission_show(commission_id) ⇒ Object

Merchant Campaign Owner or Affiliate Commission Owner: Show information about a commission



194
195
196
# File 'lib/two_performant.rb', line 194

def commission_show(commission_id)
  self.hook("/commissions/#{commission_id}.xml", "commission")
end

#commission_update(commission_id, commission) ⇒ Object

Merchant: Update a commission



199
200
201
202
203
204
# File 'lib/two_performant.rb', line 199

def commission_update(commission_id, commission)
  request = {
    'commission' => commission
  }
  self.hook("/commissions/#{commission_id}.xml", "commission", request, 'PUT')
end

#commissions_listforaffiliate(campaign_id, month, year) ⇒ Object

Affiliates: List commissions on campaigns. Month: 01 to 12; Year: 20xx.



183
184
185
186
187
188
189
190
191
# File 'lib/two_performant.rb', line 183

def commissions_listforaffiliate(campaign_id, month, year)
  request = {
    'campaign_id' => campaign_id,
    'month'       => month,
    'year'        => year
  }

  self.hook("/commissions/listforaffiliate.xml", "commission", request, 'GET')
end

#commissions_listformerchant(campaign_id, month, year) ⇒ Object

Merchants: List commissions on campaigns. Month: 01 to 12; Year: 20xx.



172
173
174
175
176
177
178
179
180
# File 'lib/two_performant.rb', line 172

def commissions_listformerchant(campaign_id, month, year)
  request = {
    'campaign_id' => campaign_id,
    'month'       => month,
    'year'        => year
  }

  self.hook("/commissions/listformerchant.xml", "campaign", request, 'GET')
end

#commissions_search(options, campaign_id = nil, month = nil, year = nil, page = 1, perpage = 6) ⇒ Object

Search for commissions. Month: 01 to 12; Year: 20xx. Status: accepted, pending or rejected. nil if empty search.



157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/two_performant.rb', line 157

def commissions_search(options, campaign_id=nil, month=nil, year=nil, page=1, perpage=6)
  request = {
    'campaign_id' => campaign_id,
    'month'       => month,
    'year'        => year,
    'page'        => page,
    'perpage'     => perpage
  }

  request.merge(options)

  self.hook("/commissions/search.xml", "commission", request, 'GET')
end

#feed_create(feed) ⇒ Object

Affiliates: Create a Feed



599
600
601
602
603
604
605
# File 'lib/two_performant.rb', line 599

def feed_create(feed)
  request = {
    'feed' => feed
  }

  self.hook("/feeds.xml", "feed", request, 'POST')
end

#feed_destroy(feed_id) ⇒ Object

Affiliates: Destroy a Feed



618
619
620
# File 'lib/two_performant.rb', line 618

def feed_destroy(feed_id)
  self.hook("/feeds/#{feed_id}.xml", "feed", nil, "DELETE")
end

#feed_update(feed_id, feed) ⇒ Object

Affiliates: Update a Feed



608
609
610
611
612
613
614
# File 'lib/two_performant.rb', line 608

def feed_update(feed_id, feed)
  request = {
    'feed' => feed
  }

  self.hook("/feeds/#{feed_id}.xml", "feed", request, 'PUT')
end

#feeds_listObject

Affiliates: List Feeds



594
595
596
# File 'lib/two_performant.rb', line 594

def feeds_list()
  self.hook("/feeds.xml", "feed", nil, "GET")
end

#hash_to_xml(var, document = nil) ⇒ Object



702
703
704
705
706
707
708
709
710
711
712
713
714
# File 'lib/two_performant.rb', line 702

def hash_to_xml(var, document = nil)
  document = REXML::Document.new if document.nil?

  if var.respond_to? :keys
    var.keys.each do |key|
      hash_to_xml(var[key], document.add_element(key.to_s))
    end
  else
    document.add_text(var.to_s)
  end

  document
end

#hook(path, expected, send = nil, method = 'GET') ⇒ Object

:nodoc:



681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
# File 'lib/two_performant.rb', line 681

def hook(path, expected, send = nil, method = 'GET') #:nodoc:
  params = normalize_params(send, method)

  if self.oauth
    result = self.oauth.send(method.downcase, "/#{version}#{path}", send, params)
  else
    result = self.class.send(method.downcase, "/#{version}#{path}", :body => params)
  end

  # scrap the container
  if result.respond_to? :values
    result.values.first
  else
    result
  end
end

#hook_create(hook, oauth_token_key = 'current') ⇒ Object

Create a Hook



668
669
670
671
672
673
674
# File 'lib/two_performant.rb', line 668

def hook_create(hook, oauth_token_key = 'current')
  request = {
    'hook' => hook
  }

  hook("/oauth_clients/#{oauth_token_key}/hooks.xml", "hook", request, 'POST')
end

#hook_destroy(hook_id, oauth_token_key = 'current') ⇒ Object

Destroy a Hook



677
678
679
# File 'lib/two_performant.rb', line 677

def hook_destroy(hook_id, oauth_token_key = 'current')
  hook("/oauth_clients/#{oauth_token_key}/hooks/#{hook_id}.xml", "hook", nil, 'DELETE')
end

#hooks_list(oauth_token_key = 'current') ⇒ Object

List Hooks



662
663
664
# File 'lib/two_performant.rb', line 662

def hooks_list(oauth_token_key = 'current')
  hook("/oauth_clients/#{oauth_token_key}/hooks.xml", "hook", nil, 'GET')
end

#lead_create(campaign_id, sale) ⇒ Object

Leads


121
122
123
124
125
126
127
# File 'lib/two_performant.rb', line 121

def lead_create(campaign_id, sale)
  request = {
    'lead' => lead
  }

  self.hook("/campaigns/#{campaign_id}/leads.xml", "lead", request, "POST")
end

#message_destroy(message_id) ⇒ Object

Destroy a message



652
653
654
# File 'lib/two_performant.rb', line 652

def message_destroy(message_id)
  self.hook("/messages/#{message_id}.xml", "message", nil, 'DELETE')
end

#message_show(message_id) ⇒ Object

Display information about a message



647
648
649
# File 'lib/two_performant.rb', line 647

def message_show(message_id)
  self.hook("/messages/#{message_id}.xml", "message")
end

#normalize_params(params, method) ⇒ Object



698
699
700
# File 'lib/two_performant.rb', line 698

def normalize_params(params, method)
  hash_to_xml(:request => params).to_s
end

#product_store_createitem(product_store_id, product) ⇒ Object

Merchants: Create a Product Store Product. Product Store Product must be a hash of:

{ "title" => "title",
  "description" => "desc",
  "caption" => "caption",
  "price" => "price(integer in RON)",
  "promoted" => "promoted (0 or 1)",
  "category" => "category",
  "subcategory" => "subcategory",
  "url" => "url",
  "image_url" => "url to image location",
  "prid" => "product id"
}


521
522
523
524
525
526
527
# File 'lib/two_performant.rb', line 521

def product_store_createitem(product_store_id, product)
  request = {
    'product' => product
  }

  self.hook("/product_stores/#{product_store_id}/createitem.xml", "product-store-data", request, 'POST')
end

#product_store_destroy(product_store_id) ⇒ Object

Merchants: Destroy a Product Store



503
504
505
# File 'lib/two_performant.rb', line 503

def product_store_destroy(product_store_id)
  self.hook("/product_stores/#{product_store_id}.xml", "product-store", nil, 'DELETE')
end

#product_store_destroyitem(product_store_id, product_id) ⇒ Object

Merchants: Destroy a product



540
541
542
543
544
545
546
# File 'lib/two_performant.rb', line 540

def product_store_destroyitem(product_store_id, product_id)
  request = {
    'pr_id' => product_id
  }

  self.hook("/product_stores/#{product_store_id}/destroyitem.xml", "product-store-data", request, 'DELETE')
end

#product_store_products_search(campaign_id, search, product_store_id = 'all', category = nil, page = 1, perpage = 6, sort = 'date', uniq_products = false) ⇒ Object

Search for Products in a Product Store



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/two_performant.rb', line 476

def product_store_products_search(campaign_id, search, product_store_id='all', category=nil, page=1, perpage=6, sort='date', uniq_products=false)
  request = {
    'page'          => page,
    'perpage'       => perpage,
    'search'        => search,
    'category'      => category,
    'campaign_id'   => campaign_id,
    'sort'          => sort
  }

  request['uniq_products'] = uniq_products if uniq_products

  product_store_id = 'all' if !product_store_id

  self.hook("/product_stores/#{product_store_id}/searchpr.xml", "product-store-data", request, 'GET')
end

#product_store_show(product_store_id) ⇒ Object

Show a Product Store



448
449
450
# File 'lib/two_performant.rb', line 448

def product_store_show(product_store_id)
  self.hook("/product_stores/#{product_store_id}.xml", "product-store")
end

#product_store_showitem(product_store_id, product_id) ⇒ Object

Show a Product from a Product Store



466
467
468
469
470
471
472
# File 'lib/two_performant.rb', line 466

def product_store_showitem(product_store_id, product_id)
  request = {
    'product_id' => product_id
  }

  self.hook("/product_stores/#{product_store_id}/showitem.xml", "product-store-data", request)
end

#product_store_showitems(product_store_id, category = nil, page = 1, perpage = 6, uniq_products = nil) ⇒ Object

Show Products from a Product Store



453
454
455
456
457
458
459
460
461
462
463
# File 'lib/two_performant.rb', line 453

def product_store_showitems(product_store_id, category=nil, page=1, perpage=6, uniq_products=nil)
  request = {
    'category'      => category,
    'page'          => page,
    'perpage'       => perpage
  }

  request['uniq_products'] = uniq_products if (uniq_products)

  self.hook("/product_stores/#{product_store_id}/showitems.xml", "product-store-data", request)
end

#product_store_update(product_store_id, product_store) ⇒ Object

Merchants: Update a Product Store



494
495
496
497
498
499
500
# File 'lib/two_performant.rb', line 494

def product_store_update(product_store_id, product_store)
  request = {
    'product_store' => product_store
  }

  self.hook("/product_stores/#{product_store_id}.xml", "product-store", request, 'PUT')
end

#product_store_updateitem(product_store_id, product_id, product) ⇒ Object

Merchants: Update a product



530
531
532
533
534
535
536
537
# File 'lib/two_performant.rb', line 530

def product_store_updateitem(product_store_id, product_id, product)
  request = {
    'product'      => product,
    'product_id'   => product_id
  }

  self.hook("/product_stores/#{product_store_id}/updateitem.xml", "product-store-data", request, 'PUT')
end

#product_stores_list(campaign_id) ⇒ Object

List Product Stores from a Campaign



439
440
441
442
443
444
445
# File 'lib/two_performant.rb', line 439

def product_stores_list(campaign_id)
  request = {
    'campaign_id' => campaign_id
  }

  self.hook("/product_stores.xml", "product-store", request)
end

#received_messages_list(page = 1, perpage = 6) ⇒ Object

List received messages. Displays the first 6 entries by default.



627
628
629
630
631
632
633
634
# File 'lib/two_performant.rb', line 627

def received_messages_list(page=1, perpage=6)
  request = {
    'page'      => page,
    'perpage'   => perpage
  }

  self.hook("/messages.xml", "message", nil, "GET")
end

#sale_create(campaign_id, sale) ⇒ Object

Sales


109
110
111
112
113
114
115
# File 'lib/two_performant.rb', line 109

def sale_create(campaign_id, sale)
  request = {
    'sale' => sale
  }

  self.hook("/campaigns/#{campaign_id}/sales.xml", "sale", request, "POST")
end

#sent_messages_list(page = 1, perpage = 6) ⇒ Object

List sent messages. Displays the first 6 entries by default.



637
638
639
640
641
642
643
644
# File 'lib/two_performant.rb', line 637

def sent_messages_list(page=1, perpage=6)
  request = {
    'page'      => page,
    'perpage'   => perpage
  }

  self.hook("/messages/sent.xml", "message", nil, "GET")
end

#site_destroy(site_id) ⇒ Object

Affiliates: Destroy a site



252
253
254
# File 'lib/two_performant.rb', line 252

def site_destroy(site_id)
  self.hook("/sites/#{site_id}.xml", "site", request, 'DELETE')
end

#site_show(site_id) ⇒ Object

Display information about a site



222
223
224
# File 'lib/two_performant.rb', line 222

def site_show(site_id)
  self.hook("/sites/#{site_id}.xml", "site")
end

#site_update(site_id, site) ⇒ Object

Affiliates: Update a site



243
244
245
246
247
248
# File 'lib/two_performant.rb', line 243

def site_update(site_id, site)
  request = {
    'site' => site
  }
  self.hook("/sites/#{site_id}.xml", "site", request, 'PUT')
end

#sites_list(category_id = nil, page = 1, perpage = 6) ⇒ Object

List sites. Displays the first 6 entries by default.



211
212
213
214
215
216
217
218
219
# File 'lib/two_performant.rb', line 211

def sites_list(category_id=nil, page=1, perpage=6)
  request = {
    'category_id' => category_id,
    'page'        => page,
    'perpage'     => perpage
  }

  self.hook("/sites.xml", "site", request)
end

#sites_listforownerObject

Affiliates: List all sites created by the logged in user



238
239
240
# File 'lib/two_performant.rb', line 238

def sites_listforowner
  self.hook("/sites/listforowner.xml", "site")
end

#sites_search(search, page = 1, perpage = 6) ⇒ Object

Search for sites



227
228
229
230
231
232
233
234
235
# File 'lib/two_performant.rb', line 227

def sites_search(search, page=1, perpage=6)
  request = {
    'page'    => page,
    'perpage' => perpage,
    'search'  => search
  }

  self.hook("/sites/search.xml", "site", request, 'GET')
end

#txtad_create(campaign_id, txtad) ⇒ Object

Merchants: Create Text Ad. Txtad must be a hash of:

{ "title" => "title",
  "content" => "content",
  "url" => "url",
  "help" => "help"
},  where "help" is optional


356
357
358
359
360
361
362
# File 'lib/two_performant.rb', line 356

def txtad_create(campaign_id, txtad)
  request = {
    'txtad' => txtad
  }

  self.hook("/campaigns/#{campaign_id}/txtads.xml", "txtad", request, 'POST')
end

#txtad_destroy(campaign_id, txtad_id) ⇒ Object

Merchants: Destroy a text ad



375
376
377
# File 'lib/two_performant.rb', line 375

def txtad_destroy(campaign_id, txtad_id)
  self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.xml", "txtad", nil, 'DELETE')
end

#txtad_show(campaign_id, txtad_id) ⇒ Object

Display information about a text ad



332
333
334
# File 'lib/two_performant.rb', line 332

def txtad_show(campaign_id, txtad_id)
  self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.xml", "txtad")
end

#txtad_update(campaign_id, txtad_id, txtad) ⇒ Object

Merchants: Update a text ad



366
367
368
369
370
371
372
# File 'lib/two_performant.rb', line 366

def txtad_update(campaign_id, txtad_id, txtad)
  request = {
    'txtad' => txtad
  }

  self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.xml", "txtad", request, 'PUT')
end

#txtads_list(campaign_id, page = 1, perpage = 6) ⇒ Object

List text ads from a campaign. Displays the first 6 entries by default.



322
323
324
325
326
327
328
329
# File 'lib/two_performant.rb', line 322

def txtads_list(campaign_id, page=1, perpage=6)
  request = {
    'page'    => page,
    'perpage' => perpage
  }

  self.hook("/campaigns/#{campaign_id}/txtads.xml", "txtad", request, 'GET')
end

#txtads_search(campaign_id, search, page = 1, perpage = 6, sort = 'date') ⇒ Object

Search for text ads in a campaign



337
338
339
340
341
342
343
344
345
346
# File 'lib/two_performant.rb', line 337

def txtads_search(campaign_id, search, page=1, perpage=6, sort='date')
  request = {
    'page'    => page,
    'perpage' => perpage,
    'search'  => search,
    'sort'    => sort
  }

  self.hook("/campaigns/#{campaign_id}/txtads/search.xml", "txtad", request, 'GET')
end

Merchants: Create Text Link.

Txtlink must be a hash of:

{ "title" => "title",
  "url" => "url",
  "help" => "help"
},  where "help" is optional


296
297
298
299
300
301
302
# File 'lib/two_performant.rb', line 296

def txtlink_create(campaign_id, txtlink)
  request = {
    'txtlink' => txtlink
  }

  self.hook("/campaigns/#{campaign_id}/txtlinks.xml", "txtlink", request, 'POST')
end

Merchants: Destroy a text link



313
314
315
# File 'lib/two_performant.rb', line 313

def txtlink_destroy(campaign_id, txtlink_id)
  self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.xml", "txtlink", nil, 'DELETE')
end

Display information about a text link



271
272
273
# File 'lib/two_performant.rb', line 271

def txtlink_show(campaign_id, txtlink_id)
  self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.xml", "txtlink")
end

Merchants: Update a text link



305
306
307
308
309
310
# File 'lib/two_performant.rb', line 305

def txtlink_update(campaign_id, txtlink_id, txtlink)
  request = {
    'txtlink' => txtlink
  }
  self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.xml", "txtlink", request, 'PUT')
end

List text links from a campaign. Displays the first 6 entries by default.



261
262
263
264
265
266
267
268
# File 'lib/two_performant.rb', line 261

def txtlinks_list(campaign_id, page=1, perpage=6)
  request = {
    'page'    => page,
    'perpage' => perpage
  }

  self.hook("/campaigns/#{campaign_id}/txtlinks.xml", "txtlink", request, 'GET')
end

Search for text links in a campaign



276
277
278
279
280
281
282
283
284
285
# File 'lib/two_performant.rb', line 276

def txtlinks_search(campaign_id, search, page=1, perpage=6, sort='date')
  request = {
    'page'    => page,
    'perpage' => perpage,
    'search'  => search,
    'sort'    => sort,
  }

  self.hook("/campaigns/#{campaign_id}/txtlinks/search.xml", "txtlink", request, 'GET')
end

#user_loggedinObject

Display public information about the logged in user



35
36
37
# File 'lib/two_performant.rb', line 35

def user_loggedin
  self.hook("/users/loggedin.xml", "user");
end

#user_show(user_id) ⇒ Object

Users


29
30
31
# File 'lib/two_performant.rb', line 29

def user_show(user_id)
  self.hook("/users/#{user_id}.xml", "user");
end