facebook_ads 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +23 -0
  4. data/.travis.yml +1 -1
  5. data/Gemfile +4 -5
  6. data/Gemfile.lock +34 -82
  7. data/{README.markdown → README.md} +43 -10
  8. data/Rakefile +6 -0
  9. data/bin/console +15 -1
  10. data/facebook_ads.gemspec +11 -13
  11. data/lib/facebook_ads.rb +11 -7
  12. data/lib/facebook_ads/ad.rb +6 -8
  13. data/lib/facebook_ads/ad_account.rb +65 -54
  14. data/lib/facebook_ads/ad_audience.rb +22 -0
  15. data/lib/facebook_ads/ad_campaign.rb +21 -17
  16. data/lib/facebook_ads/ad_creative.rb +7 -9
  17. data/lib/facebook_ads/ad_image.rb +3 -5
  18. data/lib/facebook_ads/ad_insight.rb +4 -5
  19. data/lib/facebook_ads/ad_product.rb +6 -0
  20. data/lib/facebook_ads/ad_product_catalog.rb +60 -0
  21. data/lib/facebook_ads/ad_product_feed.rb +6 -0
  22. data/lib/facebook_ads/ad_product_set.rb +6 -0
  23. data/lib/facebook_ads/ad_set.rb +9 -11
  24. data/lib/facebook_ads/ad_targeting.rb +19 -21
  25. data/lib/facebook_ads/base.rb +107 -62
  26. data/test/ad_account_test.rb +27 -0
  27. data/test/ad_campaign_test.rb +32 -0
  28. data/test/ad_creative_test.rb +7 -0
  29. data/test/ad_image_test.rb +27 -0
  30. data/test/ad_insight_test.rb +7 -0
  31. data/test/ad_product_catalog_test.rb +28 -0
  32. data/test/ad_product_feed_test.rb +7 -0
  33. data/test/ad_product_set_test.rb +7 -0
  34. data/test/ad_product_test.rb +22 -0
  35. data/test/ad_set_test.rb +7 -0
  36. data/test/ad_targeting_test.rb +7 -0
  37. data/test/ad_test.rb +7 -0
  38. data/test/facebook_ads_test.rb +8 -0
  39. data/test/test_helper.rb +64 -0
  40. data/test/vcr_cassettes/AdAccountTest-test_all.yml +70 -0
  41. data/test/vcr_cassettes/AdAccountTest-test_applications.yml +130 -0
  42. data/test/vcr_cassettes/AdAccountTest-test_find_by.yml +71 -0
  43. data/test/vcr_cassettes/AdCampaignTest-test_create.yml +295 -0
  44. data/test/vcr_cassettes/AdCampaignTest-test_list.yml +133 -0
  45. data/test/vcr_cassettes/AdImageTest-test_create.yml +2963 -0
  46. data/test/vcr_cassettes/AdImageTest-test_list.yml +137 -0
  47. data/test/vcr_cassettes/AdProductCatalogTest-test_all.yml +60 -0
  48. data/test/vcr_cassettes/AdProductCatalogTest-test_create.yml +256 -0
  49. data/test/vcr_cassettes/AdProductTest-test_list.yml +130 -0
  50. metadata +44 -49
  51. data/spec/ad_account_spec.rb +0 -78
  52. data/spec/ad_campaign_spec.rb +0 -13
  53. data/spec/ad_creative_spec.rb +0 -14
  54. data/spec/ad_image_spec.rb +0 -11
  55. data/spec/ad_insight_spec.rb +0 -11
  56. data/spec/ad_set_spec.rb +0 -13
  57. data/spec/ad_spec.rb +0 -13
  58. data/spec/ad_targeting_spec.rb +0 -4
  59. data/spec/spec_helper.rb +0 -15
  60. data/spec/support/fixtures.sh +0 -17
  61. data/spec/support/fixtures/6057330925170.json +0 -1
  62. data/spec/support/fixtures/6057810634370.json +0 -1
  63. data/spec/support/fixtures/6057810946970.json +0 -1
  64. data/spec/support/fixtures/6057824295570.json +0 -1
  65. data/spec/support/fixtures/act_861827983860489.json +0 -1
  66. data/spec/support/fixtures/act_861827983860489/adcreatives.json +0 -1
  67. data/spec/support/fixtures/act_861827983860489/adimages.json +0 -1
  68. data/spec/support/fixtures/act_861827983860489/ads.json +0 -1
  69. data/spec/support/fixtures/act_861827983860489/adsets.json +0 -1
  70. data/spec/support/fixtures/act_861827983860489/campaigns.json +0 -1
  71. data/spec/support/fixtures/me/adaccounts.json +0 -1
  72. data/spec/support/rack_facebook.rb +0 -22
