adcloud 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +69 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +50 -0
- data/LICENSE.txt +20 -0
- data/README.md +221 -0
- data/RELEASE_NOTES.md +14 -0
- data/Rakefile +8 -0
- data/adcloud.gemspec +27 -0
- data/lib/adcloud.rb +62 -0
- data/lib/adcloud/advertisement.rb +28 -0
- data/lib/adcloud/api_error.rb +33 -0
- data/lib/adcloud/authentication.rb +24 -0
- data/lib/adcloud/campaign.rb +69 -0
- data/lib/adcloud/connection.rb +46 -0
- data/lib/adcloud/customer.rb +9 -0
- data/lib/adcloud/entity.rb +84 -0
- data/lib/adcloud/exception_raiser.rb +22 -0
- data/lib/adcloud/media_file.rb +10 -0
- data/lib/adcloud/product.rb +10 -0
- data/lib/adcloud/report.rb +28 -0
- data/lib/adcloud/report_entry.rb +48 -0
- data/lib/adcloud/response_error_handler.rb +23 -0
- data/lib/adcloud/topic.rb +19 -0
- data/lib/adcloud/topic_discount.rb +16 -0
- data/lib/adcloud/version.rb +3 -0
- data/lib/adcloud/webhook.rb +35 -0
- data/lib/adcloud/webhook_config.rb +18 -0
- data/lib/adcloud/webhook_event.rb +18 -0
- data/test/adcloud/advertisement_test.rb +11 -0
- data/test/adcloud/authentication_test.rb +58 -0
- data/test/adcloud/campaign_test.rb +54 -0
- data/test/adcloud/connection_test.rb +78 -0
- data/test/adcloud/customer_test.rb +6 -0
- data/test/adcloud/entity_test.rb +159 -0
- data/test/adcloud/media_file_test.rb +7 -0
- data/test/adcloud/product_test.rb +5 -0
- data/test/adcloud/report_test.rb +34 -0
- data/test/adcloud/topic_test.rb +14 -0
- data/test/adcloud/webhook_event_test.rb +19 -0
- data/test/adcloud/webhook_test.rb +62 -0
- data/test/adcloud_test.rb +47 -0
- data/test/test_helper.rb +23 -0
- metadata +251 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
|
15
|
+
# jeweler generated
|
16
|
+
pkg
|
17
|
+
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
19
|
+
#
|
20
|
+
# * Create a file at ~/.gitignore
|
21
|
+
# * Include files you want ignored
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
23
|
+
#
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
26
|
+
#
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
28
|
+
#
|
29
|
+
# For MacOS:
|
30
|
+
#
|
31
|
+
#.DS_Store
|
32
|
+
|
33
|
+
# For TextMate
|
34
|
+
#*.tmproj
|
35
|
+
#tmtags
|
36
|
+
|
37
|
+
# For emacs:
|
38
|
+
#*~
|
39
|
+
#\#*
|
40
|
+
#.\#*
|
41
|
+
|
42
|
+
# For vim:
|
43
|
+
#*.swp
|
44
|
+
|
45
|
+
# For redcar:
|
46
|
+
#.redcar
|
47
|
+
|
48
|
+
# For rubinius:
|
49
|
+
#*.rbc
|
50
|
+
=======
|
51
|
+
*.gem
|
52
|
+
*.rbc
|
53
|
+
.bundle
|
54
|
+
.config
|
55
|
+
coverage
|
56
|
+
InstalledFiles
|
57
|
+
lib/bundler/man
|
58
|
+
pkg
|
59
|
+
rdoc
|
60
|
+
spec/reports
|
61
|
+
test/tmp
|
62
|
+
test/version_tmp
|
63
|
+
tmp
|
64
|
+
|
65
|
+
# YARD artifacts
|
66
|
+
.yardoc
|
67
|
+
_yardoc
|
68
|
+
doc/
|
69
|
+
TestCalls
|
data/.travis.yml
ADD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8zU3pjMy9jR0lNN2h6VWJhN1JPbzVqUXE2M2V2ZnJhTFk5dHQ4aUZXNHNtQXlneDlJSUYwV1cwMAplaytBZWRiUHVqR0RadDVFcjdRbzE3WnpueE9xZFdwYUpseC9GcFlsMzZ1QWpDUlUvOVprCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
adcloud (0.1.0)
|
5
|
+
activesupport (~> 3.2.6)
|
6
|
+
faraday
|
7
|
+
faraday_middleware
|
8
|
+
virtus
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (3.2.6)
|
14
|
+
i18n (~> 0.6)
|
15
|
+
multi_json (~> 1.0)
|
16
|
+
addressable (2.3.2)
|
17
|
+
backports (2.6.2)
|
18
|
+
crack (0.3.1)
|
19
|
+
faraday (0.8.1)
|
20
|
+
multipart-post (~> 1.1)
|
21
|
+
faraday_middleware (0.8.8)
|
22
|
+
faraday (>= 0.7.4, < 0.9)
|
23
|
+
i18n (0.6.0)
|
24
|
+
metaclass (0.0.1)
|
25
|
+
minitest (3.4.0)
|
26
|
+
mocha (0.12.4)
|
27
|
+
metaclass (~> 0.0.1)
|
28
|
+
multi_json (1.3.6)
|
29
|
+
multipart-post (1.1.5)
|
30
|
+
rake (0.9.2.2)
|
31
|
+
simplecov (0.6.4)
|
32
|
+
multi_json (~> 1.0)
|
33
|
+
simplecov-html (~> 0.5.3)
|
34
|
+
simplecov-html (0.5.3)
|
35
|
+
virtus (0.5.1)
|
36
|
+
backports (~> 2.6.1)
|
37
|
+
webmock (1.8.9)
|
38
|
+
addressable (>= 2.2.7)
|
39
|
+
crack (>= 0.1.7)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
adcloud!
|
46
|
+
minitest (~> 3.4.0)
|
47
|
+
mocha (~> 0.12.4)
|
48
|
+
rake
|
49
|
+
simplecov
|
50
|
+
webmock
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Jan Kus
|
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.md
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
adcloud-api
|
2
|
+
===========
|
3
|
+
|
4
|
+
A little wrapper for the adcloud API. It provides all the required classes and
|
5
|
+
configuration options to access the adcloud API and interact with it. Moreover,
|
6
|
+
you can use it to post-process incoming callbacks (implemented via http webhooks).
|
7
|
+
|
8
|
+
This is the official ruby gem for the adcloud API. If you have any problems or
|
9
|
+
requests please contact api@adcloud.com
|
10
|
+
|
11
|
+
__Warning__
|
12
|
+
|
13
|
+
* API does not yet support Campaign Updates
|
14
|
+
* API might change until it goes public, so expect changes!
|
15
|
+
|
16
|
+
|
17
|
+
Installation
|
18
|
+
------------
|
19
|
+
|
20
|
+
In order to install the gem, run
|
21
|
+
|
22
|
+
gem install adcloud-api
|
23
|
+
|
24
|
+
or if you are using bundler, add the following to your Gemfile
|
25
|
+
|
26
|
+
gem 'adcloud-api'
|
27
|
+
|
28
|
+
|
29
|
+
Configuration
|
30
|
+
-------------
|
31
|
+
|
32
|
+
You always need to provide your adcloud client id and secret. Contact
|
33
|
+
info@adcloud.com to get an account and credentials.
|
34
|
+
|
35
|
+
Adcloud.configure do |c|
|
36
|
+
c.client_id = '1234567890'
|
37
|
+
c.client_secret = '09876543'
|
38
|
+
end
|
39
|
+
|
40
|
+
Enable debug mode to log http requests and setup logging
|
41
|
+
|
42
|
+
Adcloud.configure do |c|
|
43
|
+
c.debug = true # default false
|
44
|
+
c.logger = Logger.new # defaults to STDOUT or Rails.logger if available
|
45
|
+
end
|
46
|
+
|
47
|
+
Authentication
|
48
|
+
--------------
|
49
|
+
|
50
|
+
Usually you wont need to do this, as the gem authenticates against the api by
|
51
|
+
itself. But if you wanna play with the API yourself, this might come in handy to
|
52
|
+
get a valid auth token.
|
53
|
+
|
54
|
+
adcloud_auth = Adcloud::Authentication.new(
|
55
|
+
:client_id => Adcloud.config.client_id,
|
56
|
+
:client_secret => Adcloud.config.client_secret)
|
57
|
+
adcloud_auth.authenticate!
|
58
|
+
adcloud_auth.token # returns an oauth access_token
|
59
|
+
|
60
|
+
Advertisement
|
61
|
+
-------------
|
62
|
+
|
63
|
+
Read all advertisement objects
|
64
|
+
|
65
|
+
Adcloud::Advertisement.all
|
66
|
+
|
67
|
+
Filtering
|
68
|
+
|
69
|
+
Adcloud::Advertisement.all({ active: true })
|
70
|
+
|
71
|
+
Available filter keys are:
|
72
|
+
|
73
|
+
* campaign
|
74
|
+
* product
|
75
|
+
* active
|
76
|
+
|
77
|
+
Pagination
|
78
|
+
|
79
|
+
Adcloud::Advertisement.all(nil, 2, 10)
|
80
|
+
|
81
|
+
Read/Find a advertisement
|
82
|
+
|
83
|
+
Adcloud::Advertisement.find_by_id(42)
|
84
|
+
|
85
|
+
Create/Write a new advertisement
|
86
|
+
|
87
|
+
advertisement = Adcloud::Advertisement.new({ your: 'attributes' })
|
88
|
+
advertisement.create
|
89
|
+
|
90
|
+
Campaign
|
91
|
+
--------
|
92
|
+
|
93
|
+
### Fetch campaigns list
|
94
|
+
|
95
|
+
Read all campaigns which belong to your account
|
96
|
+
|
97
|
+
Adcloud::Campaign.all
|
98
|
+
|
99
|
+
If the list gets too long, you can paginate and filter it. Provide a hash of
|
100
|
+
filter criteria as the first parameter:
|
101
|
+
|
102
|
+
Adcloud::Campaign.all({ filter_key: 'filter value' })
|
103
|
+
|
104
|
+
Available filter keys are:
|
105
|
+
|
106
|
+
company, country, customer, delivery_type, destination, managed, name,
|
107
|
+
product, status, type
|
108
|
+
|
109
|
+
Optionally set the page and page size as second and third parameter
|
110
|
+
|
111
|
+
Adcloud::Campaign.all({ status: 'online' })
|
112
|
+
Adcloud::Campaign.all({ status: 'online' }, 2, 10)
|
113
|
+
|
114
|
+
Creating a New Campaign Object
|
115
|
+
|
116
|
+
campaign = Adcloud::Campaign.new({ your: 'attributes' })
|
117
|
+
|
118
|
+
### Read a single campaign
|
119
|
+
|
120
|
+
Adcloud::Campaign.find_by_id(42)
|
121
|
+
|
122
|
+
### Validate a campaign
|
123
|
+
|
124
|
+
campaign = Adcloud::Campaign.new({ your: 'attributes' })
|
125
|
+
campaign.valid? # returns true/false
|
126
|
+
|
127
|
+
### Create a new campaign
|
128
|
+
|
129
|
+
Create a campaign by calling ```create``` on an initialized object. It will
|
130
|
+
return true when the campaign was created successfully and sets the id on the
|
131
|
+
object. Otherwise ```errors``` would provide you with the reason why it failed.
|
132
|
+
|
133
|
+
campaign = Adcloud::Campaign.new({ your: 'attributes' })
|
134
|
+
campaign.create # returns a boolean
|
135
|
+
campaign.errors
|
136
|
+
|
137
|
+
Alternatively, you could use the static method
|
138
|
+
|
139
|
+
campaign = Adcloud::Campaign.create({ your: 'attributes' })
|
140
|
+
|
141
|
+
Customer
|
142
|
+
--------
|
143
|
+
|
144
|
+
Get all customers
|
145
|
+
|
146
|
+
Customer.all
|
147
|
+
|
148
|
+
Get a customer object
|
149
|
+
|
150
|
+
Customer.find(42)
|
151
|
+
|
152
|
+
Create a customer object
|
153
|
+
|
154
|
+
Customer.create({ name: 'AdKlaus' })
|
155
|
+
|
156
|
+
Media Files
|
157
|
+
-----------
|
158
|
+
|
159
|
+
Create a new media file with
|
160
|
+
|
161
|
+
Adcloud::MediaFile.create(
|
162
|
+
uploaded_file: 'http://yourhost.com/yourfile.ext'
|
163
|
+
product_id: 123,
|
164
|
+
ad_id: 456,
|
165
|
+
flash: false,
|
166
|
+
display: false
|
167
|
+
end
|
168
|
+
|
169
|
+
where ```uploaded_file``` is a publicly accessible url to an image file.
|
170
|
+
|
171
|
+
Product
|
172
|
+
-------
|
173
|
+
|
174
|
+
Get all products
|
175
|
+
|
176
|
+
Adcloud::Product.all
|
177
|
+
|
178
|
+
Get a single product
|
179
|
+
|
180
|
+
Adcloud::Product.find(123)
|
181
|
+
|
182
|
+
Create a new product
|
183
|
+
|
184
|
+
product = Adcloud::Product.create(name: 'Product name', customer_id: 123)
|
185
|
+
# or
|
186
|
+
product = Adcloud::Product.new(name: 'Product name', customer_id: 123)
|
187
|
+
if product.create
|
188
|
+
# ...
|
189
|
+
else
|
190
|
+
puts product.errors.inspect
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
Topic
|
195
|
+
-----
|
196
|
+
|
197
|
+
Read all topics
|
198
|
+
|
199
|
+
topics = Adcloud::Topic.all
|
200
|
+
|
201
|
+
And a single topic
|
202
|
+
|
203
|
+
topic = Adcloud::Topic.find(123)
|
204
|
+
|
205
|
+
Topics provide their name in various languages
|
206
|
+
|
207
|
+
topic.names['en_gb'] # english name
|
208
|
+
topic.names['de_de'] # german name
|
209
|
+
...
|
210
|
+
|
211
|
+
Prices, reach, discounts are provided for each country
|
212
|
+
|
213
|
+
topic.discounts['gb'] # Values for England
|
214
|
+
topic.discounts['de'] # Values for Germany
|
215
|
+
|
216
|
+
Authors
|
217
|
+
-------
|
218
|
+
|
219
|
+
[Jan Kus](http://github.com/koos),
|
220
|
+
[Maximilian Schulz](http://github.com/namxam),
|
221
|
+
[Michael Bumann](http://github.com/bumi)
|
data/RELEASE_NOTES.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Release Notes
|
2
|
+
=============
|
3
|
+
|
4
|
+
### 0.7 _First public release_
|
5
|
+
|
6
|
+
* Enable configuration
|
7
|
+
* Find and create advertisements
|
8
|
+
* Find, create, validate campaigns
|
9
|
+
* Find and create customers
|
10
|
+
* Create media files
|
11
|
+
* Find and create products
|
12
|
+
* Fetch report data by day
|
13
|
+
* Find and create topics
|
14
|
+
* Parse webhooks and call configured code blocks
|
data/Rakefile
ADDED
data/adcloud.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/adcloud/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Jan Kus', 'Max Schulz']
|
6
|
+
gem.email = ['jan@railslove.com', 'm.schulz@kulturfluss.de']
|
7
|
+
gem.summary = %Q{Wrapper for adcloud API}
|
8
|
+
gem.description = %Q{This is the official adcloud API gem. If you have any problems or requests please contact api@adcloud.com.}
|
9
|
+
gem.homepage = 'http://adcloud.com/'
|
10
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
11
|
+
gem.files = `git ls-files`.split("\n")
|
12
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
gem.name = 'adcloud'
|
14
|
+
gem.require_paths = ['lib']
|
15
|
+
gem.version = Adcloud::VERSION
|
16
|
+
|
17
|
+
gem.add_development_dependency 'minitest', '~> 3.4.0'
|
18
|
+
gem.add_development_dependency 'mocha', '~> 0.12.4'
|
19
|
+
gem.add_development_dependency 'rake'
|
20
|
+
gem.add_development_dependency 'simplecov'
|
21
|
+
gem.add_development_dependency 'webmock'
|
22
|
+
|
23
|
+
gem.add_dependency 'virtus'
|
24
|
+
gem.add_dependency 'activesupport', "~>3.2.6"
|
25
|
+
gem.add_dependency 'faraday'
|
26
|
+
gem.add_dependency 'faraday_middleware'
|
27
|
+
end
|
data/lib/adcloud.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'adcloud/response_error_handler'
|
4
|
+
require 'logger'
|
5
|
+
require 'active_support/configurable'
|
6
|
+
require 'active_support/inflector'
|
7
|
+
require 'virtus'
|
8
|
+
|
9
|
+
module Adcloud
|
10
|
+
|
11
|
+
include ActiveSupport::Configurable
|
12
|
+
|
13
|
+
autoload :Ad, "adcloud/ad"
|
14
|
+
autoload :Advertisement, "adcloud/advertisement"
|
15
|
+
autoload :ApiError, "adcloud/api_error"
|
16
|
+
autoload :Authentication, "adcloud/authentication"
|
17
|
+
autoload :Campaign, "adcloud/campaign"
|
18
|
+
autoload :Connection, "adcloud/connection"
|
19
|
+
autoload :Customer, "adcloud/customer"
|
20
|
+
autoload :Entity, "adcloud/entity"
|
21
|
+
autoload :ExceptionRaiser, "adcloud/exception_raiser"
|
22
|
+
autoload :MediaFile, "adcloud/media_file"
|
23
|
+
autoload :Product, "adcloud/product"
|
24
|
+
autoload :Report, "adcloud/report"
|
25
|
+
autoload :ReportEntry, "adcloud/report_entry"
|
26
|
+
autoload :Topic, "adcloud/topic"
|
27
|
+
autoload :TopicDiscount, "adcloud/topic_discount"
|
28
|
+
autoload :Webhook, "adcloud/webhook"
|
29
|
+
autoload :WebhookConfig, "adcloud/webhook_config"
|
30
|
+
autoload :WebhookEvent, "adcloud/webhook_event"
|
31
|
+
|
32
|
+
module AdcloudSucks; class InvalidApiResponse < StandardError; end; end
|
33
|
+
class BadRequestError < ApiError; end
|
34
|
+
class NotFoundError < ApiError; end
|
35
|
+
class ServerError < ApiError; end
|
36
|
+
class Unauthorized < ApiError; end
|
37
|
+
|
38
|
+
class << self
|
39
|
+
# Access the logger instance
|
40
|
+
def logger
|
41
|
+
@@logger ||= (defined?(Rails) && Rails.logger) || Adcloud.config.logger || Logger.new(STDOUT)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Allow to override the logger
|
45
|
+
def logger=(input)
|
46
|
+
@@logger = input
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
Adcloud.configure do |c|
|
53
|
+
c.port = 443
|
54
|
+
c.protocol = 'https'
|
55
|
+
c.host = 'api.adcloud.com'
|
56
|
+
c.api_version = "v2"
|
57
|
+
c.http_open_timeout = 5
|
58
|
+
c.http_read_timeout = 10
|
59
|
+
c.debug = false
|
60
|
+
c.webhooks = Adcloud::WebhookConfig.new
|
61
|
+
c.webhooks.filter_tests = true
|
62
|
+
end
|