mailru_target 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85a6716f3c1fa1e7b99659497cfd6c26bcd5048e
4
- data.tar.gz: d226c4a4d7684fcddd4faa29ef1916f713eea09c
3
+ metadata.gz: 7f2da545e5769b74e31046f9782ca9528eea02c5
4
+ data.tar.gz: 950a4eaec9e90d7761c25855c5e176dfbb600940
5
5
  SHA512:
6
- metadata.gz: d6c16aa41301f8061837c7189b924c2f9b3d2f45e359f1c2769f122b9278a0213db26f9ab232e5ad490f2de60190fd5b736a2651860a02c2f3c4c1fb86bf2a34
7
- data.tar.gz: 7effe0ba7117f40712117b629dad5aed7d1c2a5435ae808c862e39232adbb94be095483b0fb00388c0464ec091f5e9e8941958d3870981aa6097b41d979289ab
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/api"
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 = API_URI + "/v#{params.delete(:v) || 1}" + 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 then [:get, path, { params: params }.merge(headers)]
38
- when :post then [:post, path, params, headers]
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
+
@@ -1,3 +1,3 @@
1
1
  module MailruTarget
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-05 00:00:00.000000000 Z
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.2.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