@@ -0,0 +1,130 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://graph.facebook.com/v2.8/TEST_BUSINESS_ID/product_catalogs?access_token=TEST_ACCESS_TOKEN&fields=id,name,vertical,product_count,feed_count
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Access-Control-Allow-Origin:
22
+ - "*"
23
+ Etag:
24
+ - '"4da6baa87a2d2d9485d71880069bf895add8e5de"'
25
+ Pragma:
26
+ - no-cache
27
+ Cache-Control:
28
+ - private, no-cache, no-store, must-revalidate
29
+ Facebook-Api-Version:
30
+ - v2.8
31
+ Expires:
32
+ - Sat, 01 Jan 2000 00:00:00 GMT
33
+ Content-Type:
34
+ - application/json; charset=UTF-8
35
+ X-Fb-Trace-Id:
36
+ - DLCpw/CioIz
37
+ X-Fb-Rev:
38
+ - '2761076'
39
+ Vary:
40
+ - Accept-Encoding
41
+ Content-Encoding:
42
+ - gzip
43
+ X-Fb-Debug:
44
+ - bC/e/XS1/SBBd+i8nBYjuKq8fH5lDfU2AkEMOlYrh9KbX3vOzKnhbCFebbRREnTGuNKJ2dXra6c3vxtqgCJBOw==
45
+ Date:
46
+ - Sun, 01 Jan 2017 02:33:34 GMT
47
+ Connection:
48
+ - keep-alive
49
+ Content-Length:
50
+ - '161'
51
+ body:
52
+ encoding: ASCII-8BIT
53
+ string: !binary |-
54
+ H4sIAAAAAAAAA3WMsQrCMBRF/+XNHQxRUrMJdqwu3UQkvryWok3kNRFpyL+b
55
+ Lm5u95x7uQmsCQb0JcFoQYPYq1oJuVFS7JSooQJnJipFR3Mo9CYOI5pnMein
56
+ iRip2Bd7GzHc0EcXQIsKeiL7w3wtEzOMbgCdACPPnuc13qn3vL633UOej/hp
57
+ l4Nsl0aclmZbfk0fiP/VOecvv4YTXL4AAAA=
58
+ http_version:
59
+ recorded_at: Sun, 01 Jan 2017 02:33:34 GMT
60
+ - request:
61
+ method: get
62
+ uri: https://graph.facebook.com/v2.8/197871307315718/products?access_token=TEST_ACCESS_TOKEN&fields=id,retailer_id,name,description,brand,category,currency,price,image_url,url&limit=100
63
+ body:
64
+ encoding: US-ASCII
65
+ string: ''
66
+ headers:
67
+ Accept:
68
+ - "*/*; q=0.5, application/xml"
69
+ Accept-Encoding:
70
+ - gzip, deflate
71
+ User-Agent:
72
+ - Ruby
73
+ response:
74
+ status:
75
+ code: 200
76
+ message: OK
77
+ headers:
78
+ Access-Control-Allow-Origin:
79
+ - "*"
80
+ Etag:
81
+ - '"bb480c7a1e23fbaadac31061c1b5f7ee3f4562e8"'
82
+ Pragma:
83
+ - no-cache
84
+ Cache-Control:
85
+ - private, no-cache, no-store, must-revalidate
86
+ Facebook-Api-Version:
87
+ - v2.8
88
+ Expires:
89
+ - Sat, 01 Jan 2000 00:00:00 GMT
90
+ Content-Type:
91
+ - application/json; charset=UTF-8
92
+ X-Fb-Trace-Id:
93
+ - FEsxhkoKAm0
94
+ X-Fb-Rev:
95
+ - '2761076'
96
+ Vary:
97
+ - Accept-Encoding
98
+ Content-Encoding:
99
+ - gzip
100
+ X-Fb-Debug:
101
+ - kpTAOYHwfddkGrvWp32KTHz97vxETw4MUMtmG8xz9o99LegDnrNmHSOcy8UH2v7X9Tr5z/8OvzGENyBycfDttw==
102
+ Date:
103
+ - Sun, 01 Jan 2017 02:33:34 GMT
104
+ Connection:
105
+ - keep-alive
106
+ Content-Length:
107
+ - '763'
108
+ body:
109
+ encoding: ASCII-8BIT
110
+ string: !binary |-
111
+ H4sIAAAAAAAAA+1Ty3KbMBT9FYbpeFVjxCNAZjwdYew0bajrxPE01B2PEMIo
112
+ wYhIwo+m+fcKJ7RpF1l30ZV0zz06us8HPUMS6adfH3Sa6ac6cPwAAMv0ADAd
113
+ 0/H1tzonEtGS8NWRoCzO+rxJD32COKfVWihOhTZEOT9zgilrhHbZsjQjsFzt
114
+ ShJeKpp2Rcst4RrkkuYUU1Rql0pFG/9WyYjAnNaSskqJvXE1UdC6bt/2NSS1
115
+ A2u4ljHGhSS1tqOyoJVmuX3L09JG0IoIoWXoIAwllXJUteHCjHHUCva72JQT
116
+ I0nWjB+U/wPZkZIftB8v48AN56TCrf/6KlJAzSlu83sD3BPDNBVCN2hNVg0v
117
+ FVpIWYvT5WA5IHuVbIVKY7838hRnlVERuRwIlJPV8YVRF/W7bAhn8KKa5g3Y
118
+ FHd16sx7Smh4lFk2pmm5Nnw6rUl3ZrZPSM2JaBoXBAYuWZPlnFXy+MMzCVjY
119
+ dy3HzjzHRtjGqQVSD2DbAYGVKkLHKxFXodzW6x7OxRD0VhVeFUgUKq6w3JfR
120
+ 6N4N5PREjFWif6coWV0gqdI0MNssByWTYjmwbMtzPcvXH7+pYqG1qqN++tDW
121
+ UahutdeU5Iy3JYznM2c6H+/jW2jH8/HuUwTNKUyipK0zypXw66RHNWyqzH/E
122
+ tOaoLowcYZIydvcU2NYy/OUABJ7vAdv0bOB6QAE1Z1mDpXiHMFbzspLsjlTD
123
+ MYTjT2ESBufxNQxhzG/EzlwAv66nW5nAycHdkm0yQsloPCPsHCMYNROSwCS8
124
+ nichjyZxMnJy4n+nZzj4+P7kIgnp5ZfKaWaz6GaMzhLo07ObDU3gfXByd34l
125
+ 7s9McxEC4i52SRhGt2U2n8APPlxUeczjilnbC1b69xcJvLT46IsT3ySj0WKR
126
+ +UnUyykpMzGk2XM7Ry8WtIPafezuL7aqg47b0RndNvyyn6e/s4/D3xm/5r4D
127
+ 1LVX0g2VQ2CavWMDh6/2WA3x9riH/zv4L3bwaVFfa+Hj409lK5S5NQYAAA==
128
+ http_version:
129
+ recorded_at: Sun, 01 Jan 2017 02:33:34 GMT
130
+ recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook_ads
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Estreich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-07 00:00:00.000000000 Z
11
+ date: 2017-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activesupport
14
+ name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '1.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '4.2'
27
- - !ruby/object:Gem::Dependency
28
- name: httmultiparty
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.3'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: '0.3'
26
+ version: '1.6'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: hashie
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,55 +38,64 @@ dependencies:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
40
  version: '3.4'
