Class: TwoPerformant
- Inherits:
-
Object
- Object
- TwoPerformant
- Includes:
- HTTParty
- Defined in:
- lib/two_performant.rb,
lib/two_performant/oauth.rb
Defined Under Namespace
Classes: OAuth
Instance Attribute Summary collapse
-
#auth_type ⇒ Object
Returns the value of attribute auth_type.
-
#host ⇒ Object
Returns the value of attribute host.
-
#oauth ⇒ Object
Returns the value of attribute oauth.
-
#oauth_request ⇒ Object
Returns the value of attribute oauth_request.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#user ⇒ Object
Returns the value of attribute user.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#ad_group_createitem(group_id, tool_type, tool_id, new_group = nil) ⇒ Object
Affiliates: Add item to an Ad Group / Crate new Ad Group.
-
#ad_group_destroy(ad_group_id) ⇒ Object
Affiliates: Destroy an Ad Group.
-
#ad_group_destroyitem(ad_group_id, tool_type, tool_id) ⇒ Object
Affiliates: Delete an Tool from a Group.
-
#ad_group_show(ad_group_id) ⇒ Object
Affiliates: Display information about an Ad Group.
-
#ad_groups_list ⇒ Object
Affiliates: List Ad Groups.
-
#affiliates_listformerchant(campaign_id = nil) ⇒ Object
Merchants: List affiliates approved in campaigns.
-
#affiliates_search(search, page = 1, perpage = 6) ⇒ Object
Search for affiliates.
-
#banner_create(campaign_id, banner, banner_picture) ⇒ Object
Merchants: Create a banner.
-
#banner_destroy(campaign_id, banner_id) ⇒ Object
Merchants: Destroy a banner.
-
#banner_show(campaign_id, banner_id) ⇒ Object
Display information about a banner.
-
#banner_update(campaign_id, banner_id, banner) ⇒ Object
Merchants: Update a banner.
-
#banners_list(campaign_id, page = 1, perpage = 6) ⇒ Object
List banners from a campaign.
-
#banners_search(campaign_id, search, page = 1, perpage = 6, sort = 'date') ⇒ Object
Search for banners in a campaign.
-
#campaign_quicklink(campaign_id, aff_code, redirect) ⇒ Object
Create a Deep Link.
-
#campaign_show(campaign_id) ⇒ Object
Display public information about a campaign.
-
#campaign_showforowner(campaign_id) ⇒ Object
Merchants: Display complete information about a campaign (only available to owner).
-
#campaign_update(campaign_id, campaign) ⇒ Object
Merchants: Update a campaign.
-
#campaigns_list(category_id = nil, page = 1, perpage = 6) ⇒ Object
List campaigns.
-
#campaigns_listforaffiliate ⇒ Object
Affiliates: List campaigns which have the logged in user accepted.
-
#campaigns_listforowner ⇒ Object
Merchants: List all campaigns created by the logged in user.
-
#campaigns_search(search, page = 1, perpage = 6) ⇒ Object
Search for campaigns.
-
#commission_show(commission_id) ⇒ Object
Merchant Campaign Owner or Affiliate Commission Owner: Show information about a commission.
-
#commission_update(commission_id, commission) ⇒ Object
Merchant: Update a commission.
-
#commissions_listforaffiliate(campaign_id, month, year) ⇒ Object
Affiliates: List commissions on campaigns.
-
#commissions_listformerchant(campaign_id, month, year) ⇒ Object
Merchants: List commissions on campaigns.
-
#commissions_search(options, campaign_id = nil, month = nil, year = nil, page = 1, perpage = 6) ⇒ Object
Search for commissions.
-
#feed_create(feed) ⇒ Object
Affiliates: Create a Feed.
-
#feed_destroy(feed_id) ⇒ Object
Affiliates: Destroy a Feed.
-
#feed_update(feed_id, feed) ⇒ Object
Affiliates: Update a Feed.
-
#feeds_list ⇒ Object
Affiliates: List Feeds.
-
#hook(path, expected, send = nil, method = 'GET') ⇒ Object
:nodoc:.
-
#hook_create(name, opts, oauth_token_key = 'current') ⇒ Object
Create a Hook.
-
#hook_destroy(hook_id, oauth_token_key = 'current') ⇒ Object
Destroy a Hook.
-
#hooks_list(oauth_token_key = 'current') ⇒ Object
List Hooks.
-
#initialize(auth_type, auth_obj, host) ⇒ TwoPerformant
constructor
A new instance of TwoPerformant.
-
#lead_create(campaign_id, lead) ⇒ Object
Leads ============.
-
#message_destroy(message_id) ⇒ Object
Destroy a message.
-
#message_show(message_id) ⇒ Object
Display information about a message.
-
#product_store_createitem(product_store_id, product) ⇒ Object
Merchants: Create a Product Store Product.
-
#product_store_destroy(product_store_id) ⇒ Object
Merchants: Destroy a Product Store.
-
#product_store_destroyitem(product_store_id, product_id) ⇒ Object
Merchants: Destroy a product.
-
#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.
-
#product_store_show(product_store_id) ⇒ Object
Show a Product Store.
-
#product_store_showitem(product_store_id, product_id) ⇒ Object
Show a Product from a Product Store.
-
#product_store_showitems(product_store_id, category = nil, page = 1, perpage = 6, uniq_products = nil) ⇒ Object
Show Products from a Product Store.
-
#product_store_update(product_store_id, product_store) ⇒ Object
Merchants: Update a Product Store.
-
#product_store_updateitem(product_store_id, product_id, product) ⇒ Object
Merchants: Update a product.
-
#product_stores_list(campaign_id) ⇒ Object
List Product Stores from a Campaign.
-
#received_messages_list(page = 1, perpage = 6) ⇒ Object
List received messages.
-
#sale_create(campaign_id, sale) ⇒ Object
Sales ============.
-
#sent_messages_list(page = 1, perpage = 6) ⇒ Object
List sent messages.
-
#site_destroy(site_id) ⇒ Object
Affiliates: Destroy a site.
-
#site_show(site_id) ⇒ Object
Display information about a site.
-
#site_update(site_id, site) ⇒ Object
Affiliates: Update a site.
-
#sites_list(category_id = nil, page = 1, perpage = 6) ⇒ Object
List sites.
-
#sites_listforowner ⇒ Object
Affiliates: List all sites created by the logged in user.
-
#sites_search(search, page = 1, perpage = 6) ⇒ Object
Search for sites.
-
#txtad_create(campaign_id, txtad) ⇒ Object
Merchants: Create Text Ad.
-
#txtad_destroy(campaign_id, txtad_id) ⇒ Object
Merchants: Destroy a text ad.
-
#txtad_show(campaign_id, txtad_id) ⇒ Object
Display information about a text ad.
-
#txtad_update(campaign_id, txtad_id, txtad) ⇒ Object
Merchants: Update a text ad.
-
#txtads_list(campaign_id, page = 1, perpage = 6) ⇒ Object
List text ads from a campaign.
-
#txtads_search(campaign_id, search, page = 1, perpage = 6, sort = 'date') ⇒ Object
Search for text ads in a campaign.
-
#txtlink_create(campaign_id, txtlink) ⇒ Object
Merchants: Create Text Link.
-
#txtlink_destroy(campaign_id, txtlink_id) ⇒ Object
Merchants: Destroy a text link.
-
#txtlink_show(campaign_id, txtlink_id) ⇒ Object
Display information about a text link.
-
#txtlink_update(campaign_id, txtlink_id, txtlink) ⇒ Object
Merchants: Update a text link.
-
#txtlinks_list(campaign_id, page = 1, perpage = 6) ⇒ Object
List text links from a campaign.
-
#txtlinks_search(campaign_id, search, page = 1, perpage = 6, sort = 'date') ⇒ Object
Search for text links in a campaign.
-
#user_loggedin ⇒ Object
Display public information about the logged in user.
-
#user_show(user_id) ⇒ Object
Users =======.
Constructor Details
#initialize(auth_type, auth_obj, host) ⇒ TwoPerformant
Returns a new instance of TwoPerformant.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/two_performant.rb', line 12 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_type ⇒ Object
Returns the value of attribute auth_type.
10 11 12 |
# File 'lib/two_performant.rb', line 10 def auth_type @auth_type end |
#host ⇒ Object
Returns the value of attribute host.
10 11 12 |
# File 'lib/two_performant.rb', line 10 def host @host end |
#oauth ⇒ Object
Returns the value of attribute oauth.
10 11 12 |
# File 'lib/two_performant.rb', line 10 def oauth @oauth end |
#oauth_request ⇒ Object
Returns the value of attribute oauth_request.
10 11 12 |
# File 'lib/two_performant.rb', line 10 def oauth_request @oauth_request end |
#pass ⇒ Object
Returns the value of attribute pass.
10 11 12 |
# File 'lib/two_performant.rb', line 10 def pass @pass end |
#user ⇒ Object
Returns the value of attribute user.
10 11 12 |
# File 'lib/two_performant.rb', line 10 def user @user end |
#version ⇒ Object
Returns the value of attribute version.
10 11 12 |
# File 'lib/two_performant.rb', line 10 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
564 565 566 567 568 569 570 571 572 573 |
# File 'lib/two_performant.rb', line 564 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.json", "ad_group", request, 'POST') end |
#ad_group_destroy(ad_group_id) ⇒ Object
Affiliates: Destroy an Ad Group
576 577 578 |
# File 'lib/two_performant.rb', line 576 def ad_group_destroy(ad_group_id) self.hook("/ad_groups/#{ad_group_id}.json", "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’.
581 582 583 584 585 586 587 588 |
# File 'lib/two_performant.rb', line 581 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.json", "ad_group", request, "DELETE") end |
#ad_group_show(ad_group_id) ⇒ Object
Affiliates: Display information about an Ad Group
559 560 561 |
# File 'lib/two_performant.rb', line 559 def ad_group_show(ad_group_id) self.hook("/ad_groups/#{ad_group_id}.json", "ad_group", nil, "GET") end |
#ad_groups_list ⇒ Object
Affiliates: List Ad Groups
554 555 556 |
# File 'lib/two_performant.rb', line 554 def ad_groups_list self.hook("/ad_groups.json", "ad_group", nil, "GET") end |
#affiliates_listformerchant(campaign_id = nil) ⇒ Object
Merchants: List affiliates approved in campaigns
146 147 148 149 150 151 |
# File 'lib/two_performant.rb', line 146 def affiliates_listformerchant(campaign_id=nil) request = { 'campaign_id' => campaign_id } self.hook("/affiliates/listformerchant.json", "user", request, 'GET') end |
#affiliates_search(search, page = 1, perpage = 6) ⇒ Object
Search for affiliates
135 136 137 138 139 140 141 142 143 |
# File 'lib/two_performant.rb', line 135 def affiliates_search(search, page=1, perpage=6) request = { 'page' => page, 'perpage' => perpage, 'search' => search } self.hook("/affiliates/search.json", "user", request, 'GET') end |
#banner_create(campaign_id, banner, banner_picture) ⇒ Object
Merchants: Create a banner
412 413 414 415 416 417 418 419 |
# File 'lib/two_performant.rb', line 412 def (campaign_id, , ) request = { 'banner' => , 'banner_picture' => } self.hook("/campaigns/#{campaign_id}/banners.json", "banner", request, 'POST') end |
#banner_destroy(campaign_id, banner_id) ⇒ Object
Merchants: Destroy a banner
431 432 433 |
# File 'lib/two_performant.rb', line 431 def (campaign_id, ) self.hook("/campaigns/#{campaign_id}/banners/#{}.json", "banner", nil, 'DELETE') end |
#banner_show(campaign_id, banner_id) ⇒ Object
Display information about a banner
395 396 397 |
# File 'lib/two_performant.rb', line 395 def (campaign_id, ) self.hook("/campaigns/#{campaign_id}/banners/#{}.json", "banner") end |
#banner_update(campaign_id, banner_id, banner) ⇒ Object
Merchants: Update a banner
422 423 424 425 426 427 428 |
# File 'lib/two_performant.rb', line 422 def (campaign_id, , ) request = { 'banner' => } self.hook("/campaigns/#{campaign_id}/banners/#{}.json", "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.
385 386 387 388 389 390 391 392 |
# File 'lib/two_performant.rb', line 385 def (campaign_id, page=1, perpage=6) request = { 'page' => page, 'perpage' => perpage } self.hook("/campaigns/#{campaign_id}/banners.json", "banner", request, 'GET') end |
#banners_search(campaign_id, search, page = 1, perpage = 6, sort = 'date') ⇒ Object
Search for banners in a campaign
400 401 402 403 404 405 406 407 408 409 |
# File 'lib/two_performant.rb', line 400 def (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.json", "banner", request, 'GET') end |
#campaign_quicklink(campaign_id, aff_code, redirect) ⇒ Object
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.
96 97 98 99 100 101 102 103 104 |
# File 'lib/two_performant.rb', line 96 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
67 68 69 |
# File 'lib/two_performant.rb', line 67 def campaign_show(campaign_id) self.hook("/campaigns/#{campaign_id}.json", "campaign") end |
#campaign_showforowner(campaign_id) ⇒ Object
Merchants: Display complete information about a campaign (only available to owner)
82 83 84 |
# File 'lib/two_performant.rb', line 82 def campaign_showforowner(campaign_id) self.hook("/campaigns/#{campaign_id}/showforowner.json", "campaign") end |
#campaign_update(campaign_id, campaign) ⇒ Object
Merchants: Update a campaign
87 88 89 90 91 92 |
# File 'lib/two_performant.rb', line 87 def campaign_update(campaign_id, campaign) request = { 'campaign' => campaign } self.hook("/campaigns/#{campaign_id}.json", "campaign", request, 'PUT') end |
#campaigns_list(category_id = nil, page = 1, perpage = 6) ⇒ Object
List campaigns. Displays the first 6 entries by default.
45 46 47 48 49 50 51 52 53 |
# File 'lib/two_performant.rb', line 45 def campaigns_list(category_id=nil, page=1, perpage=6) request = { 'category_id' => category_id, 'page' => page, 'perpage' => perpage } self.hook("/campaigns.json", "campaign", request, 'GET') end |
#campaigns_listforaffiliate ⇒ Object
Affiliates: List campaigns which have the logged in user accepted
72 73 74 |
# File 'lib/two_performant.rb', line 72 def campaigns_listforaffiliate self.hook("/campaigns/listforaffiliate.json", "campaign") end |
#campaigns_listforowner ⇒ Object
Merchants: List all campaigns created by the logged in user
77 78 79 |
# File 'lib/two_performant.rb', line 77 def campaigns_listforowner self.hook("/campaigns/listforowner.json", "campaign") end |
#campaigns_search(search, page = 1, perpage = 6) ⇒ Object
Search for campaigns
56 57 58 59 60 61 62 63 64 |
# File 'lib/two_performant.rb', line 56 def campaigns_search(search, page = 1, perpage = 6) request = { 'page' => page, 'perpage' => perpage, 'search' => search } self.hook("/campaigns/search.json", "campaign", request, 'GET') end |
#commission_show(commission_id) ⇒ Object
Merchant Campaign Owner or Affiliate Commission Owner: Show information about a commission
195 196 197 |
# File 'lib/two_performant.rb', line 195 def commission_show(commission_id) self.hook("/commissions/#{commission_id}.json", "commission") end |
#commission_update(commission_id, commission) ⇒ Object
Merchant: Update a commission
200 201 202 203 204 205 |
# File 'lib/two_performant.rb', line 200 def commission_update(commission_id, commission) request = { 'commission' => commission } self.hook("/commissions/#{commission_id}.json", "commission", request, 'PUT') end |
#commissions_listforaffiliate(campaign_id, month, year) ⇒ Object
Affiliates: List commissions on campaigns. Month: 01 to 12; Year: 20xx.
184 185 186 187 188 189 190 191 192 |
# File 'lib/two_performant.rb', line 184 def commissions_listforaffiliate(campaign_id, month, year) request = { 'campaign_id' => campaign_id, 'month' => month, 'year' => year } self.hook("/commissions/listforaffiliate.json", "commission", request, 'GET') end |
#commissions_listformerchant(campaign_id, month, year) ⇒ Object
Merchants: List commissions on campaigns. Month: 01 to 12; Year: 20xx.
173 174 175 176 177 178 179 180 181 |
# File 'lib/two_performant.rb', line 173 def commissions_listformerchant(campaign_id, month, year) request = { 'campaign_id' => campaign_id, 'month' => month, 'year' => year } self.hook("/commissions/listformerchant.json", "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.
158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/two_performant.rb', line 158 def commissions_search(, 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() self.hook("/commissions/search.json", "commission", request, 'GET') end |
#feed_create(feed) ⇒ Object
Affiliates: Create a Feed
600 601 602 603 604 605 606 |
# File 'lib/two_performant.rb', line 600 def feed_create(feed) request = { 'feed' => feed } self.hook("/feeds.json", "feed", request, 'POST') end |
#feed_destroy(feed_id) ⇒ Object
Affiliates: Destroy a Feed
619 620 621 |
# File 'lib/two_performant.rb', line 619 def feed_destroy(feed_id) self.hook("/feeds/#{feed_id}.json", "feed", nil, "DELETE") end |
#feed_update(feed_id, feed) ⇒ Object
Affiliates: Update a Feed
609 610 611 612 613 614 615 |
# File 'lib/two_performant.rb', line 609 def feed_update(feed_id, feed) request = { 'feed' => feed } self.hook("/feeds/#{feed_id}.json", "feed", request, 'PUT') end |
#feeds_list ⇒ Object
Affiliates: List Feeds
595 596 597 |
# File 'lib/two_performant.rb', line 595 def feeds_list() self.hook("/feeds.json", "feed", nil, "GET") end |
#hook(path, expected, send = nil, method = 'GET') ⇒ Object
:nodoc:
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 |
# File 'lib/two_performant.rb', line 683 def hook(path, expected, send = nil, method = 'GET') #:nodoc: if self.oauth result = self.oauth.send(method.downcase, "/#{version}#{path}", send) else result = self.class.send(method.downcase, "/#{version}#{path}", :body => send) result = result.parsed_response end # scrap the container if result.respond_to? :values result.values.first else result end end |
#hook_create(name, opts, oauth_token_key = 'current') ⇒ Object
Create a Hook
669 670 671 672 673 674 675 676 |
# File 'lib/two_performant.rb', line 669 def hook_create(name, opts, oauth_token_key = 'current') request = { 'name' => name, 'opts' => opts, } self.hook("/oauth_clients/#{oauth_token_key}/hooks.json", "client_application_hook", request, 'POST') end |
#hook_destroy(hook_id, oauth_token_key = 'current') ⇒ Object
Destroy a Hook
679 680 681 |
# File 'lib/two_performant.rb', line 679 def hook_destroy(hook_id, oauth_token_key = 'current') self.hook("/oauth_clients/#{oauth_token_key}/hooks/#{hook_id}.json", "client_application_hook", nil, 'DELETE') end |
#hooks_list(oauth_token_key = 'current') ⇒ Object
List Hooks
663 664 665 |
# File 'lib/two_performant.rb', line 663 def hooks_list(oauth_token_key = 'current') self.hook("/oauth_clients/#{oauth_token_key}/hooks.json", "client_application_hook", nil, 'GET') end |
#lead_create(campaign_id, lead) ⇒ Object
Leads
122 123 124 125 126 127 128 |
# File 'lib/two_performant.rb', line 122 def lead_create(campaign_id, lead) request = { 'lead' => lead } self.hook("/campaigns/#{campaign_id}/leads.json", "lead", request, "POST") end |
#message_destroy(message_id) ⇒ Object
Destroy a message
653 654 655 |
# File 'lib/two_performant.rb', line 653 def () self.hook("/messages/#{}.json", "message", nil, 'DELETE') end |
#message_show(message_id) ⇒ Object
Display information about a message
648 649 650 |
# File 'lib/two_performant.rb', line 648 def () self.hook("/messages/#{}.json", "message") 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"
}
522 523 524 525 526 527 528 |
# File 'lib/two_performant.rb', line 522 def product_store_createitem(product_store_id, product) request = { 'product' => product } self.hook("/product_stores/#{product_store_id}/createitem.json", "product-store-data", request, 'POST') end |
#product_store_destroy(product_store_id) ⇒ Object
Merchants: Destroy a Product Store
504 505 506 |
# File 'lib/two_performant.rb', line 504 def product_store_destroy(product_store_id) self.hook("/product_stores/#{product_store_id}.json", "product-store", nil, 'DELETE') end |
#product_store_destroyitem(product_store_id, product_id) ⇒ Object
Merchants: Destroy a product
541 542 543 544 545 546 547 |
# File 'lib/two_performant.rb', line 541 def product_store_destroyitem(product_store_id, product_id) request = { 'pr_id' => product_id } self.hook("/product_stores/#{product_store_id}/destroyitem.json", "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
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/two_performant.rb', line 477 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.json", "product-store-data", request, 'GET') end |
#product_store_show(product_store_id) ⇒ Object
Show a Product Store
449 450 451 |
# File 'lib/two_performant.rb', line 449 def product_store_show(product_store_id) self.hook("/product_stores/#{product_store_id}.json", "product-store") end |
#product_store_showitem(product_store_id, product_id) ⇒ Object
Show a Product from a Product Store
467 468 469 470 471 472 473 |
# File 'lib/two_performant.rb', line 467 def product_store_showitem(product_store_id, product_id) request = { 'product_id' => product_id } self.hook("/product_stores/#{product_store_id}/showitem.json", "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
454 455 456 457 458 459 460 461 462 463 464 |
# File 'lib/two_performant.rb', line 454 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.json", "product-store-data", request) end |
#product_store_update(product_store_id, product_store) ⇒ Object
Merchants: Update a Product Store
495 496 497 498 499 500 501 |
# File 'lib/two_performant.rb', line 495 def product_store_update(product_store_id, product_store) request = { 'product_store' => product_store } self.hook("/product_stores/#{product_store_id}.json", "product-store", request, 'PUT') end |
#product_store_updateitem(product_store_id, product_id, product) ⇒ Object
Merchants: Update a product
531 532 533 534 535 536 537 538 |
# File 'lib/two_performant.rb', line 531 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.json", "product-store-data", request, 'PUT') end |
#product_stores_list(campaign_id) ⇒ Object
List Product Stores from a Campaign
440 441 442 443 444 445 446 |
# File 'lib/two_performant.rb', line 440 def product_stores_list(campaign_id) request = { 'campaign_id' => campaign_id } self.hook("/product_stores.json", "product-store", request) end |
#received_messages_list(page = 1, perpage = 6) ⇒ Object
List received messages. Displays the first 6 entries by default.
628 629 630 631 632 633 634 635 |
# File 'lib/two_performant.rb', line 628 def (page=1, perpage=6) request = { 'page' => page, 'perpage' => perpage } self.hook("/messages.json", "message", nil, "GET") end |
#sale_create(campaign_id, sale) ⇒ Object
Sales
110 111 112 113 114 115 116 |
# File 'lib/two_performant.rb', line 110 def sale_create(campaign_id, sale) request = { 'sale' => sale } self.hook("/campaigns/#{campaign_id}/sales.json", "sale", request, "POST") end |
#sent_messages_list(page = 1, perpage = 6) ⇒ Object
List sent messages. Displays the first 6 entries by default.
638 639 640 641 642 643 644 645 |
# File 'lib/two_performant.rb', line 638 def (page=1, perpage=6) request = { 'page' => page, 'perpage' => perpage } self.hook("/messages/sent.json", "message", nil, "GET") end |
#site_destroy(site_id) ⇒ Object
Affiliates: Destroy a site
253 254 255 |
# File 'lib/two_performant.rb', line 253 def site_destroy(site_id) self.hook("/sites/#{site_id}.json", "site", request, 'DELETE') end |
#site_show(site_id) ⇒ Object
Display information about a site
223 224 225 |
# File 'lib/two_performant.rb', line 223 def site_show(site_id) self.hook("/sites/#{site_id}.json", "site") end |
#site_update(site_id, site) ⇒ Object
Affiliates: Update a site
244 245 246 247 248 249 |
# File 'lib/two_performant.rb', line 244 def site_update(site_id, site) request = { 'site' => site } self.hook("/sites/#{site_id}.json", "site", request, 'PUT') end |
#sites_list(category_id = nil, page = 1, perpage = 6) ⇒ Object
List sites. Displays the first 6 entries by default.
212 213 214 215 216 217 218 219 220 |
# File 'lib/two_performant.rb', line 212 def sites_list(category_id=nil, page=1, perpage=6) request = { 'category_id' => category_id, 'page' => page, 'perpage' => perpage } self.hook("/sites.json", "site", request) end |
#sites_listforowner ⇒ Object
Affiliates: List all sites created by the logged in user
239 240 241 |
# File 'lib/two_performant.rb', line 239 def sites_listforowner self.hook("/sites/listforowner.json", "site") end |
#sites_search(search, page = 1, perpage = 6) ⇒ Object
Search for sites
228 229 230 231 232 233 234 235 236 |
# File 'lib/two_performant.rb', line 228 def sites_search(search, page=1, perpage=6) request = { 'page' => page, 'perpage' => perpage, 'search' => search } self.hook("/sites/search.json", "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
357 358 359 360 361 362 363 |
# File 'lib/two_performant.rb', line 357 def txtad_create(campaign_id, txtad) request = { 'txtad' => txtad } self.hook("/campaigns/#{campaign_id}/txtads.json", "txtad", request, 'POST') end |
#txtad_destroy(campaign_id, txtad_id) ⇒ Object
Merchants: Destroy a text ad
376 377 378 |
# File 'lib/two_performant.rb', line 376 def txtad_destroy(campaign_id, txtad_id) self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.json", "txtad", nil, 'DELETE') end |
#txtad_show(campaign_id, txtad_id) ⇒ Object
Display information about a text ad
333 334 335 |
# File 'lib/two_performant.rb', line 333 def txtad_show(campaign_id, txtad_id) self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.json", "txtad") end |
#txtad_update(campaign_id, txtad_id, txtad) ⇒ Object
Merchants: Update a text ad
367 368 369 370 371 372 373 |
# File 'lib/two_performant.rb', line 367 def txtad_update(campaign_id, txtad_id, txtad) request = { 'txtad' => txtad } self.hook("/campaigns/#{campaign_id}/txtads/#{txtad_id}.json", "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.
323 324 325 326 327 328 329 330 |
# File 'lib/two_performant.rb', line 323 def txtads_list(campaign_id, page=1, perpage=6) request = { 'page' => page, 'perpage' => perpage } self.hook("/campaigns/#{campaign_id}/txtads.json", "txtad", request, 'GET') end |
#txtads_search(campaign_id, search, page = 1, perpage = 6, sort = 'date') ⇒ Object
Search for text ads in a campaign
338 339 340 341 342 343 344 345 346 347 |
# File 'lib/two_performant.rb', line 338 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.json", "txtad", request, 'GET') end |
#txtlink_create(campaign_id, txtlink) ⇒ Object
Merchants: Create Text Link.
Txtlink must be a hash of:
{ "title" => "title",
"url" => "url",
"help" => "help"
}, where "help" is optional
297 298 299 300 301 302 303 |
# File 'lib/two_performant.rb', line 297 def txtlink_create(campaign_id, txtlink) request = { 'txtlink' => txtlink } self.hook("/campaigns/#{campaign_id}/txtlinks.json", "txtlink", request, 'POST') end |
#txtlink_destroy(campaign_id, txtlink_id) ⇒ Object
Merchants: Destroy a text link
314 315 316 |
# File 'lib/two_performant.rb', line 314 def txtlink_destroy(campaign_id, txtlink_id) self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.json", "txtlink", nil, 'DELETE') end |
#txtlink_show(campaign_id, txtlink_id) ⇒ Object
Display information about a text link
272 273 274 |
# File 'lib/two_performant.rb', line 272 def txtlink_show(campaign_id, txtlink_id) self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.json", "txtlink") end |
#txtlink_update(campaign_id, txtlink_id, txtlink) ⇒ Object
Merchants: Update a text link
306 307 308 309 310 311 |
# File 'lib/two_performant.rb', line 306 def txtlink_update(campaign_id, txtlink_id, txtlink) request = { 'txtlink' => txtlink } self.hook("/campaigns/#{campaign_id}/txtlinks/#{txtlink_id}.json", "txtlink", request, 'PUT') end |
#txtlinks_list(campaign_id, page = 1, perpage = 6) ⇒ Object
List text links from a campaign. Displays the first 6 entries by default.
262 263 264 265 266 267 268 269 |
# File 'lib/two_performant.rb', line 262 def txtlinks_list(campaign_id, page=1, perpage=6) request = { 'page' => page, 'perpage' => perpage } self.hook("/campaigns/#{campaign_id}/txtlinks.json", "txtlink", request, 'GET') end |
#txtlinks_search(campaign_id, search, page = 1, perpage = 6, sort = 'date') ⇒ Object
Search for text links in a campaign
277 278 279 280 281 282 283 284 285 286 |
# File 'lib/two_performant.rb', line 277 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.json", "txtlink", request, 'GET') end |
#user_loggedin ⇒ Object
Display public information about the logged in user
36 37 38 |
# File 'lib/two_performant.rb', line 36 def user_loggedin self.hook("/users/loggedin.json", "user"); end |
#user_show(user_id) ⇒ Object
Users
30 31 32 |
# File 'lib/two_performant.rb', line 30 def user_show(user_id) self.hook("/users/#{user_id}.json", "user"); end |