adroller 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,188 @@
1
+ require 'spec_helper'
2
+
3
+ describe AdRoll::Api::Advertisable do
4
+ let!(:basic_auth) { "#{AdRoll::Api.user_name}:#{AdRoll::Api.password}" }
5
+
6
+ subject { described_class }
7
+
8
+ describe '::create' do
9
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/create" }
10
+
11
+ let!(:params) do
12
+ {
13
+ name: 'name',
14
+ organization: 'abc123',
15
+ set_as_default: true,
16
+ url: 'https://url.com',
17
+ product_name: 'product_name'
18
+ }
19
+ end
20
+
21
+ let!(:escaped_params) do
22
+ params[:url] = CGI.escape(params[:url])
23
+ params[:set_as_default] = 'true'
24
+ params
25
+ end
26
+
27
+ it 'calls the api with the correct params' do
28
+ subject.create(params)
29
+ expect(WebMock).to have_requested(:post, request_uri).with(query: escaped_params)
30
+ end
31
+ end
32
+
33
+ describe '::edit' do
34
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/edit" }
35
+
36
+ let!(:params) do
37
+ {
38
+ advertisable: 'xyz456',
39
+ name: 'advertisable test',
40
+ url: 'https://url.com',
41
+ product_name: 'product_name',
42
+ view_through_conversion_window: 30
43
+ }
44
+ end
45
+
46
+ let!(:escaped_params) do
47
+ params[:url] = CGI.escape(params[:url])
48
+ params
49
+ end
50
+
51
+ it 'calls the api with the correct params' do
52
+ subject.edit(params)
53
+ expect(WebMock).to have_requested(:put, request_uri).with(query: escaped_params)
54
+ end
55
+ end
56
+
57
+ describe '::enable_rollcrawl' do
58
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/enable_rollcrawl" }
59
+
60
+ let!(:params) do
61
+ {
62
+ advertisable: 'xyz456',
63
+ url: 'https://url.com/product_feed.json'
64
+ }
65
+ end
66
+
67
+ let!(:escaped_params) do
68
+ params[:url] = CGI.escape(params[:url])
69
+ params
70
+ end
71
+
72
+ it 'calls the api with the correct params' do
73
+ subject.enable_rollcrawl(params)
74
+ expect(WebMock).to have_requested(:get, request_uri).with(query: escaped_params)
75
+ end
76
+ end
77
+
78
+ describe '::get' do
79
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/get" }
80
+
81
+ let!(:params) do
82
+ {
83
+ advertisable: 'xyz456'
84
+ }
85
+ end
86
+
87
+ it 'calls the api with the correct params' do
88
+ subject.get(params)
89
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params)
90
+ end
91
+ end
92
+
93
+ describe '::get_adgroups' do
94
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/get_adgroups" }
95
+
96
+ let!(:params) do
97
+ {
98
+ advertisable: 'xyz456',
99
+ statuses: %w(admin_review admin_paused)
100
+ }
101
+ end
102
+
103
+ it 'calls the api with the correct params' do
104
+ subject.get_adgroups(params)
105
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params.merge(camp_active: 'true'))
106
+ end
107
+ end
108
+
109
+ describe '::get_ads' do
110
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/get_ads" }
111
+
112
+ let!(:params) do
113
+ {
114
+ advertisable: 'xyz456',
115
+ width: 300,
116
+ height: 300
117
+ }
118
+ end
119
+
120
+ it 'calls the api with the correct params' do
121
+ subject.get_ads(params)
122
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params.merge(is_active: 'true'))
123
+ end
124
+ end
125
+
126
+ describe '::get_campaigns' do
127
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/get_campaigns" }
128
+
129
+ let!(:params) do
130
+ {
131
+ advertisable: 'xyz456'
132
+ }
133
+ end
134
+
135
+ it 'calls the api with the correct params' do
136
+ subject.get_campaigns(params)
137
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params.merge(is_active: 'true'))
138
+ end
139
+ end
140
+
141
+ describe '::get_coops' do
142
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/get_coops" }
143
+
144
+ let!(:params) do
145
+ {
146
+ advertisable: 'xyz456',
147
+ filter_active: false,
148
+ coops_active: false
149
+ }
150
+ end
151
+
152
+ it 'calls the api with the correct params' do
153
+ subject.get_coops(params)
154
+ expect(WebMock).to have_requested(:get, request_uri)
155
+ .with(query: params.merge(filter_active: 'false', coops_active: 'false'))
156
+ end
157
+ end
158
+
159
+ describe '::get_pixel' do
160
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/get_pixel" }
161
+
162
+ let!(:params) do
163
+ {
164
+ advertisable: 'xyz456'
165
+ }
166
+ end
167
+
168
+ it 'calls the api with the correct params' do
169
+ subject.get_pixel(params)
170
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params)
171
+ end
172
+ end
173
+
174
+ describe '::get_segments' do
175
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/advertisable/get_segments" }
176
+
177
+ let!(:params) do
178
+ {
179
+ advertisable: 'xyz456'
180
+ }
181
+ end
182
+
183
+ it 'calls the api with the correct params' do
184
+ subject.get_segments(params)
185
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params)
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ describe AdRoll::Api::Organization do
4
+
5
+ subject { described_class }
6
+
7
+ describe '::get' do
8
+ let!(:basic_auth) { "#{AdRoll::Api.user_name}:#{AdRoll::Api.password}" }
9
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/organization/get" }
10
+
11
+ let!(:params) do
12
+ {
13
+ organization: 'abc123'
14
+ }
15
+ end
16
+
17
+ it 'calls the api with the correct params' do
18
+ subject.get(organization: 'abc123')
19
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params)
20
+ end
21
+ end
22
+
23
+ describe '::get_advertisables' do
24
+ let!(:basic_auth) { "#{AdRoll::Api.user_name}:#{AdRoll::Api.password}" }
25
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/organization/get_advertisables" }
26
+
27
+ let!(:params) do
28
+ {
29
+ organization: 'abc123'
30
+ }
31
+ end
32
+
33
+ it 'calls the api with the correct params' do
34
+ subject.get_advertisables(organization: 'abc123')
35
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params)
36
+ end
37
+ end
38
+
39
+ describe '::get_billing_methods' do
40
+ let!(:basic_auth) { "#{AdRoll::Api.user_name}:#{AdRoll::Api.password}" }
41
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/organization/get_billing_methods" }
42
+
43
+ let!(:params) do
44
+ {
45
+ organization: 'abc123'
46
+ }
47
+ end
48
+
49
+ it 'calls the api with the correct params' do
50
+ subject.get_billing_methods(organization: 'abc123')
51
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params)
52
+ end
53
+ end
54
+
55
+ describe '::get_users' do
56
+ let!(:basic_auth) { "#{AdRoll::Api.user_name}:#{AdRoll::Api.password}" }
57
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/organization/get_users" }
58
+
59
+ let!(:params) do
60
+ {
61
+ organization: 'abc123'
62
+ }
63
+ end
64
+
65
+ it 'calls the api with the correct params' do
66
+ subject.get_users(organization: 'abc123')
67
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params)
68
+ end
69
+ end
70
+
71
+ describe '::reset' do
72
+ let!(:basic_auth) { "#{AdRoll::Api.user_name}:#{AdRoll::Api.password}" }
73
+ let!(:request_uri) { "https://#{basic_auth}@api.adroll.com/v1/organization/reset" }
74
+
75
+ let!(:params) do
76
+ {
77
+ organization: 'abc123'
78
+ }
79
+ end
80
+
81
+ it 'calls the api with the correct params' do
82
+ subject.reset(organization: 'abc123')
83
+ expect(WebMock).to have_requested(:get, request_uri).with(query: params)
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe AdRoll::Api::Service do
4
+
5
+ subject { described_class }
6
+
7
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe AdRoll::Api do
4
+ subject { described_class }
5
+
6
+ it 'should return username' do
7
+ expect(subject.user_name).to eq 'USERNAME'
8
+ end
9
+
10
+ it 'should return password' do
11
+ expect(subject.password).to eq 'PASSWORD'
12
+ end
13
+
14
+ it 'should return organization eid' do
15
+ expect(subject.organization_eid).to eq 'ORG123XYZ'
16
+ end
17
+
18
+ it 'should return the base url for api endpoints' do
19
+ expect(subject.base_url).to eq 'https://api.adroll.com/v1'
20
+ end
21
+
22
+ end
@@ -0,0 +1,20 @@
1
+ require 'adroller'
2
+ require 'byebug'
3
+ require 'factory_girl'
4
+ require 'webmock/rspec'
5
+
6
+ RSpec.configure do |config|
7
+ config.include FactoryGirl::Syntax::Methods
8
+
9
+ config.before(:each) do
10
+ stub_request(:any, /https:\/\/USERNAME:PASSWORD@api.adroll.com\/v1\//)
11
+ .to_return(status: [200, 'OK'], body: { results: {} }.to_json)
12
+ end
13
+ end
14
+
15
+ FactoryGirl.definition_file_paths = [File.expand_path('../factories', __FILE__)]
16
+ FactoryGirl.find_definitions
17
+
18
+ ENV['ADROLL_USERNAME'] = 'USERNAME'
19
+ ENV['ADROLL_PASSWORD'] = 'PASSWORD'
20
+ ENV['ADROLL_ORGANIZATION_EID'] = 'ORG123XYZ'
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.include FactoryGirl::Syntax::Methods
3
+ end
@@ -0,0 +1,17 @@
1
+ require 'vcr'
2
+
3
+ VCR.configure do |cassette|
4
+ cassette.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
5
+ cassette.hook_into :webmock
6
+ cassette.configure_rspec_metadata!
7
+ end
8
+
9
+ VCR.turn_off!
10
+
11
+ VCR.extend Module.new {
12
+ def use_cassette(*args)
13
+ VCR.turn_on!
14
+ super
15
+ VCR.turn_off!
16
+ end
17
+ }
metadata ADDED
@@ -0,0 +1,207 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: adroller
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nikolas Davis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 3.4.0
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '3.4'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 3.4.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.0.0
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '3.0'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 3.0.0
81
+ - !ruby/object:Gem::Dependency
82
+ name: webmock
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.18'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.18.0
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.18'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.18.0
101
+ - !ruby/object:Gem::Dependency
102
+ name: factory_girl
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '4.4'
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 4.4.0
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.4'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 4.4.0
121
+ - !ruby/object:Gem::Dependency
122
+ name: httparty
123
+ requirement: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: 0.13.1
128
+ type: :runtime
129
+ prerelease: false
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - "~>"
133
+ - !ruby/object:Gem::Version
134
+ version: 0.13.1
135
+ description: Ruby Gem for Interaction with AdRoll v1 API
136
+ email:
137
+ - nikolasliamdavis@gmail.com
138
+ executables: []
139
+ extensions: []
140
+ extra_rdoc_files: []
141
+ files:
142
+ - ".gitignore"
143
+ - ".rubocop.yml"
144
+ - ".rubocop_todo.yml"
145
+ - Gemfile
146
+ - Gemfile.lock
147
+ - README.md
148
+ - lib/adroll.rb
149
+ - lib/adroll/ad.rb
150
+ - lib/adroll/adgroup.rb
151
+ - lib/adroll/advertisable.rb
152
+ - lib/adroll/campaign.rb
153
+ - lib/adroll/event.rb
154
+ - lib/adroll/invoice.rb
155
+ - lib/adroll/mobile_app.rb
156
+ - lib/adroll/mobile_rule.rb
157
+ - lib/adroll/organization.rb
158
+ - lib/adroll/payment_method.rb
159
+ - lib/adroll/pixel.rb
160
+ - lib/adroll/report.rb
161
+ - lib/adroll/rule.rb
162
+ - lib/adroll/segment.rb
163
+ - lib/adroll/service.rb
164
+ - lib/adroll/user.rb
165
+ - spec/factories/service_factory.rb
166
+ - spec/lib/adroll/ad_spec.rb
167
+ - spec/lib/adroll/advertisable_spec.rb
168
+ - spec/lib/adroll/organization_spec.rb
169
+ - spec/lib/adroll/service_spec.rb
170
+ - spec/lib/adroll_spec.rb
171
+ - spec/spec_helper.rb
172
+ - spec/support/factory_girl.rb
173
+ - spec/support/vcr_setup.rb
174
+ homepage: http://www.adroll.com
175
+ licenses:
176
+ - MIT
177
+ metadata: {}
178
+ post_install_message:
179
+ rdoc_options: []
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ required_rubygems_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ requirements: []
193
+ rubyforge_project:
194
+ rubygems_version: 2.4.5
195
+ signing_key:
196
+ specification_version: 4
197
+ summary: Ruby API Wrapper for AdRoll
198
+ test_files:
199
+ - spec/factories/service_factory.rb
200
+ - spec/lib/adroll/ad_spec.rb
201
+ - spec/lib/adroll/advertisable_spec.rb
202
+ - spec/lib/adroll/organization_spec.rb
203
+ - spec/lib/adroll/service_spec.rb
204
+ - spec/lib/adroll_spec.rb
205
+ - spec/spec_helper.rb
206
+ - spec/support/factory_girl.rb
207
+ - spec/support/vcr_setup.rb