tubemogul_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +60 -0
- data/.env +5 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +15 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +72 -0
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/config/endpoints_for_services.yaml +3 -0
- data/lib/tubemogul_api.rb +23 -0
- data/lib/tubemogul_api/connection.rb +65 -0
- data/lib/tubemogul_api/error.rb +17 -0
- data/lib/tubemogul_api/faraday/raise_http_error.rb +36 -0
- data/lib/tubemogul_api/service.rb +63 -0
- data/lib/tubemogul_api/service/advertiser.rb +4 -0
- data/lib/tubemogul_api/service/campaign.rb +4 -0
- data/lib/tubemogul_api/version.rb +5 -0
- data/tubemogul_api.gemspec +35 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a645e8b0668ec676a3ef2d692cac307b305d2aed11c4c47793c94600e9218725
|
4
|
+
data.tar.gz: 3da2f7b60a2357ee9771196aaae7407a6a062b2a1e5100a4efe8d5fae6cf1e5a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8bd2916d7288cbe65e63ca92426ff92a4b5f806052e37be99bf7c33a51096bcd9dfd996982a7c6e671d19a06065758377b6a31232ecdc5ae4be476ee897f994b
|
7
|
+
data.tar.gz: f393d5346b5edcba9f314d30424b1825276a586b5f3940e6ce0c60ff43e66381784cee2d735a154eaadbac37e26dcf19d286b69a5fae5a604f9103f370ae59e5
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
docker:
|
9
|
+
# specify the version you desire here
|
10
|
+
- image: circleci/ruby:2.5.1-node-browsers
|
11
|
+
|
12
|
+
# Specify service dependencies here if necessary
|
13
|
+
# CircleCI maintains a library of pre-built images
|
14
|
+
# documented at https://circleci.com/docs/2.0/circleci-images/
|
15
|
+
# - image: circleci/postgres:9.6
|
16
|
+
|
17
|
+
working_directory: ~/repo
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- checkout
|
21
|
+
|
22
|
+
# Download and cache dependencies
|
23
|
+
- restore_cache:
|
24
|
+
keys:
|
25
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
26
|
+
# fallback to using the latest cache if no exact match is found
|
27
|
+
- v1-dependencies-
|
28
|
+
|
29
|
+
- run:
|
30
|
+
name: install dependencies
|
31
|
+
command: |
|
32
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
33
|
+
|
34
|
+
- save_cache:
|
35
|
+
paths:
|
36
|
+
- ./vendor/bundle
|
37
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
38
|
+
|
39
|
+
# Database setup
|
40
|
+
# - run: bundle exec rake create_test_db
|
41
|
+
|
42
|
+
# run tests!
|
43
|
+
- run:
|
44
|
+
name: run tests
|
45
|
+
command: |
|
46
|
+
mkdir /tmp/test-results
|
47
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
48
|
+
|
49
|
+
bundle exec rspec --format progress \
|
50
|
+
--format RspecJunitFormatter \
|
51
|
+
--out /tmp/test-results/rspec.xml \
|
52
|
+
--format progress \
|
53
|
+
${TEST_FILES}
|
54
|
+
|
55
|
+
# collect reports
|
56
|
+
- store_test_results:
|
57
|
+
path: /tmp/test-results
|
58
|
+
- store_artifacts:
|
59
|
+
path: /tmp/test-results
|
60
|
+
destination: test-results
|
data/.env
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.1.0] (2018-10-18)
|
10
|
+
### Added
|
11
|
+
- Advertisers API
|
12
|
+
- Campaigns API
|
13
|
+
|
14
|
+
[Unreleased]: https://github.com/ad2games/tubemogul_api/compare/v0.1.0...HEAD
|
15
|
+
[0.1.0]: https://github.com/ad2games/tubemogul_api/commits/v0.1.0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at stefan.greffenius@ad2games.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in tubemogul_api.gemspec
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem 'rspec_junit_formatter', '0.2.2'
|
12
|
+
gem 'rubocop-ci', github: 'ad2games/rubocop-ci'
|
13
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Stefan Greffenius
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# TubemogulApi [![CircleCI](https://circleci.com/gh/ad2games/tubemogul_api.svg?style=svg)](https://circleci.com/gh/ad2games/tubemogul_api)
|
2
|
+
|
3
|
+
Unofficial client library for [Tubemogul API](https://www.tubemogul.com)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'tubemogul_api'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install tubemogul_api
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
# If you use the default ENV variables TUBEMOGUL_CLIENT_ID and TUBEMOGUL_SECRET_KEY, you can get a
|
25
|
+
# connection by:
|
26
|
+
|
27
|
+
connection = TubemogulApi::Connection.new
|
28
|
+
|
29
|
+
# Otherwise you can explicitly pass client_id and secret_key:
|
30
|
+
connection = TubemogulApi::Connection.new(
|
31
|
+
client_id: ENV.fetch('TUBEMOGUL_CLIENT_ID'),
|
32
|
+
secret_key: ENV.fetch('TUBEMOGUL_SECRET_KEY')
|
33
|
+
)
|
34
|
+
|
35
|
+
service = TubemogulApi::Service::Advertiser.new(connection)
|
36
|
+
service.get(10) # returns the advertiser with the ID 10
|
37
|
+
service.get_all # returns all advertisers
|
38
|
+
```
|
39
|
+
|
40
|
+
Also the `spec/integration` directory contains examples.
|
41
|
+
|
42
|
+
Note: Only the `Advertiser` and `Campaign` services with `get` and `get_all` requests are implemented so far.
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
Run specs with `bundle exec rspec`.
|
47
|
+
|
48
|
+
To recreate or create new VCR episodes, you need to set proper values for env vars:
|
49
|
+
* `TUBEMOGUL_CLIENT_ID`
|
50
|
+
* `TUBEMOGUL_SECRET_KEY`
|
51
|
+
* `SAMPLE_ADVERTISER_ID`
|
52
|
+
* `ACCOUNT_ID`
|
53
|
+
* `SAMPLE_CAMPAIGN_ID`
|
54
|
+
|
55
|
+
We recommend that you set it in `.env.test` file.
|
56
|
+
|
57
|
+
Note that some specs fail when recording new VCR episodes due to filtering of sensitive data.
|
58
|
+
But after that, all specs should pass in playback mode.
|
59
|
+
|
60
|
+
We run `rake rubocop` to make sure, everything looks good.
|
61
|
+
|
62
|
+
## License
|
63
|
+
|
64
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
65
|
+
|
66
|
+
## Code of Conduct
|
67
|
+
|
68
|
+
Everyone interacting in the TubemogulApi project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ad2games/tubemogul_api/blob/master/CODE_OF_CONDUCT.md).
|
69
|
+
|
70
|
+
## Contributing
|
71
|
+
|
72
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ad2games/tubemogul_api.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "tubemogul_api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday_middleware'
|
4
|
+
|
5
|
+
require 'tubemogul_api/error'
|
6
|
+
require 'tubemogul_api/faraday/raise_http_error'
|
7
|
+
|
8
|
+
require 'tubemogul_api/connection'
|
9
|
+
require 'tubemogul_api/service'
|
10
|
+
require 'tubemogul_api/version'
|
11
|
+
|
12
|
+
module TubemogulApi
|
13
|
+
AUTOLOAD_PATHS = [
|
14
|
+
Dir[File.dirname(__dir__) + '/lib/tubemogul_api/resource/*.rb'],
|
15
|
+
Dir[File.dirname(__dir__) + '/lib/tubemogul_api/service/*.rb']
|
16
|
+
].flatten.freeze
|
17
|
+
|
18
|
+
def self.root
|
19
|
+
Pathname.new(File.dirname(__dir__))
|
20
|
+
end
|
21
|
+
|
22
|
+
AUTOLOAD_PATHS.each { |file| require file }
|
23
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class TubemogulApi::Connection
|
4
|
+
TUBEMOGUL_API_URL = 'https://api.tubemogul.com'.freeze
|
5
|
+
|
6
|
+
attr_reader :config
|
7
|
+
|
8
|
+
def initialize(config = {})
|
9
|
+
@config = config
|
10
|
+
end
|
11
|
+
|
12
|
+
def connection
|
13
|
+
@connection ||= connection_builder do |conn|
|
14
|
+
conn.authorization 'Bearer', token
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def get(uri_suffix, params = {})
|
19
|
+
connection.get(uri_suffix, params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def post(uri_suffix, params = {})
|
23
|
+
connection.post(uri_suffix, params)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def url
|
29
|
+
config.fetch(:url, TUBEMOGUL_API_URL)
|
30
|
+
end
|
31
|
+
|
32
|
+
def client_id
|
33
|
+
config.fetch(:client_id, ENV['TUBEMOGUL_CLIENT_ID'])
|
34
|
+
end
|
35
|
+
|
36
|
+
def secret_key
|
37
|
+
config.fetch(:secret_key, ENV['TUBEMOGUL_SECRET_KEY'])
|
38
|
+
end
|
39
|
+
|
40
|
+
def token
|
41
|
+
@token ||= fetch_authorization_token
|
42
|
+
end
|
43
|
+
|
44
|
+
def fetch_authorization_token
|
45
|
+
connection = connection_builder do |conn|
|
46
|
+
conn.basic_auth client_id, secret_key
|
47
|
+
conn.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
48
|
+
conn.headers['Cache-Control'] = 'no-cache'
|
49
|
+
end
|
50
|
+
|
51
|
+
response = connection.run_request(:post, 'oauth/token', 'grant_type=client_credentials', nil)
|
52
|
+
|
53
|
+
response.body['token']
|
54
|
+
end
|
55
|
+
|
56
|
+
def connection_builder
|
57
|
+
Faraday.new(url) do |conn|
|
58
|
+
conn.request :json
|
59
|
+
conn.response :json, content_type: /\bjson$/
|
60
|
+
conn.use TubemogulApi::Faraday::Response::RaiseHttpError
|
61
|
+
conn.adapter Faraday.default_adapter
|
62
|
+
yield conn
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TubemogulApi
|
4
|
+
class Error < StandardError; end
|
5
|
+
class BadRequest < Error; end
|
6
|
+
class Unauthorized < Error; end
|
7
|
+
class Forbidden < Error; end
|
8
|
+
class NotFound < Error; end
|
9
|
+
class NotAcceptable < Error; end
|
10
|
+
class UnprocessableEntity < Error; end
|
11
|
+
class InternalServerError < Error; end
|
12
|
+
class NotImplemented < Error; end
|
13
|
+
class BadGateway < Error; end
|
14
|
+
class ServiceUnavailable < Error; end
|
15
|
+
class InvalidJson < Error; end
|
16
|
+
class Timeout < Error; end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TubemogulApi
|
4
|
+
module Faraday
|
5
|
+
module Response
|
6
|
+
class RaiseHttpError < ::Faraday::Response::Middleware
|
7
|
+
EXCEPTIONS = {
|
8
|
+
400 => TubemogulApi::BadRequest,
|
9
|
+
401 => TubemogulApi::Unauthorized,
|
10
|
+
403 => TubemogulApi::Forbidden,
|
11
|
+
404 => TubemogulApi::NotFound,
|
12
|
+
406 => TubemogulApi::NotAcceptable,
|
13
|
+
422 => TubemogulApi::UnprocessableEntity,
|
14
|
+
500 => TubemogulApi::InternalServerError,
|
15
|
+
501 => TubemogulApi::NotImplemented,
|
16
|
+
502 => TubemogulApi::BadGateway,
|
17
|
+
503 => TubemogulApi::ServiceUnavailable
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
def on_complete(response)
|
21
|
+
http_status = response.status.to_i
|
22
|
+
|
23
|
+
return if http_status == 200
|
24
|
+
|
25
|
+
exception = EXCEPTIONS.fetch(http_status)
|
26
|
+
|
27
|
+
raise exception, response.body
|
28
|
+
end
|
29
|
+
|
30
|
+
def error_message(response)
|
31
|
+
"#{response.method.to_s.upcase} #{response.url}: #{response.status} - #{response.body}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
class TubemogulApi::Service
|
7
|
+
attr_reader :connection
|
8
|
+
|
9
|
+
def initialize(connection)
|
10
|
+
@connection = connection
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
@name ||= begin
|
15
|
+
str = self.class.name.split('::').last
|
16
|
+
str.gsub(/(.)([A-Z])/, '\1_\2').downcase
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def uri_suffix
|
21
|
+
@@endpoints ||= YAML.load_file( # rubocop:disable Style/ClassVars
|
22
|
+
TubemogulApi.root.join('lib', 'config', 'endpoints_for_services.yaml')
|
23
|
+
)
|
24
|
+
|
25
|
+
endpoint = @@endpoints['service'][name]
|
26
|
+
|
27
|
+
endpoint || raise(TubemogulApi::NotImplemented, "No endpoint for service #{name} available.")
|
28
|
+
end
|
29
|
+
|
30
|
+
def get(id, params = {})
|
31
|
+
response = connection.get("#{uri_suffix}/#{id}", params).body
|
32
|
+
|
33
|
+
parse_response(response)
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_all(params = {})
|
37
|
+
response = connection.get(uri_suffix, params).body
|
38
|
+
|
39
|
+
parse_response(response)
|
40
|
+
end
|
41
|
+
|
42
|
+
def parse_response(response)
|
43
|
+
case response['@type']
|
44
|
+
when 'Collection'
|
45
|
+
parse_collection(response)
|
46
|
+
else
|
47
|
+
OpenStruct.new(response)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse_collection(response)
|
52
|
+
Enumerator.new do |y|
|
53
|
+
loop do
|
54
|
+
response['items'].each do |json|
|
55
|
+
y << parse_response(json)
|
56
|
+
end
|
57
|
+
paging = response['paging']
|
58
|
+
break unless paging['has_more_items']
|
59
|
+
response = connection.get(paging['next_page_uri']).body
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'tubemogul_api/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'tubemogul_api'
|
9
|
+
spec.version = TubemogulApi::VERSION
|
10
|
+
spec.authors = ['Guilherme Goettems Schneider']
|
11
|
+
spec.email = ['guilherme@ad2games.com']
|
12
|
+
|
13
|
+
spec.summary = 'Tubemogul API Client.'
|
14
|
+
spec.description = 'Tubemogul API Client.'
|
15
|
+
spec.homepage = 'https://www.combostrike.com'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_dependency 'faraday'
|
26
|
+
spec.add_dependency 'faraday_middleware'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
+
|
32
|
+
spec.add_development_dependency 'dotenv'
|
33
|
+
spec.add_development_dependency 'vcr'
|
34
|
+
spec.add_development_dependency 'webmock'
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tubemogul_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guilherme Goettems Schneider
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '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'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.15'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.15'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dotenv
|
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: vcr
|
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: webmock
|
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
|
+
description: Tubemogul API Client.
|
126
|
+
email:
|
127
|
+
- guilherme@ad2games.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".circleci/config.yml"
|
133
|
+
- ".env"
|
134
|
+
- ".gitignore"
|
135
|
+
- ".rspec"
|
136
|
+
- CHANGELOG.md
|
137
|
+
- CODE_OF_CONDUCT.md
|
138
|
+
- Gemfile
|
139
|
+
- LICENSE.txt
|
140
|
+
- README.md
|
141
|
+
- Rakefile
|
142
|
+
- bin/console
|
143
|
+
- bin/setup
|
144
|
+
- lib/config/endpoints_for_services.yaml
|
145
|
+
- lib/tubemogul_api.rb
|
146
|
+
- lib/tubemogul_api/connection.rb
|
147
|
+
- lib/tubemogul_api/error.rb
|
148
|
+
- lib/tubemogul_api/faraday/raise_http_error.rb
|
149
|
+
- lib/tubemogul_api/service.rb
|
150
|
+
- lib/tubemogul_api/service/advertiser.rb
|
151
|
+
- lib/tubemogul_api/service/campaign.rb
|
152
|
+
- lib/tubemogul_api/version.rb
|
153
|
+
- tubemogul_api.gemspec
|
154
|
+
homepage: https://www.combostrike.com
|
155
|
+
licenses:
|
156
|
+
- MIT
|
157
|
+
metadata: {}
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 2.7.6
|
175
|
+
signing_key:
|
176
|
+
specification_version: 4
|
177
|
+
summary: Tubemogul API Client.
|
178
|
+
test_files: []
|