zuck 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.markdown +35 -5
  3. data/Gemfile +3 -2
  4. data/Gemfile.lock +13 -10
  5. data/README.markdown +26 -38
  6. data/VERSION +1 -1
  7. data/console +8 -2
  8. data/lib/zuck/facebook/ad_account.rb +22 -5
  9. data/lib/zuck/facebook/ad_campaign.rb +12 -15
  10. data/lib/zuck/facebook/ad_creative.rb +14 -14
  11. data/lib/zuck/facebook/ad_group.rb +12 -12
  12. data/lib/zuck/facebook/ad_interest.rb +12 -15
  13. data/lib/zuck/facebook/ad_set.rb +30 -0
  14. data/lib/zuck/facebook/targeting_spec.rb +4 -4
  15. data/lib/zuck/fb_object/dsl.rb +15 -7
  16. data/lib/zuck/fb_object/hash_delegator.rb +20 -3
  17. data/lib/zuck/fb_object/write.rb +18 -6
  18. data/lib/zuck/fb_object.rb +1 -1
  19. data/lib/zuck/helpers.rb +20 -1
  20. data/spec/fixtures/a_single_account.yml +146 -29
  21. data/spec/fixtures/a_single_campaign.yml +61 -12
  22. data/spec/fixtures/a_single_group.yml +65 -12
  23. data/spec/fixtures/ad_interest_search_disney.yml +16 -14
  24. data/spec/fixtures/ad_interest_search_moviepilot.yml +15 -98
  25. data/spec/fixtures/ad_interest_search_nonexistant.yml +7 -5
  26. data/spec/fixtures/create_ad_campaign.yml +334 -9
  27. data/spec/fixtures/create_ad_group.yml +154 -9
  28. data/spec/fixtures/create_ad_set.yml +95 -0
  29. data/spec/fixtures/delete_ad_group.yml +55 -8
  30. data/spec/fixtures/find_a_single_group_and_update_it.yml +122 -95
  31. data/spec/fixtures/list_of_ad_accounts.yml +77 -58
  32. data/spec/fixtures/list_of_ad_campaigns.yml +77 -55
  33. data/spec/fixtures/list_of_ad_creatives.yml +61 -13
  34. data/spec/fixtures/list_of_ad_groups.yml +77 -60
  35. data/spec/fixtures/list_of_all_ad_creatives_of_account.yml +77 -73
  36. data/spec/fixtures/reach_for_invalid_interest.yml +29 -111
  37. data/spec/fixtures/reach_for_valid_keywords.yml +11 -54
  38. data/spec/fixtures/reach_for_valid_keywords_male_young.yml +11 -60
  39. data/spec/lib/zuck/facebook/ad_account_spec.rb +1 -1
  40. data/spec/lib/zuck/facebook/ad_interest_spec.rb +2 -2
  41. data/spec/lib/zuck/facebook/targeting_spec_spec.rb +13 -21
  42. data/spec/lib/zuck_spec.rb +34 -23
  43. data/spec/spec_helper.rb +2 -5
  44. data/test_access_token +1 -0
  45. data/zuck.gemspec +15 -9
  46. metadata +63 -46
