yahoo_gemini_client 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +44 -13
  4. data/lib/yahoo_gemini_client.rb +16 -3
  5. data/lib/yahoo_gemini_client/client.rb +13 -4
  6. data/lib/yahoo_gemini_client/models/ad_group.rb +38 -0
  7. data/lib/yahoo_gemini_client/{advertiser.rb → models/advertiser.rb} +0 -0
  8. data/lib/yahoo_gemini_client/models/campaign.rb +67 -0
  9. data/lib/yahoo_gemini_client/requests/ad_group_base_request.rb +25 -0
  10. data/lib/yahoo_gemini_client/requests/ad_group_fetch_request.rb +21 -0
  11. data/lib/yahoo_gemini_client/requests/advertiser_base_request.rb +25 -0
  12. data/lib/yahoo_gemini_client/requests/advertiser_fetch_request.rb +21 -0
  13. data/lib/yahoo_gemini_client/requests/base_request.rb +0 -10
  14. data/lib/yahoo_gemini_client/requests/campaign_base_request.rb +25 -0
  15. data/lib/yahoo_gemini_client/requests/campaign_fetch_request.rb +21 -0
  16. data/lib/yahoo_gemini_client/requests/custom_report_base_request.rb +25 -0
  17. data/lib/yahoo_gemini_client/requests/custom_report_check_job_request.rb +7 -9
  18. data/lib/yahoo_gemini_client/requests/custom_report_job_request.rb +5 -8
  19. data/lib/yahoo_gemini_client/responses/ad_group_response.rb +11 -0
  20. data/lib/yahoo_gemini_client/responses/advertiser_response.rb +11 -0
  21. data/lib/yahoo_gemini_client/responses/base_response.rb +3 -1
  22. data/lib/yahoo_gemini_client/responses/campaign_response.rb +22 -0
  23. data/lib/yahoo_gemini_client/responses/custom_report_response.rb +1 -5
  24. data/lib/yahoo_gemini_client/services/ad_groups.rb +12 -0
  25. data/lib/yahoo_gemini_client/services/advertisers.rb +12 -0
  26. data/lib/yahoo_gemini_client/services/campaigns.rb +11 -0
  27. data/lib/yahoo_gemini_client/version.rb +1 -1
  28. metadata +18 -5
  29. data/lib/yahoo_gemini_client/advertisers.rb +0 -22
  30. data/lib/yahoo_gemini_client/collection.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 769db0035a436bc993c65ab58afc37887e805e81
4
- data.tar.gz: 1f53ca079d78a3d734fd7a876d3644620afef740
3
+ metadata.gz: e70191d23f647d30b8dd3c8d0db05e16c0e31d6a
4
+ data.tar.gz: 4271d2ca037dbefdff853c43b637b85caed2b176
5
5
  SHA512:
6
- metadata.gz: 2f3225a7ac8057a2a300dc5c949f6a3c544826aa053bc26a34af6d786f11f0d9545ad442e6bcfdbb9723485581e637029e775adfeadb2405fa7838e401dc5b2f
7
- data.tar.gz: f8976c73c408d42d04d7f0439e59d22c029898d620f1113fb3e7046e3851e3b472b8a3f1100819690f7a4b4d7c05a7a4e361cd173373fadb615e5af0cad1c45c
6
+ metadata.gz: 12eb812b069bd68667eec7b481735296d52e8853000f790b5893682e20467d5b3277d661af018c90a8adc51f7893e42c495fa008077bb64735bbdc6566196eb8
7
+ data.tar.gz: 918cfbc4cc8f78ebd782cf1a3f2f65ec2dc4b592c01ec434a50dc8e63adfb894b4e7c968f4127a720007ac1d34ee42cb5e1cd6014559b93bb6219d84643485c6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.1.0
2
+
3
+ - Add custom reports
4
+ - Refactor advertisers
5
+
1
6
  # 0.0.1
2
7
 
3
8
  - Initial release
data/README.md CHANGED
@@ -19,27 +19,42 @@ Or install it yourself as:
19
19
  $ gem install yahoo_gemini_client
