hasoffers 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
1
  = HasOffers CHANGELOG
2
2
 
3
+ == Version 0.1.1
4
+ * Changed REMOTE_TEST environment variable to HAS_OFFERS_LIVE
5
+ * Added AffiliateBilling.find_all_invoices_by_ids
6
+
3
7
  == Version 0.1.0
4
8
 
5
9
  Initial framework including support for the following API calls:
data/README.rdoc CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
  This gem hooks into the HasOffers API as documented here: http://www.hasoffers.com/wiki/Category:API
4
4
 
5
+
5
6
  == Install
6
7
 
7
- gem install ngin-hasoffers --source http://gems.github.com
8
+ gem install hasoffers
9
+
8
10
 
9
11
  == Usage
10
12
 
@@ -20,12 +22,28 @@ Example usage: (more examples in tests)
20
22
  'status' => 'active',
21
23
  'expiration_date' => (Date.today + 30).to_s)
22
24
 
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
+
27
+ env HAS_OFFERS_LIVE=1 script/server
28
+
29
+ If you always want live api calls in development mode then you can add this line to your development.rb file:
30
+
31
+ HasOffers::Base.api_mode = :live
32
+
33
+
34
+ == Tests
35
+
23
36
  The tests can be ran in two modes:
24
37
 
25
- 1. Test mode: rake test
26
- * Does not make real API calls. Dummy responses are returned by the DummyResponse class which is also useful in development mode to avoid real API calls
38
+ === Test mode
39
+ * rake test
40
+ Does not make live API calls. Dummy responses are returned by the DummyResponse class which is also used in development mode to avoid live API calls.
41
+
42
+ === Live mode
43
+ * env REMOTE_TEST=1 rake test
44
+ Makes live api calls. Uses the HasOffer credentials in config/has_offers.yml which by default is set to the demo account credentials. HasOffers does not supply a test gateway so be careful to not run these tests against your live HasOffers account.
45
+
27
46
 
28
- 2. Live mode: env REMOTE_TEST=1 rake test
29
- * Makes real api calls. Uses the HasOffer credentials in config/has_offers.yml which by default is set to the demo account credentials. HasOffers does not supply a test gateway so be careful to not run these tests against your live HasOffers account.
47
+ == Contributing
30
48
 
31
- The HasOffers API is huge and this gem implements only a portion of what is available with their API. With this framework in place it should be easy to extend the gem to support API calls that are not yet supported. Please send contributions as git patches.
49
+ The HasOffers API is huge and this gem implements only a portion of what is available with their API. With this framework in place it should be easy to extend the gem for API calls that are not yet supported. Please send contributions as git patches to luke.ludwig@tstmedia.com, or alternatively create a fork and send a git pull request via github.
data/Rakefile CHANGED
@@ -2,13 +2,13 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('hasoffers', '0.1.0') do |p|
5
+ Echoe.new('hasoffers', '0.1.1') do |p|
6
6
  p.description = "Implementation of the HasOffers API for affiliate advertising."
7
7
  p.url = "http://github.com/ngin/hasoffers"
8
8
  p.author = "Luke Ludwig"
9
9
  p.email = "luke.ludwig@tstmedia.com"
10
10
  p.development_dependencies = []
11
- p.runtime_dependencies = ["yajl-ruby >= 0.7.6", "crack >= 0.1.6"]
11
+ p.runtime_dependencies = ["yajl-ruby >=0.7.6", "crack >=0.1.6"]
12
12
  end
13
13
 
14
14
  Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/hasoffers.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{hasoffers}
5
- s.version = "0.1.0"
5
+ s.version = "0.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Luke Ludwig"]
9
- s.date = %q{2010-07-13}
9
+ s.date = %q{2010-07-20}
10
10
  s.description = %q{Implementation of the HasOffers API for affiliate advertising.}
11
11
  s.email = %q{luke.ludwig@tstmedia.com}
12
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"]
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Hasoffers", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
17
17
  s.rubyforge_project = %q{hasoffers}
18
- s.rubygems_version = %q{1.3.5}
18
+ s.rubygems_version = %q{1.3.7}
19
19
  s.summary = %q{Implementation of the HasOffers API for affiliate advertising.}
20
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
21
 
@@ -23,15 +23,15 @@ Gem::Specification.new do |s|
23
23
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
24
  s.specification_version = 3
25
25
 
26
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
- s.add_runtime_dependency(%q<yajl-ruby>, [">= 0", "= 0.7.6"])
28
- s.add_runtime_dependency(%q<crack>, [">= 0", "= 0.1.6"])
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
29
  else
30
- s.add_dependency(%q<yajl-ruby>, [">= 0", "= 0.7.6"])
31
- s.add_dependency(%q<crack>, [">= 0", "= 0.1.6"])
30
+ s.add_dependency(%q<yajl-ruby>, [">= 0.7.6"])
31
+ s.add_dependency(%q<crack>, [">= 0.1.6"])
32
32
  end
33
33
  else
34
- s.add_dependency(%q<yajl-ruby>, [">= 0", "= 0.7.6"])
35
- s.add_dependency(%q<crack>, [">= 0", "= 0.1.6"])
34
+ s.add_dependency(%q<yajl-ruby>, [">= 0.7.6"])
35
+ s.add_dependency(%q<crack>, [">= 0.1.6"])
36
36
  end
37
37
  end
