my_target_api 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +3 -0
- data/lib/my_target_api/auth.rb +42 -0
- data/lib/my_target_api/errors/connection_error.rb +16 -0
- data/lib/my_target_api/errors/request_error.rb +25 -0
- data/lib/my_target_api/errors/using_error.rb +7 -0
- data/lib/my_target_api/request.rb +115 -0
- data/lib/my_target_api/resource.rb +60 -0
- data/lib/my_target_api/version.rb +7 -0
- data/lib/my_target_api.rb +47 -0
- data/my_target_api.gemspec +30 -0
- data/spec/request_spec.rb +25 -0
- data/spec/resource_spec.rb +59 -0
- data/spec/root_spec.rb +15 -0
- data/spec/spec_helper.rb +102 -0
- metadata +194 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9db7b825023cce20380d552563ddfea38b523162
|
4
|
+
data.tar.gz: 3b60fc29ae1509afb23350848724aefcd1902ae6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b78f6eeb2539f8ccf1703908e357e897045742420d558ec4640f2611e97675a28aa50f3f3ef4585d04dcac4f26a318c9bb3b0bc6d7fb18923cbc9dacd7849f3b
|
7
|
+
data.tar.gz: a4190f3f66544374d16bbd9e6ccb7b383b133a441ab53fdbdca60faa05af7411d0e132280c2e31b8c7f5da9e3798ee7c6b7a430888bc37f3711d41213bc24e64
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Eugeniy Belyaev
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Ruby client for myTarget API
|
2
|
+
|
3
|
+
[](https://travis-ci.org/resivalex/my_target_api) [](https://codeclimate.com/github/resivalex/my_target_api/maintainability)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem 'my_target_api', '~> 1.0.0'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```
|
22
|
+
$ gem install my_target_api
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# initialization
|
29
|
+
api = MyTargetApi.new(access_token)
|
30
|
+
|
31
|
+
|
32
|
+
# get api object
|
33
|
+
campaigns_api = api.resource('campaigns')
|
34
|
+
remarketing_api = api.resource('remarketing', v: 2)
|
35
|
+
remarketing_counters_api = remarketing_api.resource('counters')
|
36
|
+
|
37
|
+
# create
|
38
|
+
remarketing_counters_api.create(counter_id: 121212) # => [{ id: 343434 }]
|
39
|
+
|
40
|
+
# read all
|
41
|
+
campaigns_api.read # => [{ id: 12345, ... }, { ... }]
|
42
|
+
|
43
|
+
# read
|
44
|
+
campaigns_api.read(id: 12345) # => [{ id: 12345, ... }]
|
45
|
+
|
46
|
+
# update
|
47
|
+
campaigns_api.update(id: 12345, status: 'blocked') # => [{ id: 12345, status: 'blocked' }]
|
48
|
+
|
49
|
+
# delete
|
50
|
+
remarketing_counters_api.delete(id: 343434) # => true
|
51
|
+
```
|
52
|
+
|
53
|
+
## Exceptions
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
def read_active_campaigns
|
57
|
+
campaigns_api.read(status: 'active')
|
58
|
+
rescue MyTargetApi::RequestError, MyTargetApi::ConnectionError => e
|
59
|
+
logger.error(e)
|
60
|
+
raise
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
## Testing
|
65
|
+
|
66
|
+
```
|
67
|
+
bundle exec rspec
|
68
|
+
```
|
69
|
+
|
70
|
+
## Contributing
|
71
|
+
|
72
|
+
Create a pull-request or make an issue
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# see https://target.my.com/doc/api/oauth2
|
4
|
+
|
5
|
+
class MyTargetApi
|
6
|
+
# authorization
|
7
|
+
class Auth
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
include MyTargetApi::Request
|
12
|
+
|
13
|
+
def authorize_url
|
14
|
+
state = (0...32).map { rand(65..90).chr }.join.downcase
|
15
|
+
'https://target.my.com/oauth2/authorize?response_type=code' \
|
16
|
+
"&client_id=#{MyTargetApi.client_id}&state=#{state}&scope=#{MyTargetApi.scopes}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# We need new method to receive token using `agency_client_credentials` grant type
|
20
|
+
# @param client_username [String] client user_name in myTarget
|
21
|
+
# @return [Hash] containing requested access_token
|
22
|
+
def get_agency_client_credentials(client_username)
|
23
|
+
params = { grant_type: 'agency_client_credentials',
|
24
|
+
agency_client_name: client_username,
|
25
|
+
v: 2 }
|
26
|
+
request :post, '/oauth2/token', params
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_token(code)
|
30
|
+
params = { grant_type: 'authorization_code', code: code, v: 2 }
|
31
|
+
request :post, '/oauth2/token', params
|
32
|
+
end
|
33
|
+
|
34
|
+
def refresh_token(code)
|
35
|
+
params = { grant_type: 'refresh_token', refresh_token: code, v: 2 }
|
36
|
+
request :post, '/oauth2/token', params
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class MyTargetApi
|
4
|
+
# Error for request
|
5
|
+
class RequestError < StandardError
|
6
|
+
|
7
|
+
def initialize(e)
|
8
|
+
super build_message e
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def build_message(e)
|
14
|
+
body = JSON.parse e.response
|
15
|
+
if body['error']
|
16
|
+
"#{body['error']} : #{body['error_description']}"
|
17
|
+
else
|
18
|
+
body.map { |field, error| "#{field}: #{error}" }.join(', ')
|
19
|
+
end
|
20
|
+
rescue StandardError
|
21
|
+
e.response
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'rest-client'
|
5
|
+
|
6
|
+
class MyTargetApi
|
7
|
+
# Requests
|
8
|
+
class Request
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@logger = options[:logger]
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(url, params = {})
|
15
|
+
response = with_exception_handling do
|
16
|
+
RestClient::Request.execute(
|
17
|
+
method: :get,
|
18
|
+
url: url,
|
19
|
+
headers: header_parameters(params).merge(headers(params))
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
process_response(response)
|
24
|
+
end
|
25
|
+
|
26
|
+
def post(url, params = {})
|
27
|
+
response = with_exception_handling do
|
28
|
+
RestClient::Request.execute(
|
29
|
+
method: :post,
|
30
|
+
url: url,
|
31
|
+
payload: body_parameters(params),
|
32
|
+
headers: headers(params)
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
process_response(response)
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(url, params = {})
|
40
|
+
result_params = params.dup
|
41
|
+
result_params.delete(:access_token)
|
42
|
+
response = with_exception_handling do
|
43
|
+
RestClient::Request.execute(
|
44
|
+
method: :delete,
|
45
|
+
url: url,
|
46
|
+
headers: header_parameters(params).merge(headers(params))
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
process_response(response)
|
51
|
+
end
|
52
|
+
|
53
|
+
def body_parameters(params)
|
54
|
+
result_params = params.dup
|
55
|
+
result_params.delete(:access_token)
|
56
|
+
|
57
|
+
if params.values.any? { |param| param.is_a? IO } || params[:grant_type]
|
58
|
+
params.map do |name, value|
|
59
|
+
[name, value.is_a?(Array) || value.is_a?(Hash) ? value.to_json : value]
|
60
|
+
end.to_h
|
61
|
+
else
|
62
|
+
params.to_json
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def header_parameters(params)
|
67
|
+
result_params = params.dup
|
68
|
+
result_params.delete(:access_token)
|
69
|
+
result_params
|
70
|
+
end
|
71
|
+
|
72
|
+
def headers(params)
|
73
|
+
{ Authorization: "Bearer #{params[:access_token]}" }
|
74
|
+
end
|
75
|
+
|
76
|
+
def process_response(response)
|
77
|
+
JSON.parse(response.body)
|
78
|
+
rescue JSON::ParserError
|
79
|
+
response.body
|
80
|
+
end
|
81
|
+
|
82
|
+
def with_exception_handling
|
83
|
+
response = yield
|
84
|
+
logger << response if logger
|
85
|
+
response
|
86
|
+
rescue RestClient::Unauthorized, RestClient::Forbidden,
|
87
|
+
RestClient::BadRequest, RestClient::RequestFailed,
|
88
|
+
RestClient::ResourceNotFound => e
|
89
|
+
|
90
|
+
log_rest_client_exception(e)
|
91
|
+
raise MyTargetApi::RequestError, e
|
92
|
+
rescue SocketError => e
|
93
|
+
raise MyTargetApi::ConnectionError, e
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
attr_reader :logger
|
99
|
+
|
100
|
+
def log_rest_client_exception(exception)
|
101
|
+
log_message =
|
102
|
+
<<-LOG
|
103
|
+
RestClient exception
|
104
|
+
Class: #{exception.class}
|
105
|
+
Message: #{exception.message}
|
106
|
+
HTTP Code: #{exception.http_code}
|
107
|
+
HTTP Body: #{exception.http_body}
|
108
|
+
HTTP headers: #{exception.http_headers}
|
109
|
+
LOG
|
110
|
+
|
111
|
+
logger << log_message if logger
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class MyTargetApi
|
4
|
+
# Reflects api resource
|
5
|
+
class Resource
|
6
|
+
|
7
|
+
def initialize(api, path)
|
8
|
+
@api = api
|
9
|
+
@path = path
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(params = {})
|
13
|
+
params = prepare_params(params)
|
14
|
+
|
15
|
+
api.post_request("#{path}.json", params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def read(params = {})
|
19
|
+
params = prepare_params(params)
|
20
|
+
id = params.delete(:id)
|
21
|
+
|
22
|
+
if id
|
23
|
+
api.get_request("#{path}/#{id}.json", params)
|
24
|
+
else
|
25
|
+
api.get_request("#{path}.json", params)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def update(params = {})
|
30
|
+
params = prepare_params(params)
|
31
|
+
id = params.delete(:id)
|
32
|
+
|
33
|
+
api.post_request("#{path}/#{id}.json", params)
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete(params = {})
|
37
|
+
params = prepare_params(params)
|
38
|
+
id = params.delete(:id)
|
39
|
+
|
40
|
+
api.delete_request("#{path}/#{id}.json", params)
|
41
|
+
end
|
42
|
+
|
43
|
+
def resource(relative_path)
|
44
|
+
MyTargetApi::Resource.new(api, "#{path}/#{relative_path}")
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
attr_reader :api, :path
|
50
|
+
|
51
|
+
def prepare_params(params)
|
52
|
+
raise UsingError, 'Params must be a Hash' unless params.is_a? Hash
|
53
|
+
|
54
|
+
params.map do |param, value|
|
55
|
+
[param.to_sym, value]
|
56
|
+
end.to_h
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# MyTargetApi
|
4
|
+
class MyTargetApi
|
5
|
+
|
6
|
+
API_BASE_URL = 'https://target.my.com/api'
|
7
|
+
|
8
|
+
autoload :Resource, 'my_target_api/resource'
|
9
|
+
autoload :Request, 'my_target_api/request'
|
10
|
+
autoload :Session, 'my_target_api/session'
|
11
|
+
|
12
|
+
autoload :ConnectionError, 'my_target_api/errors/connection_error'
|
13
|
+
autoload :RequestError, 'my_target_api/errors/request_error'
|
14
|
+
|
15
|
+
def initialize(access_token, options = {})
|
16
|
+
@access_token = access_token
|
17
|
+
@options = options
|
18
|
+
end
|
19
|
+
|
20
|
+
def resource(path, options = {})
|
21
|
+
version = options[:v]
|
22
|
+
version_part = version ? "v#{version}" : 'v1'
|
23
|
+
|
24
|
+
Resource.new(self, "#{API_BASE_URL}/#{version_part}/#{path}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_request(url, params)
|
28
|
+
request_object.get(url, params.merge(access_token: access_token))
|
29
|
+
end
|
30
|
+
|
31
|
+
def post_request(url, params)
|
32
|
+
request_object.post(url, params.merge(access_token: access_token))
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_request(url, params)
|
36
|
+
request_object.delete(url, params.merge(access_token: access_token))
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :access_token, :options
|
42
|
+
|
43
|
+
def request_object
|
44
|
+
Request.new(logger: options[:logger])
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'my_target_api/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'my_target_api'
|
9
|
+
spec.version = MyTargetApi::VERSION
|
10
|
+
spec.authors = ['Reshetnikov Ivan']
|
11
|
+
spec.email = ['help@oneretarget.com']
|
12
|
+
spec.summary = 'Ruby client for myTarget API'
|
13
|
+
spec.description = 'This library was created by OneRetarget.com - advertising automation service'
|
14
|
+
spec.homepage = 'https://github.com/resivalex/my_target_api'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = Dir['**/*']
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^spec/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'json', '~> 2.0', '>= 2.0.0'
|
23
|
+
spec.add_runtime_dependency 'rest-client', '~> 2.0', '>= 2.0.0'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
26
|
+
spec.add_development_dependency 'rake', '~> 12.3.0', '>= 12.3.0'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.7.0', '>= 3.7.0'
|
28
|
+
spec.add_development_dependency 'rubocop', '~> 0.54.0'
|
29
|
+
spec.add_development_dependency 'webmock', '~> 2.3.2', '>= 2.3.2'
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'my_target_api'
|
4
|
+
|
5
|
+
describe MyTargetApi::Request do
|
6
|
+
let(:access_token) { 'myTarget token' }
|
7
|
+
|
8
|
+
let(:request) { MyTargetApi::Request.new }
|
9
|
+
|
10
|
+
describe 'myTarget request types' do
|
11
|
+
it { expect(request).to respond_to(:get) }
|
12
|
+
it { expect(request).to respond_to(:post) }
|
13
|
+
it { expect(request).to respond_to(:delete) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'request something' do
|
17
|
+
it 'return parsed json' do
|
18
|
+
stub_request(:get, 'https://target.my.com/api/v1/campaigns.json')
|
19
|
+
.to_return(body: '{"name": "Campaign 1"}')
|
20
|
+
|
21
|
+
expect(subject.get('https://target.my.com/api/v1/campaigns.json'))
|
22
|
+
.to eq('name' => 'Campaign 1')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'my_target_api'
|
4
|
+
|
5
|
+
describe MyTargetApi::Resource do
|
6
|
+
let(:api) { double }
|
7
|
+
let(:path) { 'api_path' }
|
8
|
+
|
9
|
+
let(:resource) { MyTargetApi::Resource.new(api, path) }
|
10
|
+
|
11
|
+
describe 'responds to CRUD methods' do
|
12
|
+
it { expect(resource).to respond_to :create }
|
13
|
+
it { expect(resource).to respond_to :read }
|
14
|
+
it { expect(resource).to respond_to :update }
|
15
|
+
it { expect(resource).to respond_to :delete }
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#create' do
|
19
|
+
it 'request path to all objects' do
|
20
|
+
expect(api).to receive(:post_request).with('api_path.json', {})
|
21
|
+
resource.create
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#read' do
|
26
|
+
it 'request path to all objects' do
|
27
|
+
expect(api).to receive(:get_request).with('api_path.json', {})
|
28
|
+
resource.read
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'request path to one object' do
|
32
|
+
expect(api).to receive(:get_request).with('api_path/7.json', {})
|
33
|
+
resource.read(id: 7)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#update' do
|
38
|
+
it 'request path to all objects' do
|
39
|
+
expect(api).to receive(:get_request).with('api_path.json', {})
|
40
|
+
resource.read
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#delete' do
|
45
|
+
it 'request path to all objects' do
|
46
|
+
expect(api).to receive(:delete_request).with('api_path/7.json', {})
|
47
|
+
resource.delete(id: 7)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#resource' do
|
52
|
+
let(:nested_resource) { resource.resource('nested') }
|
53
|
+
|
54
|
+
it 'create nested resource' do
|
55
|
+
expect(api).to receive(:post_request).with('api_path/nested.json', {})
|
56
|
+
nested_resource.create
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/root_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'my_target_api'
|
4
|
+
|
5
|
+
describe MyTargetApi do
|
6
|
+
let(:access_token) { 'Access token' }
|
7
|
+
|
8
|
+
subject { MyTargetApi.new(access_token) }
|
9
|
+
|
10
|
+
it { should respond_to :resource }
|
11
|
+
|
12
|
+
it { should respond_to :get_request }
|
13
|
+
it { should respond_to :post_request }
|
14
|
+
it { should respond_to :delete_request }
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'webmock/rspec'
|
4
|
+
|
5
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
6
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
7
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
8
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
9
|
+
# files.
|
10
|
+
#
|
11
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
12
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
13
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
14
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
15
|
+
# a separate helper file that requires the additional dependencies and performs
|
16
|
+
# the additional setup, and require it from the spec files that actually need
|
17
|
+
# it.
|
18
|
+
#
|
19
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# rspec-expectations config goes here. You can use an alternate
|
22
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
23
|
+
# assertions if you prefer.
|
24
|
+
config.expect_with :rspec do |expectations|
|
25
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
26
|
+
# and `failure_message` of custom matchers include text for helper methods
|
27
|
+
# defined using `chain`, e.g.:
|
28
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
29
|
+
# # => "be bigger than 2 and smaller than 4"
|
30
|
+
# ...rather than:
|
31
|
+
# # => "be bigger than 2"
|
32
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
33
|
+
end
|
34
|
+
|
35
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
36
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
37
|
+
config.mock_with :rspec do |mocks|
|
38
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
39
|
+
# a real object. This is generally recommended, and will default to
|
40
|
+
# `true` in RSpec 4.
|
41
|
+
mocks.verify_partial_doubles = true
|
42
|
+
end
|
43
|
+
|
44
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
45
|
+
# have no way to turn it off -- the option exists only for backwards
|
46
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
47
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
48
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
49
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
50
|
+
|
51
|
+
# The settings below are suggested to provide a good initial experience
|
52
|
+
# with RSpec, but feel free to customize to your heart's content.
|
53
|
+
# # This allows you to limit a spec run to individual examples or groups
|
54
|
+
# # you care about by tagging them with `:focus` metadata. When nothing
|
55
|
+
# # is tagged with `:focus`, all examples get run. RSpec also provides
|
56
|
+
# # aliases for `it`, `describe`, and `context` that include `:focus`
|
57
|
+
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
58
|
+
# config.filter_run_when_matching :focus
|
59
|
+
#
|
60
|
+
# # Allows RSpec to persist some state between runs in order to support
|
61
|
+
# # the `--only-failures` and `--next-failure` CLI options. We recommend
|
62
|
+
# # you configure your source control system to ignore this file.
|
63
|
+
# config.example_status_persistence_file_path = "spec/examples.txt"
|
64
|
+
#
|
65
|
+
# # Limits the available syntax to the non-monkey patched syntax that is
|
66
|
+
# # recommended. For more details, see:
|
67
|
+
# # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
68
|
+
# # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
69
|
+
# # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
70
|
+
# config.disable_monkey_patching!
|
71
|
+
#
|
72
|
+
# # This setting enables warnings. It's recommended, but in some cases may
|
73
|
+
# # be too noisy due to issues in dependencies.
|
74
|
+
# config.warnings = true
|
75
|
+
#
|
76
|
+
# # Many RSpec users commonly either run the entire suite or an individual
|
77
|
+
# # file, and it's useful to allow more verbose output when running an
|
78
|
+
# # individual spec file.
|
79
|
+
# if config.files_to_run.one?
|
80
|
+
# # Use the documentation formatter for detailed output,
|
81
|
+
# # unless a formatter has already been configured
|
82
|
+
# # (e.g. via a command-line flag).
|
83
|
+
# config.default_formatter = "doc"
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# # Print the 10 slowest examples and example groups at the
|
87
|
+
# # end of the spec run, to help surface which specs are running
|
88
|
+
# # particularly slow.
|
89
|
+
# config.profile_examples = 10
|
90
|
+
#
|
91
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
92
|
+
# # order dependency and want to debug it, you can fix the order by providing
|
93
|
+
# # the seed, which is printed after each run.
|
94
|
+
# # --seed 1234
|
95
|
+
# config.order = :random
|
96
|
+
#
|
97
|
+
# # Seed global randomization in this process using the `--seed` CLI option.
|
98
|
+
# # Setting this allows you to use `--seed` to deterministically reproduce
|
99
|
+
# # test failures related to randomization by passing the same `--seed` value
|
100
|
+
# # as the one that triggered the failure.
|
101
|
+
# Kernel.srand config.seed
|
102
|
+
end
|
metadata
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: my_target_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Reshetnikov Ivan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rest-client
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.0.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '2.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.0.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: bundler
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.6'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.6'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 12.3.0
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 12.3.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 12.3.0
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 12.3.0
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: rspec
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 3.7.0
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.7.0
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.7.0
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 3.7.0
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: rubocop
|
109
|
+
requirement: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "~>"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 0.54.0
|
114
|
+
type: :development
|
115
|
+
prerelease: false
|
116
|
+
version_requirements: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - "~>"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.54.0
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: webmock
|
123
|
+
requirement: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: 2.3.2
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 2.3.2
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 2.3.2
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 2.3.2
|
141
|
+
description: This library was created by OneRetarget.com - advertising automation
|
142
|
+
service
|
143
|
+
email:
|
144
|
+
- help@oneretarget.com
|
145
|
+
executables: []
|
146
|
+
extensions: []
|
147
|
+
extra_rdoc_files: []
|
148
|
+
files:
|
149
|
+
- Gemfile
|
150
|
+
- LICENSE.txt
|
151
|
+
- README.md
|
152
|
+
- Rakefile
|
153
|
+
- lib/my_target_api.rb
|
154
|
+
- lib/my_target_api/auth.rb
|
155
|
+
- lib/my_target_api/errors/connection_error.rb
|
156
|
+
- lib/my_target_api/errors/request_error.rb
|
157
|
+
- lib/my_target_api/errors/using_error.rb
|
158
|
+
- lib/my_target_api/request.rb
|
159
|
+
- lib/my_target_api/resource.rb
|
160
|
+
- lib/my_target_api/version.rb
|
161
|
+
- my_target_api.gemspec
|
162
|
+
- spec/request_spec.rb
|
163
|
+
- spec/resource_spec.rb
|
164
|
+
- spec/root_spec.rb
|
165
|
+
- spec/spec_helper.rb
|
166
|
+
homepage: https://github.com/resivalex/my_target_api
|
167
|
+
licenses:
|
168
|
+
- MIT
|
169
|
+
metadata: {}
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options: []
|
172
|
+
require_paths:
|
173
|
+
- lib
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '0'
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 2.6.11
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: Ruby client for myTarget API
|
190
|
+
test_files:
|
191
|
+
- spec/request_spec.rb
|
192
|
+
- spec/resource_spec.rb
|
193
|
+
- spec/root_spec.rb
|
194
|
+
- spec/spec_helper.rb
|