pasrb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/CHANGELOG +4 -1
  2. data/README +17 -6
  3. data/Rakefile +1 -1
  4. data/lib/pas.rb +16 -1
  5. data/pasrb.gemspec +2 -2
  6. data/spec/pas_spec.rb +76 -0
  7. metadata +4 -4
data/CHANGELOG CHANGED
@@ -1 +1,4 @@
1
- v0.1. Initial release
1
+ v0.0.2. Changes:
2
+ * website_offers api method call
3
+
4
+ v0.0.1. Initial release
data/README CHANGED
@@ -1,25 +1,36 @@
1
1
  PAS.rb -- the ruby window to PAS API
2
- ------------------------------------
2
+ ====================================
3
3
 
4
4
  This gem is a client library for querying PAS API.
5
5
  API docs can be found here: http://www.pokeraffiliatesolutions.com/docs/
6
6
 
7
7
  Installation
8
- ------------
8
+ ============
9
9
 
10
10
  * `gem install pasrb`
11
- * `require pasrb`
11
+ * `require pas`
12
12
  *
13
13
  pas_api = PAS.new('YOUR_API_ACCESS_KEY', 'YOUR_API_ACCESS_TOKEN')
14
14
  pas_api.list_all_members # { "SAMPLEUSER" => {:id => 28746, :login => "SAMPLEUSER", ...}, "WTFOMG" => {:id => 28123, :login => "WTFOMG", ...} }
15
15
 
16
+
17
+ Problems
18
+ ========
19
+
20
+ Most methods are safeguarded with rescues. If you have problems struggling with them, or you need explicit error messages, let me know, I'll set up some
21
+ anti-safeguards.
22
+
16
23
 
17
24
  Important notes