55
- description: This gem allows to easily manage your Facebook ads via Facebook's Marketing
56
- API in ruby.
41
+ description: This gem allows to easily manage your Facebook ads via Facebook's
42
+ Marketing API in ruby.
57
43
  email: cestreich@gmail.com
58
44
  executables:
59
45
  - console
60
46
  extensions: []
61
47
  extra_rdoc_files:
62
- - README.markdown
48
+ - README.md
63
49
  files:
64
50
  - ".gitignore"
51
+ - ".rubocop.yml"
65
52
  - ".travis.yml"
66
53
  - Gemfile
67
54
  - Gemfile.lock
68
- - README.markdown
55
+ - README.md
56
+ - Rakefile
69
57
  - bin/console
70
58
  - facebook_ads.gemspec
71
59
  - lib/facebook_ads.rb
72
60
  - lib/facebook_ads/ad.rb
73
61
  - lib/facebook_ads/ad_account.rb
62
+ - lib/facebook_ads/ad_audience.rb
74
63
  - lib/facebook_ads/ad_campaign.rb
75
64
  - lib/facebook_ads/ad_creative.rb
76
65
  - lib/facebook_ads/ad_image.rb
77
66
  - lib/facebook_ads/ad_insight.rb
67
+ - lib/facebook_ads/ad_product.rb
68
+ - lib/facebook_ads/ad_product_catalog.rb
69
+ - lib/facebook_ads/ad_product_feed.rb
70
+ - lib/facebook_ads/ad_product_set.rb
78
71
  - lib/facebook_ads/ad_set.rb
