fb_graph 2.1.0.alpha → 2.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.
- data/.travis.yml +0 -1
- data/Gemfile.lock +1 -2
- data/VERSION +1 -1
- data/lib/fb_graph/ad_account.rb +1 -0
- data/lib/fb_graph/ad_campaign.rb +2 -0
- data/lib/fb_graph/ad_group.rb +22 -0
- data/lib/fb_graph/connections/{ad_campaign.rb → ad_campaigns.rb} +0 -0
- data/lib/fb_graph/connections/ad_groups.rb +24 -0
- data/lib/fb_graph.rb +1 -0
- data/spec/fb_graph/ad_group_spec.rb +53 -0
- data/spec/fb_graph/connections/ad_groups_spec.rb +54 -0
- data/spec/mock_json/ad_accounts/ad_groups/post_with_valid_access_token.json +1 -0
- data/spec/mock_json/ad_campaigns/ad_groups/22334455_ad_groups.json +23 -0
- data/spec/mock_json/ad_groups/test_ad_group.json +13 -0
- metadata +62 -7
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fb_graph (2.0.
|
4
|
+
fb_graph (2.1.0.alpha)
|
5
5
|
httpclient (>= 2.2.0.2)
|
6
6
|
rack-oauth2 (>= 0.8.0)
|
7
7
|
|
@@ -41,7 +41,6 @@ GEM
|
|
41
41
|
jruby-openssl (0.7.4)
|
42
42
|
bouncy-castle-java
|
43
43
|
json (1.5.4)
|
44
|
-
json (1.5.4-java)
|
45
44
|
multi_json (1.0.3)
|
46
45
|
rack (1.3.2)
|
47
46
|
rack-cache (1.0.3)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.0
|
1
|
+
2.1.0
|
data/lib/fb_graph/ad_account.rb
CHANGED
data/lib/fb_graph/ad_campaign.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class AdGroup < Node
|
3
|
+
attr_accessor :ad_id, :campaign_id, :name, :adgroup_status, :bid_type, :max_bid, :adgroup_id, :end_time, :start_time, :updated_time
|
4
|
+
|
5
|
+
def initialize(identifier, attributes = {})
|
6
|
+
super
|
7
|
+
|
8
|
+
%w(ad_id campaign_id name adgroup_status bid_type max_bid adgroup_id).each do |field|
|
9
|
+
send("#{field}=", attributes[field.to_sym])
|
10
|
+
end
|
11
|
+
|
12
|
+
%w(start_time end_time updated_time).each do |field|
|
13
|
+
if val = attributes[field.to_sym]
|
14
|
+
# Handles integer timestamps and ISO8601 strings
|
15
|
+
time = Time.parse(val) rescue Time.at(val.to_i)
|
16
|
+
send("#{field}=", time)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module Connections
|
3
|
+
module AdGroups
|
4
|
+
def ad_groups(options = {})
|
5
|
+
ad_groups = self.connection(:adgroups, options)
|
6
|
+
ad_groups.map! do |ad_group|
|
7
|
+
AdGroup.new(ad_group[:id], ad_group.merge(
|
8
|
+
:access_token => options[:access_token] || self.access_token
|
9
|
+
))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Note: AdGroups can only be created via the AdAccount connection. Even though it makes sense, they
|
14
|
+
# cannot be created via the AdCampaign connection
|
15
|
+
def ad_group!(options = {})
|
16
|
+
ad_group = post(options.merge(:connection => :adgroups))
|
17
|
+
AdGroup.new(ad_group[:id], options.merge(ad_group).merge(
|
18
|
+
:access_token => options[:access_token] || self.access_token
|
19
|
+
))
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
data/lib/fb_graph.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph::AdGroup, '.new' do
|
4
|
+
attr_accessor :ad_id, :campaign_id, :name, :adgroup_status, :bid_type, :max_bid, :adgroup_id, :end_time, :start_time, :updated_time
|
5
|
+
it 'should setup all supported attributes' do
|
6
|
+
attributes = {
|
7
|
+
:id => '6003590469668',
|
8
|
+
:ad_id => 6003590469668,
|
9
|
+
:campaign_id => 6003590468467,
|
10
|
+
:name => 'Ad Group 1',
|
11
|
+
:adgroup_status => 1,
|
12
|
+
:bid_type => 1,
|
13
|
+
:max_bid => 1000,
|
14
|
+
:adgroup_id => 6003590469668,
|
15
|
+
:end_time => "2011-09-10T00:00:00+00:00",
|
16
|
+
:start_time => "2011-09-01T12:00:00-07:00",
|
17
|
+
:updated_time => "2011-09-04T16:00:00+00:00"
|
18
|
+
}
|
19
|
+
ad_group = FbGraph::AdGroup.new(attributes.delete(:id), attributes)
|
20
|
+
ad_group.identifier.should == "6003590469668"
|
21
|
+
ad_group.ad_id.should == 6003590469668
|
22
|
+
ad_group.campaign_id.should == 6003590468467
|
23
|
+
ad_group.name.should == "Ad Group 1"
|
24
|
+
ad_group.adgroup_status.should == 1
|
25
|
+
ad_group.bid_type.should == 1
|
26
|
+
ad_group.max_bid.should == 1000
|
27
|
+
ad_group.adgroup_id.should == 6003590469668
|
28
|
+
ad_group.end_time.should == Time.parse("2011-09-10T00:00:00+00:00")
|
29
|
+
ad_group.start_time.should == Time.parse("2011-09-01T12:00:00-07:00")
|
30
|
+
ad_group.updated_time.should == Time.parse("2011-09-04T16:00:00+00:00")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
describe FbGraph::AdGroup, '.fetch' do
|
36
|
+
it 'should get the ad group' do
|
37
|
+
mock_graph :get, '6003590469668', 'ad_groups/test_ad_group', :access_token => 'access_token' do
|
38
|
+
ad_group = FbGraph::AdGroup.fetch('6003590469668', :access_token => 'access_token')
|
39
|
+
|
40
|
+
ad_group.identifier.should == "6003590469668"
|
41
|
+
ad_group.ad_id.should == 6003590469668
|
42
|
+
ad_group.campaign_id.should == 6003590468467
|
43
|
+
ad_group.name.should == "Ad Group 1"
|
44
|
+
ad_group.adgroup_status.should == 1
|
45
|
+
ad_group.bid_type.should == 1
|
46
|
+
ad_group.max_bid.should == 1000
|
47
|
+
ad_group.adgroup_id.should == 6003590469668
|
48
|
+
ad_group.end_time.should == Time.parse("2011-09-10T00:00:00+00:00")
|
49
|
+
ad_group.start_time.should == Time.parse("2011-09-01T12:00:00-07:00")
|
50
|
+
ad_group.updated_time.should == Time.parse("2011-09-04T16:00:00+00:00")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph::Connections::AdGroups, '#ad_groups' do
|
4
|
+
context 'when included by FbGraph::AdCampaign' do
|
5
|
+
context 'when access_token is given' do
|
6
|
+
it 'should return ad_groups as FbGraph::AdGroup' do
|
7
|
+
mock_graph :get, '22334455/adgroups', 'ad_campaigns/ad_groups/22334455_ad_groups', :access_token => 'access_token' do
|
8
|
+
ad_groups = FbGraph::AdCampaign.new('22334455', :access_token => 'access_token').ad_groups
|
9
|
+
ad_groups.first.should == FbGraph::AdGroup.new(
|
10
|
+
44556677,
|
11
|
+
:access_token => 'access_token',
|
12
|
+
:ad_id => 44556677,
|
13
|
+
:campaign_id => 22334455,
|
14
|
+
:name => "Test Ad Group 1",
|
15
|
+
:adgroup_status => 1,
|
16
|
+
:bid_type => 1,
|
17
|
+
:max_bid => 150,
|
18
|
+
:adgroup_id => 44556677,
|
19
|
+
:end_time => Time.parse("2011-09-01T00:00:00+00:00"),
|
20
|
+
:start_time => Time.parse("2011-09-10T00:00:00+00:00"),
|
21
|
+
:updated_time => Time.parse("2011-09-05T00:00:00+00:00")
|
22
|
+
)
|
23
|
+
ad_groups.each { |ad_group| ad_group.should be_instance_of(FbGraph::AdGroup) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe FbGraph::Connections::AdGroups, '#ad_group!' do
|
31
|
+
context 'when included by FbGraph::AdAccount' do
|
32
|
+
it 'should return generated ad_group' do
|
33
|
+
mock_graph :post, 'act_22334455/adgroups', 'ad_accounts/ad_groups/post_with_valid_access_token' do
|
34
|
+
ad_group = FbGraph::AdAccount.new('act_22334455', :access_token => 'valid').ad_group!(
|
35
|
+
:name => "Test Ad 1",
|
36
|
+
:campaign_id => 66778899,
|
37
|
+
:bid_type => 1,
|
38
|
+
:max_bid => 100,
|
39
|
+
:start_time => Time.parse("2011-09-10T12:00:00+00:00"),
|
40
|
+
:end_time => Time.parse("2011-09-20T16:00:00-04:00")
|
41
|
+
)
|
42
|
+
|
43
|
+
ad_group.identifier.should == 112233445566
|
44
|
+
ad_group.campaign_id.should == 66778899
|
45
|
+
ad_group.name.should == "Test Ad 1"
|
46
|
+
ad_group.bid_type.should == 1
|
47
|
+
ad_group.max_bid.should == 100
|
48
|
+
ad_group.start_time.should == Time.parse("2011-09-10T12:00:00+00:00")
|
49
|
+
ad_group.end_time.should == Time.parse("2011-09-20T16:00:00-04:00")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":112233445566}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
{
|
2
|
+
"data":[
|
3
|
+
{
|
4
|
+
"id": 44556677,
|
5
|
+
"adgroup_id": 44556677,
|
6
|
+
"access_token": "access_token",
|
7
|
+
"ad_id": 44556677,
|
8
|
+
"campaign_id": 22334455,
|
9
|
+
"name": "Test Ad Group 1",
|
10
|
+
"adgroup_status": 1,
|
11
|
+
"bid_type": 1,
|
12
|
+
"max_bid": 150,
|
13
|
+
"adgroup_id": 44556677,
|
14
|
+
"end_time": "2011-09-01T00:00:00+0000",
|
15
|
+
"start_time": "2011-09-10T00:00:00+0000",
|
16
|
+
"updated_time": "2011-09-05T00:00:00+0000"
|
17
|
+
}
|
18
|
+
],
|
19
|
+
"count": 1,
|
20
|
+
"limit": 500,
|
21
|
+
"offset": 0,
|
22
|
+
"include_deleted": null
|
23
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
{
|
2
|
+
"id": "6003590469668",
|
3
|
+
"ad_id": 6003590469668,
|
4
|
+
"campaign_id":6003590468467,
|
5
|
+
"name": "Ad Group 1",
|
6
|
+
"adgroup_status": 1,
|
7
|
+
"bid_type": 1,
|
8
|
+
"max_bid": 1000,
|
9
|
+
"adgroup_id": 6003590469668,
|
10
|
+
"end_time": "2011-09-10T00:00:00+00:00",
|
11
|
+
"start_time": "2011-09-01T12:00:00-07:00",
|
12
|
+
"updated_time": "2011-09-04T16:00:00+00:00"
|
13
|
+
}
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 11
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 2.1.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- nov matake
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-07 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: httpclient
|
@@ -20,6 +25,12 @@ dependencies:
|
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 123
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 2
|
32
|
+
- 0
|
33
|
+
- 2
|
23
34
|
version: 2.2.0.2
|
24
35
|
type: :runtime
|
25
36
|
version_requirements: *id001
|
@@ -31,6 +42,11 @@ dependencies:
|
|
31
42
|
requirements:
|
32
43
|
- - ">="
|
33
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 63
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 8
|
49
|
+
- 0
|
34
50
|
version: 0.8.0
|
35
51
|
type: :runtime
|
36
52
|
version_requirements: *id002
|
@@ -42,6 +58,10 @@ dependencies:
|
|
42
58
|
requirements:
|
43
59
|
- - ">="
|
44
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 27
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 8
|
45
65
|
version: "0.8"
|
46
66
|
type: :development
|
47
67
|
version_requirements: *id003
|
@@ -53,6 +73,10 @@ dependencies:
|
|
53
73
|
requirements:
|
54
74
|
- - ">="
|
55
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 25
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
- 9
|
56
80
|
version: "0.9"
|
57
81
|
type: :development
|
58
82
|
version_requirements: *id004
|
@@ -64,6 +88,9 @@ dependencies:
|
|
64
88
|
requirements:
|
65
89
|
- - ">="
|
66
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 7
|
92
|
+
segments:
|
93
|
+
- 2
|
67
94
|
version: "2"
|
68
95
|
type: :development
|
69
96
|
version_requirements: *id005
|
@@ -75,6 +102,11 @@ dependencies:
|
|
75
102
|
requirements:
|
76
103
|
- - ">="
|
77
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 11
|
106
|
+
segments:
|
107
|
+
- 1
|
108
|
+
- 6
|
109
|
+
- 2
|
78
110
|
version: 1.6.2
|
79
111
|
type: :development
|
80
112
|
version_requirements: *id006
|
@@ -86,6 +118,11 @@ dependencies:
|
|
86
118
|
requirements:
|
87
119
|
- - ">="
|
88
120
|
- !ruby/object:Gem::Version
|
121
|
+
hash: 11
|
122
|
+
segments:
|
123
|
+
- 3
|
124
|
+
- 0
|
125
|
+
- 6
|
89
126
|
version: 3.0.6
|
90
127
|
type: :development
|
91
128
|
version_requirements: *id007
|
@@ -116,6 +153,7 @@ files:
|
|
116
153
|
- lib/fb_graph/action.rb
|
117
154
|
- lib/fb_graph/ad_account.rb
|
118
155
|
- lib/fb_graph/ad_campaign.rb
|
156
|
+
- lib/fb_graph/ad_group.rb
|
119
157
|
- lib/fb_graph/album.rb
|
120
158
|
- lib/fb_graph/app_request.rb
|
121
159
|
- lib/fb_graph/application.rb
|
@@ -130,7 +168,8 @@ files:
|
|
130
168
|
- lib/fb_graph/connections.rb
|
131
169
|
- lib/fb_graph/connections/accounts.rb
|
132
170
|
- lib/fb_graph/connections/activities.rb
|
133
|
-
- lib/fb_graph/connections/
|
171
|
+
- lib/fb_graph/connections/ad_campaigns.rb
|
172
|
+
- lib/fb_graph/connections/ad_groups.rb
|
134
173
|
- lib/fb_graph/connections/albums.rb
|
135
174
|
- lib/fb_graph/connections/app_requests.rb
|
136
175
|
- lib/fb_graph/connections/attending.rb
|
@@ -225,6 +264,7 @@ files:
|
|
225
264
|
- lib/patch/rack/oauth2/util.rb
|
226
265
|
- spec/fb_graph/ad_account_spec.rb
|
227
266
|
- spec/fb_graph/ad_campaign_spec.rb
|
267
|
+
- spec/fb_graph/ad_group_spec.rb
|
228
268
|
- spec/fb_graph/album_spec.rb
|
229
269
|
- spec/fb_graph/app_request_spec.rb
|
230
270
|
- spec/fb_graph/application_spec.rb
|
@@ -237,6 +277,7 @@ files:
|
|
237
277
|
- spec/fb_graph/connection_spec.rb
|
238
278
|
- spec/fb_graph/connections/accounts_spec.rb
|
239
279
|
- spec/fb_graph/connections/activities_spec.rb
|
280
|
+
- spec/fb_graph/connections/ad_groups_spec.rb
|
240
281
|
- spec/fb_graph/connections/albums_spec.rb
|
241
282
|
- spec/fb_graph/connections/app_requests_spec.rb
|
242
283
|
- spec/fb_graph/connections/attending_spec.rb
|
@@ -329,8 +370,11 @@ files:
|
|
329
370
|
- spec/fb_graph/work_spec.rb
|
330
371
|
- spec/fb_graph_spec.rb
|
331
372
|
- spec/helpers/webmock_helper.rb
|
373
|
+
- spec/mock_json/ad_accounts/ad_groups/post_with_valid_access_token.json
|
332
374
|
- spec/mock_json/ad_accounts/test_ad_account.json
|
375
|
+
- spec/mock_json/ad_campaigns/ad_groups/22334455_ad_groups.json
|
333
376
|
- spec/mock_json/ad_campaigns/test_ad_campaign.json
|
377
|
+
- spec/mock_json/ad_groups/test_ad_group.json
|
334
378
|
- spec/mock_json/albums/photos/matake_private.json
|
335
379
|
- spec/mock_json/albums/photos/post_with_valid_access_token.json
|
336
380
|
- spec/mock_json/applications/accounts/private.json
|
@@ -485,23 +529,30 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
485
529
|
requirements:
|
486
530
|
- - ">="
|
487
531
|
- !ruby/object:Gem::Version
|
532
|
+
hash: 3
|
533
|
+
segments:
|
534
|
+
- 0
|
488
535
|
version: "0"
|
489
536
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
490
537
|
none: false
|
491
538
|
requirements:
|
492
|
-
- - "
|
539
|
+
- - ">="
|
493
540
|
- !ruby/object:Gem::Version
|
494
|
-
|
541
|
+
hash: 3
|
542
|
+
segments:
|
543
|
+
- 0
|
544
|
+
version: "0"
|
495
545
|
requirements: []
|
496
546
|
|
497
547
|
rubyforge_project:
|
498
|
-
rubygems_version: 1.8.
|
548
|
+
rubygems_version: 1.8.5
|
499
549
|
signing_key:
|
500
550
|
specification_version: 3
|
501
551
|
summary: A full-stack Facebook Graph API wrapper in Ruby.
|
502
552
|
test_files:
|
503
553
|
- spec/fb_graph/ad_account_spec.rb
|
504
554
|
- spec/fb_graph/ad_campaign_spec.rb
|
555
|
+
- spec/fb_graph/ad_group_spec.rb
|
505
556
|
- spec/fb_graph/album_spec.rb
|
506
557
|
- spec/fb_graph/app_request_spec.rb
|
507
558
|
- spec/fb_graph/application_spec.rb
|
@@ -514,6 +565,7 @@ test_files:
|
|
514
565
|
- spec/fb_graph/connection_spec.rb
|
515
566
|
- spec/fb_graph/connections/accounts_spec.rb
|
516
567
|
- spec/fb_graph/connections/activities_spec.rb
|
568
|
+
- spec/fb_graph/connections/ad_groups_spec.rb
|
517
569
|
- spec/fb_graph/connections/albums_spec.rb
|
518
570
|
- spec/fb_graph/connections/app_requests_spec.rb
|
519
571
|
- spec/fb_graph/connections/attending_spec.rb
|
@@ -606,8 +658,11 @@ test_files:
|
|
606
658
|
- spec/fb_graph/work_spec.rb
|
607
659
|
- spec/fb_graph_spec.rb
|
608
660
|
- spec/helpers/webmock_helper.rb
|
661
|
+
- spec/mock_json/ad_accounts/ad_groups/post_with_valid_access_token.json
|
609
662
|
- spec/mock_json/ad_accounts/test_ad_account.json
|
663
|
+
- spec/mock_json/ad_campaigns/ad_groups/22334455_ad_groups.json
|
610
664
|
- spec/mock_json/ad_campaigns/test_ad_campaign.json
|
665
|
+
- spec/mock_json/ad_groups/test_ad_group.json
|
611
666
|
- spec/mock_json/albums/photos/matake_private.json
|
612
667
|
- spec/mock_json/albums/photos/post_with_valid_access_token.json
|
613
668
|
- spec/mock_json/applications/accounts/private.json
|