yandex_offers 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yandex_offers/api/v1/campaigns.rb +6 -22
- data/lib/yandex_offers/authorization.rb +2 -2
- data/lib/yandex_offers/request.rb +24 -3
- data/lib/yandex_offers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 489c45ab21294d78a111893deabbb1a7c58309e0
|
4
|
+
data.tar.gz: 613bd92aca987595be301a70bb712b272ae404a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1140b4588c2f9c59b94460c996ea07f95b681344b6da11043b55753f60541f95e338b38e7b2d37056c56d353e8fcec49c1a6cca211803364f76832a9aa03b479
|
7
|
+
data.tar.gz: 19e6664e933f84a1336be6b6fbc7ac334fe396c6f1976b85c95cd02009f23be09d7c0f72edc1d594c72bbf0cf916c6f5c4d0ade58d391b722ae3fa07dc8588e0
|
@@ -4,43 +4,27 @@ module YandexOffers
|
|
4
4
|
class Campaigns
|
5
5
|
|
6
6
|
def create(*args)
|
7
|
-
|
8
|
-
Request.post("/campaigns/create", options)
|
7
|
+
Request.post_with_authorization("/campaigns/create", args)
|
9
8
|
end
|
10
9
|
|
11
10
|
def start(*args)
|
12
|
-
|
13
|
-
Request.post("/campaigns/start", options)
|
11
|
+
Request.post_with_authorization("/campaigns/start", args)
|
14
12
|
end
|
15
13
|
|
16
14
|
def stop(*args)
|
17
|
-
|
18
|
-
Request.post("/campaigns/stop", options)
|
15
|
+
Request.post_with_authorization("/campaigns/stop", args)
|
19
16
|
end
|
20
17
|
|
21
18
|
def get(*args)
|
22
|
-
|
23
|
-
Request.post("/campaigns/get", options)
|
19
|
+
Request.post_with_authorization("/campaigns/get", args)
|
24
20
|
end
|
25
21
|
|
26
22
|
def get_all_campaigns(*args)
|
27
|
-
|
28
|
-
Request.post("/campaigns/get_all_campaigns", options)
|
23
|
+
Request.post_with_authorization("/campaigns/get-all-campaigns", args)
|
29
24
|
end
|
30
25
|
|
31
26
|
def add_pins(*args)
|
32
|
-
|
33
|
-
Request.post("/campaigns/add_pins", options)
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def token
|
39
|
-
@token ||= Authorization.new.get_token
|
40
|
-
end
|
41
|
-
|
42
|
-
def headers
|
43
|
-
{ headers: { Authorization: "Bearer #{token}"} }
|
27
|
+
Request.post_with_authorization("/campaigns/add-pins", args)
|
44
28
|
end
|
45
29
|
end
|
46
30
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module YandexOffers
|
2
2
|
class Authorization
|
3
3
|
def get_token
|
4
|
-
|
5
|
-
response = Request.post("/users/login",
|
4
|
+
body = { login: YandexOffers.configuration.login, password: YandexOffers.configuration.password }
|
5
|
+
response = Request.post("/users/login", body)
|
6
6
|
response["accessToken"]
|
7
7
|
end
|
8
8
|
end
|
@@ -3,8 +3,29 @@ require 'httparty'
|
|
3
3
|
class YandexOffers::Request
|
4
4
|
include HTTParty
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
class << self
|
7
|
+
def post(url, body)
|
8
|
+
options = {}
|
9
|
+
options[:format] = :json
|
10
|
+
options[:body] = body
|
11
|
+
options[:headers] = self.headers
|
12
|
+
HTTParty.post("#{YandexOffers.configuration.base_url}#{url}", options).parsed_response
|
13
|
+
end
|
14
|
+
|
15
|
+
def post_with_authorization(url, body)
|
16
|
+
options = {}
|
17
|
+
options[:format] = :json
|
18
|
+
options[:body] = body.to_json
|
19
|
+
options[:headers] = self.headers.merge({"Authorization" => "Bearer #{self.token}"})
|
20
|
+
HTTParty.post("#{YandexOffers.configuration.base_url}#{url}", options).parsed_response
|
21
|
+
end
|
22
|
+
|
23
|
+
def token
|
24
|
+
@token ||= YandexOffers::Authorization.new.get_token
|
25
|
+
end
|
26
|
+
|
27
|
+
def headers
|
28
|
+
@headers ||= { "Content-Type" => "application/json", "Accept" => "application/json" }
|
29
|
+
end
|
9
30
|
end
|
10
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yandex_offers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fenec
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|