20
20
 
21
21
  ## Usage
22
+ Currently supports OAuth2 Auth Code Strategy (Explicit Grant Flow) only.
23
+ For more info see https://developer.yahoo.com/oauth2/guide/flows_authcode/
22
24
 
23
- ```ruby
24
- # Currently supports OAuth2 Auth Code Strategy (Explicit Grant Flow) only
25
- # see https://developer.yahoo.com/oauth2/guide/flows_authcode/
25
+ ### Getting a refresh token
26
+
27
+ Your app can start using this gem if you have a refresh token.
28
+ A refresh token can be manually generated through the console.
26
29
 
30
+ ```ruby
27
31
  client = YahooGeminiClient::Client.new(
28
- client_id: "consumer_key",
29
- client_secret: "consumer_secret",
30
- refresh_token: "refresh_token"
32
+ consumer_key: "consumer_key",
33
+ consumer_secret: "consumer_secret",
31
34
  )
32
35
 
33
- client.authorization_url # returns authorization url
36
+ # open a browser and go to the authorization url given to get the authorization code
37
+ authorization_url = client.authorization_url
34
38
 
35
- # visit authorization url returned in a web browser to get the Authorization Code
36
- # assuming you've got an authentication code...
39
+ # you can now generate the refresh token once you have the authorization code
40
+ refresh_token = client.get_token("the_authorization_code").refresh_token
37
41
 
38
- client.get_token(authorization_code)
42
+ # with the refresh token you can now instantiate and use a YahooGeminiClient::Client anytime
43
+ client = YahooGeminiClient::Client.new(
44
+ consumer_key: "consumer_key",
45
+ consumer_secret: "consumer_secret",
46
+ refresh_token: refresh_token,
47
+ )
48
+ ```
49
+
50
+ ### Advertisers
39
51
 
40
- # Advertisers endpoint
41
- client.advertisers.each { |advertiser| puts advertiser.advertiser_name }
42
- client.advertisers.find(123)
52
+ #### Retrieving
53
+
54
+ ```ruby
55
+ response = client.advertisers.find(123)
56
+ response.error? # check if response is error
57
+ response.advertiser # returns a YahooGeminiClient::Advertiser
43
58
  ```
44
59
 
45
60
  ### Custom Reports
@@ -78,6 +93,22 @@ client.advertisers.find(123)
78
93
  response.csv_url # get the csv url of the created report
79
94
  ```
80
95
 
96
+ ### Campaigns
97
+
98
+ #### Fetching campaigns for an advertiser
99
+
100
+ ```ruby
101
+ params = {advertiser_id: 12345}
102
+ response = client.campaigns.where(params)
103
+ response.campaigns # returns Array[YahooGeminiClient::Campaign]
104
+ ```
105
+
106
+ ## Creating a Test Yahoo Gemini Account (For Testing)
107
+
108
+ 1. Sign in using any given Yahoo Mail Account and go to `https://gemini.yahoo.com/advertiser/home`
109
+ 2. Press "Sign Up" to create a Yahoo Gemini Account.
110
+ 3. From here, you can create an advertiser and corresponding campaigns
111
+
81
112
  ## Development
82
113
 
83
114
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -5,15 +5,28 @@ require "active_support/core_ext/hash/indifferent_access"
5
5
  require "yahoo_gemini_client/version"
6
6
  require "yahoo_gemini_client/client"
7
7
  require "yahoo_gemini_client/generate_member_uri"
8
- require "yahoo_gemini_client/collection"
9
- require "yahoo_gemini_client/advertisers"
10
- require "yahoo_gemini_client/advertiser"
8
+ require "yahoo_gemini_client/models/campaign"
9
+ require "yahoo_gemini_client/services/campaigns"
11
10
  require "yahoo_gemini_client/services/custom_report"
11
+ require "yahoo_gemini_client/models/advertiser"
12
+ require "yahoo_gemini_client/services/advertisers"
13
+ require "yahoo_gemini_client/models/ad_group"
14
+ require "yahoo_gemini_client/services/ad_groups"
12
15
  require "yahoo_gemini_client/responses/base_response"