@@ -23,6 +23,19 @@ module HasOffers
23
23
  response
24
24
  end
25
25
 
26
+ def find_all_invoices_by_ids(ids, params = {})
27
+ params['ids'] = ids
28
+ response = get_request(Target, 'findAllInvoicesByIds', params)
29
+ if response.success?
30
+ # strip out the clutter
31
+ data = response.data.map do |invoice|
32
+ invoice[1].values.first
33
+ end
34
+ response.set_data data
35
+ end
36
+ response
37
+ end
38
+
26
39
  def create_invoice(data, return_object = false)
27
40
  requires!(data, %w[affiliate_id start_date end_date status])
28
41
  params = build_data(data, return_object)
@@ -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['REMOTE_TEST'] == '1') ? :live : :test
7
+ @@api_mode = (ENV['RAILS_ENV'] == 'production' or ENV['HAS_OFFERS_LIVE'] == '1') ? :live : :test
8
8
  @@default_params = nil
9
9
 
10
10
  class << self
@@ -31,7 +31,7 @@ module HasOffers
31
31
  @@api_mode == :live
32
32
  end
33
33
 
34
- def set_api_mode(mode)
34
+ def api_mode=(mode)
35
35
  @@api_mode = mode
36
36
  end
37
37
 
@@ -62,6 +62,10 @@ module HasOffers
62
62
  {"response" => { "status" => 1, "data" => {"1" => {"AffiliateInvoice" => {"id" => "1", "affiliate_id" => "2", "datetime" => "2009-06-02 20:14:05", "start_date" => "2009-06-01", "end_date" => "2009-06-02", "is_paid" => "1", "memo" => "asdf", "status" => "active", "notes" => "", "receipt_id" => nil, "currency" => "USD", "amount" => "12.00", "conversions" => "12" }}}, "errors" => []}}
63
63
  end
64
64
 
65
+ def response_for_affiliatebilling_findallinvoicesbyids(params)
66
+ {"response" => { "status" => 1, "data" => {"1" => {"AffiliateInvoice" => {"id" => "1", "affiliate_id" => "2", "datetime" => "2009-06-02 20:14:05", "start_date" => "2009-06-01", "end_date" => "2009-06-02", "is_paid" => "1", "memo" => "asdf", "status" => "active", "notes" => "", "receipt_id" => nil, "currency" => "USD", "amount" => "12.00", "conversions" => "12" }}}, "errors" => []}}
67
+ end
68
+
65
69
  def response_for_report_getstats(params)
66
70
  {"response"=>{"data"=>{"pageCount"=>1, "data"=>[{"Stat"=>{"affiliate_id"=>"1", "clicks"=>"20645"}}], "current"=>50, "count"=>1, "page"=>1}, "errors"=>[], "status"=>1}}
67
71
  end
@@ -22,6 +22,13 @@ class AffiliateBillingTest < Test::Unit::TestCase
22
22
  assert response.data.length > 0, "No invoices were returned."
23
23
  end
24
24
 
25
+ def test_find_all_invoices_by_ids
26
+ response = HasOffers::AffiliateBilling.find_all_invoices_by_ids([7,11]
27
+ )
28
+ assert_success response
29
+ assert response.data.length > 0, "No invoices were returned."
30
+ end
31
+
25
32
  def good_params
26
33
  {'affiliate_id' => '1',
27
34
  'start_date' => '2010-01-01',
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hasoffers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
5
11
  platform: ruby
6
12
  authors:
7
13
  - Luke Ludwig
@@ -9,35 +15,41 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-07-13 00:00:00 -05:00
18
+ date: 2010-07-20 00:00:00 -05:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: yajl-ruby
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
23
- version: "0"
24
- - - "="
25
- - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 0
32
+ - 7
33
+ - 6
26
34
  version: 0.7.6
27
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
28
37
  - !ruby/object:Gem::Dependency
29
38
  name: crack
30
- type: :runtime
31
- version_requirement:
32
- version_requirements: !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
33
42
  requirements:
34
43
  - - ">="
35
44
  - !ruby/object:Gem::Version
36
- version: "0"
37
- - - "="
38
- - !ruby/object:Gem::Version
45
+ hash: 23
46
+ segments:
47
+ - 0
48
+ - 1
49
+ - 6
39
50
  version: 0.1.6
40
- version:
51
+ type: :runtime
52
+ version_requirements: *id002
41
53
  description: Implementation of the HasOffers API for affiliate advertising.
42
54
  email: luke.ludwig@tstmedia.com
43
55
  executables: []
@@ -98,21 +110,28 @@ rdoc_options:
98
110
  require_paths:
99
111
  - lib
100
112
  required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
101
114
  requirements:
102
115
  - - ">="
103
116
  - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
104
120
  version: "0"
105
- version:
106
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
+ none: false
107
123
  requirements:
108
124
  - - ">="
109
125
  - !ruby/object:Gem::Version
126
+ hash: 11
127
+ segments:
128
+ - 1
129
+ - 2
110
130
  version: "1.2"
111
- version:
112
131
  requirements: []
113
132
 
114
133
  rubyforge_project: hasoffers
115
- rubygems_version: 1.3.5
134
+ rubygems_version: 1.3.7
116
135
  signing_key:
117
136
  specification_version: 3
118
137
  summary: Implementation of the HasOffers API for affiliate advertising.