mailru_target 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/mailru_target/request.rb +15 -5
- data/lib/mailru_target/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f2da545e5769b74e31046f9782ca9528eea02c5
|
4
|
+
data.tar.gz: 950a4eaec9e90d7761c25855c5e176dfbb600940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf789b9dec26f289b7b1605a1e1c02fe485d2588affc832f12de39d363ff7bc7f748518883d3ded4470cae53022161c947da9e4c6ef6ffba0be116e306408fd8
|
7
|
+
data.tar.gz: 9e5f0de5b5b9947168ede71d8ca126c9c8c330866326553b5d5caf7fca453a660e425ac05493477c098b318284ef37f096a237c0c1cf86c6cb5e5dac5d9afce1
|
data/README.md
CHANGED
@@ -38,6 +38,11 @@ Initialize new session and request restful resources:
|
|
38
38
|
session = MailruTarget::Session.new(token)
|
39
39
|
session.request :get, "/campaigns", status: "active"
|
40
40
|
|
41
|
+
Request with 'sudo' mode:
|
42
|
+
|
43
|
+
session = MailruTarget::Session.new(token)
|
44
|
+
session.request :get, "/campaigns", { as_user: "xxxxxxx@agency_client", status: "active" }
|
45
|
+
|
41
46
|
## Contributing
|
42
47
|
|
43
48
|
1. Fork it ( https://github.com/[my-github-username]/mailru_target/fork )
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module MailruTarget
|
2
2
|
module Request
|
3
|
-
API_URI = "https://target.mail.ru/
|
3
|
+
API_URI = "https://target.mail.ru/"
|
4
|
+
SUDO_API_URI = "https://target.mail.ru/users/"
|
4
5
|
|
5
6
|
def request(method, path, params = {}, headers = {})
|
6
7
|
JSON.parse make_request(method, path, params, headers).to_s
|
@@ -24,7 +25,7 @@ module MailruTarget
|
|
24
25
|
private
|
25
26
|
|
26
27
|
def build(method, path, params, headers)
|
27
|
-
path =
|
28
|
+
path = get_uri(params) + "api/v#{params.delete(:v) || 1}" + path
|
28
29
|
path << ".json" unless path.split("/").last["."]
|
29
30
|
|
30
31
|
if params[:token]
|
@@ -34,9 +35,18 @@ module MailruTarget
|
|
34
35
|
end
|
35
36
|
|
36
37
|
case method
|
37
|
-
when :get
|
38
|
-
|
38
|
+
when :get
|
39
|
+
[:get, path, { params: params }.merge(headers)]
|
40
|
+
when :post
|
41
|
+
params = params[:grant_type] ? params : params.to_json
|
42
|
+
[:post, path, params, headers]
|
39
43
|
end
|
40
44
|
end
|
45
|
+
|
46
|
+
def get_uri(params)
|
47
|
+
user = params.delete(:as_user)
|
48
|
+
user ? "#{SUDO_API_URI}#{user}/" : API_URI
|
49
|
+
end
|
41
50
|
end
|
42
|
-
end
|
51
|
+
end
|
52
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailru_target
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugeniy Belyaev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.0.3
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Target.Mail.ru api via oauth2
|