18
- ---------------
25
+ ===============
26
+
27
+ That is some minimal subset of PAS API functions (I, for one, don't need most of them),
28
+ if you'd like to modify / add functionality, feel free to fork + pull request.
29
+
30
+ That is a working draft, although I could make use of it, hope it's helpful for ya.
19
31
 
20
- That is some minimal subset of PAS API functions (I, for one, don't need most of them), if you'd like to modify / add functionality, feel free to fork + pull request.
21
32
 
22
33
  License & Authorship
23
- --------------------
34
+ ====================
24
35
 
25
36
  PASrb is written by Mark Markiz Abramov and distributed under terms of MIT license.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'echoe'
2
- Echoe.new('pasrb', '0.0.1') do |g|
2
+ Echoe.new('pasrb', '0.0.2') do |g|
3
3
  g.description = "PokerAffiliateSupport api querying via ruby"
4
4
  g.url = "http://github.com/markiz/pasrb"
5
5
  g.author = "Markiz"
data/lib/pas.rb CHANGED
@@ -90,6 +90,8 @@ class PAS
90
90
  []
91
91
  end
92
92
 
93
+ # Gather stats for specific member for specific period of time
94
+ # Warning: probably not page aware: didn't check that one
93
95
  def get_member_trackers_stats(member_id, start_date, end_date)
94
96
  @member_tracker_stats ||= {}
95
97
  @member_tracker_stats[member_id] ||= {}
@@ -118,7 +120,7 @@ class PAS
118
120
  rescue
119
121
  nil
120
122
  end
121
-
123
+
122
124
  def get_member_tracker_stats(member_id, tracker_id, start_date, end_date)
123
125
  trackers = get_member_trackers_stats(member_id, start_date, end_date)
124
126
  trackers ? trackers[tracker_id] : nil
@@ -126,6 +128,8 @@ class PAS
126
128
  nil
127
129
  end
128
130
 
131
+
132
+ # Creates a member for given website offer
129
133
  def create_member_tracker(member_id, identifier, website_offer_id)
130
134
  new_member_tracker = {"member_tracker" => {"identifier" => identifier, "website_offer_id" => website_offer_id}}
131
135
  response = make_request("/publisher_members/#{member_id}/publisher_member_trackers.xml", "POST", hash_to_xml(new_member_tracker))
@@ -140,6 +144,17 @@ class PAS
140
144
  rescue
141
145
  nil
142
146
  end
147
+
148
+ # Returns array of website offers for given website id
149
+ def website_offers(website_id)
150
+ response = make_request("/website_offers.xml", "GET", {:website_id => website_id})
151
+ response = [xml_to_hash(response)["offers"]["offer"]].flatten
152
+ symbolize_keys(response).map {|o| o[:id] = o[:id].to_i; o }
153
+ rescue
154
+ []
155
+ end
156
+ alias_method :get_website_offers, :website_offers
157
+
143
158
  #protected
144
159
  def xml_to_hash(xml)
145
160
  XmlSimple.xml_in(xml,
data/pasrb.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{pasrb}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Markiz"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = %q{PokerAffiliateSupport api querying via ruby}
11
11
  s.email = %q{markizko@gmail.com}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README", "lib/pas.rb"]
13
- s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "autotest/discover.rb", "lib/pas.rb", "spec/pas_spec.rb", "spec/spec_helper.rb", "pasrb.gemspec"]
13
+ s.files = ["CHANGELOG", "LICENSE", "Manifest", "README", "Rakefile", "autotest/discover.rb", "lib/pas.rb", "pasrb.gemspec", "spec/pas_spec.rb", "spec/spec_helper.rb"]
14
14
  s.homepage = %q{http://github.com/markiz/pasrb}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Pasrb", "--main", "README"]
16
16
  s.require_paths = ["lib"]
data/spec/pas_spec.rb CHANGED
@@ -377,4 +377,80 @@ describe PAS do
377
377
  subject.create_member_tracker(member_id, identifier, website_offer_id).should == nil
378
378
  end
379
379
  end
380
+
381
+ describe "#website_offers" do
382
+ before(:each) {
383
+ stub_request('xml version="1.0" encoding="UTF-8"?>
384
+ <offers>
385
+ <offer>
386
+ <id>4881</id>
387
+ <poker_room_id>6</poker_room_id>
388
+ <poker_room_xml_url>https://publisher.pokeraffiliatesolutions.com/feeds/poker_rooms/absolute-poker.xml</poker_room_xml_url>
389
+ <slug>absolute-poker</slug>
390
+ <image_url>http://publisher.pokeraffiliatesolutions.com/images/offers/lg_6.gif</image_url>
391
+ <icon_url>http://publisher.pokeraffiliatesolutions.com/images/icons/icon_6.gif</icon_url>
392
+ <tny_image_url>http://publisher.pokeraffiliatesolutions.com/images/offers/tny_6.gif</tny_image_url>
393
+ <name>Absolute Poker</name>
394
+ <network>Cereus</network>
395
+ <direct_url>http://publisher.pokeraffiliatesolutions.com/outgoing/4881</direct_url>
396
+ <link>http://www.raketracker.ru/rakeback/absolute-poker.html</link>
397
+ <rb_player>30%</rb_player>
398
+ <stats>Daily</stats>
399
+ <sitebonus>150% up to $500</sitebonus>
400
+ <raketype>contributed</raketype>
401
+ <offer_type>Rakeback</offer_type>
402
+ <signup_code>RAKETRACK</signup_code>
403
+ <account_identifier>Screen Name</account_identifier>
404
+ <show_cookies_message>true</show_cookies_message>
405
+ <requires_preloaded_tracker>false</requires_preloaded_tracker>
406
+ <promotions>
407
+ <promotion>
408
+ <name>Cereus Rake Race</name>
409
+ <feed_url>https://publisher.pokeraffiliatesolutions.com/feeds/promotions/CEREUS.xml?type=rake_race</feed_url>
410
+ </promotion>
411
+ </promotions>
412
+ </offer>
413
+ <offer>
414
+ <id>34835</id>
415
+ <poker_room_id>85</poker_room_id>
416
+ <poker_room_xml_url>https://publisher.pokeraffiliatesolutions.com/feeds/poker_rooms/minted-poker.xml</poker_room_xml_url>
417
+ <slug>minted-poker</slug>
418
+ <image_url>http://publisher.pokeraffiliatesolutions.com/images/offers/lg_85.gif</image_url>
419
+ <icon_url>http://publisher.pokeraffiliatesolutions.com/images/icons/icon_85.gif</icon_url>
420
+ <tny_image_url>http://publisher.pokeraffiliatesolutions.com/images/offers/tny_85.gif</tny_image_url>
421
+ <name>Minted Poker</name>
422
+ <network>Everleaf Gaming</network>
423
+ <direct_url>http://publisher.pokeraffiliatesolutions.com/outgoing/34835</direct_url>
424
+ <link>http://www.raketracker.ru/rakeback/minted-poker.html</link>
425
+ <rb_player>40%</rb_player>
426
+ <stats>Monthly</stats>
427
+ <sitebonus>100% up to $400</sitebonus>
428
+ <raketype>contributed</raketype>
429
+ <offer_type>Rakeback</offer_type>
430
+ <signup_code>TrackRB</signup_code>
431
+ <account_identifier>Nickname</account_identifier>
432
+ <show_cookies_message>true</show_cookies_message>
433
+ <requires_preloaded_tracker>false</requires_preloaded_tracker>
434
+ <promotions>
435
+ <promotion>
436
+ <name>Minted Rake Chase</name>
437
+ <feed_url>https://publisher.pokeraffiliatesolutions.com/feeds/promotions/minted.xml?type=rake_chase</feed_url>
438
+ </promotion>
439
+ </promotions>
440
+ </offer>
441
+ </offers>')
442
+ }
443
+
444
+ it "should gather website offers from api" do
445
+ website_offers = subject.website_offers(12345)
446
+ website_offers[1][:id].should == 34835
447
+ website_offers[1][:slug].should == "minted-poker"
448
+ end
449
+
450
+ it "should return empty array on failure" do
451
+ stub_request("<invalid></xml>")
452
+ subject.website_offers(12345).should == []
453
+ end
454
+ end
455
+
380
456
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pasrb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Markiz
@@ -65,9 +65,9 @@ files:
65
65
  - Rakefile
66
66
  - autotest/discover.rb
67
67
  - lib/pas.rb
68
+ - pasrb.gemspec
68
69
  - spec/pas_spec.rb
69
70
  - spec/spec_helper.rb
70
- - pasrb.gemspec
71
71
  has_rdoc: true
72
72
  homepage: http://github.com/markiz/pasrb
73
73
  licenses: []