@@ -2,60 +2,13 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://graph.facebook.com/search?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&keyword_list=Eminem,invalidsssssssssssssss&type=adkeywordvalid
5
+ uri: https://graph.facebook.com/search?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&q=Eminem&type=adinterest
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.8.7
12
- Accept-Encoding:
13
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
- Accept:
15
- - ! '*/*'
16
- response:
17
- status:
18
- code: 400
19
- message: Bad Request
20
- headers:
21
- Www-Authenticate:
22
- - OAuth "Facebook Platform" "invalid_request" "This search type has been deprecated
23
- for your app."
24
- Content-Type:
25
- - application/json; charset=UTF-8
26
- Pragma:
27
- - no-cache
28
- Access-Control-Allow-Origin:
29
- - ! '*'
30
- X-Fb-Rev:
31
- - '1216101'
32
- Cache-Control:
33
- - no-store
34
- Expires:
35
- - Sat, 01 Jan 2000 00:00:00 GMT
36
- X-Fb-Debug:
37
- - 5YWQGv5UmUcgvCXSOo52+SA8r7cDrVuPgHIvhviZFdc=
38
- Date:
39
- - Tue, 22 Apr 2014 13:36:40 GMT
40
- Connection:
41
- - keep-alive
42
- Content-Length:
43
- - '115'
44
- body:
45
- encoding: US-ASCII
46
- string: ! '{"error":{"message":"This search type has been deprecated for your
47
- app.","type":"GraphMethodException","code":100}}'
48
- http_version:
49
- recorded_at: Tue, 22 Apr 2014 13:36:41 GMT
50
- - request:
51
- method: get
52
- uri: https://graph.facebook.com/search?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&keyword_list=Eminem,invalidsssssssssssssss&type=adinterestvalid
53
- body:
54
- encoding: US-ASCII
55
- string: ''
56
- headers:
57
- User-Agent:
58
- - Faraday v0.8.7
11
+ - Faraday v0.8.9
59
12
  Accept-Encoding:
60
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
61
14
  Accept:
@@ -65,8 +18,10 @@ http_interactions:
65
18
  code: 200
66
19
  message: OK
67
20
  headers:
21
+ Facebook-Api-Version:
22
+ - v1.0
68
23
  Etag:
69
- - ! '"1050253aec7b29caff644806927dabfa81406eee"'
24
+ - ! '"038ae6611c2b53eb4b5ed92233d5c571c499c852"'
70
25
  Content-Type:
71
26
  - application/json; charset=UTF-8
72
27
  Pragma:
@@ -74,79 +29,40 @@ http_interactions:
74
29
  Access-Control-Allow-Origin:
75
30
  - ! '*'
76
31
  X-Fb-Rev:
77
- - '1216101'
32
+ - '1534884'
78
33
  Cache-Control:
79
34
  - private, no-cache, no-store, must-revalidate
80
35
  Expires:
81
36
  - Sat, 01 Jan 2000 00:00:00 GMT
82
37
  X-Fb-Debug:
83
- - ojR7Y6RIT7GLVdCXuXQmUXCaTKnDob/Lcxk/NYR6FVE=
84
- Date:
85
- - Tue, 22 Apr 2014 15:53:05 GMT
86
- Connection:
87
- - keep-alive
88
- Content-Length:
89
- - '11'
90
- body:
91
- encoding: US-ASCII
92
- string: ! '{"data":[]}'
93
- http_version:
94
- recorded_at: Tue, 22 Apr 2014 15:53:07 GMT
95
- - request:
96
- method: get
97
- uri: https://graph.facebook.com/search?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&interest_list=Eminem,invalidsssssssssssssss&type=adinterestvalid
98
- body:
99
- encoding: US-ASCII
100
- string: ''
101
- headers:
102
- User-Agent:
103
- - Faraday v0.8.7
104
- Accept-Encoding:
105
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
106
- Accept:
107
- - ! '*/*'
108
- response:
109
- status:
110
- code: 400
111
- message: Bad Request
112
- headers:
113
- Www-Authenticate:
114
- - OAuth "Facebook Platform" "invalid_request" "(#100) param interest_list must
115
- be an array."
116
- Content-Type:
117
- - application/json; charset=UTF-8
118
- Pragma:
119
- - no-cache
120
- Access-Control-Allow-Origin:
121
- - ! '*'
122
- X-Fb-Rev:
123
- - '1216101'
124
- Cache-Control:
125
- - no-store
126
- Expires:
127
- - Sat, 01 Jan 2000 00:00:00 GMT
128
- X-Fb-Debug:
129
- - d4l2YYQRkv0eOtLLFGlS40LwTDqugSEc3O5ILobLc8E=
38
+ - Xx4hmJYbZbA8bbIW6ZUL908Kqm/xhnf9OyKPefsMFeuqPg1VyWP5KzlKaEPcLMc6BFyJ4Y4aHTwD2Hs+egBJ7Q==
130
39
  Date:
131
- - Tue, 22 Apr 2014 15:55:06 GMT
40
+ - Wed, 17 Dec 2014 13:24:52 GMT
132
41
  Connection:
133
42
  - keep-alive
134
43
  Content-Length:
135
- - '103'
44
+ - '805'
136
45
  body:
137
46
  encoding: US-ASCII
138
- string: ! '{"error":{"message":"(#100) param interest_list must be an array.","type":"OAuthException","code":100}}'
47
+ string: ! '{"data":[{"name":"Eminem","id":6003135347608,"audience_size":108895170,"path":[],"description":null},{"name":"The
48
+ Eminem Show","id":6003250214311,"audience_size":77608860,"path":[],"description":null},{"name":"Recovery
49
+ (Eminem album)","id":6003489780564,"audience_size":78112930,"path":[],"description":null},{"name":"eminem
50
+ fans","id":6004596403706,"audience_size":1249510,"path":[],"description":null},{"name":"eminem
51
+ lovers","id":6003291289702,"audience_size":1103070,"path":[],"description":null},{"name":"eminem
52
+ world","id":6003455354537,"audience_size":693520,"path":[],"description":null},{"name":"eminem
53
+ forever blog","id":6017042219356,"audience_size":463490,"path":[],"description":null},{"name":"eminem
54
+ marshall mathers","id":6003009763850,"audience_size":331000,"path":[],"description":null}]}'
139
55
  http_version:
140
- recorded_at: Tue, 22 Apr 2014 15:55:07 GMT
56
+ recorded_at: Wed, 17 Dec 2014 13:24:52 GMT
141
57
  - request:
142
58
  method: get
143
- uri: https://graph.facebook.com/search?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&interest_list%5B%5D=invalidsssssssssssssss&type=adinterestvalid
59
+ uri: https://graph.facebook.com/search?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&q=invalidsssssssssssssss&type=adinterest
144
60
  body:
145
61
  encoding: US-ASCII
146
62
  string: ''
147
63
  headers:
148
64
  User-Agent:
149
- - Faraday v0.8.7
65
+ - Faraday v0.8.9
150
66
  Accept-Encoding:
151
67
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
152
68
  Accept:
@@ -156,8 +72,10 @@ http_interactions:
156
72
  code: 200
157
73
  message: OK
158
74
  headers:
75
+ Facebook-Api-Version:
76
+ - v1.0
159
77
  Etag:
160
- - ! '"99b46c018fb5ff17aaa09a5f4c8cc1e39a023833"'
78
+ - ! '"1050253aec7b29caff644806927dabfa81406eee"'
161
79
  Content-Type:
162
80
  - application/json; charset=UTF-8
163
81
  Pragma:
@@ -165,22 +83,22 @@ http_interactions:
165
83
  Access-Control-Allow-Origin:
166
84
  - ! '*'
167
85
  X-Fb-Rev:
168
- - '1216101'
86
+ - '1534884'
169
87
  Cache-Control:
170
88
  - private, no-cache, no-store, must-revalidate
171
89
  Expires:
172
90
  - Sat, 01 Jan 2000 00:00:00 GMT
173
91
  X-Fb-Debug:
174
- - pRnjXTFy5pPE54NjzHEgMQgm1715mvuGDsxzdtLib40=
92
+ - O5K0/pQRSftbJQUJZxGLcsf58NbkxSIuuEmiBp2N3w2a/thaJMEiOylfYED9tI17bZItsWBh8PKjqJqzqmclgg==
175
93
  Date:
176
- - Tue, 22 Apr 2014 15:56:01 GMT
94
+ - Wed, 17 Dec 2014 13:24:52 GMT
177
95
  Connection:
178
96
  - keep-alive
179
97
  Content-Length:
180
- - '269'
98
+ - '11'
181
99
  body:
182
100
  encoding: US-ASCII
183
- string: ! '{"data":[{"name":"Eminem","valid":true,"id":6003267925601,"audience_size":121735657,"path":[],"description":null},{"name":"em\u0131nem","valid":true,"id":6004151469695,"audience_size":44621,"path":[],"description":null},{"name":"invalidsssssssssssssss","valid":false}]}'
101
+ string: ! '{"data":[]}'
184
102
  http_version:
