https://github.com/forward3d/three-sixty
A Ruby gem for connecting to the 360 Dianjing AD system, using the Open API Platform
https://github.com/forward3d/three-sixty
Last synced: 2 months ago
JSON representation
A Ruby gem for connecting to the 360 Dianjing AD system, using the Open API Platform
- Host: GitHub
- URL: https://github.com/forward3d/three-sixty
- Owner: forward3d
- Created: 2014-05-30T14:35:43.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-08-08T10:00:48.000Z (almost 2 years ago)
- Last Synced: 2024-04-24T08:55:25.815Z (about 1 year ago)
- Language: Ruby
- Size: 30.3 KB
- Stars: 0
- Watchers: 21
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 360
A Ruby gem for connecting to the 360 Dianjing AD system, using the Open API Platform## Install
Using bundler, add to your Gemfile
gem 'three-sixty'
## Configuration
require 'three-sixty'
ThreeSixty.configure(logger: Logger.new($stdout))## Authenticate
require 'three-sixty'
client = ThreeSixty::Client.new(api_key, api_secret)
client.authenticate!(username, password)You can specify a hash of optional parameters when initializing the client. These include
:endpoint - The 360 api endpoint (This is unlikely to change)
:version - The 360 api version number
:format - The api reponse format (Currently JSON or XML and is only useful when using the core library)
:logger - The client logger## Get Campaign Ids
require 'three-sixty'
client = ThreeSixty::Client.new(api_key, api_secret)
client.authenticate!(username, password)account = ThreeSixty::Account.new(client, opts)
campaign_ids = account.download_campaign_idsYou can specify a hash of optional parameters when initializing the account. These include
:logger - Attach a local logger
:report_generating_backoff - Create a lambda for your backoff strategy when polling the report generate e.g. lambda { |retry_number| [1 30 60 300].index(retry_number) }## Streaming Campaign Ids to a File
File.open('campaign_ids.csv', 'w') do |file|
account.download_campaigns(campaign_ids) do |content|
file.write content
end
end## Download Campaign Ids to a File
file = account.download_campaigns_to_file(campaign_ids, opts)
You can specify a hash of optional parameters, which includes
:download_dir - The directory to download the file
:filename - The full path of the file you wish to create
:encoding - The encoding used when downloading the file## Download Campaign Info
campaign = ThreeSixty::Campaign.new(client)
campaign_info = campaign.download_all_campaigns## Download All Ad Groups for a Campaign
group = ThreeSixty::Group.new(client)
group_info = group.download_campaign_all_ad_groups(campaigns_id)## Download All Creatives for a Campaign
group = ThreeSixty::Group.new(client)
ad_group_ids = group.download_campaign_ad_group_ids(campaign_id)creatives = []
creative = ThreeSixty::Creative.new(client)
ad_group_ids.each do |ad_group_id|
creatives += creative.download_ad_group_all_creatives(ad_group_id)
end## Downlod All Keywords for a Campaign
group = ThreeSixty::Group.new(client)
ad_group_ids = group.download_campaign_ad_group_ids(campaign_id)keywords = []
keyword = ThreeSixty::Keyword.new(client)
ad_group_ids.each do |ad_group_id|
keywords += keyword.download_ad_group_all_keywords(ad_group_id)
end