79
72
  - lib/facebook_ads/ad_targeting.rb
80
73
  - lib/facebook_ads/base.rb
81
- - spec/ad_account_spec.rb
82
- - spec/ad_campaign_spec.rb
83
- - spec/ad_creative_spec.rb
84
- - spec/ad_image_spec.rb
85
- - spec/ad_insight_spec.rb
86
- - spec/ad_set_spec.rb
87
- - spec/ad_spec.rb
88
- - spec/ad_targeting_spec.rb
89
- - spec/spec_helper.rb
90
- - spec/support/fixtures.sh
91
- - spec/support/fixtures/6057330925170.json
92
- - spec/support/fixtures/6057810634370.json
93
- - spec/support/fixtures/6057810946970.json
94
- - spec/support/fixtures/6057824295570.json
95
- - spec/support/fixtures/act_861827983860489.json
96
- - spec/support/fixtures/act_861827983860489/adcreatives.json
97
- - spec/support/fixtures/act_861827983860489/adimages.json
98
- - spec/support/fixtures/act_861827983860489/ads.json
99
- - spec/support/fixtures/act_861827983860489/adsets.json
100
- - spec/support/fixtures/act_861827983860489/campaigns.json
101
- - spec/support/fixtures/me/adaccounts.json
102
- - spec/support/rack_facebook.rb
103
- homepage: https://github.com/cte/facebook-ads-sdk-ruby
74
+ - test/ad_account_test.rb
75
+ - test/ad_campaign_test.rb
76
+ - test/ad_creative_test.rb
77
+ - test/ad_image_test.rb
78
+ - test/ad_insight_test.rb
79
+ - test/ad_product_catalog_test.rb
80
+ - test/ad_product_feed_test.rb
81
+ - test/ad_product_set_test.rb
82
+ - test/ad_product_test.rb
83
+ - test/ad_set_test.rb
84
+ - test/ad_targeting_test.rb
85
+ - test/ad_test.rb
86
+ - test/facebook_ads_test.rb
87
+ - test/test_helper.rb
88
+ - test/vcr_cassettes/AdAccountTest-test_all.yml
89
+ - test/vcr_cassettes/AdAccountTest-test_applications.yml
90
+ - test/vcr_cassettes/AdAccountTest-test_find_by.yml
91
+ - test/vcr_cassettes/AdCampaignTest-test_create.yml
92
+ - test/vcr_cassettes/AdCampaignTest-test_list.yml
93
+ - test/vcr_cassettes/AdImageTest-test_create.yml
94
+ - test/vcr_cassettes/AdImageTest-test_list.yml
95
+ - test/vcr_cassettes/AdProductCatalogTest-test_all.yml
96
+ - test/vcr_cassettes/AdProductCatalogTest-test_create.yml
97
+ - test/vcr_cassettes/AdProductTest-test_list.yml
98
+ homepage: https://github.com/cte/facebook-ruby-ads-sdk
104
99
  licenses:
105
100
  - MIT
106
101
  metadata: {}
@@ -120,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
115
  version: '0'
121
116
  requirements: []
122
117
  rubyforge_project:
123
- rubygems_version: 2.4.8
118
+ rubygems_version: 2.6.8
124
119
  signing_key:
125
120
  specification_version: 4