185
- recorded_at: Tue, 22 Apr 2014 15:56:03 GMT
103
+ recorded_at: Wed, 17 Dec 2014 13:24:52 GMT
186
104
  recorded_with: VCR 2.3.0
@@ -2,13 +2,13 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://graph.facebook.com/act_1384977038406122/reachestimate?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&targeting_spec=%7B%22geo_locations%22:%7B%22countries%22:%5B%22US%22%5D%7D,%22interests%22:%5B%22Eminem%22,%22Sting%22%5D,%22age_min%22:13,%22countries%22:%5B%5D,%22connections%22:%5B%5D,%22broad_age%22:false%7D
5
+ uri: https://graph.facebook.com/act_1384977038406122/reachestimate?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&targeting_spec=%7B%22geo_locations%22:%7B%22countries%22:%5B%22US%22%5D%7D,%22interests%22:%5B%7B%22id%22:%226003135347608%22,%22name%22:%22Eminem%22%7D,%7B%22id%22:%226003504886186%22,%22name%22:%22Sting%20(musician)%22%7D%5D,%22age_min%22:13,%22countries%22:%5B%5D,%22connections%22:%5B%5D,%22broad_age%22:false%7D
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.8.7
11
+ - Faraday v0.8.9
12
12
  Accept-Encoding:
13
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
14
  Accept:
@@ -18,8 +18,10 @@ http_interactions:
18
18
  code: 200
19
19
  message: OK
20
20
  headers:
21
+ Facebook-Api-Version:
22
+ - v1.0
21
23
  Etag:
22
- - ! '"c1294c35226a3ed2f57509721e541bd19ab3a0ed"'
24
+ - ! '"6091c44df86603e9fa3d02108fa4a66195cc8afc"'
23
25
  Content-Type:
24
26
  - application/json; charset=UTF-8
25
27
  Pragma:
@@ -27,67 +29,22 @@ http_interactions:
27
29
  Access-Control-Allow-Origin:
28
30
  - ! '*'
29
31
  X-Fb-Rev:
30
- - '1216101'
32
+ - '1534884'
31
33
  Cache-Control:
32
34
  - private, no-cache, no-store, must-revalidate
33
35
  Expires:
34
36
  - Sat, 01 Jan 2000 00:00:00 GMT
35
37
  X-Fb-Debug:
36
- - TKktKl3jf/UiEoF+94LZ687QmZePRbIbsuJtQAwSVYQ=
38
+ - UQm3XcD/KHuSX+cXCyjgiHZPvXyxjJ3dmixnCSxG/7ErgcSDcDfNv6PKJ4iFqpsdg0rdQzbZg5Y2NhT8uzGMxQ==
37
39
  Date:
38
- - Tue, 22 Apr 2014 13:31:34 GMT
40
+ - Wed, 17 Dec 2014 13:24:53 GMT
39
41
  Connection:
40
42
  - keep-alive
41
43
  Content-Length:
42
- - '488'
44
+ - '456'
43
45
  body:
44
46
  encoding: US-ASCII
45
- string: ! '{"users":28000000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":10,"cpa_median":16,"cpa_max":21,"cpc_min":10,"cpc_median":16,"cpc_max":21,"cpm_min":7,"cpm_median":93,"cpm_max":271}],"estimate_ready":true,"imp_estimates":[],"data":{"users":28000000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":10,"cpa_median":16,"cpa_max":21,"cpc_min":10,"cpc_median":16,"cpc_max":21,"cpm_min":7,"cpm_median":93,"cpm_max":271}],"estimate_ready":true,"imp_estimates":[]}}'
47
+ string: ! '{"users":28000000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":37,"cpa_median":69,"cpa_max":100,"cpc_min":19,"cpc_median":35,"cpc_max":50,"cpm_min":84,"cpm_median":270,"cpm_max":440}],"estimate_ready":true,"data":{"users":28000000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":37,"cpa_median":69,"cpa_max":100,"cpc_min":19,"cpc_median":35,"cpc_max":50,"cpm_min":84,"cpm_median":270,"cpm_max":440}],"estimate_ready":true}}'
46
48
  http_version:
47
- recorded_at: Tue, 22 Apr 2014 13:31:35 GMT
48
- - request:
49
- method: get
50
- uri: https://graph.facebook.com/act_1384977038406122/reachestimate?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&targeting_spec=%7B%22geo_locations%22:%7B%22countries%22:%5B%22US%22%5D%7D,%22interests%22:%5B%22Eminem%22,%22Sting%20(Musician)%22%5D,%22age_min%22:13,%22countries%22:%5B%5D,%22connections%22:%5B%5D,%22broad_age%22:false%7D
51
- body:
52
- encoding: US-ASCII
53
- string: ''
54
- headers:
55
- User-Agent:
56
- - Faraday v0.8.7
57
- Accept-Encoding:
58
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
59
- Accept:
60
- - ! '*/*'
61
- response:
62
- status:
63
- code: 200
64
- message: OK
65
- headers:
66
- Etag:
67
- - ! '"a8f1384987b3c658b17a07155c2cc83b2a1701ce"'
68
- Content-Type:
69
- - application/json; charset=UTF-8
70
- Pragma:
71
- - no-cache
72
- Access-Control-Allow-Origin:
73
- - ! '*'
74
- X-Fb-Rev:
75
- - '1216101'
76
- Cache-Control:
77
- - private, no-cache, no-store, must-revalidate
78
- Expires:
79
- - Sat, 01 Jan 2000 00:00:00 GMT
80
- X-Fb-Debug:
81
- - ORocQtfaAdpNtxSIfrYYstW/EysQjQ78NX75OLnYKII=
82
- Date:
83
- - Tue, 22 Apr 2014 14:21:09 GMT
84
- Connection:
85
- - keep-alive
86
- Content-Length:
87
- - '490'
88
- body:
89
- encoding: US-ASCII
90
- string: ! '{"users":28000000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":12,"cpa_median":19,"cpa_max":25,"cpc_min":11,"cpc_median":17,"cpc_max":22,"cpm_min":7,"cpm_median":124,"cpm_max":283}],"estimate_ready":true,"imp_estimates":[],"data":{"users":28000000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":12,"cpa_median":19,"cpa_max":25,"cpc_min":11,"cpc_median":17,"cpc_max":22,"cpm_min":7,"cpm_median":124,"cpm_max":283}],"estimate_ready":true,"imp_estimates":[]}}'
91
- http_version:
92
- recorded_at: Tue, 22 Apr 2014 14:21:11 GMT
49
+ recorded_at: Wed, 17 Dec 2014 13:24:53 GMT
93
50
  recorded_with: VCR 2.3.0
