hq_tencent_dsp_api 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e18353ad19ed3d141d2f5221fe2087013d00934
4
+ data.tar.gz: 1c429e6cdf526537d53193fde94a3feb77ca5e99
5
+ SHA512:
6
+ metadata.gz: 5bc475b652316a825377f3a2276ed47fe0568ecdebb77a784b996490c48c8010f8750a57e9db4da174f6e6b650572d282dfba55a4ba872cae7b88e822efa5c06
7
+ data.tar.gz: 410b787e837075c0fc6486a8d72cd4e5df34da69986a59e89727962afbeb04ae3dbed1fe6e4db82984840bd7c52c7591ac2b856b8340aacd5697b12de2dcf04c
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hq_tencent_dsp_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 hhg08
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # HqTencentDspApi
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/hq_tencent_dsp_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'hq_tencent_dsp_api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install hq_tencent_dsp_api
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hq_tencent_dsp_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "hq_tencent_dsp_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hq_tencent_dsp_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hq_tencent_dsp_api"
8
+ spec.version = HqTencentDspApi::VERSION
9
+ spec.authors = ["hhg08"]
10
+ spec.email = ["594139475@qq.com"]
11
+
12
+ spec.summary = %q{tencent_dsp_api}
13
+ spec.description = %q{tencent_dsp_api}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+
20
+
21
+ # spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.files = `git ls-files -z`.split("\x0")
23
+ # spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.10"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ end
@@ -0,0 +1,157 @@
1
+ require "hq_tencent_dsp_api/version"
2
+ require 'net/http'
3
+ module HqTencentDspApi
4
+ DSP_ID = '190'
5
+ TOKEN = '73553e669b7270a4934706f76a99ad36'
6
+ AD_LIST_URL = 'http://opentest.adx.qq.com/location/list' #广告位信息同步API
7
+ UPLOAD_ORDER_URl = 'http://opentest.adx.qq.com/order/sync' #广告信息同步API
8
+ DENY_STATUS_URL = 'http://opentest.adx.qq.com/file/denylist' #获取审核未通过的广告信息API
9
+ GET_STARTUS_URL = 'http://opentest.adx.qq.com/order/getstatus' #批量获取广告的审核状态
10
+ UPLOAD_CUSTOMER_INFO_URL = 'http://opentest.adx.qq.com/client/sync' #批量上传客户信息审核
11
+ GET_CUSTOMER_STATUS_URL= 'http://opentest.adx.qq.com/client/info' #批量获取客户的审核信息
12
+ GET_QUALITIFIED_URL = 'http://opentest.adx.qq.com/client/quali' #获取审核通过客户的信息
13
+ REPORT_FORM_URL = 'http://opentest.adx.qq.com/order/report'#获取腾讯一个时间段内的数据报表
14
+ # Your code goes here...
15
+ def self.upload_order_info(order_info)
16
+ url = UPLOAD_ORDER_URl
17
+ params = {
18
+ 'dsp_id' => DSP_ID,
19
+ 'token' => TOKEN,
20
+ }
21
+ order_info = {"order_info"=>order_info}
22
+ url = URI.parse(url)
23
+ parameters = params.merge(order_info)
24
+ result = Net::HTTP.post_form(url,parameters)
25
+ return result
26
+ end
27
+
28
+
29
+ #广告位信息同步------------下载广告位信息
30
+ def self.load_ad_from_adx(date=nil)
31
+ url = AD_LIST_URL
32
+ params = {
33
+ "dsp_id" => DSP_ID,
34
+ "token"=>TOKEN,
35
+ "date"=> (date.nil? ? '' : date)
36
+ }
37
+ result = post(url,params)
38
+ return result
39
+ end
40
+
41
+ #获取审核未通过的广告信息
42
+ def self.get_ads_info_of_deny(upload_date)
43
+ url = DENY_STATUS_URL
44
+ params = {
45
+ "dsp_id"=>DSP_ID,
46
+ "token"=>TOKEN,
47
+ "upload_date"=>upload_date
48
+ }
49
+ result = post(url,params)
50
+ return result
51
+ end
52
+
53
+ #批量获取广告的审核状态
54
+ # result = TencentAdList.new.nums_of_ad_status(["48"].to_json)
55
+ # {"ret_code"=>0, "ret_msg"=>{"total"=>1, "count"=>1, "records"=>{"48"=>[{"status"=>"待审核", "client_name"=>"浩趣互动", "file_count"=>"1",
56
+ # "file_info"=>["http://dsp.hogic.cn/Public/Uploads/201508/55e00f321ba3c.flv#48"], "targeting_url"=>"http://dsp.hogic.cn", "monitor_url"=>"[]", "monitor_position"=>[""]}]}}, "error_code"=>0}
57
+ def self.nums_of_ad_status(dsp_order_id_info)
58
+ url = GET_STARTUS_URL
59
+ # url = URI.parse(url)
60
+ params = {
61
+ "dsp_id"=>DSP_ID,
62
+ "token"=>TOKEN,
63
+ "dsp_order_id_info"=>dsp_order_id_info
64
+ }
65
+ result = post(url,params)
66
+ return result
67
+ end
68
+
69
+ def post(url,params)
70
+ url = URI(url)
71
+ # http = Net::HTTP.new(url.host,url.port)
72
+ # request = Net::HTTP::Post.new(http.request_uri)
73
+ # request.body = params.to_json
74
+ # response = http.request(request)
75
+ # result = response.body
76
+ result = Net::HTTP.post_form(url,params)
77
+ result = ActiveSupport::JSON.decode(result.body)
78
+ if result["ret_code"].to_i!=0
79
+ raise "请求错误:#{result}"
80
+ end
81
+ return result
82
+ end
83
+
84
+
85
+ #客户信息同步----------批量上传客户信息
86
+ def self.upload_customer_info_confirm(client_info)
87
+ url = UPLOAD_CUSTOMER_INFO_URL
88
+ params = {
89
+ "dsp_id"=>DSP_ID,
90
+ "token"=>TOKEN,
91
+ "client_info"=>client_info||[]
92
+ }
93
+ result = post(url,params)
94
+ return result
95
+ end
96
+
97
+ #批量获取客户审核信息
98
+ # names = [{'names':'浩趣互动'}.to_json]
99
+ # result = TencentAdList.new.get_customer_status(names)
100
+ # => {"ret_code"=>0, "ret_msg"=>{"浩趣互动"=>{"verify_status"=>"待通过", "audit_info"=>"", "is_black"=>"N", "type"=>"ADX", "vocation"=>"", "vocation_all"=>""}}, "error_code"=>0}
101
+ def self.get_customer_status(names)
102
+ url = GET_CUSTOMER_STATUS_URL
103
+ params={
104
+ "dsp_id"=>DSP_ID,
105
+ "token"=>TOKEN,
106
+ "names"=>names||[]
107
+ }
108
+ p params
109
+ result = post(url,params)
110
+ return result
111
+ end
112
+
113
+ #获取审核通过客户的信息
114
+ def self.get_customer_qualitied
115
+ url = GET_QUALITIFIED_URL
116
+ params = {
117
+ "dsp_id"=>DSP_ID,
118
+ "token"=>TOKEN,
119
+ }
120
+ result = post(url,params)
121
+ return result
122
+ end
123
+
124
+ #腾讯报表 --用于定时任务调取
125
+ def self.get_tencent_report_form(start_date,end_date)
126
+ url = REPORT_FORM_URL
127
+ #由于start_date 跟end_date之间的差值超过7腾讯会直接报错,所以这地方判断一下,超过7就直接退出不去请求
128
+ s= Date.parse(start_date)-Date.parse(end_date)
129
+ if !s.nil? && s.to_i>7
130
+ raise '请求下载报表数据不能超过一周'
131
+ end
132
+ params = {
133
+ "dsp_id"=>DSP_ID,
134
+ "token"=>TOKEN,
135
+ "start_date"=>start_date,
136
+ "end_date"=>end_date
137
+ }
138
+ result = post(url,params)
139
+ if result["ret_code"].to_i != 0
140
+ raise "请求错误 #{result}"
141
+ end
142
+ return result
143
+ end
144
+
145
+ #添加一个地址
146
+ def getTrackingUrl(hqAdId,hqCreativeId,hqSource='youku',hqEvent=1)
147
+ sql = "select *,hq_expand_ad.id as aid from hq_expand_ad left join hq_expand_plan on hq_expand_ad.plan=hq_expand_plan.id where hq_expand_ad.id=#{hqAdId}"
148
+ conn = ActiveRecord::Base.connection_pool.checkout
149
+ results = conn.select_all(sql).to_hash
150
+ result = results[0]
151
+ hqClientId = result['company']
152
+ hqAdId = result['aid']
153
+ hqGroupId = result['plan']
154
+ # $hqCreativeId = $result['originality'];
155
+ return "http://track.hogic.cn/api/ads?hqClientId=#{hqClientId}&hqGroupId=#{hqGroupId}&hqAdId=#{hqAdId}&hqCreativeId=#{hqCreativeId}&hqSource=#{hqSource}&hqEvent=#{hqEvent}"
156
+ end
157
+ end
@@ -0,0 +1,3 @@
1
+ module HqTencentDspApi
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hq_tencent_dsp_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - hhg08
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: tencent_dsp_api
42
+ email:
43
+ - 594139475@qq.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - CODE_OF_CONDUCT.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - hq_tencent_dsp_api.gemspec
58
+ - lib/hq_tencent_dsp_api.rb
59
+ - lib/hq_tencent_dsp_api/version.rb
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.8
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: tencent_dsp_api
84
+ test_files: []