16
+ require "yahoo_gemini_client/responses/advertiser_response"
13
17
  require "yahoo_gemini_client/requests/base_request"
18
+ require "yahoo_gemini_client/requests/custom_report_base_request"
14
19
  require "yahoo_gemini_client/requests/custom_report_job_request"
15
20
  require "yahoo_gemini_client/requests/custom_report_check_job_request"
21
+ require "yahoo_gemini_client/requests/campaign_base_request"
22
+ require "yahoo_gemini_client/requests/campaign_fetch_request"
23
+ require "yahoo_gemini_client/requests/advertiser_base_request"
24
+ require "yahoo_gemini_client/requests/advertiser_fetch_request"
25
+ require "yahoo_gemini_client/requests/ad_group_base_request"
26
+ require "yahoo_gemini_client/requests/ad_group_fetch_request"
16
27
  require "yahoo_gemini_client/responses/custom_report_response"
28
+ require "yahoo_gemini_client/responses/campaign_response"
29
+ require "yahoo_gemini_client/responses/ad_group_response"
17
30
 
18
31
  module YahooGeminiClient
19
32
 
@@ -12,13 +12,13 @@ module YahooGeminiClient
12
12
  def initialize(options={})
13
13
  @consumer_key = options[:consumer_key]
14
14
  @consumer_secret = options[:consumer_secret]
15
- @refresh_token = options[:refresh_token]
16
15
  @oauth2_client ||= OAuth2::Client.new(consumer_key, consumer_secret, {
17
16
  :site => 'https://api.login.yahoo.com',
18
17
  :authorize_url => '/oauth2/request_auth',
19
18
  :token_url => '/oauth2/get_token',
20
19
  })