@@ -2,64 +2,13 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://graph.facebook.com/act_1384977038406122/reachestimate?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&targeting_spec=%7B%22geo_locations%22:%7B%22countries%22:%5B%22US%22%5D%7D,%22interests%22:%5B%22Sting%22%5D,%22age_min%22:13,%22age_max%22:24,%22genders%22:%5B2%5D,%22countries%22:%5B%5D,%22connections%22:%5B%5D,%22broad_age%22:false%7D
5
+ uri: https://graph.facebook.com/act_1384977038406122/reachestimate?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&targeting_spec=%7B%22geo_locations%22:%7B%22countries%22:%5B%22US%22%5D%7D,%22interests%22:%5B%7B%22id%22:%226003504886186%22,%22name%22:%22Sting%20(musician)%22%7D%5D,%22age_min%22:13,%22age_max%22:24,%22genders%22:%5B2%5D,%22countries%22:%5B%5D,%22connections%22:%5B%5D,%22broad_age%22:false%7D
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.8.7
12
- Accept-Encoding:
13
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
- Accept:
15
- - ! '*/*'
16
- response:
17
- status:
18
- code: 400
19
- message: Bad Request
20
- headers:
21
- Www-Authenticate:
22
- - ! 'OAuth "Facebook Platform" "invalid_request" "(#1487703) Invalid Interests
23
- Targeting: You have selected invalid interests.,Invalid Interests Targeting:
24
- You have selected invalid interests."'
25
- Content-Type:
26
- - application/json; charset=UTF-8
27
- Pragma:
28
- - no-cache
29
- Access-Control-Allow-Origin:
30
- - ! '*'
31
- X-Fb-Rev:
32
- - '1216101'
33
- Cache-Control:
34
- - no-store
35
- Expires:
36
- - Sat, 01 Jan 2000 00:00:00 GMT
37
- X-Fb-Debug:
38
- - OKnEh+SCMeuUtDeOx7uBgc2Y3+cP/ADtQmizuwCFbh4=
39
- Date:
40
- - Tue, 22 Apr 2014 13:31:34 GMT
41
- Connection:
42
- - keep-alive
43
- Content-Length:
44
- - '376'
45
- body:
46
- encoding: US-ASCII
47
- string: ! '{"error":{"message":"(#1487703) Invalid Interests Targeting: You
48
- have selected invalid interests.,Invalid Interests Targeting: You have selected
49
- invalid interests.","type":"OAuthException","code":1487703,"error_data":{"showable_errors":["Invalid
50
- Interests Targeting: You have selected invalid interests.","Invalid Interests
51
- Targeting: You have selected invalid interests."]}}}'
52
- http_version:
53
- recorded_at: Tue, 22 Apr 2014 13:31:36 GMT
54
- - request:
55
- method: get
56
- uri: https://graph.facebook.com/act_1384977038406122/reachestimate?access_token=CAAEvJ5vzhl8BAPGZCZCPL4FxryEHXGxPCuCGeqe3PEWIjhIvJ00HB8PPpokFmUkemvmEUHirqdNMc7zIDLSTVnX6jTQjAgSlzcYrAYJRQ32fr6RM5ZAnKPdgFEwN5tgvswatXZAI4vu7ZBAQexRl9MU0CpwW7JDDBZAGo5XDrCKrBxkUUWJUvh&targeting_spec=%7B%22geo_locations%22:%7B%22countries%22:%5B%22US%22%5D%7D,%22interests%22:%5B%22Sting%20(musician)%22%5D,%22age_min%22:13,%22age_max%22:24,%22genders%22:%5B2%5D,%22countries%22:%5B%5D,%22connections%22:%5B%5D,%22broad_age%22:false%7D
57
- body:
58
- encoding: US-ASCII
59
- string: ''
60
- headers:
61
- User-Agent:
62
- - Faraday v0.8.7
11
+ - Faraday v0.8.9
63
12
  Accept-Encoding:
64
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
65
14
  Accept:
@@ -69,8 +18,10 @@ http_interactions:
69
18
  code: 200
70
19
  message: OK
71
20
  headers:
21
+ Facebook-Api-Version:
22
+ - v1.0
72
23
  Etag:
73
- - ! '"535b11b3cffda3c65a081209ee4ddf3835e6f914"'
24
+ - ! '"3af0f7e765b8380f2a723302f594d583fde67beb"'
74
25
  Content-Type:
75
26
  - application/json; charset=UTF-8
76
27
  Pragma:
@@ -78,22 +29,22 @@ http_interactions:
78
29
  Access-Control-Allow-Origin:
79
30
  - ! '*'
80
31
  X-Fb-Rev:
81
- - '1216101'
32
+ - '1534884'
82
33
  Cache-Control:
83
34
  - private, no-cache, no-store, must-revalidate
84
35
  Expires:
85
36
  - Sat, 01 Jan 2000 00:00:00 GMT
86
37
  X-Fb-Debug:
87
- - 7bO34dIJWYBvK8cDwLDpgiq7ZexaDsJ9Ij4Qa/B1jFw=
38
+ - O43UJHL/22OCfbvpGri9vMFEaOzegP5DNpgNRrrpuZyyhX54rTAXn0RVqN83GxQz0Yyu6YdxjfZBJMCY9QAqxw==
88
39
  Date:
89
- - Tue, 22 Apr 2014 14:20:18 GMT
40
+ - Wed, 17 Dec 2014 13:24:54 GMT
90
41
  Connection:
91
42
  - keep-alive
