my_target_api 1.0.1 → 1.0.2
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 +4 -4
- data/Gemfile.lock +81 -0
- data/README.md +28 -27
- data/lib/my_target_api/request.rb +2 -2
- data/lib/my_target_api/version.rb +1 -1
- data/my_target_api.gemspec +5 -1
- data/spec/request_spec.rb +9 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60253aa7844b7f653d225c75305b9b051c79c940
|
4
|
+
data.tar.gz: c934fe8dd6d462427089aef5d6a965419f3aa2ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bc0e9b258b4dc79453f8cd7d5c9b91b1e0be31d44d1632690203179d298d0cffd668d29b6b7c9a6229f0aa154f9fc199eb9861e0ea9f3a7683ee3df5d218d7b
|
7
|
+
data.tar.gz: a7fd520c9966ca7027cbb1fcfdc5a23c119c1c6cb9431fcbe60cdb5673815ddc82ce6a6d030002847400fc3bd923f763d74e021a2852edc7d9442ed3cf2e7308
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
my_target_api (1.0.1)
|
5
|
+
json (~> 2.0, >= 2.0.0)
|
6
|
+
rest-client (~> 2.0, >= 2.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.5.2)
|
12
|
+
public_suffix (>= 2.0.2, < 4.0)
|
13
|
+
ast (2.4.0)
|
14
|
+
crack (0.4.3)
|
15
|
+
safe_yaml (~> 1.0.0)
|
16
|
+
diff-lcs (1.3)
|
17
|
+
domain_name (0.5.20170404)
|
18
|
+
unf (>= 0.0.5, < 1.0.0)
|
19
|
+
hashdiff (0.3.7)
|
20
|
+
http-cookie (1.0.3)
|
21
|
+
domain_name (~> 0.5)
|
22
|
+
json (2.1.0)
|
23
|
+
mime-types (3.1)
|
24
|
+
mime-types-data (~> 3.2015)
|
25
|
+
mime-types-data (3.2016.0521)
|
26
|
+
netrc (0.11.0)
|
27
|
+
parallel (1.12.1)
|
28
|
+
parser (2.5.0.5)
|
29
|
+
ast (~> 2.4.0)
|
30
|
+
powerpack (0.1.1)
|
31
|
+
public_suffix (3.0.2)
|
32
|
+
rainbow (3.0.0)
|
33
|
+
rake (12.3.1)
|
34
|
+
rest-client (2.0.2)
|
35
|
+
http-cookie (>= 1.0.2, < 2.0)
|
36
|
+
mime-types (>= 1.16, < 4.0)
|
37
|
+
netrc (~> 0.8)
|
38
|
+
rspec (3.7.0)
|
39
|
+
rspec-core (~> 3.7.0)
|
40
|
+
rspec-expectations (~> 3.7.0)
|
41
|
+
rspec-mocks (~> 3.7.0)
|
42
|
+
rspec-core (3.7.1)
|
43
|
+
rspec-support (~> 3.7.0)
|
44
|
+
rspec-expectations (3.7.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.7.0)
|
47
|
+
rspec-mocks (3.7.0)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.7.0)
|
50
|
+
rspec-support (3.7.1)
|
51
|
+
rubocop (0.54.0)
|
52
|
+
parallel (~> 1.10)
|
53
|
+
parser (>= 2.5)
|
54
|
+
powerpack (~> 0.1)
|
55
|
+
rainbow (>= 2.2.2, < 4.0)
|
56
|
+
ruby-progressbar (~> 1.7)
|
57
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
58
|
+
ruby-progressbar (1.9.0)
|
59
|
+
safe_yaml (1.0.4)
|
60
|
+
unf (0.1.4)
|
61
|
+
unf_ext
|
62
|
+
unf_ext (0.0.7.5)
|
63
|
+
unicode-display_width (1.3.0)
|
64
|
+
webmock (2.3.2)
|
65
|
+
addressable (>= 2.3.6)
|
66
|
+
crack (>= 0.3.2)
|
67
|
+
hashdiff
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
bundler (~> 1.6)
|
74
|
+
my_target_api!
|
75
|
+
rake (~> 12.3.0, >= 12.3.0)
|
76
|
+
rspec (~> 3.7.0, >= 3.7.0)
|
77
|
+
rubocop (~> 0.54.0)
|
78
|
+
webmock (~> 2.3.2, >= 2.3.2)
|
79
|
+
|
80
|
+
BUNDLED WITH
|
81
|
+
1.16.1
|
data/README.md
CHANGED
@@ -7,16 +7,10 @@
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```
|
10
|
-
gem 'my_target_api', '~> 1.0.
|
10
|
+
gem 'my_target_api', '~> 1.0.2'
|
11
11
|
```
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
```
|
16
|
-
$ bundle
|
17
|
-
```
|
18
|
-
|
19
|
-
Or install it yourself as:
|
13
|
+
Or install from command line:
|
20
14
|
|
21
15
|
```
|
22
16
|
$ gem install my_target_api
|
@@ -24,40 +18,47 @@ $ gem install my_target_api
|
|
24
18
|
|
25
19
|
## Usage
|
26
20
|
|
21
|
+
### Initialization
|
27
22
|
```ruby
|
28
|
-
#
|
29
|
-
|
23
|
+
# You need an access token to use API
|
24
|
+
my_target_api = MyTargetApi.new(access_token)
|
25
|
+
```
|
30
26
|
|
27
|
+
### Resources
|
28
|
+
```ruby
|
29
|
+
# root resources
|
30
|
+
campaigns_resource = my_target_api.resource('campaigns')
|
31
|
+
remarketing_resource = my_target_api.resource('remarketing', v: 2)
|
31
32
|
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
# nested resources
|
34
|
+
remarketing_counters_resource = my_target_api.resource('remarketing/counters', v: 2)
|
35
|
+
remarketing_counters_resource = remarketing_resource.resource('counters')
|
36
|
+
```
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
### Create, Read, Update, Delete
|
39
|
+
```ruby
|
40
|
+
remarketing_counters_resource.create(counter_id: 121212) # => [{ id: 343434 }]
|
39
41
|
|
40
|
-
#
|
41
|
-
campaigns_api.read # => [{ id: 12345, ... }, { ... }]
|
42
|
+
campaigns_resource.read # => [{ id: 12345, ... }, { ... }]
|
42
43
|
|
43
|
-
#
|
44
|
-
campaigns_api.read(id: 12345) # => [{ id: 12345, ... }]
|
44
|
+
campaigns_resource.read(id: 12345) # => [{ id: 12345, ... }]
|
45
45
|
|
46
|
-
#
|
47
|
-
campaigns_api.update(id: 12345, status: 'blocked') # => [{ id: 12345, status: 'blocked' }]
|
46
|
+
campaigns_resource.update(id: 12345, status: 'blocked') # => [{ id: 12345, status: 'blocked' }]
|
48
47
|
|
49
|
-
#
|
50
|
-
remarketing_counters_api.delete(id: 343434) # => true
|
48
|
+
remarketing_counters_resource.delete(id: 343434) # => true
|
51
49
|
```
|
52
50
|
|
53
51
|
## Exceptions
|
54
52
|
|
55
53
|
```ruby
|
56
54
|
def read_active_campaigns
|
57
|
-
|
55
|
+
|
56
|
+
campaigns_resource.read(status: 'active')
|
57
|
+
|
58
58
|
rescue MyTargetApi::RequestError, MyTargetApi::ConnectionError => e
|
59
|
-
|
60
|
-
|
59
|
+
|
60
|
+
puts e.message, e.backtrace
|
61
|
+
|
61
62
|
end
|
62
63
|
```
|
63
64
|
|
@@ -28,11 +28,11 @@ class MyTargetApi
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def delete(url, params = {})
|
31
|
-
|
31
|
+
with_exception_handling do
|
32
32
|
RestClient.delete(url, headers(params).merge(params: header_parameters(params)))
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
true
|
36
36
|
end
|
37
37
|
|
38
38
|
def body_parameters(params)
|
data/my_target_api.gemspec
CHANGED
@@ -10,7 +10,11 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = ['Reshetnikov Ivan']
|
11
11
|
spec.email = ['help@oneretarget.com']
|
12
12
|
spec.summary = 'Ruby client for myTarget API'
|
13
|
-
spec.description =
|
13
|
+
spec.description = <<~DESC
|
14
|
+
Ruby client for myTarget API.
|
15
|
+
It takes care of JSON parsing, file parameters, nested resources, api versions.
|
16
|
+
OneRetarget.com - advertising automation service
|
17
|
+
DESC
|
14
18
|
spec.homepage = 'https://github.com/resivalex/my_target_api'
|
15
19
|
spec.license = 'MIT'
|
16
20
|
|
data/spec/request_spec.rb
CHANGED
@@ -29,5 +29,14 @@ describe MyTargetApi::Request do
|
|
29
29
|
expect(subject.get('https://target.my.com/api/v1/vk_groups.json', q: 'unfound'))
|
30
30
|
.to eq([])
|
31
31
|
end
|
32
|
+
|
33
|
+
it 'deletes object' do
|
34
|
+
stub_request(:delete, 'https://target.my.com/api/v1/remarketing_context_phrases/53.json')
|
35
|
+
.to_return(body: '[]')
|
36
|
+
|
37
|
+
expect(
|
38
|
+
subject.delete('https://target.my.com/api/v1/remarketing_context_phrases/53.json')
|
39
|
+
).to eq(true)
|
40
|
+
end
|
32
41
|
end
|
33
42
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_target_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reshetnikov Ivan
|
@@ -138,8 +138,10 @@ dependencies:
|
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: 2.3.2
|
141
|
-
description:
|
142
|
-
|
141
|
+
description: |
|
142
|
+
Ruby client for myTarget API.
|
143
|
+
It takes care of JSON parsing, file parameters, nested resources, api versions.
|
144
|
+
OneRetarget.com - advertising automation service
|
143
145
|
email:
|
144
146
|
- help@oneretarget.com
|
145
147
|
executables: []
|
@@ -147,6 +149,7 @@ extensions: []
|
|
147
149
|
extra_rdoc_files: []
|
148
150
|
files:
|
149
151
|
- Gemfile
|
152
|
+
- Gemfile.lock
|
150
153
|
- LICENSE.txt
|
151
154
|
- README.md
|
152
155
|
- Rakefile
|