126
121
  summary: Facebook Marketing API SDK for Ruby.
@@ -1,78 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FacebookAds::AdAccount do
4
-
5
- describe '.all' do
6
- it 'Lists all AdAccount instances' do
7
- accounts = FacebookAds::AdAccount.all
8
- expect(accounts.length).to eql(7)
9
- end
10
- end
11
-
12
- describe '.find' do
13
- it 'Finds an AdAccount by id' do
14
- id = 'act_861827983860489'
15
- account = FacebookAds::AdAccount.find(id)
16
- expect(account.id).to eql(id)
17
- end
18
- end
19
-
20
- describe '.find_by' do
21
- it 'Finds an AdAccount by name' do
22
- name = 'Android'
23
- account = FacebookAds::AdAccount.find_by(name: name)
24
- expect(account.name).to eql(name)
25
- end
26
- end
27
-
28
- describe '.ad_campaigns' do
29
- it 'Lists AdCampaign instances' do
30
- ad_campaigns = account.ad_campaigns
31
- ad_campaign = ad_campaigns.first
32
- expect(ad_campaign.account_id).to eql(account_id)
33
- end
34
- end
35
-
36
- describe '.ad_images' do
37
- it 'Lists AdImage instances' do
38
- ad_images = account.ad_images
39
- ad_image = ad_images.first
40
- expect(ad_image.account_id).to eql(account_id)
41
- end
42
- end
43
-
44
- describe '.ad_creatives' do
45
- it 'Lists AdCreative instances' do
46
- ad_creatives = account.ad_creatives
47
- ad_creative = ad_creatives.first
48
- expect(ad_creative.id).to eql('6057824295570')
49
- end
50
- end
51
-
52
- describe '.ad_sets' do
53
- it 'Lists AdSet instances' do
54
- ad_sets = account.ad_sets
55
- ad_set = ad_sets.first
56
- expect(ad_set.account_id).to eql(account_id)
57
- end
58
- end
59
-
60
- describe '.ads' do
61
- it 'Lists Ad instances' do
62
- ads = account.ads
63
- ad = ads.first
64
- expect(ad.account_id).to eql(account_id)
65
- end
66
- end
67
-
68
- private
69
-
70
- def account
71
- FacebookAds::AdAccount.find_by(account_id: account_id)
72
- end
73
-
74
- def account_id
75
- '861827983860489'
76
- end
77
-
78
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FacebookAds::AdCampaign do
4
-
5
- describe '.find' do
6
- it 'Finds an AdCampaign instance' do
7
- id = '6057330925170'
8
- campaign = FacebookAds::AdCampaign.find(id)
9
- expect(campaign.id).to eql(id)
10
- end
11
- end
12
-
13
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FacebookAds::AdCreative do
4
-
5
- describe '.find' do
6
- it 'Finds an AdCreative instance' do
7
- id = '6057824295570'
8
- creative = FacebookAds::AdCreative.find(id)
9
- expect(creative.id).to eql(id)
10
- expect(creative.object_story_spec.class).to eql(Hash)
11
- end
12
- end
13
-
14
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FacebookAds::AdImage do
4
-
5
- describe '.find' do
6
- it 'Raises an exception' do
7
- expect { FacebookAds::AdImage.find('test') }.to raise_error(Exception)
8
- end
9
- end
10
-
11
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FacebookAds::AdInsight do
4
-
5
- describe '.find' do
6
- it 'Raises an exception' do
7
- expect { FacebookAds::AdInsight.find('test') }.to raise_error(Exception)
8
- end
9
- end
10
-
11
- end
data/spec/ad_set_spec.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FacebookAds::AdSet do
4
-
5
- describe '.find' do
6
- it 'Finds an AdSet instance' do
7
- id = '6057810946970'
8
- ad_set = FacebookAds::AdSet.find(id)
9
- expect(ad_set.id).to eql(id)
10
- end
11
- end
12
-
13
- end
data/spec/ad_spec.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FacebookAds::Ad do
4
-
5
- describe '.find' do
6
- it 'Finds an Ad instance' do
7
- id = '6057810634370'
8
- ad = FacebookAds::Ad.find(id)
9
- expect(ad.id).to eql(id)
10
- end
11
- end
12
-
13
- end