92
43
  Content-Length:
93
- - '480'
44
+ - '452'
94
45
  body:
95
46
  encoding: US-ASCII
96
- string: ! '{"users":74000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":10,"cpa_median":15,"cpa_max":20,"cpc_min":9,"cpc_median":14,"cpc_max":18,"cpm_min":6,"cpm_median":17,"cpm_max":136}],"estimate_ready":true,"imp_estimates":[],"data":{"users":74000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":10,"cpa_median":15,"cpa_max":20,"cpc_min":9,"cpc_median":14,"cpc_max":18,"cpm_min":6,"cpm_median":17,"cpm_max":136}],"estimate_ready":true,"imp_estimates":[]}}'
47
+ string: ! '{"users":220000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":30,"cpa_median":58,"cpa_max":83,"cpc_min":15,"cpc_median":28,"cpc_max":39,"cpm_min":101,"cpm_median":270,"cpm_max":427}],"estimate_ready":true,"data":{"users":220000,"bid_estimations":[{"unsupported":false,"location":3,"cpa_min":30,"cpa_median":58,"cpa_max":83,"cpc_min":15,"cpc_median":28,"cpc_max":39,"cpm_min":101,"cpm_median":270,"cpm_max":427}],"estimate_ready":true}}'
97
48
  http_version:
98
- recorded_at: Tue, 22 Apr 2014 14:20:20 GMT
49
+ recorded_at: Wed, 17 Dec 2014 13:24:54 GMT
99
50
  recorded_with: VCR 2.3.0
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Zuck::AdAccount do
4
4
 
5
5
  let(:graph){ Koala::Facebook::API.new(:token) }
6
- let(:acc){ Zuck::AdAccount.new(graph, name: :dance_in_style) }
6
+ let(:acc){ Zuck::AdAccount.new(graph, name: :dance_in_style, id: '123') }
7
7
 
8
8
  it "initializes graph correctly" do
9
9
  acc.graph.should == graph
@@ -5,13 +5,13 @@ describe Zuck::AdInterest do
5
5
 
6
6
  it "finds the best interest with a #" do
7
7
  VCR.use_cassette('ad_interest_search_disney') do
8
- Zuck::AdInterest.best_guess(graph, 'disney')[:interest].should == 'The Walt Disney Company'
8
+ Zuck::AdInterest.best_guess(graph, 'disney')[:name].should == 'The Walt Disney Company'
9
9
  end
10
10
  end
11
11
 
12
12
  it "finds the best interest when no keyword with # is available" do
13
13
  VCR.use_cassette('ad_interest_search_moviepilot') do
14
- Zuck::AdInterest.best_guess(graph, 'moviepilot')[:interest].should == 'moviepilotcom'
14
+ Zuck::AdInterest.best_guess(graph, 'moviepilot')[:name].should == 'moviepilot horror'
15
15
  end
16
16
  end
17
17
 
@@ -6,19 +6,12 @@ describe Zuck::TargetingSpec do
6
6
 
7
7
  describe "validating interests" do
8
8
 
9
- let(:valid_interest_result){ [{"name" => "foo", "valid" => true }] }
10
- let(:invalid_interest_result){ [{"name" => "sdjf", "valid" => false }] }
9
+ let(:valid_interest_result){ [{"name" => "foo", "valid" => true }] }
10
+ let(:invalid_interest_result){ [] }
11
11
 
12
- it "escapes commas" do
13
- o = {type: 'adinterestvalid', interest_list: ['foo%2Cbar'] }
14
- graph.should_receive(:search).with(nil, o).and_return []
15
- fts = Zuck::TargetingSpec.new(graph, ad_account, interests: 'foo,bar')
16
- fts.validate_interest('foo,bar').should == false
17
- end
18
12
 
19
13
  it "acknowledges valid interests" do
20
- o = {type: 'adinterestvalid', interest_list: ['foo'] }
21
- graph.should_receive(:search).with(nil, o).and_return valid_interest_result
14
+ graph.should_receive(:search).with('foo', type: :adinterest).and_return(valid_interest_result)
22
15
  #graph.should_not_receive(:search)
