fbaa_api 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/.gitignore +9 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/README.md +62 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/fbaa_api.gemspec +31 -0
- data/lib/fbaa_api/client.rb +74 -0
- data/lib/fbaa_api/configuration.rb +26 -0
- data/lib/fbaa_api/version.rb +3 -0
- data/lib/fbaa_api.rb +30 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aad5db93bd6c16b8f66eaf86ebec17144a524ad3
|
4
|
+
data.tar.gz: 57c3c9d06cc4385bb98d44b4a0ea88d599b54034
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b0cb23a0191b6bc39e0b0c0f152ef58135b47e2eafe8e8ac0866d1585dd474bf6aa59a22a3dc63d724f188bc9d22999ff32afe9f81bdcef78ae1b9576d3a6ab8
|
7
|
+
data.tar.gz: 3b8cf54610db52483bbe71945ecb04e6d39911b1a23546cabc574ee58ebbd0cc73c7b646bfed0bb85b765c545f127ebf77a674cf1d131b544373e063bdec6384
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
[](https://circleci.com/gh/constantcontact/fbaa_api)
|
2
|
+
|
3
|
+
# FbaaApi
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/fbaa_api`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
TODO: Delete this and the text above, and describe your gem
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'fbaa_api'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install fbaa_api
|
24
|
+
|
25
|
+
## Configuration
|
26
|
+
|
27
|
+
Configure the gem using the ```#configure``` method like so:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
FbaaApi.configure do |c|
|
31
|
+
c.base_url = 'https://example.com' # mandatory
|
32
|
+
c.token = 'yourtoken1234' # mandatory, authentication token
|
33
|
+
c.api_version = 'v1' # optional, defaults to v1
|
34
|
+
c.logger = Logger.new * optional, defaults to STDOUT
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
FbaaApi.configure do |c|
|
42
|
+
# c.base_url = ... etc, etc
|
43
|
+
end
|
44
|
+
|
45
|
+
client = FbaaApi::Client.new
|
46
|
+
|
47
|
+
client.create_ad(params)
|
48
|
+
client.update_ad(id, params)
|
49
|
+
client.get_ad(id, params)
|
50
|
+
client.validate_image(params)
|
51
|
+
```
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
56
|
+
|
57
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fbaa_api.
|
62
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fbaa_api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/fbaa_api.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fbaa_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'fbaa_api'
|
8
|
+
spec.version = FbaaApi::VERSION
|
9
|
+
spec.authors = ['Jarrod Spillers']
|
10
|
+
spec.email = ['jspillers@constantcontact.com']
|
11
|
+
|
12
|
+
spec.summary = %q{API client for facebook ads adapter}
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.homepage = 'https://github.com/constantcontact/fbaa_api'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.4.2'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
|
+
spec.add_development_dependency 'rspec-its'
|
25
|
+
spec.add_development_dependency 'pry', '~> 0.10.1'
|
26
|
+
|
27
|
+
spec.add_dependency 'rspec_junit_formatter', '0.2.2'
|
28
|
+
spec.add_dependency 'faraday', '~> 0.9.2'
|
29
|
+
spec.add_dependency 'faraday_middleware', '~> 0.10.0'
|
30
|
+
spec.add_dependency 'json', '~> 1.8.3'
|
31
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module FbaaApi
|
2
|
+
class Client
|
3
|
+
|
4
|
+
def get(path, params = {})
|
5
|
+
request(:get, path, params)
|
6
|
+
end
|
7
|
+
|
8
|
+
def post(path, params = {})
|
9
|
+
request(:post, path, params)
|
10
|
+
end
|
11
|
+
|
12
|
+
def put(path, params = {})
|
13
|
+
request(:put, path, params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete(path, params = {})
|
17
|
+
request(:delete, path, params)
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_ad(params = {})
|
21
|
+
post 'ads', params
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_ad(id, params = {})
|
25
|
+
put "ads/#{id}", params
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_ad(id, params = {})
|
29
|
+
get "ads/#{id}", params
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate_image(params = {})
|
33
|
+
get "image_validations", params
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def fbaa_url
|
39
|
+
@fbaa_url ||= "#{config.base_url}/api/#{config.api_version}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def connection(opts = {})
|
43
|
+
opts[:headers] ||= { 'Accept' => 'application/json' }
|
44
|
+
config.logger.info("Fbaa::Client - fbaa_url #{fbaa_url}")
|
45
|
+
Faraday.new(url: fbaa_url) do |faraday|
|
46
|
+
faraday.headers = opts[:headers]
|
47
|
+
# this is required to be after headers to work
|
48
|
+
faraday.basic_auth 'roving', config.fbaa_password
|
49
|
+
faraday.request :url_encoded
|
50
|
+
faraday.adapter Faraday.default_adapter
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def request(method, path, params = {})
|
55
|
+
config.logger.info("Fbaa::Client - path #{path}")
|
56
|
+
response = connection.send(method, path) do |request|
|
57
|
+
request.body = params if [:post, :put].include? method
|
58
|
+
request.params = params
|
59
|
+
end
|
60
|
+
config.logger.info("Fbaa::Client - status #{response.status}")
|
61
|
+
config.logger.info("Fbaa::Client - body #{response.body}")
|
62
|
+
|
63
|
+
{ status: response.status, body: JSON.parse(response.body) }
|
64
|
+
rescue JSON::ParserError
|
65
|
+
{ status: 500, body: { error_messages: "JSON::ParseError #{response.body}" } }
|
66
|
+
end
|
67
|
+
|
68
|
+
def config
|
69
|
+
FbaaApi.configuration
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module FbaaApi
|
2
|
+
class Configuration
|
3
|
+
# Sets which FBAA API version to use
|
4
|
+
attr_accessor :api_version
|
5
|
+
|
6
|
+
# Sets base url for FBAA
|
7
|
+
attr_accessor :base_url
|
8
|
+
|
9
|
+
# Sets ctct token
|
10
|
+
attr_accessor :token
|
11
|
+
|
12
|
+
# Sets ctct token
|
13
|
+
attr_accessor :fbaa_password
|
14
|
+
|
15
|
+
# Set a logger, or use stdout by default
|
16
|
+
attr_accessor :logger
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@api_version = 'v1'
|
20
|
+
@base_url = ''
|
21
|
+
@fbaa_password = ''
|
22
|
+
@logger = Logger.new(STDOUT)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/fbaa_api.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'json'
|
3
|
+
require 'fbaa_api/client'
|
4
|
+
require "fbaa_api/version"
|
5
|
+
require "fbaa_api/configuration"
|
6
|
+
require 'faraday'
|
7
|
+
require 'faraday_middleware'
|
8
|
+
|
9
|
+
module FbaaApi
|
10
|
+
class << self
|
11
|
+
attr_writer :configuration
|
12
|
+
|
13
|
+
def new
|
14
|
+
Client.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def configuration
|
18
|
+
@configuration ||= Configuration.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def configure
|
22
|
+
yield configuration
|
23
|
+
end
|
24
|
+
|
25
|
+
def reset
|
26
|
+
self.configuration = Configuration.new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fbaa_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jarrod Spillers
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.4.2
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.4.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.10.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.10.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec_junit_formatter
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.2.2
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.2.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faraday
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.9.2
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.9.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: faraday_middleware
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.10.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.10.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: json
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.8.3
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.8.3
|
139
|
+
description: API client for facebook ads adapter
|
140
|
+
email:
|
141
|
+
- jspillers@constantcontact.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- Gemfile
|
149
|
+
- README.md
|
150
|
+
- Rakefile
|
151
|
+
- bin/console
|
152
|
+
- bin/setup
|
153
|
+
- fbaa_api.gemspec
|
154
|
+
- lib/fbaa_api.rb
|
155
|
+
- lib/fbaa_api/client.rb
|
156
|
+
- lib/fbaa_api/configuration.rb
|
157
|
+
- lib/fbaa_api/version.rb
|
158
|
+
homepage: https://github.com/constantcontact/fbaa_api
|
159
|
+
licenses: []
|
160
|
+
metadata: {}
|
161
|
+
post_install_message:
|
162
|
+
rdoc_options: []
|
163
|
+
require_paths:
|
164
|
+
- lib
|
165
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - ">="
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
requirements: []
|
176
|
+
rubyforge_project:
|
177
|
+
rubygems_version: 2.4.5.1
|
178
|
+
signing_key:
|
179
|
+
specification_version: 4
|
180
|
+
summary: API client for facebook ads adapter
|
181
|
+
test_files: []
|