fake_fb_marketing_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c9e916084f69d4c775a025c3bb6948843c85e121
4
+ data.tar.gz: f99a3b4b67c3f6209a82e26fb45903e4f85388f7
5
+ SHA512:
6
+ metadata.gz: 7e2bad6aae8e22ac811433dbaf252447b8b3529cdaa5406d26092db792e867ab1ce4150615d068e1450d7a6e04e6066f23e7ffe225a416ea98d31d92d04d17b4
7
+ data.tar.gz: d57770fdd7181beed6a70d317330c9af955f0be75ef9c4ee8cb95078922757600a3836b0c1d53ea79c53f038e2182b378e2987a55d77c7c3cae7e64c4c06871c
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ lib/fake_fb_marketing_api/log/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ # remove all vim files
15
+ **/*.swo
16
+ **/*.swn
17
+ **/*.swp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.3
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.3
7
+ before_install: gem install bundler -v 1.17.1
8
+
9
+ install: bundle install --jobs=3 --retry=3
10
+
11
+ env:
12
+ global:
13
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true # prevents nokogiri from downloading slooooow librarie
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mike@humanagency.org. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in fake_fb_marketing_api.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,128 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fake_fb_marketing_api (0.0.1)
5
+ sinatra (~> 2.0)
6
+ we-call (~> 0.9)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.6.0)
12
+ public_suffix (>= 2.0.2, < 4.0)
13
+ binding_of_caller (0.8.0)
14
+ debug_inspector (>= 0.0.1)
15
+ byebug (10.0.2)
16
+ capybara (3.13.2)
17
+ addressable
18
+ mini_mime (>= 0.1.3)
19
+ nokogiri (~> 1.8)
20
+ rack (>= 1.6.0)
21
+ rack-test (>= 0.6.3)
22
+ regexp_parser (~> 1.2)
23
+ xpath (~> 3.2)
24
+ capybara_discoball (0.1.0)
25
+ capybara (>= 2.7, < 4)
26
+ coderay (1.1.2)
27
+ concurrent-ruby (1.1.4)
28
+ crack (0.4.3)
29
+ safe_yaml (~> 1.0.0)
30
+ debug_inspector (0.0.3)
31
+ diff-lcs (1.3)
32
+ ethon (0.12.0)
33
+ ffi (>= 1.3.0)
34
+ faker (1.9.1)
35
+ i18n (>= 0.7)
36
+ faraday (0.15.4)
37
+ multipart-post (>= 1.2, < 3)
38
+ faraday-sunset (0.2.0)
39
+ faraday (>= 0.9.0, < 1)
40
+ faraday_middleware (0.13.1)
41
+ faraday (>= 0.7.4, < 1.0)
42
+ ffi (1.10.0)
43
+ hashdiff (0.3.8)
44
+ i18n (1.5.3)
45
+ concurrent-ruby (~> 1.0)
46
+ json (2.1.0)
47
+ koala (3.0.0)
48
+ addressable
49
+ faraday
50
+ json (>= 1.8)
51
+ method_source (0.9.2)
52
+ mini_mime (1.0.1)
53
+ mini_portile2 (2.4.0)
54
+ multipart-post (2.0.0)
55
+ mustermann (1.0.3)
56
+ nokogiri (1.10.1)
57
+ mini_portile2 (~> 2.4.0)
58
+ pry (0.12.2)
59
+ coderay (~> 1.1.0)
60
+ method_source (~> 0.9.0)
61
+ pry-byebug (3.6.0)
62
+ byebug (~> 10.0)
63
+ pry (~> 0.10)
64
+ pry-stack_explorer (0.4.9.3)
65
+ binding_of_caller (>= 0.7)
66
+ pry (>= 0.9.11)
67
+ public_suffix (3.0.3)
68
+ rack (2.0.6)
69
+ rack-protection (2.0.5)
70
+ rack
71
+ rack-test (1.1.0)
72
+ rack (>= 1.0, < 3)
73
+ rake (10.5.0)
74
+ regexp_parser (1.3.0)
75
+ rspec (3.8.0)
76
+ rspec-core (~> 3.8.0)
77
+ rspec-expectations (~> 3.8.0)
78
+ rspec-mocks (~> 3.8.0)
79
+ rspec-core (3.8.0)
80
+ rspec-support (~> 3.8.0)
81
+ rspec-expectations (3.8.2)
82
+ diff-lcs (>= 1.2.0, < 2.0)
83
+ rspec-support (~> 3.8.0)
84
+ rspec-mocks (3.8.0)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.8.0)
87
+ rspec-support (3.8.0)
88
+ safe_yaml (1.0.4)
89
+ sinatra (2.0.5)
90
+ mustermann (~> 1.0)
91
+ rack (~> 2.0)
92
+ rack-protection (= 2.0.5)
93
+ tilt (~> 2.0)
94
+ tilt (2.0.9)
95
+ typhoeus (1.3.1)
96
+ ethon (>= 0.9.0)
97
+ we-call (0.9.0)
98
+ faraday (>= 0.9.0, < 1)
99
+ faraday-sunset (~> 0.2)
100
+ faraday_middleware (~> 0.10)
101
+ typhoeus (~> 1.3)
102
+ webmock (3.5.1)
103
+ addressable (>= 2.3.6)
104
+ crack (>= 0.3.2)
105
+ hashdiff
106
+ xpath (3.2.0)
107
+ nokogiri (~> 1.8)
108
+
109
+ PLATFORMS
110
+ ruby
111
+
112
+ DEPENDENCIES
113
+ bundler (~> 1.15)
114
+ capybara_discoball
115
+ fake_fb_marketing_api!
116
+ faker (~> 1.9)
117
+ faraday
118
+ koala (~> 3.0)
119
+ pry
120
+ pry-byebug
121
+ pry-stack_explorer
122
+ rack-test (~> 1.0)
123
+ rake (~> 10.0)
124
+ rspec (~> 3.0)
125
+ webmock
126
+
127
+ BUNDLED WITH
128
+ 1.15.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Mike Menne
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # FakeFbMarketingApi
2
+
3
+ This sinatra server provides a reverse proxy to the Facebook graph API at `graph.facebook.com`.
4
+
5
+ Select APIs can intercepted and return static responses.
6
+
7
+ ## Setup
8
+
9
+ ### Koala
10
+
11
+ These instructions assume that you are using [Koala](https://github.com/arsduo/koala) as your interface to the Facebook graph API.
12
+
13
+ In order to use this reverse proxy, you will need to redirect all Koala requests to your local `fake-fb-marketing-api` server.
14
+
15
+ In your Koala config, replace the URL for FB:
16
+ ```
17
+ Koala.configure do |config|
18
+ if Rails.env.development?
19
+ config.graph_server = 'localhost:9292'
20
+ end
21
+ end
22
+ ```
23
+
24
+ In your Koala config, you will also need to disable SSL since our local server is not running with certificates:
25
+ ```
26
+ Koala.http_service.http_options = {
27
+ use_ssl: false
28
+ }
29
+ ```
30
+
31
+ You will also need to set several `ENV` variables:
32
+ ```
33
+ export FACEBOOK_AD_ACCOUNT_ID='xxxxxx'
34
+ export BRAND_AWARENESS_CAMPAIGN_ID='xxxxxx'
35
+ export LINK_CLICKS_CAMPAIGN_ID='xxxxxx'
36
+ export VIDEO_VIEWS_CAMPAIGN_ID='xxxxxx'
37
+ export REACH_CAMPAIGN_ID='xxxxxx'
38
+ export POST_ENGAGEMENT_CAMPAIGN_ID='xxxxxx'
39
+ export PAGE_LIKES_CAMPAIGN_ID='xxxxxx'
40
+ ```
41
+
42
+ It may be easier to run foreman with a separate ENV file that will set these values:
43
+ ```
44
+ foreman start --f Procfile.dev --env fake.env
45
+ ```
46
+ *Note* Foreman is particular about the format of the ENV file and does not support dot_env format (comments, etc.). This prevents us from using our normal `.env.development` to set variables for the entiree process.
47
+
48
+ Any calls that create an ad account will return the value in the `FACEBOOK_AD_ACCOUNT_ID`.
49
+
50
+ Any campaigns created will return the value in the `XXX_CAMPAIGN_ID` variables.
51
+
52
+ ## Notes
53
+
54
+ ### Development
55
+
56
+ ### Test
57
+
58
+ ### Staging
59
+
60
+ ### Production
61
+ ### Limitations
62
+
63
+ This server forwards all web requests via a Faraday wrapper. It does not support `keep-alive` `Connection` header.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'fake_fb_marketing_api'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/config.ru ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # config.ru
4
+
5
+ $LOAD_PATH << File.expand_path('lib', __dir__)
6
+ require 'fake_fb_marketing_api/application'
7
+
8
+ $stdout.sync = true
9
+
10
+ run FakeFbMarketingApi::Application.new
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'fake_fb_marketing_api/version'
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = 'fake_fb_marketing_api'
9
+ gem.version = FakeFbMarketingApi::VERSION
10
+ gem.authors = ['Mike Menne']
11
+ gem.email = ['mike@humanagency.org']
12
+
13
+ gem.summary = 'Provides a stubbed interface for select Facebook Marketing API endpoints'
14
+ gem.description = 'The key purpose of this gem is to allow developers the ability to stub the endpoints related the the Facebook Business API. Commands such as creating ad accounts can not be reversed and count against quota.'
15
+ gem.homepage = 'https://humanagency.org/'
16
+ gem.license = 'MIT'
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ if gem.respond_to?(:metadata)
21
+ # gem.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
22
+
23
+ # gem.metadata["homepage_uri"] = gem.homepage
24
+ # gem.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
25
+ # gem.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
26
+ else
27
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
28
+ 'public gem pushes.'
29
+ end
30
+
31
+ # Specify which files should be added to the gem when it is released.
32
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
33
+ gem.files = Dir.chdir(File.expand_path(__dir__)) do
34
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|gem|features)/}) }
35
+ end
36
+ gem.required_ruby_version = '>= 2.4.3'
37
+
38
+ gem.add_development_dependency 'bundler', '~> 1.15'
39
+ gem.add_development_dependency 'capybara_discoball'
40
+ gem.add_development_dependency 'faker', '~> 1.9'
41
+ gem.add_development_dependency 'faraday'
42
+ gem.add_development_dependency 'koala', '~> 3.0'
43
+ gem.add_development_dependency 'pry'
44
+ gem.add_development_dependency 'pry-byebug'
45
+ gem.add_development_dependency 'pry-stack_explorer'
46
+ gem.add_development_dependency 'rack-test', '~> 1.0'
47
+ gem.add_development_dependency 'rake', '~> 10.0'
48
+ gem.add_development_dependency 'rspec', '~> 3.0'
49
+ gem.add_development_dependency 'webmock'
50
+ gem.add_runtime_dependency 'sinatra', '~> 2.0'
51
+ gem.add_runtime_dependency 'we-call', '~> 0.9'
52
+ end