23
16
  fts = Zuck::TargetingSpec.new(graph, ad_account)
24
17
 
@@ -26,8 +19,7 @@ describe Zuck::TargetingSpec do
26
19
  end
27
20
 
28
21
  it "refuses invalid interests" do
29
- o = {type: 'adinterestvalid', interest_list: ['sdjf'] }
30
- graph.should_receive(:search).with(nil, o).and_return invalid_interest_result
22
+ graph.should_receive(:search).with('sdjf', type: :adinterest).and_return(invalid_interest_result)
31
23
  fts = Zuck::TargetingSpec.new(graph, ad_account)
32
24
 
33
25
  fts.validate_interest('sdjf').should == false
@@ -37,25 +29,25 @@ describe Zuck::TargetingSpec do
37
29
  describe "options given in spec" do
38
30
  it "accepts male as gender" do
39
31
  expect{
40
- Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: ['foo'], gender: 'male')
32
+ Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}], gender: 'male')
41
33
  }.to_not raise_error
42
34
  end
43
35
 
44
36
  it "accepts male as gender for young people" do
45
37
  expect{
46
- Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: ['foo'], gender: 'male', age_class: 'young')
38
+ Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}], gender: 'male', age_class: 'young')
47
39
  }.to_not raise_error
48
40
  end
49
41
 
50
42
  it "accepts male as gender for old people" do
51
43
  expect{
52
- Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: ['foo'], gender: 'male', age_class: 'old')
44
+ Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}], gender: 'male', age_class: 'old')
53
45
  }.to_not raise_error
54
46
  end
55
47
 
56
48
  it "accepts without gender" do
57
49
  expect{
58
- Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: ['foo'])
50
+ Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}])
59
51
  }.to_not raise_error
60
52
  end
61
53
 
@@ -67,13 +59,13 @@ describe Zuck::TargetingSpec do
67
59
 
68
60
  it "does not accept invalid genders" do
69
61
  expect{
70
- Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: ['foo'], gender: 'gemale')
62
+ Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['US']}, interests: [{id: '123', name: 'foo'}], gender: 'gemale')
71
63
  }.to raise_error("Gender can only be male or female")
72
64
  end
73
65
 
74
66
  it "does not accept invalid countries" do
75
67
  expect{
76
- z = Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['XX']}, interests: ['foo'], gender: 'female')
68
+ z = Zuck::TargetingSpec.new(graph, ad_account, geo_locations: {countries: ['XX']}, interests: [{id: '123', name: 'foo'}], gender: 'female')
77
69
  z.send(:validate_spec)
78
70
  }.to raise_error('Invalid countrie(s): ["XX"]')
79
71
  end
@@ -103,7 +95,7 @@ describe Zuck::TargetingSpec do
103
95
 
104
96
  it "works without gender or age" do
105
97
  VCR.use_cassette('reach_for_valid_keywords') do
106
- spec = {geo_locations: {countries: ['us']}, interests: ['Eminem', 'Sting (Musician)'] }
98
+ spec = {geo_locations: {countries: ['us']}, interests: [{id: '6003135347608', name: 'Eminem'}, {id: '6003504886186', name: 'Sting (musician)'}] }
107
99
  ts = Zuck::TargetingSpec.new(graph, ad_account, spec)
108
100
  reach = ts.fetch_reach
109
101
  reach[:users].should == 28_00_0000
@@ -112,10 +104,10 @@ describe Zuck::TargetingSpec do
112
104
 
113
105
  it "works with gender and age" do
114
106
  VCR.use_cassette('reach_for_valid_keywords_male_young') do
115
- spec = {geo_locations: {countries: ['us']}, interests: ['Sting (musician)'], gender: :female, age_class: :young }
107
+ spec = {geo_locations: {countries: ['us']}, interests: [{id: '6003504886186', name: 'Sting (musician)'}], gender: :female, age_class: :young }
116
108
  ts = Zuck::TargetingSpec.new(graph, ad_account, spec)
117
109
  reach = ts.fetch_reach
118
- reach[:users].should == 74_000
110
+ reach[:users].should == 220_000
119
111
  end
120
112
  end
121
113