hasoffers 0.1.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg
2
+ doc
3
+ Manifest
data/CHANGELOG CHANGED
@@ -1,5 +1,8 @@
1
1
  = HasOffers CHANGELOG
2
2
 
3
+ == Version 0.1.2
4
+ * Minor bug fix for running without the has_offers.yml config file
5
+
3
6
  == Version 0.1.1.1
4
7
  * Minor fix to README
5
8
 
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in hasoffers.gemspec
4
+ gemspec
data/README.rdoc CHANGED
@@ -24,11 +24,14 @@ Example usage: (more examples in tests)
24
24
 
25
25
  When running in development mode, by default live api calls are not made. Dummy responses are returned from the DummyResponse class. Set the HAS_OFFERS_LIVE environment variable to "1" to make live api calls when in development mode like so:
26
26
 
27
- env HAS_OFFERS_LIVE=1 script/server
27
+ Rails 2.x: env HAS_OFFERS_LIVE=1 script/server
28
+ Rails 3.x: env HAS_OFFERS_LIVE=1 rails server
28
29
 
29
- If you always want live api calls in development mode then you can add this line to your development.rb file:
30
+ If you always want live api calls in development mode then you can add this line within the config.after_initialize block of your development.rb file:
30
31
 
31
- HasOffers::Base.api_mode = :live
32
+ config.after_initialize do
33
+ HasOffers::Base.api_mode = :live
34
+ end
32
35
 
33
36
 
34
37
  == Tests
data/Rakefile CHANGED
@@ -1,14 +1,2 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'echoe'
4
-
5
- Echoe.new('hasoffers', '0.1.1.1') do |p|
6
- p.description = "Implementation of the HasOffers API for affiliate advertising."
7
- p.url = "http://github.com/ngin/hasoffers"
8
- p.author = "Luke Ludwig"
9
- p.email = "luke.ludwig@tstmedia.com"
10
- p.development_dependencies = []
11
- p.runtime_dependencies = ["yajl-ruby >=0.7.6", "crack >=0.1.6"]
12
- end
13
-
14
- Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/hasoffers.gemspec CHANGED
@@ -1,37 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "hasoffers/version"
2
4
 
3
5
  Gem::Specification.new do |s|
4
- s.name = %q{hasoffers}
5
- s.version = "0.1.1.1"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Luke Ludwig"]
9
- s.date = %q{2010-07-20}
6
+ s.name = "hasoffers"
7
+ s.version = Hasoffers::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Luke Ludwig"]
10
+ s.email = ["luke.ludwig@tstmedia.com"]
11
+ s.homepage = "https://github.com/ngin/hasoffers"
12
+ s.summary = %q{Implementation of the HasOffers API for affiliate advertising.}
10
13
  s.description = %q{Implementation of the HasOffers API for affiliate advertising.}