21
- if options[:token]
20
+ if token_hash = options[:token]
21
+ @refresh_token = token_hash[:refresh_token]
22
22
  @token = OAuth2::AccessToken.from_hash(
23
23
  @oauth2_client,
24
24
  options[:token]
@@ -68,15 +68,24 @@ module YahooGeminiClient
68
68
  Advertisers.new(client: self)
69
69
  end
70
70
 
71
+ def campaigns
72
+ Campaigns.new(client: self)
73
+ end
74
+
75
+ def custom_report
76
+ CustomReport.new(client: self)
77
+ end
78
+
71
79
  def token_refresh!
80
+ # TODO: handle when there's no token
72
81
  self.token = self.token.refresh!({
73
82
  :redirect_uri => 'oob',
74
83
  :headers => oauth2_headers
75
84
  })
76
85
  end
77
86
 
78
- def custom_report
79
- CustomReport.new(client: self)
87
+ def ad_groups
88
+ AdGroups.new(client: self)
80
89
  end
81
90
 
82
91
  end
@@ -0,0 +1,38 @@
1
+ module YahooGeminiClient
2
+ class AdGroup
3
+
4
+ def initialize(hash)
5
+ @hash = hash
6
+ end
7
+
8
+ def id
9
+ @hash["id"]
10
+ end
11
+
12
+ def bid_set
13
+ # TODO wrap into array of Bid objects
14
+ @hash["bidSet"]
15
+ end
16
+
17
+ def advertiser_id
18
+ @hash["advertiserId"]
19
+ end
20
+
21
+ def ad_group_name
22
+ @hash["adGroupName"]
23
+ end
24
+
25
+ def campaign_id
26
+ @hash["campaignId"]
27
+ end
28
+
29
+ def start_date_str
30
+ @hash["startDateStr"]
31
+ end
32
+ def end_date_str
33
+ @hash["endDateStr"]
34
+ end
35
+
36
+ end
37
+ end
38
+
@@ -0,0 +1,67 @@
1
+ module YahooGeminiClient
2
+ class Campaign
3
+
4
+ def initialize(campaign_hash)
5
+ @hash = campaign_hash.map do |key,value|
6
+ {key.to_s.camelize(:lower) => value}
7
+ end.reduce(:merge)
8
+ end
9
+
10
+ def id
11
+ @hash["id"]
12
+ end
13
+
14
+ def status
15
+ @hash["status"]
16
+ end
17
+
18
+ def name
19
+ @hash["campaignName"]
20
+ end
21
+
22
+ def budget
23
+ @hash["budget"]
24
+ end
25
+
26
+ def language
27
+ @hash["language"]
28
+ end
29
+
30
+ def budget_type
31
+ @hash["budgetType"]
32
+ end
33
+
34
+ def advertiser_id
35
+ @hash["advertiserId"]
36
+ end
37
+
38
+ def channel
39
+ @hash["channel"]
40
+ end
41
+
42
+ def objective
43
+ @hash["objective"]
44
+ end
45
+
46
+ def is_partner_network
47
+ @hash["isPartnerNetwork"]
48
+ end
49
+
50
+ def default_landing_url
51
+ @hash["defaultLandingUrl"]
52
+ end
53
+
54
+ def tracking_partner
55
+ @hash["trackingPartner"]
56
+ end
57
+
58
+ def app_locale
59
+ @hash["appLocale"]
60
+ end
61
+
62
+ def to_params_hash
63
+ @hash
64
+ end
65
+
66
+ end
67
+ end
@@ -0,0 +1,25 @@
1
+ module YahooGeminiClient
2
+ class AdGroupBaseRequest < BaseRequest
3
+ REQUEST_URI = "https://api.admanager.yahoo.com/v1/rest/adgroup"
4
+ include Virtus.model
5
+
6
+ def http_authorization_header
7
+ {"Authorization" => "Bearer #{access_token}"}
8
+ end
9
+
10
+ protected
11
+
12
+ def post(opts)
13
+ HTTParty.post(REQUEST_URI,
14
+ headers: http_request_header.merge(http_authorization_header),
15
+ body: request_body.to_json,
16
+ )
17
+ end
18
+
19
+ def get(opts)
20
+ HTTParty.get(opts[:request_uri],
21
+ headers: http_request_header.merge(http_authorization_header),
22
+ )
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ module YahooGeminiClient
2
+ class AdGroupFetchRequest < AdGroupBaseRequest
3
+
4
+ attribute :ad_group_id, String
5
+
6
+ def execute
7
+ response = get(request_uri: build_request_uri)
8
+ AdGroupResponse.new(response.with_indifferent_access)
9
+ end
10
+
11
+ private
12
+
13
+ def build_request_uri
14
+ REQUEST_URI + ad_group_id_http_parameter
15
+ end
16
+
17
+ def ad_group_id_http_parameter
18
+ "/#{ad_group_id}"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ module YahooGeminiClient
2
+ class AdvertiserBaseRequest < BaseRequest
3
+ REQUEST_URI = "https://api.admanager.yahoo.com/v1/rest/advertiser"
4
+ include Virtus.model
5
+
6
+ def http_authorization_header
7
+ {"Authorization" => "Bearer #{access_token}"}
8
+ end
9
+
10
+ protected
11
+
12
+ def post(opts)
13
+ HTTParty.post(REQUEST_URI,
14
+ headers: http_request_header.merge(http_authorization_header),
15
+ body: request_body.to_json,
16
+ )
17
+ end
18
+
19
+ def get(opts)
20
+ HTTParty.get(opts[:request_uri],
21
+ headers: http_request_header.merge(http_authorization_header),
22
+ )
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ module YahooGeminiClient
2
+ class AdvertiserFetchRequest < AdvertiserBaseRequest
3
+
4
+ attribute :advertiser_id, String
5
+
6
+ def execute
7
+ response = get(request_uri: build_request_uri)
8
+ AdvertiserResponse.new(response.with_indifferent_access)
9
+ end
10
+
11
+ private
12
+
13
+ def build_request_uri
14
+ REQUEST_URI + advertiser_id_http_parameter
15
+ end
16
+
17
+ def advertiser_id_http_parameter
18
+ "/#{advertiser_id}"
19
+ end
20
+ end
21
+ end
@@ -28,16 +28,6 @@ module YahooGeminiClient
28
28
  self.class.name.demodulize.gsub("Request", "").underscore.to_sym
29
29
  end
30
30
 
31
- # def client
32
- # @client ||= Client.new(
33
- # consumer_key: ENV["YAHOO_GEMINI_TEST_CONSUMER_KEY"],
34
- # consumer_secret: ENV["YAHOO_GEMINI_TEST_CONSUMER_SECRET"],
35
- # token: {
36
- # refresh_token: ENV["YAHOO_GEMINI_TEST_REFRESH_TOKEN"],
37
- # }
38
- # )
39
- # end
40
-
41
31
  protected
42
32
 
43
33
  def access_token
@@ -0,0 +1,25 @@
1
+ module YahooGeminiClient
2
+ class CampaignBaseRequest < BaseRequest
3
+ REQUEST_URI = "https://api.admanager.yahoo.com/v1/rest/campaign"
4
+ include Virtus.model
5
+
6
+ def http_authorization_header
7
+ {"Authorization" => "Bearer #{access_token}"}
8
+ end
9
+
10
+ protected
11
+
12
+ def post(opts)
13
+ HTTParty.post(REQUEST_URI,
14
+ headers: http_request_header.merge(http_authorization_header),
15
+ body: request_body.to_json,
16
+ )
17
+ end
18
+
19
+ def get(opts)
20
+ HTTParty.get(opts[:request_uri],
21
+ headers: http_request_header.merge(http_authorization_header),
22
+ )
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ module YahooGeminiClient
2
+ class CampaignFetchRequest < CampaignBaseRequest
3
+
4
+ attribute :advertiser_id, String
5
+
6
+ def execute
7
+ response = get(request_uri: build_request_uri)
8
+ CampaignResponse.new(response.with_indifferent_access)
9
+ end
10
+
11
+ private
12
+
13
+ def build_request_uri
14
+ REQUEST_URI + advertiser_id_http_parameter
15
+ end
16
+
17
+ def advertiser_id_http_parameter
18
+ "?advertiserId=#{advertiser_id}"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,25 @@
1
+ module YahooGeminiClient
2
+ class CustomReportBaseRequest < BaseRequest
3
+ REQUEST_URI = "https://api.admanager.yahoo.com/v1/rest/reports/custom"
4
+ include Virtus.model
5
+
6
+ def http_authorization_header
7
+ {"Authorization" => "Bearer #{access_token}"}
8
+ end
9
+
10
+ protected
11
+
12
+ def post(opts)
13
+ HTTParty.post(REQUEST_URI,
14
+ headers: http_request_header.merge(http_authorization_header),
15
+ body: request_body.to_json,
16
+ )
17
+ end
18
+
19
+ def get(opts)
20
+ HTTParty.get(opts[:request_uri],
21
+ headers: http_request_header.merge(http_authorization_header),
22
+ )
23
+ end
24
+ end
25
+ end
@@ -1,23 +1,21 @@
1
1
  module YahooGeminiClient
2
- class CustomReportCheckJobRequest < BaseRequest
3
- REQUEST_URI = "https://api.admanager.yahoo.com/v1/rest/reports/custom/"
4
-
5
- attribute :request_body, String
2
+ class CustomReportCheckJobRequest < CustomReportBaseRequest
6
3
  attribute :advertiser_id, String
7
4
  attribute :job_id, String
8
5
 
9
6
  def execute
10
- http_authorization_header = {"Authorization" => "Bearer #{access_token}"}
11
- response = HTTParty.get(build_request_uri,
12
- headers: http_request_header.merge(http_authorization_header),
13
- )
7
+ response = get(request_uri: build_request_uri)
14
8
  CustomReportResponse.new(response.with_indifferent_access)
15
9
  end
16
10
 
17
11
  private
18
12
 
19
13
  def build_request_uri
20
- REQUEST_URI + job_id + advertiser_id_http_parameter
14
+ REQUEST_URI + job_id_http_parameter + advertiser_id_http_parameter
15
+ end
16
+
17
+ def job_id_http_parameter
18
+ "/#{job_id}"
21
19
  end
22
20
 
23
21
  def advertiser_id_http_parameter
@@ -1,15 +1,12 @@
1
1
  module YahooGeminiClient
2
- class CustomReportJobRequest < BaseRequest
3
- REQUEST_URI = "https://api.admanager.yahoo.com/v1/rest/reports/custom"
4
-
2
+ class CustomReportJobRequest < CustomReportBaseRequest
5
3
  attribute :request_body
6
4
 
7
5
  def execute
8
- http_authorization_header = {"Authorization" => "Bearer #{access_token}"}
9
- response = HTTParty.post(REQUEST_URI,
10
- headers: http_request_header.merge(http_authorization_header),
11
- body: request_body.to_json,
12
- )
6
+ response = post({
7
+ request_uri: REQUEST_URI,
8
+ request_body: request_body.to_json
9
+ })
13
10
  CustomReportResponse.new(response.with_indifferent_access)
14
11
  end
15
12
  end
@@ -0,0 +1,11 @@
1
+ module YahooGeminiClient
2
+ class AdGroupResponse < BaseResponse
3
+ attr_accessor :errors, :timestamp, :ad_group
4
+
5
+ def initialize(json_response)
6
+ @errors = json_response[:errors]
7
+ @timestamp = json_response[:timestamp]
8
+ @ad_group = AdGroup.new(json_response[:response])
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module YahooGeminiClient
2
+ class AdvertiserResponse < BaseResponse
3
+ attr_accessor :errors, :timestamp, :advertiser
4
+
5
+ def initialize(json_response)
6
+ @errors = json_response[:errors]
7
+ @timestamp = json_response[:timestamp]
8
+ @advertiser = Advertiser.new(json_response[:response])
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,7 @@
1
1
  module YahooGeminiClient
2
2
  class BaseResponse
3
-
3
+ def error?
4
+ !@errors.nil?
5
+ end
4
6
  end
5
7
  end
@@ -0,0 +1,22 @@
1
+ module YahooGeminiClient
2
+ class CampaignResponse < BaseResponse
3
+ attr_accessor :errors, :timestamp, :campaigns
4
+
5
+ def initialize(json_response)
6
+ @errors = json_response[:errors]
7
+ @timestamp = json_response[:timestamp]
8
+ @campaigns = []
9
+ if json_response[:response]
10
+ build_campaigns(json_response[:response])
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def build_campaigns(campaigns_hashes)
17
+ @campaigns = campaigns_hashes.map do |campaign_hash|
18
+ Campaign.new(campaign_hash)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  module YahooGeminiClient
2
- class CustomReportResponse
2
+ class CustomReportResponse < BaseResponse
3
3
  attr_accessor :errors, :timestamp, :job_id, :status, :csv_url
4
4
 
5
5
  def initialize(json_response)
@@ -12,10 +12,6 @@ module YahooGeminiClient
12
12
  end
13
13
  end
14
14
 
15
- def error?
16
- !@errors.nil?
17
- end
18
-
19
15
  def completed?
20
16
  @status == "completed"
21
17
  end
@@ -0,0 +1,12 @@
1
+ module YahooGeminiClient
2
+ class AdGroups
3
+ def initialize(opts={})
4
+ @client = opts[:client]
5
+ end
6
+
7
+ def find(ad_group_id)
8
+ params = { ad_group_id: ad_group_id }
9
+ AdGroupFetchRequest.new(params.merge(client: @client)).execute
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module YahooGeminiClient
2
+ class Advertisers
3
+ def initialize(opts={})
4
+ @client = opts[:client]
5
+ end
6
+
7
+ def find(advertiser_id)
8
+ params = { advertiser_id: advertiser_id }
9
+ AdvertiserFetchRequest.new(params.merge(client: @client)).execute
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ module YahooGeminiClient
2
+ class Campaigns
3
+ def initialize(opts={})
4
+ @client = opts[:client]
5
+ end
6
+
7
+ def where(params)
8
+ CampaignFetchRequest.new(params.merge(client: @client)).execute
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module YahooGeminiClient
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahoo_gemini_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramon Tayag
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-08-06 00:00:00.000000000 Z
12
+ date: 2015-08-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2
@@ -230,16 +230,29 @@ files:
230
230
  - bin/console
231
231
  - bin/setup
232
232
  - lib/yahoo_gemini_client.rb
233
- - lib/yahoo_gemini_client/advertiser.rb
234
- - lib/yahoo_gemini_client/advertisers.rb
235
233
  - lib/yahoo_gemini_client/client.rb
236
- - lib/yahoo_gemini_client/collection.rb
237
234
  - lib/yahoo_gemini_client/generate_member_uri.rb
235
+ - lib/yahoo_gemini_client/models/ad_group.rb
236
+ - lib/yahoo_gemini_client/models/advertiser.rb
237
+ - lib/yahoo_gemini_client/models/campaign.rb
238
+ - lib/yahoo_gemini_client/requests/ad_group_base_request.rb
239
+ - lib/yahoo_gemini_client/requests/ad_group_fetch_request.rb
240
+ - lib/yahoo_gemini_client/requests/advertiser_base_request.rb
241
+ - lib/yahoo_gemini_client/requests/advertiser_fetch_request.rb
238
242
  - lib/yahoo_gemini_client/requests/base_request.rb
243
+ - lib/yahoo_gemini_client/requests/campaign_base_request.rb
244
+ - lib/yahoo_gemini_client/requests/campaign_fetch_request.rb
245
+ - lib/yahoo_gemini_client/requests/custom_report_base_request.rb
239
246
  - lib/yahoo_gemini_client/requests/custom_report_check_job_request.rb
240
247
  - lib/yahoo_gemini_client/requests/custom_report_job_request.rb
248
+ - lib/yahoo_gemini_client/responses/ad_group_response.rb
249
+ - lib/yahoo_gemini_client/responses/advertiser_response.rb
241
250
  - lib/yahoo_gemini_client/responses/base_response.rb
251
+ - lib/yahoo_gemini_client/responses/campaign_response.rb
242
252
  - lib/yahoo_gemini_client/responses/custom_report_response.rb
253
+ - lib/yahoo_gemini_client/services/ad_groups.rb
254
+ - lib/yahoo_gemini_client/services/advertisers.rb
255
+ - lib/yahoo_gemini_client/services/campaigns.rb
243
256
  - lib/yahoo_gemini_client/services/custom_report.rb
244
257
  - lib/yahoo_gemini_client/version.rb
245
258
  - yahoo_gemini_client.gemspec
@@ -1,22 +0,0 @@
1
- module YahooGeminiClient
2
- class Advertisers < Collection
3
-
4
- def all
5
- response = get(base_uri)
6
- response.map do |advertiser_hash|
7
- Advertiser.new(advertiser_hash)
8
- end
9
- end
10
-
11
- def find(ids)
12
- uri = GenerateMemberURI.execute(base_uri, ids)
13
- response = get(uri.to_s)
14
- response.map { |advertiser_hash| Advertiser.new(advertiser_hash) }
15
- end
16
-
17
- def base_uri
18
- 'https://api.admanager.yahoo.com/v1/rest/advertiser/'
19
- end
20
-
21
- end
22
- end
@@ -1,41 +0,0 @@
1
- module YahooGeminiClient
2
- class Collection
3
-
4
- attr_reader :client
5
- include Enumerable
6
-
7
- def initialize(opts={})
8
- @client = opts[:client]
9
- end
10
-
11
- def api_request_headers
12
- client.api_request_headers
13
- end
14
-
15
- def each
16
- @members ||= all
17
- @members.each { |member| yield member }
18
- end
19
-
20
- private
21
-
22
- def get(uri)
23
- response = HTTParty.get(uri, headers: api_request_headers)
24
- if response.success?
25
- JSON.parse(response.body).with_indifferent_access[:response]
26
- else
27
- # TODO testme
28
- raise "Reponse Unsuccessful: #{response.body}"
29
- end
30
- end
31
-
32
- def member_uri(ids)
33
- GenerateMemberURI.execute(ids)
34
- end
35
-
36
- def base_uri
37
- raise 'This must be overriden'
38
- end
39
-
40
- end
41
- end