admitad_query 0.0.4
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/lib/admitad.rb +74 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a16a44a3807b728078204ce62f96361c1a69bad06230932c50d5f25fb4011147
|
4
|
+
data.tar.gz: 678ddd935da89a2096c61358bcbd3fc9fa5879a68ac38bb30dd4e281897ae709
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 46dceb09a6f3776dfc6d033b695f8e6b8932caf6684059e3227fb19fd7bd651f20fb4cf65406c8f57fb76a21ed87d9544867e82c89f15ecba970d102ef75d785
|
7
|
+
data.tar.gz: 67d945a0b26e8f4887a82a9471287eab9025307bfe074f5f033a8a2658366c4fe9f3f79e1a3c7a69c2e8fecb40ff2a709de23783c8082711c95b17726fd8504e
|
data/lib/admitad.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "admitad/version"
|
4
|
+
|
5
|
+
module Admitad
|
6
|
+
class Error < StandardError; end
|
7
|
+
# frozen_string_literal: true
|
8
|
+
# Rails cache
|
9
|
+
# Singeltone
|
10
|
+
require 'http'
|
11
|
+
require 'uri'
|
12
|
+
require 'net/http'
|
13
|
+
require 'json'
|
14
|
+
|
15
|
+
Admitad.config do |c|
|
16
|
+
c.client_id = '9Oo9LsDIaQhqCUtVkbSFIPfSmXQ7mQ'
|
17
|
+
c.client_secret = '0cD5yQEVDAA8hK4NSqDVJF7VUHHU5A'
|
18
|
+
c.scope = ''
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_json(request)
|
22
|
+
raw_json = JSON.generate(request)
|
23
|
+
raw_json = JSON.parse raw_json.gsub('=>', ':')
|
24
|
+
JSON(raw_json)
|
25
|
+
end
|
26
|
+
|
27
|
+
def autorisation_admitad
|
28
|
+
cookies[:code] = params[:code] unless params[:code].nil?
|
29
|
+
url = URI("https://api.admitad.com/token/?state=7c232ff20e64432fbe071228c0779f&redirect_uri=http%3A%2F%2F127.0.0.1:3000%2F&response_type=code&client_id=9Oo9LsDIaQhqCUtVkbSFIPfSmXQ7mQ&client_secret=0cD5yQEVDAA8hK4NSqDVJF7VUHHU5A&code=#{cookies[:code]}&grant_type=authorization_code")
|
30
|
+
|
31
|
+
https = Net::HTTP.new(url.host, url.port)
|
32
|
+
https.use_ssl = true
|
33
|
+
|
34
|
+
request = Net::HTTP::Post.new(url)
|
35
|
+
request['Authorization'] =
|
36
|
+
'Basic OU9vOUxzRElhUWhxQ1V0VmtiU0ZJUGZTbVhRN21ROjBjRDV5UUVWREFBOGhLNE5TcURWSkY3VlVISFU1QQ=='
|
37
|
+
request['Cookie'] = 'gdpr_country=0'
|
38
|
+
|
39
|
+
request = create_json(https.request(request).read_body)
|
40
|
+
@response = request
|
41
|
+
cookies[:refresh_token] = request['refresh_token'] unless request['refresh_token'].nil?
|
42
|
+
cookies[:access_token] = request['access_token'] unless request['refresh_token'].nil?
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_subid_data
|
46
|
+
url = URI('https://api.admitad.com/statistics/sub_ids/?date_start=01.01.2021&order_by=sub_id')
|
47
|
+
|
48
|
+
https = Net::HTTP.new(url.host, url.port)
|
49
|
+
https.use_ssl = true
|
50
|
+
|
51
|
+
request = Net::HTTP::Get.new(url)
|
52
|
+
request['Authorization'] = "Bearer #{cookies[:access_token]}"
|
53
|
+
request['Cookie'] = 'gdpr_country=0; user_default_language=en'
|
54
|
+
request = create_json(https.request(request).read_body)
|
55
|
+
puts "11111111111111111111111111111111111"
|
56
|
+
@subid_data = request
|
57
|
+
cookies[:subid_data] = request['results'] unless request['status_code'] == 401
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_action_data
|
61
|
+
url = URI('https://api.admitad.com/statistics/actions/?date_start=14.03.2021&limit=222&order_by=date&action_type=1')
|
62
|
+
|
63
|
+
https = Net::HTTP.new(url.host, url.port)
|
64
|
+
https.use_ssl = true
|
65
|
+
|
66
|
+
request = Net::HTTP::Get.new(url)
|
67
|
+
request['Authorization'] = "Bearer #{cookies[:access_token]}"
|
68
|
+
request['Cookie'] = 'gdpr_country=0; user_default_language=en'
|
69
|
+
puts "-------------------------------"
|
70
|
+
puts https.request(request).read_body
|
71
|
+
request = create_json(https.request(request).read_body.force_encoding('utf-8'))
|
72
|
+
@action_data = request['results']
|
73
|
+
end
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: admitad_query
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cruelRamp
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A gem whit redy qury methods
|
14
|
+
email: minery27@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/admitad.rb
|
20
|
+
homepage:
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.1.2
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: Hola!
|
43
|
+
test_files: []
|