11
- s.email = %q{luke.ludwig@tstmedia.com}
12
- s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/has_offers_model.rb", "lib/hasoffers.rb", "lib/hasoffers/advertiser.rb", "lib/hasoffers/affiliate.rb", "lib/hasoffers/affiliate_billing.rb", "lib/hasoffers/base.rb", "lib/hasoffers/conversion.rb", "lib/hasoffers/dummy_response.rb", "lib/hasoffers/offer.rb", "lib/hasoffers/report.rb", "lib/hasoffers/response.rb"]
13
- s.files = ["CHANGELOG", "README.rdoc", "Rakefile", "config/has_offers.yml", "lib/has_offers_model.rb", "lib/hasoffers.rb", "lib/hasoffers/advertiser.rb", "lib/hasoffers/affiliate.rb", "lib/hasoffers/affiliate_billing.rb", "lib/hasoffers/base.rb", "lib/hasoffers/conversion.rb", "lib/hasoffers/dummy_response.rb", "lib/hasoffers/offer.rb", "lib/hasoffers/report.rb", "lib/hasoffers/response.rb", "test/advertiser_test.rb", "test/affiliate_billing_test.rb", "test/affiliate_test.rb", "test/conversion_test.rb", "test/offer_test.rb", "test/report_test.rb", "test/test_helper.rb", "Manifest", "hasoffers.gemspec"]
14
- s.homepage = %q{http://github.com/ngin/hasoffers}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Hasoffers", "--main", "README.rdoc"]
16
- s.require_paths = ["lib"]
17
- s.rubyforge_project = %q{hasoffers}
18
- s.rubygems_version = %q{1.3.7}
19
- s.summary = %q{Implementation of the HasOffers API for affiliate advertising.}
20
- s.test_files = ["test/advertiser_test.rb", "test/affiliate_billing_test.rb", "test/affiliate_test.rb", "test/conversion_test.rb", "test/offer_test.rb", "test/report_test.rb", "test/test_helper.rb"]
21
14
 
22
- if s.respond_to? :specification_version then
23
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
- s.specification_version = 3
15
+ s.rubyforge_project = "hasoffers"
25
16
 
26
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- s.add_runtime_dependency(%q<yajl-ruby>, [">= 0.7.6"])
28
- s.add_runtime_dependency(%q<crack>, [">= 0.1.6"])
29
- else
30
- s.add_dependency(%q<yajl-ruby>, [">= 0.7.6"])
31
- s.add_dependency(%q<crack>, [">= 0.1.6"])
32
- end
33
- else
34
- s.add_dependency(%q<yajl-ruby>, [">= 0.7.6"])
35
- s.add_dependency(%q<crack>, [">= 0.1.6"])
36
- end
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
37
21
  end
@@ -4,7 +4,7 @@ module HasOffers
4
4
  class Base
5
5
 
6
6
  BaseUri = 'https://api.hasoffers.com/Api'
7
- @@api_mode = (ENV['RAILS_ENV'] == 'production' or ENV['HAS_OFFERS_LIVE'] == '1') ? :live : :test
7
+ @@api_mode = ((defined?(Rails) and Rails.env.production?) or ENV['HAS_OFFERS_LIVE'] == '1') ? :live : :test
8
8
  @@default_params = nil
9
9
 
10
10
  class << self
@@ -19,6 +19,7 @@ module HasOffers
19
19
  'NetworkId' => config['network_id'],
20
20
  'NetworkToken' => config['api_key']}
21
21
  else
22
+ @@default_params = {}
22
23
  puts "Missing config/has_offers.yml file!"
23
24
  end
24
25
  end
@@ -70,6 +70,10 @@ module HasOffers
70
70
  {"response"=>{"data"=>{"pageCount"=>1, "data"=>[{"Stat"=>{"affiliate_id"=>"1", "clicks"=>"20645"}}], "current"=>50, "count"=>1, "page"=>1}, "errors"=>[], "status"=>1}}
71
71
  end
72
72
 
73
+ def response_for_report_getconversions(params)
74
+ {"response"=>{"data"=>{"pageCount"=>1, "data"=>[{"Stat"=>{"affiliate_id"=>"1", "payout"=>"100.00"}}], "current"=>50, "count"=>1, "page"=>1}, "errors"=>[], "status"=>1}}
75
+ end
76
+
73
77
  end
74
78
 
75
79
  attr_accessor :code, :message, :body, :headers
@@ -19,6 +19,18 @@ module HasOffers
19
19
  response
20
20
  end
21
21
 
22
+ def get_conversions(params)
23
+ response = get_request(Target, 'getConversions', params)
24
+ if response.success?
25
+ # strip out the 'Stat' keys which is just extra clutter
26
+ data = response.data.map do |stat|
27
+ stat["Stat"]
28
+ end
29
+ response.set_data data
30
+ end
31
+ response
32
+ end
33
+
22
34
  end
23
35
 
24
36
  end
@@ -0,0 +1,3 @@
1
+ module Hasoffers
2
+ VERSION = "0.1.2"
3
+ end
data/test/report_test.rb CHANGED
@@ -10,4 +10,12 @@ class ReportTest < Test::Unit::TestCase
10
10
  assert_success response
11
11
  end
12
12
 
13
+ def test_get_conversions
14
+ response = HasOffers::Report.get_conversions(
15
+ 'fields' => ['Stat.payout'],
16
+ 'filters' => ['Stat.affiliate_id' => ['values' => 1, 'conditional' => 'EQUAL_TO']]
17
+ )
18
+ assert_success response
19
+ end
20
+
13
21
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hasoffers
3
3
  version: !ruby/object:Gem::Version
4
- hash: 65
5
- prerelease: false
4
+ hash: 31
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- - 1
11
- version: 0.1.1.1
9
+ - 2
10
+ version: 0.1.2
12
11
  platform: ruby
13
12
  authors:
14
13
  - Luke Ludwig
@@ -16,66 +15,27 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-07-20 00:00:00 -05:00
18
+ date: 2011-03-17 00:00:00 -05:00
20
19
  default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
