beeswaxapi 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +80 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/beeswaxapi.gemspec +34 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/beeswaxapi.rb +14 -0
- data/lib/beeswaxapi/app.rb +20 -0
- data/lib/beeswaxapi/endpoint.rb +15 -0
- data/lib/beeswaxapi/endpoints.rb +44 -0
- data/lib/beeswaxapi/endpoints/account.rb +5 -0
- data/lib/beeswaxapi/endpoints/account_alert.rb +5 -0
- data/lib/beeswaxapi/endpoints/account_setting.rb +5 -0
- data/lib/beeswaxapi/endpoints/activity_log.rb +5 -0
- data/lib/beeswaxapi/endpoints/advertiser.rb +5 -0
- data/lib/beeswaxapi/endpoints/alert.rb +5 -0
- data/lib/beeswaxapi/endpoints/authenticate.rb +5 -0
- data/lib/beeswaxapi/endpoints/campaign.rb +5 -0
- data/lib/beeswaxapi/endpoints/change_password.rb +5 -0
- data/lib/beeswaxapi/endpoints/creative.rb +5 -0
- data/lib/beeswaxapi/endpoints/creative_addon.rb +5 -0
- data/lib/beeswaxapi/endpoints/creative_approval_queue.rb +5 -0
- data/lib/beeswaxapi/endpoints/creative_approval_queue_history.rb +5 -0
- data/lib/beeswaxapi/endpoints/creative_asset.rb +5 -0
- data/lib/beeswaxapi/endpoints/creative_asset/upload.rb +8 -0
- data/lib/beeswaxapi/endpoints/creative_bulk_upload.rb +5 -0
- data/lib/beeswaxapi/endpoints/creative_bulk_upload/upload.rb +8 -0
- data/lib/beeswaxapi/endpoints/creative_line_item.rb +5 -0
- data/lib/beeswaxapi/endpoints/creative_template.rb +5 -0
- data/lib/beeswaxapi/endpoints/custom_list.rb +5 -0
- data/lib/beeswaxapi/endpoints/custom_list_item.rb +5 -0
- data/lib/beeswaxapi/endpoints/dashboard.rb +5 -0
- data/lib/beeswaxapi/endpoints/event.rb +5 -0
- data/lib/beeswaxapi/endpoints/event_tag.rb +5 -0
- data/lib/beeswaxapi/endpoints/line_item.rb +5 -0
- data/lib/beeswaxapi/endpoints/native_offer.rb +5 -0
- data/lib/beeswaxapi/endpoints/push_queue.rb +5 -0
- data/lib/beeswaxapi/endpoints/report_queue.rb +18 -0
- data/lib/beeswaxapi/endpoints/report_save.rb +5 -0
- data/lib/beeswaxapi/endpoints/role.rb +5 -0
- data/lib/beeswaxapi/endpoints/search.rb +5 -0
- data/lib/beeswaxapi/endpoints/segment.rb +5 -0
- data/lib/beeswaxapi/endpoints/segment_category.rb +5 -0
- data/lib/beeswaxapi/endpoints/segment_category_association.rb +5 -0
- data/lib/beeswaxapi/endpoints/segment_category_sharing.rb +5 -0
- data/lib/beeswaxapi/endpoints/segment_sharing.rb +5 -0
- data/lib/beeswaxapi/endpoints/segment_tag.rb +5 -0
- data/lib/beeswaxapi/endpoints/segment_upload.rb +5 -0
- data/lib/beeswaxapi/endpoints/strategy.rb +5 -0
- data/lib/beeswaxapi/endpoints/strategy_targeting.rb +5 -0
- data/lib/beeswaxapi/endpoints/targeting_template.rb +5 -0
- data/lib/beeswaxapi/endpoints/user.rb +5 -0
- data/lib/beeswaxapi/endpoints/user_lookup.rb +5 -0
- data/lib/beeswaxapi/endpoints/vendor.rb +5 -0
- data/lib/beeswaxapi/endpoints/video_asset.rb +5 -0
- data/lib/beeswaxapi/endpoints/view.rb +5 -0
- data/lib/beeswaxapi/endpoints/view_list.rb +5 -0
- data/lib/beeswaxapi/errors.rb +9 -0
- data/lib/beeswaxapi/errors/beeswaxapi_error.rb +6 -0
- data/lib/beeswaxapi/errors/failure_response.rb +15 -0
- data/lib/beeswaxapi/errors/missing_configuration.rb +6 -0
- data/lib/beeswaxapi/errors/timed_out_request.rb +6 -0
- data/lib/beeswaxapi/request.rb +123 -0
- data/lib/beeswaxapi/response.rb +10 -0
- data/lib/beeswaxapi/types.rb +5 -0
- data/lib/beeswaxapi/vendor_fee.rb +5 -0
- data/lib/beeswaxapi/version.rb +3 -0
- metadata +248 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c2807d7a85e70a8fd03adf359bebdd737d872375db55af0e15a21c768e13eca8
|
4
|
+
data.tar.gz: dfc51608b392029bbcc1d84e2180eca66aeebf67067bd5d599b055497282bbc6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42c6f4101e4a29bb40aa9cecda8ea59aa35cac837206b4a8827af449e5199e7b811c93a9efc51f0e5c1350bae78c127f97b257fad6292ac9f3ec14889080f7c4
|
7
|
+
data.tar.gz: 25966274ef20d2a56e352bc8aec0cf727cc30d916f987698a1e7f47bab13a4a0c6bc19ea5a487d71da79e9f757c00595f2256c040ad58676ca142f8d43b32eda
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
beeswaxapi (0.0.8)
|
5
|
+
dry-configurable (~> 0.7.0)
|
6
|
+
dry-struct (~> 0.4.0)
|
7
|
+
dry-types (~> 0.12.2)
|
8
|
+
typhoeus (~> 1.3)
|
9
|
+
yajl-ruby (~> 1.3, >= 1.3.1)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://www.rubygems.org/
|
13
|
+
specs:
|
14
|
+
coderay (1.1.2)
|
15
|
+
concurrent-ruby (1.0.5)
|
16
|
+
diff-lcs (1.3)
|
17
|
+
dry-configurable (0.7.0)
|
18
|
+
concurrent-ruby (~> 1.0)
|
19
|
+
dry-container (0.6.0)
|
20
|
+
concurrent-ruby (~> 1.0)
|
21
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
22
|
+
dry-core (0.4.1)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
dry-equalizer (0.2.0)
|
25
|
+
dry-logic (0.4.2)
|
26
|
+
dry-container (~> 0.2, >= 0.2.6)
|
27
|
+
dry-core (~> 0.2)
|
28
|
+
dry-equalizer (~> 0.2)
|
29
|
+
dry-struct (0.4.0)
|
30
|
+
dry-core (~> 0.4, >= 0.4.1)
|
31
|
+
dry-equalizer (~> 0.2)
|
32
|
+
dry-types (~> 0.12, >= 0.12.2)
|
33
|
+
ice_nine (~> 0.11)
|
34
|
+
dry-types (0.12.2)
|
35
|
+
concurrent-ruby (~> 1.0)
|
36
|
+
dry-configurable (~> 0.1)
|
37
|
+
dry-container (~> 0.3)
|
38
|
+
dry-core (~> 0.2, >= 0.2.1)
|
39
|
+
dry-equalizer (~> 0.2)
|
40
|
+
dry-logic (~> 0.4, >= 0.4.2)
|
41
|
+
inflecto (~> 0.0.0, >= 0.0.2)
|
42
|
+
ethon (0.11.0)
|
43
|
+
ffi (>= 1.3.0)
|
44
|
+
ffi (1.9.18)
|
45
|
+
ice_nine (0.11.2)
|
46
|
+
inflecto (0.0.2)
|
47
|
+
method_source (0.9.0)
|
48
|
+
pry (0.11.2)
|
49
|
+
coderay (~> 1.1.0)
|
50
|
+
method_source (~> 0.9.0)
|
51
|
+
rake (10.5.0)
|
52
|
+
rspec (3.7.0)
|
53
|
+
rspec-core (~> 3.7.0)
|
54
|
+
rspec-expectations (~> 3.7.0)
|
55
|
+
rspec-mocks (~> 3.7.0)
|
56
|
+
rspec-core (3.7.0)
|
57
|
+
rspec-support (~> 3.7.0)
|
58
|
+
rspec-expectations (3.7.0)
|
59
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
60
|
+
rspec-support (~> 3.7.0)
|
61
|
+
rspec-mocks (3.7.0)
|
62
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
+
rspec-support (~> 3.7.0)
|
64
|
+
rspec-support (3.7.0)
|
65
|
+
typhoeus (1.3.0)
|
66
|
+
ethon (>= 0.9.0)
|
67
|
+
yajl-ruby (1.3.1)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
beeswaxapi!
|
74
|
+
bundler (~> 1.16)
|
75
|
+
pry (~> 0.11.2)
|
76
|
+
rake (~> 10.0)
|
77
|
+
rspec (~> 3.0)
|
78
|
+
|
79
|
+
BUNDLED WITH
|
80
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Valentyn Ostakh
|
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,39 @@
|
|
1
|
+
# Beeswaxapi
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/beeswaxapi`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'beeswaxapi'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install beeswaxapi
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/beeswaxapi.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/beeswaxapi.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "beeswaxapi/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "beeswaxapi"
|
8
|
+
spec.version = BeeswaxAPI::VERSION
|
9
|
+
spec.authors = ["Valentyn Ostakh"]
|
10
|
+
spec.email = ["valikos.ost@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Beeswax.com rest api client}
|
13
|
+
spec.description = %q{Simple ruby client to work with beeswax buzz api}
|
14
|
+
spec.homepage = "https://github.com/valikos/beeswaxapi"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency "typhoeus", "~> 1.3"
|
25
|
+
spec.add_dependency "dry-types", "~> 0.12.2"
|
26
|
+
spec.add_dependency "dry-struct", "~> 0.4.0"
|
27
|
+
spec.add_dependency "dry-configurable", "~> 0.7.0"
|
28
|
+
spec.add_dependency "yajl-ruby", "~> 1.3", ">= 1.3.1"
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
spec.add_development_dependency "pry", "~> 0.11.2"
|
34
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'beeswaxapi'
|
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
|
data/bin/setup
ADDED
data/lib/beeswaxapi.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'dry-types'
|
2
|
+
require 'dry-struct'
|
3
|
+
require 'dry-configurable'
|
4
|
+
|
5
|
+
require 'beeswaxapi/version'
|
6
|
+
require 'beeswaxapi/app'
|
7
|
+
require 'beeswaxapi/errors'
|
8
|
+
require 'beeswaxapi/types'
|
9
|
+
require 'beeswaxapi/response'
|
10
|
+
require 'beeswaxapi/endpoint'
|
11
|
+
require 'beeswaxapi/endpoints'
|
12
|
+
|
13
|
+
module BeeswaxAPI
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BeeswaxAPI
|
2
|
+
class App
|
3
|
+
extend Dry::Configurable
|
4
|
+
|
5
|
+
# auth_strategy: set auth method for api
|
6
|
+
# "basic" or "cookies"
|
7
|
+
# cookie_file: path where to store cookie
|
8
|
+
# base_uri: base url for api
|
9
|
+
# user_name: user email
|
10
|
+
# password: user password
|
11
|
+
# logger: inject logger
|
12
|
+
|
13
|
+
setting :auth_strategy, 'basic'
|
14
|
+
setting :cookie_file
|
15
|
+
setting :base_uri
|
16
|
+
setting :user_name
|
17
|
+
setting :password
|
18
|
+
setting :logger
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'beeswaxapi/endpoints/account_alert'
|
2
|
+
require 'beeswaxapi/endpoints/account_setting'
|
3
|
+
require 'beeswaxapi/endpoints/account'
|
4
|
+
require 'beeswaxapi/endpoints/activity_log'
|
5
|
+
require 'beeswaxapi/endpoints/advertiser'
|
6
|
+
require 'beeswaxapi/endpoints/alert'
|
7
|
+
require 'beeswaxapi/endpoints/authenticate'
|
8
|
+
require 'beeswaxapi/endpoints/campaign'
|
9
|
+
require 'beeswaxapi/endpoints/change_password'
|
10
|
+
require 'beeswaxapi/endpoints/creative_addon'
|
11
|
+
require 'beeswaxapi/endpoints/creative_approval_queue_history'
|
12
|
+
require 'beeswaxapi/endpoints/creative_approval_queue'
|
13
|
+
require 'beeswaxapi/endpoints/creative_asset'
|
14
|
+
require 'beeswaxapi/endpoints/creative_asset/upload'
|
15
|
+
require 'beeswaxapi/endpoints/creative_bulk_upload'
|
16
|
+
require 'beeswaxapi/endpoints/creative_bulk_upload/upload'
|
17
|
+
require 'beeswaxapi/endpoints/creative_line_item'
|
18
|
+
require 'beeswaxapi/endpoints/creative_template'
|
19
|
+
require 'beeswaxapi/endpoints/creative'
|
20
|
+
require 'beeswaxapi/endpoints/custom_list_item'
|
21
|
+
require 'beeswaxapi/endpoints/custom_list'
|
22
|
+
require 'beeswaxapi/endpoints/dashboard'
|
23
|
+
require 'beeswaxapi/endpoints/event_tag'
|
24
|
+
require 'beeswaxapi/endpoints/event'
|
25
|
+
require 'beeswaxapi/endpoints/line_item'
|
26
|
+
require 'beeswaxapi/endpoints/native_offer'
|
27
|
+
require 'beeswaxapi/endpoints/push_queue'
|
28
|
+
require 'beeswaxapi/endpoints/report_queue'
|
29
|
+
require 'beeswaxapi/endpoints/report_save'
|
30
|
+
require 'beeswaxapi/endpoints/role'
|
31
|
+
require 'beeswaxapi/endpoints/search'
|
32
|
+
require 'beeswaxapi/endpoints/segment_category_association'
|
33
|
+
require 'beeswaxapi/endpoints/segment_category_sharing'
|
34
|
+
require 'beeswaxapi/endpoints/segment_category'
|
35
|
+
require 'beeswaxapi/endpoints/segment_sharing'
|
36
|
+
require 'beeswaxapi/endpoints/segment_tag'
|
37
|
+
require 'beeswaxapi/endpoints/segment_upload'
|
38
|
+
require 'beeswaxapi/endpoints/segment'
|
39
|
+
require 'beeswaxapi/endpoints/targeting_template'
|
40
|
+
require 'beeswaxapi/endpoints/user'
|
41
|
+
require 'beeswaxapi/endpoints/vendor'
|
42
|
+
require 'beeswaxapi/endpoints/video_asset'
|
43
|
+
require 'beeswaxapi/endpoints/view_list'
|
44
|
+
require 'beeswaxapi/endpoints/view'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module BeeswaxAPI
|
2
|
+
class ReportQueue < Endpoint
|
3
|
+
path :report_queue
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def success_response_handler(origin_response)
|
7
|
+
parsed_response_body = parsed_body(origin_response.body)
|
8
|
+
|
9
|
+
# NOTE: get method returns document in body
|
10
|
+
if origin_response.request.options[:method] == :get
|
11
|
+
Response.new(payload: parsed_response_body)
|
12
|
+
else
|
13
|
+
Response.new(parsed_response_body)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'typhoeus'
|
2
|
+
require 'yajl'
|
3
|
+
|
4
|
+
module BeeswaxAPI
|
5
|
+
module Request
|
6
|
+
def retrieve(**opts, &block)
|
7
|
+
opts[:method] = :get
|
8
|
+
request_for(opts, &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def create(**opts, &block)
|
12
|
+
opts[:method] = :post
|
13
|
+
request_for(opts, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def update(**opts, &block)
|
17
|
+
opts[:method] = :put
|
18
|
+
request_for(opts, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(**opts, &block)
|
22
|
+
opts[:method] = :delete
|
23
|
+
request_for(opts, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def request_for(**opts)
|
29
|
+
# TODO: better url constructor
|
30
|
+
target_url = [App.config.base_uri, @path].join('/')
|
31
|
+
|
32
|
+
if opts.has_key? :path
|
33
|
+
target_url = [target_url, opts.delete(:path)].join('/')
|
34
|
+
end
|
35
|
+
|
36
|
+
case App.config.auth_strategy
|
37
|
+
when 'basic'
|
38
|
+
userpwd = "#{App.config.user_name}:#{App.config.password}"
|
39
|
+
opts[:userpwd] = userpwd
|
40
|
+
when 'cookies'
|
41
|
+
cookie_file_path = App.config.cookie_file
|
42
|
+
|
43
|
+
if cookie_file_path.nil? || cookie_file_path.empty?
|
44
|
+
fail(
|
45
|
+
Errors::MissingConfiguration,
|
46
|
+
"Path to cookies is missed. Please check configuration."
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
opts = opts.merge(
|
51
|
+
cookiefile: App.config.cookie_file,
|
52
|
+
cookiejar: App.config.cookie_file
|
53
|
+
)
|
54
|
+
else
|
55
|
+
fail(
|
56
|
+
Errors::MissingConfiguration,
|
57
|
+
"Authencation strategy can't be missed. Please check configuration."
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
if opts.has_key? :body_params
|
62
|
+
opts[:body] = Yajl.dump(opts.delete(:body_params))
|
63
|
+
end
|
64
|
+
|
65
|
+
request = Typhoeus::Request.new(target_url, opts)
|
66
|
+
|
67
|
+
if App.config.logger
|
68
|
+
App.config.logger.info before_request_log(target_url, opts)
|
69
|
+
end
|
70
|
+
|
71
|
+
request.on_complete do |response|
|
72
|
+
if App.config.logger
|
73
|
+
App.config.logger.info after_request_log(target_url, opts, response)
|
74
|
+
end
|
75
|
+
|
76
|
+
if response.success?
|
77
|
+
return success_response_handler(response)
|
78
|
+
elsif response.timed_out?
|
79
|
+
return timed_out_response_handler(response)
|
80
|
+
elsif response.code >= 400 && response.code < 500
|
81
|
+
return failure_response_handler(response)
|
82
|
+
elsif response.code >= 500 && response.code
|
83
|
+
return failure_response_handler(response)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
request.run
|
88
|
+
end
|
89
|
+
|
90
|
+
# TODO: improve heredoc formatting
|
91
|
+
def before_request_log(target_url, opts)
|
92
|
+
<<-LOG
|
93
|
+
Start request #{opts[:method].upcase} #{target_url}
|
94
|
+
#{opts[:body] if opts[:body]}
|
95
|
+
LOG
|
96
|
+
end
|
97
|
+
|
98
|
+
# TODO: improve heredoc formatting
|
99
|
+
def after_request_log(target_url, opts, response)
|
100
|
+
<<-LOG
|
101
|
+
Finish request #{opts[:method].upcase} #{target_url} with #{response.code}
|
102
|
+
#{response.body}
|
103
|
+
LOG
|
104
|
+
end
|
105
|
+
|
106
|
+
def parsed_body(body)
|
107
|
+
Yajl.load(body, symbolize_keys: true)
|
108
|
+
end
|
109
|
+
|
110
|
+
def success_response_handler(origin_response)
|
111
|
+
Response.new(parsed_body(origin_response.body))
|
112
|
+
end
|
113
|
+
|
114
|
+
def failure_response_handler(origin_response)
|
115
|
+
response = Response.new(parsed_body(origin_response.body))
|
116
|
+
fail Errors::FailureResponse.new(errors: response.errors)
|
117
|
+
end
|
118
|
+
|
119
|
+
def timed_out_response_handler(origin_response)
|
120
|
+
fail Errors::TimedOutRequest.new, 'Request skipped by time out'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module BeeswaxAPI
|
2
|
+
class Response < Dry::Struct
|
3
|
+
constructor_type :schema
|
4
|
+
|
5
|
+
attribute :success, Types::Bool
|
6
|
+
attribute :message, Types::String.optional
|
7
|
+
attribute :errors, Types::Array.member(Types::String).optional
|
8
|
+
attribute :payload, Types::Hash
|
9
|
+
end
|
10
|
+
end
|
metadata
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: beeswaxapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Valentyn Ostakh
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: typhoeus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-types
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.12.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.12.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-struct
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.4.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.4.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dry-configurable
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.7.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.7.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yajl-ruby
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.3.1
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.3'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.3.1
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: bundler
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.16'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '1.16'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rake
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '10.0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '10.0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rspec
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '3.0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '3.0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: pry
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.11.2
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.11.2
|
145
|
+
description: Simple ruby client to work with beeswax buzz api
|
146
|
+
email:
|
147
|
+
- valikos.ost@gmail.com
|
148
|
+
executables: []
|
149
|
+
extensions: []
|
150
|
+
extra_rdoc_files: []
|
151
|
+
files:
|
152
|
+
- ".gitignore"
|
153
|
+
- ".rspec"
|
154
|
+
- ".travis.yml"
|
155
|
+
- Gemfile
|
156
|
+
- Gemfile.lock
|
157
|
+
- LICENSE.txt
|
158
|
+
- README.md
|
159
|
+
- Rakefile
|
160
|
+
- beeswaxapi.gemspec
|
161
|
+
- bin/console
|
162
|
+
- bin/setup
|
163
|
+
- lib/beeswaxapi.rb
|
164
|
+
- lib/beeswaxapi/app.rb
|
165
|
+
- lib/beeswaxapi/endpoint.rb
|
166
|
+
- lib/beeswaxapi/endpoints.rb
|
167
|
+
- lib/beeswaxapi/endpoints/account.rb
|
168
|
+
- lib/beeswaxapi/endpoints/account_alert.rb
|
169
|
+
- lib/beeswaxapi/endpoints/account_setting.rb
|
170
|
+
- lib/beeswaxapi/endpoints/activity_log.rb
|
171
|
+
- lib/beeswaxapi/endpoints/advertiser.rb
|
172
|
+
- lib/beeswaxapi/endpoints/alert.rb
|
173
|
+
- lib/beeswaxapi/endpoints/authenticate.rb
|
174
|
+
- lib/beeswaxapi/endpoints/campaign.rb
|
175
|
+
- lib/beeswaxapi/endpoints/change_password.rb
|
176
|
+
- lib/beeswaxapi/endpoints/creative.rb
|
177
|
+
- lib/beeswaxapi/endpoints/creative_addon.rb
|
178
|
+
- lib/beeswaxapi/endpoints/creative_approval_queue.rb
|
179
|
+
- lib/beeswaxapi/endpoints/creative_approval_queue_history.rb
|
180
|
+
- lib/beeswaxapi/endpoints/creative_asset.rb
|
181
|
+
- lib/beeswaxapi/endpoints/creative_asset/upload.rb
|
182
|
+
- lib/beeswaxapi/endpoints/creative_bulk_upload.rb
|
183
|
+
- lib/beeswaxapi/endpoints/creative_bulk_upload/upload.rb
|
184
|
+
- lib/beeswaxapi/endpoints/creative_line_item.rb
|
185
|
+
- lib/beeswaxapi/endpoints/creative_template.rb
|
186
|
+
- lib/beeswaxapi/endpoints/custom_list.rb
|
187
|
+
- lib/beeswaxapi/endpoints/custom_list_item.rb
|
188
|
+
- lib/beeswaxapi/endpoints/dashboard.rb
|
189
|
+
- lib/beeswaxapi/endpoints/event.rb
|
190
|
+
- lib/beeswaxapi/endpoints/event_tag.rb
|
191
|
+
- lib/beeswaxapi/endpoints/line_item.rb
|
192
|
+
- lib/beeswaxapi/endpoints/native_offer.rb
|
193
|
+
- lib/beeswaxapi/endpoints/push_queue.rb
|
194
|
+
- lib/beeswaxapi/endpoints/report_queue.rb
|
195
|
+
- lib/beeswaxapi/endpoints/report_save.rb
|
196
|
+
- lib/beeswaxapi/endpoints/role.rb
|
197
|
+
- lib/beeswaxapi/endpoints/search.rb
|
198
|
+
- lib/beeswaxapi/endpoints/segment.rb
|
199
|
+
- lib/beeswaxapi/endpoints/segment_category.rb
|
200
|
+
- lib/beeswaxapi/endpoints/segment_category_association.rb
|
201
|
+
- lib/beeswaxapi/endpoints/segment_category_sharing.rb
|
202
|
+
- lib/beeswaxapi/endpoints/segment_sharing.rb
|
203
|
+
- lib/beeswaxapi/endpoints/segment_tag.rb
|
204
|
+
- lib/beeswaxapi/endpoints/segment_upload.rb
|
205
|
+
- lib/beeswaxapi/endpoints/strategy.rb
|
206
|
+
- lib/beeswaxapi/endpoints/strategy_targeting.rb
|
207
|
+
- lib/beeswaxapi/endpoints/targeting_template.rb
|
208
|
+
- lib/beeswaxapi/endpoints/user.rb
|
209
|
+
- lib/beeswaxapi/endpoints/user_lookup.rb
|
210
|
+
- lib/beeswaxapi/endpoints/vendor.rb
|
211
|
+
- lib/beeswaxapi/endpoints/video_asset.rb
|
212
|
+
- lib/beeswaxapi/endpoints/view.rb
|
213
|
+
- lib/beeswaxapi/endpoints/view_list.rb
|
214
|
+
- lib/beeswaxapi/errors.rb
|
215
|
+
- lib/beeswaxapi/errors/beeswaxapi_error.rb
|
216
|
+
- lib/beeswaxapi/errors/failure_response.rb
|
217
|
+
- lib/beeswaxapi/errors/missing_configuration.rb
|
218
|
+
- lib/beeswaxapi/errors/timed_out_request.rb
|
219
|
+
- lib/beeswaxapi/request.rb
|
220
|
+
- lib/beeswaxapi/response.rb
|
221
|
+
- lib/beeswaxapi/types.rb
|
222
|
+
- lib/beeswaxapi/vendor_fee.rb
|
223
|
+
- lib/beeswaxapi/version.rb
|
224
|
+
homepage: https://github.com/valikos/beeswaxapi
|
225
|
+
licenses:
|
226
|
+
- MIT
|
227
|
+
metadata: {}
|
228
|
+
post_install_message:
|
229
|
+
rdoc_options: []
|
230
|
+
require_paths:
|
231
|
+
- lib
|
232
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
|
+
requirements:
|
239
|
+
- - ">="
|
240
|
+
- !ruby/object:Gem::Version
|
241
|
+
version: '0'
|
242
|
+
requirements: []
|
243
|
+
rubyforge_project:
|
244
|
+
rubygems_version: 2.7.1
|
245
|
+
signing_key:
|
246
|
+
specification_version: 4
|
247
|
+
summary: Beeswax.com rest api client
|
248
|
+
test_files: []
|