eucalyptus 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 +7 -0
- data/.document +5 -0
- data/.env +1 -0
- data/.rspec +1 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +102 -0
- data/LICENSE.txt +20 -0
- data/README.md +57 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/eucalyptus.gemspec +94 -0
- data/fixtures/vcr_cassettes/account_ad_sets.yml +256 -0
- data/fixtures/vcr_cassettes/account_ads.yml +154 -0
- data/fixtures/vcr_cassettes/account_campaigns.yml +154 -0
- data/fixtures/vcr_cassettes/test2.yml +103 -0
- data/lib/eucalyptus/account.rb +19 -0
- data/lib/eucalyptus/ad.rb +9 -0
- data/lib/eucalyptus/ad_set.rb +9 -0
- data/lib/eucalyptus/campaign.rb +9 -0
- data/lib/eucalyptus/custom_audience.rb +9 -0
- data/lib/eucalyptus/resource.rb +29 -0
- data/lib/eucalyptus/response.rb +16 -0
- data/lib/eucalyptus.rb +17 -0
- data/spec/eucalyptus/account_spec.rb +44 -0
- data/spec/eucalyptus/custom_audience_spec.rb +4 -0
- data/spec/eucalyptus/resource_spec.rb +45 -0
- data/spec/eucalyptus_spec.rb +19 -0
- data/spec/spec_helper.rb +42 -0
- metadata +212 -0
@@ -0,0 +1,154 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://graph.facebook.com/v2.3/me/adaccounts?access_token=<TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
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: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Access-Control-Allow-Origin:
|
22
|
+
- "*"
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=UTF-8
|
25
|
+
X-Fb-Trace-Id:
|
26
|
+
- CGMf/82jm7U
|
27
|
+
X-Fb-Rev:
|
28
|
+
- '1786490'
|
29
|
+
Etag:
|
30
|
+
- '"77dece23ab85d29f77e0ac944b8ea2c599b17702"'
|
31
|
+
Pragma:
|
32
|
+
- no-cache
|
33
|
+
Cache-Control:
|
34
|
+
- private, no-cache, no-store, must-revalidate
|
35
|
+
Facebook-Api-Version:
|
36
|
+
- v2.3
|
37
|
+
Expires:
|
38
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
39
|
+
X-Fb-Debug:
|
40
|
+
- 4x4TXOwjcWDCSsx46PnNk1JpPNHeV1j0csSQKBAmk/qzAuI+NBaeJfa0PkpVJX7Y8rd5zm/M+TylmAhpQcNh/A==
|
41
|
+
Date:
|
42
|
+
- Mon, 15 Jun 2015 18:48:47 GMT
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
Content-Length:
|
46
|
+
- '206'
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: '{"data":[{"account_id":"1387991991504454","id":"act_1387991991504454"},{"account_id":"330410070","id":"act_330410070"}],"paging":{"cursors":{"before":"NjAyMTM3NDcwNTI1OA==","after":"NjAwMzQwNjkyMTA3MQ=="}}}'
|
50
|
+
http_version:
|
51
|
+
recorded_at: Mon, 15 Jun 2015 18:48:47 GMT
|
52
|
+
- request:
|
53
|
+
method: get
|
54
|
+
uri: https://graph.facebook.com/v2.3/act_330410070/adgroups?access_token=<TOKEN>
|
55
|
+
body:
|
56
|
+
encoding: US-ASCII
|
57
|
+
string: ''
|
58
|
+
headers:
|
59
|
+
User-Agent:
|
60
|
+
- Faraday v0.9.1
|
61
|
+
Accept-Encoding:
|
62
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
63
|
+
Accept:
|
64
|
+
- "*/*"
|
65
|
+
response:
|
66
|
+
status:
|
67
|
+
code: 200
|
68
|
+
message: OK
|
69
|
+
headers:
|
70
|
+
Access-Control-Allow-Origin:
|
71
|
+
- "*"
|
72
|
+
Content-Type:
|
73
|
+
- application/json; charset=UTF-8
|
74
|
+
X-Fb-Trace-Id:
|
75
|
+
- CYDMUzv8elF
|
76
|
+
X-Fb-Rev:
|
77
|
+
- '1786490'
|
78
|
+
Etag:
|
79
|
+
- '"85ebdf05ed9fd10b5695834881f49f597c5265b6"'
|
80
|
+
Pragma:
|
81
|
+
- no-cache
|
82
|
+
Cache-Control:
|
83
|
+
- private, no-cache, no-store, must-revalidate
|
84
|
+
Facebook-Api-Version:
|
85
|
+
- v2.3
|
86
|
+
Expires:
|
87
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
88
|
+
Vary:
|
89
|
+
- Accept-Encoding
|
90
|
+
X-Fb-Debug:
|
91
|
+
- vgbGVkUIKry7Lky52tplsciSbrEQ+5VFYyxc/LArFSY4MF2Pqt/XoiOUJ0lXLDZt/KYmdf0fFrcqgvzy/LaqEg==
|
92
|
+
Date:
|
93
|
+
- Mon, 15 Jun 2015 18:48:48 GMT
|
94
|
+
Connection:
|
95
|
+
- keep-alive
|
96
|
+
Content-Length:
|
97
|
+
- '526'
|
98
|
+
body:
|
99
|
+
encoding: UTF-8
|
100
|
+
string: '{"data":[{"id":"6025433555071"},{"id":"6025433765271"},{"id":"6025526303471"},{"id":"6025526321871"},{"id":"6025396551671"},{"id":"6025352670471"},{"id":"6025611509471"},{"id":"6025615327871"},{"id":"6025122270071"},{"id":"6025622524871"},{"id":"6025621391271"},{"id":"6025433764471"},{"id":"6025621319071"},{"id":"6025620897271"},{"id":"6025433769871"},{"id":"6025620875871"},{"id":"6025620341871"},{"id":"6025620304871"},{"id":"6025616608471"},{"id":"6025615296471"},{"id":"6025615366671"},{"id":"6025352667271"},{"id":"6025615366871"},{"id":"6025279133071"},{"id":"6025396552871"}],"paging":{"cursors":{"before":"NjAyNTQzMzU1NTA3MQ==","after":"NjAyNTM5NjU1Mjg3MQ=="},"next":"https:\/\/graph.facebook.com\/v2.3\/act_330410070\/adgroups?access_token=<TOKEN>&limit=25&after=NjAyNTM5NjU1Mjg3MQ\u00253D\u00253D"}}'
|
101
|
+
http_version:
|
102
|
+
recorded_at: Mon, 15 Jun 2015 18:48:48 GMT
|
103
|
+
- request:
|
104
|
+
method: get
|
105
|
+
uri: https://graph.facebook.com/v2.3/act_330410070/adgroups?access_token=<TOKEN>
|
106
|
+
body:
|
107
|
+
encoding: US-ASCII
|
108
|
+
string: ''
|
109
|
+
headers:
|
110
|
+
User-Agent:
|
111
|
+
- Faraday v0.9.1
|
112
|
+
Accept-Encoding:
|
113
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
114
|
+
Accept:
|
115
|
+
- "*/*"
|
116
|
+
response:
|
117
|
+
status:
|
118
|
+
code: 200
|
119
|
+
message: OK
|
120
|
+
headers:
|
121
|
+
Access-Control-Allow-Origin:
|
122
|
+
- "*"
|
123
|
+
Content-Type:
|
124
|
+
- application/json; charset=UTF-8
|
125
|
+
X-Fb-Trace-Id:
|
126
|
+
- FoDErvnpmq/
|
127
|
+
X-Fb-Rev:
|
128
|
+
- '1786490'
|
129
|
+
Etag:
|
130
|
+
- '"85ebdf05ed9fd10b5695834881f49f597c5265b6"'
|
131
|
+
Pragma:
|
132
|
+
- no-cache
|
133
|
+
Cache-Control:
|
134
|
+
- private, no-cache, no-store, must-revalidate
|
135
|
+
Facebook-Api-Version:
|
136
|
+
- v2.3
|
137
|
+
Expires:
|
138
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
139
|
+
Vary:
|
140
|
+
- Accept-Encoding
|
141
|
+
X-Fb-Debug:
|
142
|
+
- bi6jwWxtFnaxM90ZLkoxvUKU0hQ6yJb7JHlRldStruYXM0soxGk21/OfZ0vcVa1NI/X/Hl+MGAfZXO4NlbhBfQ==
|
143
|
+
Date:
|
144
|
+
- Mon, 15 Jun 2015 18:48:49 GMT
|
145
|
+
Connection:
|
146
|
+
- keep-alive
|
147
|
+
Content-Length:
|
148
|
+
- '526'
|
149
|
+
body:
|
150
|
+
encoding: UTF-8
|
151
|
+
string: '{"data":[{"id":"6025433555071"},{"id":"6025433765271"},{"id":"6025526303471"},{"id":"6025526321871"},{"id":"6025396551671"},{"id":"6025352670471"},{"id":"6025611509471"},{"id":"6025615327871"},{"id":"6025122270071"},{"id":"6025622524871"},{"id":"6025621391271"},{"id":"6025433764471"},{"id":"6025621319071"},{"id":"6025620897271"},{"id":"6025433769871"},{"id":"6025620875871"},{"id":"6025620341871"},{"id":"6025620304871"},{"id":"6025616608471"},{"id":"6025615296471"},{"id":"6025615366671"},{"id":"6025352667271"},{"id":"6025615366871"},{"id":"6025279133071"},{"id":"6025396552871"}],"paging":{"cursors":{"before":"NjAyNTQzMzU1NTA3MQ==","after":"NjAyNTM5NjU1Mjg3MQ=="},"next":"https:\/\/graph.facebook.com\/v2.3\/act_330410070\/adgroups?access_token=<TOKEN>&limit=25&after=NjAyNTM5NjU1Mjg3MQ\u00253D\u00253D"}}'
|
152
|
+
http_version:
|
153
|
+
recorded_at: Mon, 15 Jun 2015 18:48:49 GMT
|
154
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,154 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://graph.facebook.com/v2.3/me/adaccounts?access_token=<TOKEN>
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
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: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Access-Control-Allow-Origin:
|
22
|
+
- "*"
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=UTF-8
|
25
|
+
X-Fb-Trace-Id:
|
26
|
+
- GXb07i291Mm
|
27
|
+
X-Fb-Rev:
|
28
|
+
- '1786490'
|
29
|
+
Etag:
|
30
|
+
- '"77dece23ab85d29f77e0ac944b8ea2c599b17702"'
|
31
|
+
Pragma:
|
32
|
+
- no-cache
|
33
|
+
Cache-Control:
|
34
|
+
- private, no-cache, no-store, must-revalidate
|
35
|
+
Facebook-Api-Version:
|
36
|
+
- v2.3
|
37
|
+
Expires:
|
38
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
39
|
+
X-Fb-Debug:
|
40
|
+
- X+E1AoeQ8ejNE21hPO6ZyAAd8w4dy16GQlExON+JzaQ65caTKeyydbZPSVVy331B86Lz38b8nnymqLYS15gUGA==
|
41
|
+
Date:
|
42
|
+
- Mon, 15 Jun 2015 18:48:50 GMT
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
Content-Length:
|
46
|
+
- '206'
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: '{"data":[{"account_id":"1387991991504454","id":"act_1387991991504454"},{"account_id":"330410070","id":"act_330410070"}],"paging":{"cursors":{"before":"NjAyMTM3NDcwNTI1OA==","after":"NjAwMzQwNjkyMTA3MQ=="}}}'
|
50
|
+
http_version:
|
51
|
+
recorded_at: Mon, 15 Jun 2015 18:48:50 GMT
|
52
|
+
- request:
|
53
|
+
method: get
|
54
|
+
uri: https://graph.facebook.com/v2.3/act_330410070/adcampaign_groups?access_token=<TOKEN>
|
55
|
+
body:
|
56
|
+
encoding: US-ASCII
|
57
|
+
string: ''
|
58
|
+
headers:
|
59
|
+
User-Agent:
|
60
|
+
- Faraday v0.9.1
|
61
|
+
Accept-Encoding:
|
62
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
63
|
+
Accept:
|
64
|
+
- "*/*"
|
65
|
+
response:
|
66
|
+
status:
|
67
|
+
code: 200
|
68
|
+
message: OK
|
69
|
+
headers:
|
70
|
+
Access-Control-Allow-Origin:
|
71
|
+
- "*"
|
72
|
+
Content-Type:
|
73
|
+
- application/json; charset=UTF-8
|
74
|
+
X-Fb-Trace-Id:
|
75
|
+
- EywWkH9ud3d
|
76
|
+
X-Fb-Rev:
|
77
|
+
- '1786490'
|
78
|
+
Etag:
|
79
|
+
- '"1c1bc53719df772ddb175a142e48a736fb5b8a8c"'
|
80
|
+
Pragma:
|
81
|
+
- no-cache
|
82
|
+
Cache-Control:
|
83
|
+
- private, no-cache, no-store, must-revalidate
|
84
|
+
Facebook-Api-Version:
|
85
|
+
- v2.3
|
86
|
+
Expires:
|
87
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
88
|
+
Vary:
|
89
|
+
- Accept-Encoding
|
90
|
+
X-Fb-Debug:
|
91
|
+
- So+2L5joSrQ2zyLiB1OF4GLYwyGxLASdDuR/8WRZ6ksMBiLTqKvwPkKuoOU9cJJ5bWp2Anm1UiIRFcWSb2dumQ==
|
92
|
+
Date:
|
93
|
+
- Mon, 15 Jun 2015 18:48:50 GMT
|
94
|
+
Connection:
|
95
|
+
- keep-alive
|
96
|
+
Content-Length:
|
97
|
+
- '538'
|
98
|
+
body:
|
99
|
+
encoding: UTF-8
|
100
|
+
string: '{"data":[{"id":"6018202879071"},{"id":"6022352143271"},{"id":"6025097858271"},{"id":"6025097858471"},{"id":"6025097858871"},{"id":"6025097860071"},{"id":"6025097860271"},{"id":"6025097860471"},{"id":"6013694911671"},{"id":"6013695314071"},{"id":"6013695715071"},{"id":"6013696183271"},{"id":"6013734336471"},{"id":"6013734800271"},{"id":"6013734827271"},{"id":"6013844400071"},{"id":"6013844400271"},{"id":"6013939530271"},{"id":"6014309373671"},{"id":"6016656440871"},{"id":"6016925455671"},{"id":"6016925455871"},{"id":"6017065961671"},{"id":"6017066317671"},{"id":"6018117120071"}],"paging":{"cursors":{"before":"NjAxODIwMjg3OTA3MQ==","after":"NjAxODExNzEyMDA3MQ=="},"next":"https:\/\/graph.facebook.com\/v2.3\/act_330410070\/adcampaign_groups?access_token=<TOKEN>&limit=25&after=NjAxODExNzEyMDA3MQ\u00253D\u00253D"}}'
|
101
|
+
http_version:
|
102
|
+
recorded_at: Mon, 15 Jun 2015 18:48:50 GMT
|
103
|
+
- request:
|
104
|
+
method: get
|
105
|
+
uri: https://graph.facebook.com/v2.3/act_330410070/adcampaign_groups?access_token=<TOKEN>
|
106
|
+
body:
|
107
|
+
encoding: US-ASCII
|
108
|
+
string: ''
|
109
|
+
headers:
|
110
|
+
User-Agent:
|
111
|
+
- Faraday v0.9.1
|
112
|
+
Accept-Encoding:
|
113
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
114
|
+
Accept:
|
115
|
+
- "*/*"
|
116
|
+
response:
|
117
|
+
status:
|
118
|
+
code: 200
|
119
|
+
message: OK
|
120
|
+
headers:
|
121
|
+
Access-Control-Allow-Origin:
|
122
|
+
- "*"
|
123
|
+
Content-Type:
|
124
|
+
- application/json; charset=UTF-8
|
125
|
+
X-Fb-Trace-Id:
|
126
|
+
- FoKdGVJrJ39
|
127
|
+
X-Fb-Rev:
|
128
|
+
- '1786490'
|
129
|
+
Etag:
|
130
|
+
- '"1c1bc53719df772ddb175a142e48a736fb5b8a8c"'
|
131
|
+
Pragma:
|
132
|
+
- no-cache
|
133
|
+
Cache-Control:
|
134
|
+
- private, no-cache, no-store, must-revalidate
|
135
|
+
Facebook-Api-Version:
|
136
|
+
- v2.3
|
137
|
+
Expires:
|
138
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
139
|
+
Vary:
|
140
|
+
- Accept-Encoding
|
141
|
+
X-Fb-Debug:
|
142
|
+
- 1it4e6361+JsAiof91hSUYmJqHF3OL/+esomw99BiCmp+tQzU/yx1h61Accj8j66aHg2QDrycT4X5hbFirBV/g==
|
143
|
+
Date:
|
144
|
+
- Mon, 15 Jun 2015 18:48:51 GMT
|
145
|
+
Connection:
|
146
|
+
- keep-alive
|
147
|
+
Content-Length:
|
148
|
+
- '538'
|
149
|
+
body:
|
150
|
+
encoding: UTF-8
|
151
|
+
string: '{"data":[{"id":"6018202879071"},{"id":"6022352143271"},{"id":"6025097858271"},{"id":"6025097858471"},{"id":"6025097858871"},{"id":"6025097860071"},{"id":"6025097860271"},{"id":"6025097860471"},{"id":"6013694911671"},{"id":"6013695314071"},{"id":"6013695715071"},{"id":"6013696183271"},{"id":"6013734336471"},{"id":"6013734800271"},{"id":"6013734827271"},{"id":"6013844400071"},{"id":"6013844400271"},{"id":"6013939530271"},{"id":"6014309373671"},{"id":"6016656440871"},{"id":"6016925455671"},{"id":"6016925455871"},{"id":"6017065961671"},{"id":"6017066317671"},{"id":"6018117120071"}],"paging":{"cursors":{"before":"NjAxODIwMjg3OTA3MQ==","after":"NjAxODExNzEyMDA3MQ=="},"next":"https:\/\/graph.facebook.com\/v2.3\/act_330410070\/adcampaign_groups?access_token=<TOKEN>&limit=25&after=NjAxODExNzEyMDA3MQ\u00253D\u00253D"}}'
|
152
|
+
http_version:
|
153
|
+
recorded_at: Mon, 15 Jun 2015 18:48:51 GMT
|
154
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,103 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://graph.facebook.com/v2.3/me/adaccounts?access_token=CAAT2zroqzZBgBAGZAPGRB4nnNOsOeskFd8wCn82iqgCLjf66ZBY6KsaJ8QL9NoHUGSkagizo2hZAw0hg6BtPiZC1zQUPhbezboBODBJZA1YVYtHbv0ZB5Fx992elxUizs6JzKBf6ZC3nOoE11Ft5wfbgNjfyeAx1W2GqRVWzExhHaaqJNZATrIqKvZBMFWNUJKCeBpgRbEcdaa4t39g4DAiAzG
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
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: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Access-Control-Allow-Origin:
|
22
|
+
- "*"
|
23
|
+
Content-Type:
|
24
|
+
- application/json; charset=UTF-8
|
25
|
+
X-Fb-Trace-Id:
|
26
|
+
- FzFVzTkRLiX
|
27
|
+
X-Fb-Rev:
|
28
|
+
- '1786490'
|
29
|
+
Etag:
|
30
|
+
- '"77dece23ab85d29f77e0ac944b8ea2c599b17702"'
|
31
|
+
Pragma:
|
32
|
+
- no-cache
|
33
|
+
Cache-Control:
|
34
|
+
- private, no-cache, no-store, must-revalidate
|
35
|
+
Facebook-Api-Version:
|
36
|
+
- v2.3
|
37
|
+
Expires:
|
38
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
39
|
+
X-Fb-Debug:
|
40
|
+
- jYXykZtn9tWZi6stLkFTIjNLTyFllTxPLgnyQLXULu5DF/OV4Rwp9nf4GawLTqFR6q8qLI0KHCTUgE/YjASxtQ==
|
41
|
+
Date:
|
42
|
+
- Mon, 15 Jun 2015 18:02:02 GMT
|
43
|
+
Connection:
|
44
|
+
- keep-alive
|
45
|
+
Content-Length:
|
46
|
+
- '206'
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: '{"data":[{"account_id":"1387991991504454","id":"act_1387991991504454"},{"account_id":"330410070","id":"act_330410070"}],"paging":{"cursors":{"before":"NjAyMTM3NDcwNTI1OA==","after":"NjAwMzQwNjkyMTA3MQ=="}}}'
|
50
|
+
http_version:
|
51
|
+
recorded_at: Mon, 15 Jun 2015 18:02:02 GMT
|
52
|
+
- request:
|
53
|
+
method: get
|
54
|
+
uri: https://graph.facebook.com/v2.3/act_330410070/adgroups?access_token=CAAT2zroqzZBgBAGZAPGRB4nnNOsOeskFd8wCn82iqgCLjf66ZBY6KsaJ8QL9NoHUGSkagizo2hZAw0hg6BtPiZC1zQUPhbezboBODBJZA1YVYtHbv0ZB5Fx992elxUizs6JzKBf6ZC3nOoE11Ft5wfbgNjfyeAx1W2GqRVWzExhHaaqJNZATrIqKvZBMFWNUJKCeBpgRbEcdaa4t39g4DAiAzG
|
55
|
+
body:
|
56
|
+
encoding: US-ASCII
|
57
|
+
string: ''
|
58
|
+
headers:
|
59
|
+
User-Agent:
|
60
|
+
- Faraday v0.9.1
|
61
|
+
Accept-Encoding:
|
62
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
63
|
+
Accept:
|
64
|
+
- "*/*"
|
65
|
+
response:
|
66
|
+
status:
|
67
|
+
code: 200
|
68
|
+
message: OK
|
69
|
+
headers:
|
70
|
+
Access-Control-Allow-Origin:
|
71
|
+
- "*"
|
72
|
+
Content-Type:
|
73
|
+
- application/json; charset=UTF-8
|
74
|
+
X-Fb-Trace-Id:
|
75
|
+
- FZ9Vk1VwYvT
|
76
|
+
X-Fb-Rev:
|
77
|
+
- '1786490'
|
78
|
+
Etag:
|
79
|
+
- '"85ebdf05ed9fd10b5695834881f49f597c5265b6"'
|
80
|
+
Pragma:
|
81
|
+
- no-cache
|
82
|
+
Cache-Control:
|
83
|
+
- private, no-cache, no-store, must-revalidate
|
84
|
+
Facebook-Api-Version:
|
85
|
+
- v2.3
|
86
|
+
Expires:
|
87
|
+
- Sat, 01 Jan 2000 00:00:00 GMT
|
88
|
+
Vary:
|
89
|
+
- Accept-Encoding
|
90
|
+
X-Fb-Debug:
|
91
|
+
- "/SveTwoSDIVXo/8hvQF3K7d/Vgtch6d2tuAvCWRR4gefclSgThUJ87QrRmikBph2+jfKRmLhtjTvm6BnGFrupw=="
|
92
|
+
Date:
|
93
|
+
- Mon, 15 Jun 2015 18:02:02 GMT
|
94
|
+
Connection:
|
95
|
+
- keep-alive
|
96
|
+
Content-Length:
|
97
|
+
- '526'
|
98
|
+
body:
|
99
|
+
encoding: UTF-8
|
100
|
+
string: '{"data":[{"id":"6025433555071"},{"id":"6025433765271"},{"id":"6025526303471"},{"id":"6025526321871"},{"id":"6025396551671"},{"id":"6025352670471"},{"id":"6025611509471"},{"id":"6025615327871"},{"id":"6025122270071"},{"id":"6025622524871"},{"id":"6025621391271"},{"id":"6025433764471"},{"id":"6025621319071"},{"id":"6025620897271"},{"id":"6025433769871"},{"id":"6025620875871"},{"id":"6025620341871"},{"id":"6025620304871"},{"id":"6025616608471"},{"id":"6025615296471"},{"id":"6025615366671"},{"id":"6025352667271"},{"id":"6025615366871"},{"id":"6025279133071"},{"id":"6025396552871"}],"paging":{"cursors":{"before":"NjAyNTQzMzU1NTA3MQ==","after":"NjAyNTM5NjU1Mjg3MQ=="},"next":"https:\/\/graph.facebook.com\/v2.3\/act_330410070\/adgroups?access_token=CAAT2zroqzZBgBAGZAPGRB4nnNOsOeskFd8wCn82iqgCLjf66ZBY6KsaJ8QL9NoHUGSkagizo2hZAw0hg6BtPiZC1zQUPhbezboBODBJZA1YVYtHbv0ZB5Fx992elxUizs6JzKBf6ZC3nOoE11Ft5wfbgNjfyeAx1W2GqRVWzExhHaaqJNZATrIqKvZBMFWNUJKCeBpgRbEcdaa4t39g4DAiAzG&limit=25&after=NjAyNTM5NjU1Mjg3MQ\u00253D\u00253D"}}'
|
101
|
+
http_version:
|
102
|
+
recorded_at: Mon, 15 Jun 2015 18:02:02 GMT
|
103
|
+
recorded_with: VCR 2.9.2
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'resource'
|
2
|
+
|
3
|
+
module Eucalyptus
|
4
|
+
class Account < Resource
|
5
|
+
def self.api_path
|
6
|
+
"adaccounts"
|
7
|
+
end
|
8
|
+
|
9
|
+
# 'me' is a facebook helper which refers to the user who created the access token
|
10
|
+
def self.parent
|
11
|
+
OpenStruct.new(id: "me")
|
12
|
+
end
|
13
|
+
|
14
|
+
# associations
|
15
|
+
def ads; Ad.all(parent: self); end
|
16
|
+
def ad_sets; AdSet.all(parent: self); end
|
17
|
+
def campaigns; Campaign.all(parent: self); end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Eucalyptus
|
2
|
+
class Resource
|
3
|
+
def self.api_path
|
4
|
+
raise "You must implement this method"
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.parent
|
8
|
+
Account.all.last
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find(id, graph: Eucalyptus.graph)
|
12
|
+
response = graph.get_object(id)
|
13
|
+
self.new(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.all(graph: Eucalyptus.graph, parent: self.parent)
|
17
|
+
response = graph.get_connection(parent.id, api_path)
|
18
|
+
response.collect{ |res| self.new(res) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(response)
|
22
|
+
@response = Response.new(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
def method_missing(method_sym, *args, &block)
|
26
|
+
@response.send(method_sym)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Eucalyptus
|
2
|
+
class Response < OpenStruct
|
3
|
+
# extend OpenStruct to work with nested hashes
|
4
|
+
def initialize(hash)
|
5
|
+
@table = {}
|
6
|
+
@hash_table = {}
|
7
|
+
|
8
|
+
hash.each do |k, v|
|
9
|
+
@table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
|
10
|
+
@hash_table[k.to_sym] = v
|
11
|
+
|
12
|
+
new_ostruct_member(k)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/eucalyptus.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'koala'
|
2
|
+
Dir[File.dirname(__FILE__) + '/eucalyptus/**/*.rb'].each do |file|
|
3
|
+
require file
|
4
|
+
end
|
5
|
+
|
6
|
+
Koala.config.api_version = 'v2.3'
|
7
|
+
|
8
|
+
module Eucalyptus
|
9
|
+
class << self
|
10
|
+
attr_accessor :access_token, :graph
|
11
|
+
|
12
|
+
def configure
|
13
|
+
yield(self)
|
14
|
+
self.graph = Koala::Facebook::API.new(access_token)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Eucalyptus::Account do
|
4
|
+
before do
|
5
|
+
Eucalyptus.configure do |config|
|
6
|
+
config.access_token = ENV["ACCESS_TOKEN"]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#ads' do
|
11
|
+
let(:account) { Eucalyptus::Account.all.last }
|
12
|
+
|
13
|
+
it 'returns a collection of Ad objects which belong to the account' do
|
14
|
+
VCR.use_cassette("account_ads") do
|
15
|
+
expect(account.ads).to be_a Array
|
16
|
+
expect(account.ads.first).to be_a Eucalyptus::Ad
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#ad_sets' do
|
22
|
+
let(:account) { Eucalyptus::Account.all.last }
|
23
|
+
|
24
|
+
it 'returns a collection of AdSet objects which belong to the account' do
|
25
|
+
VCR.use_cassette("account_ad_sets") do
|
26
|
+
expect(account.ad_sets).to be_a Array
|
27
|
+
expect(account.ad_sets.first).to be_a Eucalyptus::AdSet
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#campaigns' do
|
34
|
+
let(:account) { Eucalyptus::Account.all.last }
|
35
|
+
|
36
|
+
it 'returns a collection of AdSet objects which belong to the account' do
|
37
|
+
VCR.use_cassette("account_campaigns") do
|
38
|
+
expect(account.campaigns).to be_a Array
|
39
|
+
expect(account.campaigns.first).to be_a Eucalyptus::Campaign
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Eucalyptus::Resource do
|
4
|
+
|
5
|
+
context "given a class which inherits from Eucalyptus::Resource" do
|
6
|
+
describe ".find" do
|
7
|
+
let(:graph) { double(:graph, get_object: { "id" => "123" }) }
|
8
|
+
|
9
|
+
it 'returns an instance of Resource' do
|
10
|
+
expect(Eucalyptus::CustomAudience.find(123, graph: graph) ).to be_a Eucalyptus::CustomAudience
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'takes an id and returns an object which returns that id' do
|
14
|
+
audience = Eucalyptus::CustomAudience.find(123, graph: graph)
|
15
|
+
expect(audience.id).to eql "123"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.all' do
|
20
|
+
let(:response) { [{ "id" => "123"}, {"id" => "321"}] }
|
21
|
+
let(:graph) { double(:graph, get_connection: response) }
|
22
|
+
let(:parent) { double(:parent, id: 123) }
|
23
|
+
|
24
|
+
it 'returns a collection of resources' do
|
25
|
+
expect(Eucalyptus::CustomAudience.all(graph: graph, parent: parent)).to be_a Array
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#method_missing' do
|
30
|
+
let(:response) { { "id" => "123", "name" => "Audience", "stats" => {"cpa" => "12"} }}
|
31
|
+
let(:resource) { Eucalyptus::CustomAudience.new(response) }
|
32
|
+
it 'responds to a message which corresponds with a key in the response hash' do
|
33
|
+
expect( resource.name ).to eql "Audience"
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'works with nested hashes too' do
|
37
|
+
expect( resource.stats.cpa ).to eql "12"
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns nil when tryng to access a key which doesnt exist in the response' do
|
41
|
+
expect( resource.fake_key ).to eql nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Eucalyptus" do
|
4
|
+
describe ".configure" do
|
5
|
+
let(:access_token) { "123abc" }
|
6
|
+
|
7
|
+
before do
|
8
|
+
Eucalyptus.configure do |config|
|
9
|
+
config.access_token = access_token
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns a graph object which has the configured access_token" do
|
14
|
+
graph = Eucalyptus.graph
|
15
|
+
expect(graph.access_token).to eql access_token
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|