23
- name: yajl-ruby
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 15
31
- segments:
32
- - 0
33
- - 7
34
- - 6
35
- version: 0.7.6
36
- type: :runtime
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
39
- name: crack
40
- prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- hash: 23
47
- segments:
48
- - 0
49
- - 1
50
- - 6
51
- version: 0.1.6
52
- type: :runtime
53
- version_requirements: *id002
20
+ dependencies: []
21
+
54
22
  description: Implementation of the HasOffers API for affiliate advertising.
55
- email: luke.ludwig@tstmedia.com
23
+ email:
24
+ - luke.ludwig@tstmedia.com
56
25
  executables: []
57
26
 
58
27
  extensions: []
59
28
 
60
- extra_rdoc_files:
61
- - CHANGELOG
62
- - README.rdoc
63
- - lib/has_offers_model.rb
64
- - lib/hasoffers.rb
65
- - lib/hasoffers/advertiser.rb
66
- - lib/hasoffers/affiliate.rb
67
- - lib/hasoffers/affiliate_billing.rb
68
- - lib/hasoffers/base.rb
69
- - lib/hasoffers/conversion.rb
70
- - lib/hasoffers/dummy_response.rb
71
- - lib/hasoffers/offer.rb
72
- - lib/hasoffers/report.rb
73
- - lib/hasoffers/response.rb
29
+ extra_rdoc_files: []
30
+
74
31
  files:
32
+ - .gitignore
75
33
  - CHANGELOG
34
+ - Gemfile
76
35
  - README.rdoc
77
36
  - Rakefile
78
37
  - config/has_offers.yml
38
+ - hasoffers.gemspec
79
39
  - lib/has_offers_model.rb
80
40
  - lib/hasoffers.rb
81
41
  - lib/hasoffers/advertiser.rb
@@ -87,6 +47,7 @@ files:
87
47
  - lib/hasoffers/offer.rb
88
48
  - lib/hasoffers/report.rb
89
49
  - lib/hasoffers/response.rb
50
+ - lib/hasoffers/version.rb
90
51
  - test/advertiser_test.rb
91
52
  - test/affiliate_billing_test.rb
92
53
  - test/affiliate_test.rb
@@ -94,20 +55,13 @@ files:
94
55
  - test/offer_test.rb
95
56
  - test/report_test.rb
96
57
  - test/test_helper.rb
97
- - Manifest
98
- - hasoffers.gemspec
99
58
  has_rdoc: true
100
- homepage: http://github.com/ngin/hasoffers
59
+ homepage: https://github.com/ngin/hasoffers
101
60
  licenses: []
102
61
 
103
62
  post_install_message:
104
- rdoc_options:
105
- - --line-numbers
106
- - --inline-source
107
- - --title
108
- - Hasoffers
109
- - --main
110
- - README.rdoc
63
+ rdoc_options: []
64
+
111
65
  require_paths:
112
66
  - lib
113
67
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -124,15 +78,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
78
  requirements:
125
79
  - - ">="
126
80
  - !ruby/object:Gem::Version
127
- hash: 11
81
+ hash: 3
128
82
  segments:
129
- - 1
130
- - 2
131
- version: "1.2"
83
+ - 0
84
+ version: "0"
132
85
  requirements: []
133
86
 
134
87
  rubyforge_project: hasoffers
135
- rubygems_version: 1.3.7
88
+ rubygems_version: 1.4.2
136
89
  signing_key:
137
90
  specification_version: 3
138
91
  summary: Implementation of the HasOffers API for affiliate advertising.
data/Manifest DELETED
@@ -1,23 +0,0 @@
1
- CHANGELOG
2
- README.rdoc
3
- Rakefile
4
- config/has_offers.yml
5
- lib/has_offers_model.rb
6
- lib/hasoffers.rb
7
- lib/hasoffers/advertiser.rb
8
- lib/hasoffers/affiliate.rb
9
- lib/hasoffers/affiliate_billing.rb
10
- lib/hasoffers/base.rb
11
- lib/hasoffers/conversion.rb
12
- lib/hasoffers/dummy_response.rb
13
- lib/hasoffers/offer.rb
14
- lib/hasoffers/report.rb
15
- lib/hasoffers/response.rb
16
- test/advertiser_test.rb
17
- test/affiliate_billing_test.rb
18
- test/affiliate_test.rb
19
- test/conversion_test.rb
20
- test/offer_test.rb
21
- test/report_test.rb
22
- test/test_helper.rb
23
- Manifest