adops_report_scrapper 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edfa740c95e357d7bb46833be1c18bf610ea38af
4
- data.tar.gz: 9370b7ba6a8f9bcf1066f8c904967866a54cb68c
3
+ metadata.gz: 2062161736aa199788f24a787649cc654fce4f67
4
+ data.tar.gz: dd424d62acb31fc097d8a4dd6951aa9b75e37d5b
5
5
  SHA512:
6
- metadata.gz: e47ee08b90c72bcf731d1d2d8ac66cf3304a8b284c73e787bbad0d0823625603e676a224c00a5d4cd5a98d55c8f2c377926971434977d967bcc0aa993bd34e26
7
- data.tar.gz: cf3eeb5ad64dd98de6a45958bef94c3106b5bbbcee97b7766687f6d74d3d1382f3a373ea89affa52158557bbaa0fd485e23519ec95372647366db0a19064cb89
6
+ metadata.gz: f8e3e4d325b51ff318ab3a944d2c2fbcdc29bd7583a0e5287000417fec93377fc7bc1f5ebdf5edd07894337c059bc6307efac91ec5edc88a5c3189bd203d065f
7
+ data.tar.gz: 9090366aabcb84f92dc3c86127059e5d29d70cac949a0a98c88b6dcca2759ad65dd29baa4042da5b555df047e13f159e329150bc05ac6e86ccb0acc4c2baba2d
data/CHANGELOG CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.9
4
+ fix spotxchange
5
+
3
6
  ## 0.2.8
4
7
  implement spotxchange
5
8
 
@@ -12,8 +12,11 @@ class AdopsReportScrapper::SpotxchangeClient < AdopsReportScrapper::BaseClient
12
12
  private
13
13
 
14
14
  def init_client
15
- fail 'please specify spotxchange oauth code' unless @options['code']
16
- @code = @options['code']
15
+ fail 'please specify spotxchange oauth client_id' unless @options['client_id']
16
+ @client_id = @options['client_id']
17
+ fail 'please specify spotxchange oauth client_secret' unless @options['client_secret']
18
+ @client_secret = @options['client_secret']
19
+ super
17
20
  end
18
21
 
19
22
  def before_quit_with_error
@@ -22,7 +25,19 @@ class AdopsReportScrapper::SpotxchangeClient < AdopsReportScrapper::BaseClient
22
25
  def scrap
23
26
  date_str = @date.strftime('%Y-%m-%d')
24
27
 
25
- body = { 'client_id' => @login, 'client_secret' => @secret, 'grant_type' => 'authorization_code', 'code' => @code }
28
+ @client.visit "https://publisher-api.spotxchange.com/oauth2/publisher/approval.html?client_id=#{@client_id}&response_type=code&state=xyz"
29
+ @client.click_button 'Accept'
30
+
31
+ @client.fill_in 'Username', :with => @login
32
+ @client.fill_in 'Password', :with => @secret
33
+ @client.click_button 'Login'
34
+
35
+ @client.click_button 'Accept'
36
+ sleep 1
37
+
38
+ code = URI::decode_www_form(URI.parse(@client.driver.network_traffic.last.url).query).to_h['code']
39
+
40
+ body = { 'client_id' => @client_id, 'client_secret' => @client_secret, 'grant_type' => 'authorization_code', 'code' => code }
26
41
  response = HTTPClient.post 'https://publisher-api.spotxchange.com/1.0/token', body
27
42
  token = JSON.parse(response.body)['value']['data']['access_token']
28
43
 
@@ -1,3 +1,3 @@
1
1
  module AdopsReportScrapper
2
- VERSION = "0.2.8"
2
+ VERSION = "0.2.9"
3
3
  end
data/secret.sample.yml CHANGED
@@ -135,4 +135,5 @@ spotxchange:
135
135
  login: ------
136
136
  secret: ------
137
137
  options:
138
- code: ------
138
+ client_id: ------
139
+ client_secret: ------
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adops_report_scrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stayman Hou