affiliate-window 0.1.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +97 -0
- data/Rakefile +55 -0
- data/lib/affiliate-window.rb +53 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 475bdebb4c9395e8b8482318264dc7345d774de4
|
4
|
+
data.tar.gz: 796a08e3040ac2c071a8c6b0bf654023b0bf0da2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 815cd27fddd94692a4cf8efc6ff6f81998301ee542b8b5a2bd2579437a24cb0d24cca5abb9d272b100822064ff61b7f7115d2237ed94c6aca5780ebebb8fdd0a
|
7
|
+
data.tar.gz: 135346c074f730e95076ab92ea47a6dc384736172307dab0ff2458225493178129dfedf2966a9804c44cb736743b2c890b8bd9a3a537efd51bcaad766deeac89
|
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'savon', '>= 0.9.7'
|
4
|
+
gem 'savon_model', '>= 0.0.0'
|
5
|
+
gem 'hashie', '>= 0.0.0'
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'minitest', '>= 0'
|
9
|
+
gem 'minitest-reporters', '>= 0'
|
10
|
+
gem 'simplecov', '>= 0'
|
11
|
+
gem 'fakeweb', '>= 0'
|
12
|
+
gem 'mocha', '>= 0'
|
13
|
+
gem 'bundler', '~> 1.0.0'
|
14
|
+
gem 'jeweler', '~> 1.6.4'
|
15
|
+
gem 'rcov', '>= 0'
|
16
|
+
gem 'rdoc', '>= 0'
|
17
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 andy.triggs@gmail.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
= affiliate-window
|
2
|
+
|
3
|
+
This Ruby gem contains clients for the AffiliateWindow (http://www.affiliatewindow.com/) suite of APIs and webservices. It currently supports:
|
4
|
+
|
5
|
+
* AffiliateService (SOAP)
|
6
|
+
* Merchant and category meta-data
|
7
|
+
* ShopWindow data feeds.
|
8
|
+
|
9
|
+
|
10
|
+
== Getting started
|
11
|
+
|
12
|
+
Configure an account for the gem to use with all clients. If you're working with Rails, you could do this in an initializer:
|
13
|
+
|
14
|
+
AffiliateWindow.account = AffiliateWindow::Account.new(
|
15
|
+
:user => '12345',
|
16
|
+
:datafeed_password => 'e9db...',
|
17
|
+
:api_key => 'fc70...',
|
18
|
+
:api_password => 'dc3024ea...'
|
19
|
+
)
|
20
|
+
|
21
|
+
|
22
|
+
== Examples
|
23
|
+
|
24
|
+
|
25
|
+
=== AffiliateService
|
26
|
+
|
27
|
+
To get all today's transactions with the AffiliateService SOAP client:
|
28
|
+
|
29
|
+
client = AffiliateWindow::Clients::AffiliateService.new
|
30
|
+
response = client.request(:get_transaction_list) do
|
31
|
+
soap.body = {
|
32
|
+
:d_start_date => Time.now.beginning_of_day,
|
33
|
+
:d_end_date => Time.now.end_of_day,
|
34
|
+
:s_date_type => 'transaction'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
puts r.to_hash
|
39
|
+
|
40
|
+
This outputs something like:
|
41
|
+
|
42
|
+
{:get_transaction_list_response=>{:get_transaction_list_return=>{:transaction=>{:i_id=>"72417910", :s_status=>"pending", :s_type=>"normal", :s_ip=>"0.0.0.0", :b_paid=>false, :i_payment_id=>"0", :i_merchant_id=>"9999", :f_sale_amount=>"318.74", :f_commission_amount=>"9.56", :d_click_date=>"2012-05-26 19:48:30", :d_transaction_date=>"2012-05-26 20:41:03", :s_clickref=>"4fc125b25ef7f37589000ac7", :a_transaction_parts=>{:transaction_part=>{:s_commission_group_name=>"Default Commission", :f_sale_amount=>"318.74", :f_commission_amount=>"9.56", :i_commission=>"3", :s_commission_type=>"percentage"}}}}, :get_transaction_list_count_return=>{:i_rows_returned=>"1", :i_rows_available=>"1"}}}
|
43
|
+
|
44
|
+
|
45
|
+
=== ShopWindow
|
46
|
+
|
47
|
+
To download a product feed CSV for a set of merchants:
|
48
|
+
|
49
|
+
store_to = "tmp/data.csv.zip"
|
50
|
+
client = AffiliateWindow::Clients::ShopWindow.new(:merchant_ids => [1,2,3,4])
|
51
|
+
client.fetch(store_to)
|
52
|
+
|
53
|
+
|
54
|
+
=== Merchants and categories
|
55
|
+
|
56
|
+
Merchants:
|
57
|
+
|
58
|
+
AffiliateWindow::Clients::Merchant.new.each { |merchant| puts merchant.inspect }
|
59
|
+
|
60
|
+
Categories:
|
61
|
+
|
62
|
+
AffiliateWindow::Clients::Category.new.each { |category| puts merchant.inspect }
|
63
|
+
|
64
|
+
|
65
|
+
== Models
|
66
|
+
|
67
|
+
There's currently only a Transaction model, and this is a work in progress.
|
68
|
+
|
69
|
+
|
70
|
+
== ToDo
|
71
|
+
|
72
|
+
* Use VCR for test coverage
|
73
|
+
* Extend test coverage to actually connect to API with real URLs and test responses, to protect against API changes.
|
74
|
+
* Handle 'merchant' user type for AffiliateService authentications.
|
75
|
+
|
76
|
+
|
77
|
+
== In production
|
78
|
+
|
79
|
+
This is in production use on http://www.bikepimp.co.uk. If you're using this, let me know.
|
80
|
+
|
81
|
+
|
82
|
+
== Contributing to affiliate-window
|
83
|
+
|
84
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
85
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
86
|
+
* Fork the project
|
87
|
+
* Start a feature/bugfix branch
|
88
|
+
* Commit and push until you are happy with your contribution
|
89
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
90
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
91
|
+
|
92
|
+
|
93
|
+
== Copyright
|
94
|
+
|
95
|
+
Copyright (c) 2011 andy.triggs@gmail.com. See LICENSE.txt for
|
96
|
+
further details.
|
97
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
require './lib/affiliate-window/version'
|
16
|
+
Jeweler::Tasks.new do |gem|
|
17
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
18
|
+
gem.name = "affiliate-window"
|
19
|
+
gem.homepage = "http://github.com/andyt/affiliate-window"
|
20
|
+
gem.license = "MIT"
|
21
|
+
gem.summary = %Q{Clients and other publisher tools for using Affiliate Window APIs}
|
22
|
+
gem.description = %Q{Affiliate Window provide APIs for interacting with their merchant, product and transaction data via your publisher account. This gem provides clients for those APIs.}
|
23
|
+
gem.email = "andy.triggs@gmail.com"
|
24
|
+
gem.authors = ["andy.triggs@gmail.com"]
|
25
|
+
gem.version = AffiliateWindow::Version::STRING
|
26
|
+
# dependencies defined in Gemfile
|
27
|
+
end
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
Rake::TestTask.new(:test) do |test|
|
32
|
+
test.libs << 'lib' << 'spec'
|
33
|
+
test.pattern = 'spec/**/*_spec.rb'
|
34
|
+
test.verbose = false
|
35
|
+
end
|
36
|
+
|
37
|
+
require 'rcov/rcovtask'
|
38
|
+
Rcov::RcovTask.new do |test|
|
39
|
+
test.libs << 'test'
|
40
|
+
test.pattern = 'test/**/test_*.rb'
|
41
|
+
test.verbose = true
|
42
|
+
test.rcov_opts << '--exclude "gems/*"'
|
43
|
+
end
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
require 'rdoc/task'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "affiliate-window #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module AffiliateWindow
|
2
|
+
|
3
|
+
require 'csv'
|
4
|
+
require 'net/http'
|
5
|
+
require 'savon'
|
6
|
+
require 'savon_model'
|
7
|
+
require 'affiliate-window/version'
|
8
|
+
require 'affiliate-window/helpers/account'
|
9
|
+
require 'affiliate-window/helpers/client'
|
10
|
+
require 'affiliate-window/helpers/csv'
|
11
|
+
require 'affiliate-window/account'
|
12
|
+
require 'affiliate-window/clients/category'
|
13
|
+
require 'affiliate-window/clients/merchant'
|
14
|
+
require 'affiliate-window/clients/affiliate_service'
|
15
|
+
require 'affiliate-window/clients/shop_window'
|
16
|
+
require 'affiliate-window/models/transaction'
|
17
|
+
|
18
|
+
DEFAULT_USER_AGENT = "AffiliateWindow rubygem v#{Version::STRING} (http://github.com/andyt/affiliate-window)"
|
19
|
+
|
20
|
+
def self.account
|
21
|
+
@account
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.account=(account)
|
25
|
+
@account = account
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.user_agent
|
29
|
+
@user_agent || DEFAULT_USER_AGENT
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.user_agent=(string)
|
33
|
+
@user_agent = string
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.fetch(uri, target = Tempfile.new('awin').path)
|
37
|
+
uri = URI(uri)
|
38
|
+
|
39
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
40
|
+
request = Net::HTTP::Get.new uri.request_uri, {'User-Agent' => self.user_agent}
|
41
|
+
|
42
|
+
http.request request do |response|
|
43
|
+
open target, 'wb' do |io|
|
44
|
+
response.read_body do |chunk|
|
45
|
+
io.write chunk
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
target
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: affiliate-window
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- andy.triggs@gmail.com
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2011-11-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: savon
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: savon_model
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hashie
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-reporters
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: fakeweb
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mocha
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: bundler
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.0.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.0.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: jeweler
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.6.4
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.6.4
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rcov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rdoc
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: Affiliate Window provide APIs for interacting with their merchant, product
|
182
|
+
and transaction data via your publisher account. This gem provides clients for those
|
183
|
+
APIs.
|
184
|
+
email: andy.triggs@gmail.com
|
185
|
+
executables: []
|
186
|
+
extensions: []
|
187
|
+
extra_rdoc_files:
|
188
|
+
- LICENSE.txt
|
189
|
+
- README.rdoc
|
190
|
+
files:
|
191
|
+
- ".document"
|
192
|
+
- Gemfile
|
193
|
+
- LICENSE.txt
|
194
|
+
- README.rdoc
|
195
|
+
- Rakefile
|
196
|
+
- lib/affiliate-window.rb
|
197
|
+
homepage: http://github.com/andyt/affiliate-window
|
198
|
+
licenses:
|
199
|
+
- MIT
|
200
|
+
metadata: {}
|
201
|
+
post_install_message:
|
202
|
+
rdoc_options: []
|
203
|
+
require_paths:
|
204
|
+
- lib
|
205
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '0'
|
210
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ">"
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: 1.3.1
|
215
|
+
requirements: []
|
216
|
+
rubyforge_project:
|
217
|
+
rubygems_version: 2.5.0
|
218
|
+
signing_key:
|
219
|
+
specification_version: 3
|
220
|
+
summary: Clients and other publisher tools for using Affiliate Window APIs
|
221
|
+
test_files: []
|